summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/locks/src/locks-mem-types.h1
-rw-r--r--xlators/features/locks/src/locks.h6
-rw-r--r--xlators/features/locks/src/posix.c37
-rw-r--r--xlators/features/marker/src/marker-mem-types.h4
-rw-r--r--xlators/features/marker/src/marker-quota-helper.c12
-rw-r--r--xlators/features/marker/src/marker-quota-helper.h2
-rw-r--r--xlators/features/marker/src/marker-quota.h23
-rw-r--r--xlators/features/marker/src/marker.c46
-rw-r--r--xlators/features/marker/src/marker.h16
-rw-r--r--xlators/features/quota/src/quota-mem-types.h3
-rw-r--r--xlators/features/quota/src/quota.c19
-rw-r--r--xlators/features/quota/src/quota.h8
-rw-r--r--xlators/features/trash/src/trash-mem-types.h3
-rw-r--r--xlators/features/trash/src/trash.c22
14 files changed, 101 insertions, 101 deletions
diff --git a/xlators/features/locks/src/locks-mem-types.h b/xlators/features/locks/src/locks-mem-types.h
index 9d44f0eba10..5b29cbc7257 100644
--- a/xlators/features/locks/src/locks-mem-types.h
+++ b/xlators/features/locks/src/locks-mem-types.h
@@ -32,7 +32,6 @@ enum gf_locks_mem_types_ {
gf_locks_mt_truncate_ops,
gf_locks_mt_pl_rw_req_t,
gf_locks_mt_posix_locks_private_t,
- gf_locks_mt_pl_local_t,
gf_locks_mt_pl_fdctx_t,
gf_locks_mt_end
};
diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h
index 0dcbdf97901..653cc4d6b8b 100644
--- a/xlators/features/locks/src/locks.h
+++ b/xlators/features/locks/src/locks.h
@@ -164,6 +164,12 @@ typedef struct {
gf_boolean_t entrylk_count_req;
gf_boolean_t inodelk_count_req;
gf_boolean_t posixlk_count_req;
+
+ /* used by {f,}truncate */
+ loc_t loc;
+ fd_t *fd;
+ off_t offset;
+ enum {TRUNCATE, FTRUNCATE} op;
} pl_local_t;
typedef struct {
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 17bc802a000..b3ea23dfc41 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -49,13 +49,6 @@
void do_blocked_rw (pl_inode_t *);
static int __rw_allowable (pl_inode_t *, posix_lock_t *, glusterfs_fop_t);
-struct _truncate_ops {
- loc_t loc;
- fd_t *fd;
- off_t offset;
- enum {TRUNCATE, FTRUNCATE} op;
-};
-
static pl_fdctx_t *
pl_new_fdctx ()
{
@@ -111,7 +104,7 @@ pl_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
struct iatt *postbuf)
{
- struct _truncate_ops *local = NULL;
+ pl_local_t *local = NULL;
local = frame->local;
@@ -163,7 +156,7 @@ truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *buf)
{
posix_locks_private_t *priv = NULL;
- struct _truncate_ops *local = NULL;
+ pl_local_t *local = NULL;
inode_t *inode = NULL;
pl_inode_t *pl_inode = NULL;
@@ -230,10 +223,9 @@ int
pl_truncate (call_frame_t *frame, xlator_t *this,
loc_t *loc, off_t offset)
{
- struct _truncate_ops *local = NULL;
+ pl_local_t *local = NULL;
- local = GF_CALLOC (1, sizeof (struct _truncate_ops),
- gf_locks_mt_truncate_ops);
+ local = mem_get0 (this->local_pool);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
local->op = TRUNCATE;
@@ -260,10 +252,9 @@ int
pl_ftruncate (call_frame_t *frame, xlator_t *this,
fd_t *fd, off_t offset)
{
- struct _truncate_ops *local = NULL;
+ pl_local_t *local = NULL;
- local = GF_CALLOC (1, sizeof (struct _truncate_ops),
- gf_locks_mt_truncate_ops);
+ local = mem_get0 (this->local_pool);
GF_VALIDATE_OR_GOTO (this->name, local, unwind);
local->op = FTRUNCATE;
@@ -1576,7 +1567,7 @@ pl_lookup_cbk (call_frame_t *frame,
frame->local = NULL;
if (local != NULL)
- GF_FREE (local);
+ mem_put (local);
out:
STACK_UNWIND_STRICT (
@@ -1604,7 +1595,7 @@ pl_lookup (call_frame_t *frame,
VALIDATE_OR_GOTO (this, out);
VALIDATE_OR_GOTO (loc, out);
- local = GF_CALLOC (1, sizeof (*local), gf_locks_mt_pl_local_t);
+ local = mem_get0 (this->local_pool);
GF_VALIDATE_OR_GOTO (this->name, local, out);
if (xattr_req) {
@@ -1657,7 +1648,7 @@ unwind:
STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries);
if (local)
- GF_FREE (local);
+ mem_put (local);
return 0;
}
@@ -1668,7 +1659,7 @@ pl_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
{
pl_local_t *local = NULL;
- local = GF_CALLOC (1, sizeof (*local), gf_locks_mt_pl_local_t);
+ local = mem_get0 (this->local_pool);
GF_VALIDATE_OR_GOTO (this->name, local, out);
if (dict) {
@@ -2056,6 +2047,14 @@ init (xlator_t *this)
}
}
+ this->local_pool = mem_pool_new (pl_local_t, 1024);
+ if (!this->local_pool) {
+ ret = -1;
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to create local_t's memory pool");
+ goto out;
+ }
+
this->private = priv;
ret = 0;
diff --git a/xlators/features/marker/src/marker-mem-types.h b/xlators/features/marker/src/marker-mem-types.h
index f2723dc26e9..2f49c0d9d4e 100644
--- a/xlators/features/marker/src/marker-mem-types.h
+++ b/xlators/features/marker/src/marker-mem-types.h
@@ -23,14 +23,12 @@
#include "mem-types.h"
enum gf_marker_mem_types_ {
- gf_marker_mt_marker_local_t = gf_common_mt_end + 1,
- gf_marker_mt_marker_conf_t,
+ gf_marker_mt_marker_conf_t = gf_common_mt_end + 1,
gf_marker_mt_loc_t,
gf_marker_mt_volume_mark,
gf_marker_mt_int64_t,
gf_marker_mt_quota_inode_ctx_t,
gf_marker_mt_marker_inode_ctx_t,
- gf_marker_mt_quota_local_t,
gf_marker_mt_inode_contribution_t,
gf_marker_mt_end
};
diff --git a/xlators/features/marker/src/marker-quota-helper.c b/xlators/features/marker/src/marker-quota-helper.c
index 7b7c3026f90..8d4ff7786a6 100644
--- a/xlators/features/marker/src/marker-quota-helper.c
+++ b/xlators/features/marker/src/marker-quota-helper.c
@@ -328,21 +328,15 @@ mq_inode_ctx_new (inode_t * inode, xlator_t *this)
quota_local_t *
mq_local_new ()
{
- int32_t ret = -1;
quota_local_t *local = NULL;
- QUOTA_ALLOC (local, quota_local_t, ret);
- if (ret < 0)
+ local = mem_get0 (THIS->local_pool);
+ if (!local)
goto out;
local->ref = 1;
- local->delta = 0;
- local->err = 0;
LOCK_INIT (&local->lock);
- memset (&local->loc, 0, sizeof (loc_t));
- memset (&local->parent_loc, 0, sizeof (loc_t));
-
local->ctx = NULL;
local->contri = NULL;
@@ -384,7 +378,7 @@ mq_local_unref (xlator_t *this, quota_local_t *local)
LOCK_DESTROY (&local->lock);
- GF_FREE (local);
+ mem_put (local);
out:
return 0;
}
diff --git a/xlators/features/marker/src/marker-quota-helper.h b/xlators/features/marker/src/marker-quota-helper.h
index 56080f0dc21..e019fbd52ad 100644
--- a/xlators/features/marker/src/marker-quota-helper.h
+++ b/xlators/features/marker/src/marker-quota-helper.h
@@ -23,7 +23,7 @@
#include "config.h"
#endif
-#include "marker-quota.h"
+#include "marker.h"
#define QUOTA_FREE_CONTRIBUTION_NODE(_contribution) \
do { \
diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h
index 7a90b28b7ed..30ee4426449 100644
--- a/xlators/features/marker/src/marker-quota.h
+++ b/xlators/features/marker/src/marker-quota.h
@@ -24,7 +24,6 @@
#include "config.h"
#endif
-#include "marker.h"
#include "xlator.h"
#include "marker-mem-types.h"
@@ -104,28 +103,6 @@ struct inode_contribution {
};
typedef struct inode_contribution inode_contribution_t;
-struct quota_local {
- int64_t delta;
- int64_t d_off;
- int32_t err;
- int32_t ref;
- int64_t sum;
- int64_t size;
- int32_t hl_count;
- int32_t dentry_child_count;
-
- fd_t *fd;
- call_frame_t *frame;
- gf_lock_t lock;
-
- loc_t loc;
- loc_t parent_loc;
-
- quota_inode_ctx_t *ctx;
- inode_contribution_t *contri;
-};
-typedef struct quota_local quota_local_t;
-
int32_t
mq_get_lock_on_parent (call_frame_t *, xlator_t *);
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c
index 54a7e1a28f3..6e384f0b9b4 100644
--- a/xlators/features/marker/src/marker.c
+++ b/xlators/features/marker/src/marker.c
@@ -177,7 +177,7 @@ marker_local_unref (marker_local_t *local)
marker_local_unref (local->oplocal);
local->oplocal = NULL;
}
- GF_FREE (local);
+ mem_put (local);
out:
return 0;
}
@@ -509,7 +509,7 @@ marker_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -580,7 +580,7 @@ marker_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -655,7 +655,7 @@ marker_writev (call_frame_t *frame,
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -723,7 +723,7 @@ marker_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags)
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -820,7 +820,7 @@ marker_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
if (priv->feature_enabled == 0)
goto unlink_wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -897,7 +897,7 @@ marker_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc)
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -1412,11 +1412,11 @@ marker_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
if (priv->feature_enabled == 0)
goto rename_wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
- ALLOCATE_OR_GOTO (oplocal, marker_local_t, err);
+ oplocal = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, oplocal);
@@ -1533,7 +1533,7 @@ marker_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset)
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -1600,7 +1600,7 @@ marker_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -1669,7 +1669,7 @@ marker_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -1739,7 +1739,7 @@ marker_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -1869,7 +1869,7 @@ marker_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
if (ret == 0)
return 0;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -1936,7 +1936,7 @@ marker_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
if (ret == 0)
return 0;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -2002,7 +2002,7 @@ marker_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -2070,7 +2070,7 @@ marker_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -2133,7 +2133,7 @@ marker_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -2203,7 +2203,7 @@ marker_lookup (call_frame_t *frame, xlator_t *this,
if (priv->feature_enabled == 0)
goto wind;
- ALLOCATE_OR_GOTO (local, marker_local_t, err);
+ local = mem_get0 (this->local_pool);
MARKER_INIT_LOCAL (frame, local);
@@ -2241,6 +2241,7 @@ unwind:
return 0;
}
+
int
marker_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
off_t offset, dict_t *dict)
@@ -2503,6 +2504,13 @@ init (xlator_t *this)
}
}
+ this->local_pool = mem_pool_new (marker_local_t, 1024);
+ if (!this->local_pool) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to create local_t's memory pool");
+ goto err;
+ }
+
return 0;
err:
marker_priv_cleanup (this);
diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h
index f5ed9df399e..3dcb41f8ad3 100644
--- a/xlators/features/marker/src/marker.h
+++ b/xlators/features/marker/src/marker.h
@@ -103,9 +103,25 @@ struct marker_local{
call_stub_t *stub;
int64_t contribution;
struct marker_local *oplocal;
+
+ /* marker quota specific */
+ int64_t delta;
+ int64_t d_off;
+ int64_t sum;
+ int64_t size;
+ int32_t hl_count;
+ int32_t dentry_child_count;
+
+ fd_t *fd;
+ call_frame_t *frame;
+
+ quota_inode_ctx_t *ctx;
+ inode_contribution_t *contri;
};
typedef struct marker_local marker_local_t;
+#define quota_local_t marker_local_t
+
struct marker_inode_ctx {
struct quota_inode_ctx *quota_ctx;
};
diff --git a/xlators/features/quota/src/quota-mem-types.h b/xlators/features/quota/src/quota-mem-types.h
index da28be5b380..ed70c29285e 100644
--- a/xlators/features/quota/src/quota-mem-types.h
+++ b/xlators/features/quota/src/quota-mem-types.h
@@ -23,8 +23,7 @@
#include "mem-types.h"
enum gf_quota_mem_types_ {
- gf_quota_mt_quota_local_t = gf_common_mt_end + 1,
- gf_quota_mt_quota_priv_t,
+ gf_quota_mt_quota_priv_t = gf_common_mt_end + 1,
gf_quota_mt_quota_inode_ctx_t,
gf_quota_mt_loc_t,
gf_quota_mt_char,
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index 3710e8f90cf..6b7db70cfa4 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -141,14 +141,13 @@ out:
}
-quota_local_t *
+static inline quota_local_t *
quota_local_new ()
{
- quota_local_t *local = NULL;
- GF_UNUSED int32_t ret = 0;
-
- QUOTA_LOCAL_ALLOC_OR_GOTO (local, quota_local_t, err);
-err:
+ quota_local_t *local = NULL;
+ local = mem_get0 (THIS->local_pool);
+ if (local)
+ LOCK_INIT (&local->lock);
return local;
}
@@ -3001,6 +3000,14 @@ init (xlator_t *this)
GF_OPTION_INIT ("timeout", priv->timeout, int64, err);
+ this->local_pool = mem_pool_new (quota_local_t, 1024);
+ if (!this->local_pool) {
+ ret = -1;
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to create local_t's memory pool");
+ goto err;
+ }
+
ret = 0;
err:
return ret;
diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h
index 9b94d592077..79b4d07e351 100644
--- a/xlators/features/quota/src/quota.h
+++ b/xlators/features/quota/src/quota.h
@@ -60,12 +60,6 @@
UNLOCK (lock); \
} while (0)
-#define QUOTA_LOCAL_ALLOC_OR_GOTO(local, type, label) \
- do { \
- QUOTA_ALLOC_OR_GOTO (local, type, label); \
- LOCK_INIT (&local->lock); \
- } while (0)
-
#define QUOTA_ALLOC_OR_GOTO(var, type, label) \
do { \
var = GF_CALLOC (sizeof (type), 1, \
@@ -89,7 +83,7 @@
} \
STACK_UNWIND_STRICT (fop, frame, params); \
quota_local_cleanup (_this, _local); \
- GF_FREE (_local); \
+ mem_put (_local); \
} while (0)
#define QUOTA_FREE_CONTRIBUTION_NODE(_contribution) \
diff --git a/xlators/features/trash/src/trash-mem-types.h b/xlators/features/trash/src/trash-mem-types.h
index 6608abf6a17..bb2cd33cfe0 100644
--- a/xlators/features/trash/src/trash-mem-types.h
+++ b/xlators/features/trash/src/trash-mem-types.h
@@ -23,8 +23,7 @@
#include "mem-types.h"
enum gf_trash_mem_types_ {
- gf_trash_mt_trash_local_t = gf_common_mt_end + 1,
- gf_trash_mt_trash_private_t,
+ gf_trash_mt_trash_private_t = gf_common_mt_end + 1,
gf_trash_mt_char,
gf_trash_mt_trash_elim_pattern_t,
gf_trash_mt_end
diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c
index 38920db6c71..0aec4bc3d79 100644
--- a/xlators/features/trash/src/trash.c
+++ b/xlators/features/trash/src/trash.c
@@ -63,7 +63,7 @@ trash_local_wipe (trash_local_t *local)
if (local->newfd)
fd_unref (local->newfd);
- GF_FREE (local);
+ mem_put (local);
out:
return;
}
@@ -533,8 +533,7 @@ trash_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
return 0;
}
- local = GF_CALLOC (1, sizeof (trash_local_t),
- gf_trash_mt_trash_local_t);
+ local = mem_get0 (this->local_pool);
if (!local) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
TRASH_STACK_UNWIND (rename, frame, -1, ENOMEM,
@@ -610,8 +609,7 @@ trash_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc)
return 0;
}
- local = GF_CALLOC (1, sizeof (trash_local_t),
- gf_trash_mt_trash_local_t);
+ local = mem_get0 (this->local_pool);
if (!local) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
TRASH_STACK_UNWIND (unlink, frame, -1, ENOMEM, NULL, NULL);
@@ -1044,8 +1042,7 @@ trash_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,
LOCK_INIT (&frame->lock);
- local = GF_CALLOC (1, sizeof (trash_local_t),
- gf_trash_mt_trash_local_t);
+ local = mem_get0 (this->local_pool);
if (!local) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
TRASH_STACK_UNWIND (truncate, frame, -1, ENOMEM, NULL, NULL);
@@ -1385,8 +1382,7 @@ trash_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
return 0;
}
- local = GF_CALLOC (1, sizeof (trash_local_t),
- gf_trash_mt_trash_local_t);
+ local = mem_get0 (this->local_pool);
if (!local) {
gf_log (this->name, GF_LOG_DEBUG, "out of memory");
TRASH_STACK_UNWIND (ftruncate, frame, -1, ENOMEM, NULL, NULL);
@@ -1522,6 +1518,14 @@ init (xlator_t *this)
_priv->max_trash_file_size);
}
+ this->local_pool = mem_pool_new (trash_local_t, 1024);
+ if (!this->local_pool) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to create local_t's memory pool");
+ return -1;
+ }
+
+
this->private = (void *)_priv;
return 0;
}