summaryrefslogtreecommitdiffstats
path: root/xlators/performance/write-behind
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2012-02-21 14:47:48 +0530
committerAnand Avati <avati@redhat.com>2012-02-21 02:42:09 -0800
commit0ef7e763c85c045ef7937d0ca02d8c5f0333e6e8 (patch)
treee41180dde3fd17b008d8da13357c779b98e351c3 /xlators/performance/write-behind
parent1f296b84e6c7bf55fc81d0c1dade7ccda75229a6 (diff)
core: utilize mempool for frame->local allocations
in each translator, which uses 'frame->local', we are using GF_CALLOC/GF_FREE, which would be costly considering the number of allocation happening in a lifetime of 'fop'. It would be good to utilize the mem pool framework for xlator's local structures, so there is no allocation overhead. Change-Id: Ida6e65039a24d9c219b380aa1c3559f36046dc94 Signed-off-by: Amar Tumballi <amar@gluster.com> BUG: 765336 Reviewed-on: http://review.gluster.com/2772 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/performance/write-behind')
-rw-r--r--xlators/performance/write-behind/src/write-behind-mem-types.h1
-rw-r--r--xlators/performance/write-behind/src/write-behind.c36
2 files changed, 20 insertions, 17 deletions
diff --git a/xlators/performance/write-behind/src/write-behind-mem-types.h b/xlators/performance/write-behind/src/write-behind-mem-types.h
index 5a3ee4aed0f..0b03875fda2 100644
--- a/xlators/performance/write-behind/src/write-behind-mem-types.h
+++ b/xlators/performance/write-behind/src/write-behind-mem-types.h
@@ -25,7 +25,6 @@
enum gf_wb_mem_types_ {
gf_wb_mt_wb_file_t = gf_common_mt_end + 1,
- gf_wb_mt_wb_local_t,
gf_wb_mt_wb_request_t,
gf_wb_mt_iovec,
gf_wb_mt_wb_conf_t,
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index a8b1c0c3cff..7cae5405d9e 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -483,8 +483,7 @@ wb_sync (call_frame_t *frame, wb_file_t *file, list_head_t *winds)
goto out;
}
- local = GF_CALLOC (1, sizeof (*local),
- gf_wb_mt_wb_local_t);
+ local = mem_get0 (THIS->local_pool);
if (local == NULL) {
bytes = -1;
op_errno = ENOMEM;
@@ -579,7 +578,7 @@ out:
wb_request_unref (request);
}
- GF_FREE (local);
+ mem_put (local);
local = NULL;
}
@@ -722,7 +721,7 @@ wb_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
}
}
- local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -847,8 +846,7 @@ wb_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd)
}
}
- local = GF_CALLOC (1, sizeof (*local),
- gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -1007,8 +1005,7 @@ wb_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset)
}
}
- local = GF_CALLOC (1, sizeof (*local),
- gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -1133,7 +1130,7 @@ wb_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
}
}
- local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -1275,7 +1272,7 @@ wb_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
GF_VALIDATE_OR_GOTO (frame->this->name, loc, unwind);
- local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -1431,7 +1428,7 @@ wb_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
wb_local_t *local = NULL;
int32_t op_errno = EINVAL;
- local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -2177,8 +2174,7 @@ wb_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
goto unwind;
}
- local = GF_CALLOC (1, sizeof (*local),
- gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -2304,7 +2300,7 @@ wb_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
}
}
- local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -2493,7 +2489,7 @@ wb_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
}
if (file != NULL) {
- local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -2637,7 +2633,7 @@ wb_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync)
}
}
- local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
goto unwind;
@@ -2959,6 +2955,14 @@ init (xlator_t *this)
GF_OPTION_INIT ("enable-trickling-writes", conf->enable_trickling_writes,
bool, out);
+ this->local_pool = mem_pool_new (wb_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 = conf;
ret = 0;