summaryrefslogtreecommitdiffstats
path: root/xlators/performance
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
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')
-rw-r--r--xlators/performance/io-cache/src/io-cache.c36
-rw-r--r--xlators/performance/io-cache/src/ioc-mem-types.h1
-rw-r--r--xlators/performance/io-cache/src/page.c5
-rw-r--r--xlators/performance/quick-read/src/quick-read-mem-types.h1
-rw-r--r--xlators/performance/quick-read/src/quick-read.c62
-rw-r--r--xlators/performance/read-ahead/src/page.c6
-rw-r--r--xlators/performance/read-ahead/src/read-ahead-mem-types.h1
-rw-r--r--xlators/performance/read-ahead/src/read-ahead.c11
-rw-r--r--xlators/performance/write-behind/src/write-behind-mem-types.h1
-rw-r--r--xlators/performance/write-behind/src/write-behind.c36
10 files changed, 79 insertions, 81 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 0ab36454c86..d8fa5e9914f 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -275,8 +275,7 @@ ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
ioc_local_t *local = NULL;
int32_t op_errno = -1, ret = -1;
- local = GF_CALLOC (1, sizeof (*local),
- gf_ioc_mt_ioc_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -455,8 +454,7 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
int32_t ret = 0;
local = frame->local;
- validate_local = GF_CALLOC (1, sizeof (ioc_local_t),
- gf_ioc_mt_ioc_local_t);
+ validate_local = mem_get0 (THIS->local_pool);
if (validate_local == NULL) {
ret = -1;
local->op_ret = -1;
@@ -471,7 +469,7 @@ ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
ret = -1;
local->op_ret = -1;
local->op_errno = ENOMEM;
- GF_FREE (validate_local);
+ mem_put (validate_local);
gf_log (ioc_inode->table->xl->name, GF_LOG_ERROR,
"out of memory");
goto out;
@@ -589,7 +587,7 @@ ioc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
}
out:
- GF_FREE (local);
+ mem_put (local);
frame->local = NULL;
STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd);
@@ -686,7 +684,7 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
out:
frame->local = NULL;
- GF_FREE (local);
+ mem_put (local);
STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf,
preparent, postparent);
@@ -739,7 +737,7 @@ out:
frame->local = NULL;
loc_wipe (&local->file_loc);
- GF_FREE (local);
+ mem_put (local);
STACK_UNWIND_STRICT (mknod, frame, op_ret, op_errno, inode, buf,
preparent, postparent);
@@ -754,8 +752,7 @@ ioc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
ioc_local_t *local = NULL;
int32_t op_errno = -1, ret = -1;
- local = GF_CALLOC (1, sizeof (*local),
- gf_ioc_mt_ioc_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_errno = ENOMEM;
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -780,7 +777,7 @@ ioc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
unwind:
if (local != NULL) {
loc_wipe (&local->file_loc);
- GF_FREE (local);
+ mem_put (local);
}
STACK_UNWIND_STRICT (mknod, frame, -1, op_errno, NULL, NULL,
@@ -805,7 +802,7 @@ ioc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
ioc_local_t *local = NULL;
- local = GF_CALLOC (1, sizeof (ioc_local_t), gf_ioc_mt_ioc_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
STACK_UNWIND_STRICT (open, frame, -1, ENOMEM, NULL);
@@ -841,7 +838,7 @@ ioc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
{
ioc_local_t *local = NULL;
- local = GF_CALLOC (1, sizeof (ioc_local_t), gf_ioc_mt_ioc_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
STACK_UNWIND_STRICT (create, frame, -1, ENOMEM, NULL, NULL,
@@ -1171,8 +1168,7 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
return 0;
}
- local = (ioc_local_t *) GF_CALLOC (1, sizeof (ioc_local_t),
- gf_ioc_mt_ioc_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
op_errno = ENOMEM;
@@ -1256,7 +1252,7 @@ ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
ioc_local_t *local = NULL;
uint64_t ioc_inode = 0;
- local = GF_CALLOC (1, sizeof (ioc_local_t), gf_ioc_mt_ioc_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
gf_log (this->name, GF_LOG_ERROR, "out of memory");
@@ -1751,6 +1747,14 @@ init (xlator_t *this)
for (index = 0; index < (table->max_pri); index++)
INIT_LIST_HEAD (&table->inode_lru[index]);
+ this->local_pool = mem_pool_new (ioc_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;
+ }
+
pthread_mutex_init (&table->table_lock, NULL);
this->private = table;
ret = 0;
diff --git a/xlators/performance/io-cache/src/ioc-mem-types.h b/xlators/performance/io-cache/src/ioc-mem-types.h
index 421485e2698..0cae40b5c7f 100644
--- a/xlators/performance/io-cache/src/ioc-mem-types.h
+++ b/xlators/performance/io-cache/src/ioc-mem-types.h
@@ -26,7 +26,6 @@ enum gf_ioc_mem_types_ {
gf_ioc_mt_iovec = gf_common_mt_end + 1,
gf_ioc_mt_ioc_table_t,
gf_ioc_mt_char,
- gf_ioc_mt_ioc_local_t,
gf_ioc_mt_ioc_waitq_t,
gf_ioc_mt_ioc_priority,
gf_ioc_mt_list_head,
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c
index 93c4a51de3e..87a78ecda20 100644
--- a/xlators/performance/io-cache/src/page.c
+++ b/xlators/performance/io-cache/src/page.c
@@ -602,8 +602,7 @@ ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
goto err;
}
- fault_local = GF_CALLOC (1, sizeof (ioc_local_t),
- gf_ioc_mt_ioc_local_t);
+ fault_local = mem_get0 (THIS->local_pool);
if (fault_local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -881,7 +880,7 @@ unwind:
}
pthread_mutex_destroy (&local->local_lock);
- GF_FREE (local);
+ mem_put (local);
return;
}
diff --git a/xlators/performance/quick-read/src/quick-read-mem-types.h b/xlators/performance/quick-read/src/quick-read-mem-types.h
index b6a65e57cb0..68e893a6fac 100644
--- a/xlators/performance/quick-read/src/quick-read-mem-types.h
+++ b/xlators/performance/quick-read/src/quick-read-mem-types.h
@@ -25,7 +25,6 @@
enum gf_qr_mem_types_ {
gf_qr_mt_qr_inode_t = gf_common_mt_end + 1,
gf_qr_mt_qr_fd_ctx_t,
- gf_qr_mt_qr_local_t,
gf_qr_mt_iovec,
gf_qr_mt_qr_conf_t,
gf_qr_mt_qr_priority_t,
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index c1460b1debf..b1b260f5528 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -39,7 +39,7 @@ qr_local_free (qr_local_t *local)
GF_FREE (local->path);
}
- GF_FREE (local);
+ mem_put (local);
out:
return;
@@ -450,7 +450,7 @@ qr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req)
}
table = &priv->table;
- local = GF_CALLOC (1, sizeof (*local), gf_qr_mt_qr_local_t);
+ local = mem_get0 (this->local_pool);
GF_VALIDATE_OR_GOTO_WITH_ERROR (this->name, local, unwind, op_errno,
ENOMEM);
@@ -683,7 +683,7 @@ qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
tmp_fd_ctx = NULL;
- local = GF_CALLOC (1, sizeof (*local), gf_qr_mt_qr_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -915,7 +915,7 @@ qr_validate_cache (call_frame_t *frame, xlator_t *this, fd_t *fd,
GF_VALIDATE_OR_GOTO (frame->this->name, stub, out);
if (frame->local == NULL) {
- local = GF_CALLOC (1, sizeof (*local), gf_qr_mt_qr_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
goto out;
}
@@ -1245,9 +1245,7 @@ out:
can_wind = 1;
} else {
if (frame->local == NULL) {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -1432,9 +1430,7 @@ qr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
if (qr_fd_ctx->opened) {
can_wind = 1;
} else {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -1587,9 +1583,7 @@ qr_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd)
if (qr_fd_ctx->opened) {
can_wind = 1;
} else {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -1746,9 +1740,7 @@ qr_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
if (qr_fd_ctx->opened) {
can_wind = 1;
} else {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -1906,9 +1898,7 @@ qr_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
if (qr_fd_ctx->opened) {
can_wind = 1;
} else {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -2070,9 +2060,7 @@ qr_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name)
if (qr_fd_ctx->opened) {
can_wind = 1;
} else {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -2213,9 +2201,7 @@ qr_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
if (qr_fd_ctx->opened) {
can_wind = 1;
} else if (qr_fd_ctx->open_in_transit) {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -2355,9 +2341,7 @@ qr_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
if (qr_fd_ctx->opened) {
can_wind = 1;
} else {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -2516,9 +2500,7 @@ qr_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
if (qr_fd_ctx->opened) {
can_wind = 1;
} else {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -2673,9 +2655,7 @@ qr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags)
if (qr_fd_ctx->opened) {
can_wind = 1;
} else {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -2871,7 +2851,7 @@ qr_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset)
qr_fd_ctx = (qr_fd_ctx_t *)(long)value;
}
- local = GF_CALLOC (1, sizeof (*local), gf_qr_mt_qr_local_t);
+ local = mem_get0 (this->local_pool);
if (local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -3046,9 +3026,7 @@ qr_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
if (qr_fd_ctx->opened) {
can_wind = 1;
} else {
- frame->local = GF_CALLOC (1,
- sizeof (qr_local_t),
- gf_qr_mt_qr_local_t);
+ frame->local = mem_get0 (this->local_pool);
if (frame->local == NULL) {
op_ret = -1;
op_errno = ENOMEM;
@@ -3574,6 +3552,14 @@ init (xlator_t *this)
INIT_LIST_HEAD (&priv->table.lru[i]);
}
+ this->local_pool = mem_pool_new (qr_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;
+ }
+
ret = 0;
this->private = priv;
diff --git a/xlators/performance/read-ahead/src/page.c b/xlators/performance/read-ahead/src/page.c
index 8aa55c065c5..1e6a92087a5 100644
--- a/xlators/performance/read-ahead/src/page.c
+++ b/xlators/performance/read-ahead/src/page.c
@@ -233,7 +233,7 @@ unlock:
fd_unref (local->fd);
- GF_FREE (frame->local);
+ mem_put (frame->local);
frame->local = NULL;
out:
@@ -261,7 +261,7 @@ ra_page_fault (ra_file_t *file, call_frame_t *frame, off_t offset)
goto err;
}
- fault_local = GF_CALLOC (1, sizeof (ra_local_t), gf_ra_mt_ra_local_t);
+ fault_local = mem_get0 (THIS->local_pool);
if (fault_local == NULL) {
STACK_DESTROY (fault_frame->root);
op_ret = -1;
@@ -451,7 +451,7 @@ ra_frame_unwind (call_frame_t *frame)
iobref_unref (iobref);
pthread_mutex_destroy (&local->local_lock);
- GF_FREE (local);
+ mem_put (local);
GF_FREE (vector);
out:
diff --git a/xlators/performance/read-ahead/src/read-ahead-mem-types.h b/xlators/performance/read-ahead/src/read-ahead-mem-types.h
index 7ca09369653..d2d184f0966 100644
--- a/xlators/performance/read-ahead/src/read-ahead-mem-types.h
+++ b/xlators/performance/read-ahead/src/read-ahead-mem-types.h
@@ -25,7 +25,6 @@
enum gf_ra_mem_types_ {
gf_ra_mt_ra_file_t = gf_common_mt_end + 1,
- gf_ra_mt_ra_local_t,
gf_ra_mt_ra_conf_t,
gf_ra_mt_ra_page_t,
gf_ra_mt_ra_waitq_t,
diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c
index f58c4078db9..72c7e6aa234 100644
--- a/xlators/performance/read-ahead/src/read-ahead.c
+++ b/xlators/performance/read-ahead/src/read-ahead.c
@@ -522,7 +522,7 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
flush_region (frame, file, 0, file->pages.prev->offset + 1, 0);
}
- local = (void *) GF_CALLOC (1, sizeof (*local), gf_ra_mt_ra_local_t);
+ local = mem_get0 (this->local_pool);
if (!local) {
op_errno = ENOMEM;
goto unwind;
@@ -1061,6 +1061,15 @@ init (xlator_t *this)
conf->files.prev = &conf->files;
pthread_mutex_init (&conf->conf_lock, NULL);
+
+ this->local_pool = mem_pool_new (ra_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;
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;