From 0ef7e763c85c045ef7937d0ca02d8c5f0333e6e8 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 21 Feb 2012 14:47:48 +0530 Subject: 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 BUG: 765336 Reviewed-on: http://review.gluster.com/2772 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/features/trash/src/trash.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'xlators/features/trash/src/trash.c') 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; } -- cgit