From f9431f330e8f304e82d9b1443018987a926d56b6 Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Thu, 5 Aug 2010 04:00:14 +0000 Subject: mem pool for fd_t Ran posix compliance test and sanity test Signed-off-by: shishir gowda Signed-off-by: Anand V. Avati BUG: 329 (Replacing memory allocation functions with mem-type functions) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=329 --- libglusterfs/src/fd.c | 8 ++++++-- libglusterfs/src/inode.c | 7 +++++++ libglusterfs/src/inode.h | 1 + libglusterfsclient/src/libglusterfsclient.c | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c index 9269e5cf8..231b7c5b0 100644 --- a/libglusterfs/src/fd.c +++ b/libglusterfs/src/fd.c @@ -402,6 +402,7 @@ fd_destroy (fd_t *fd) xlator_t *xl = NULL; int i = 0; xlator_t *old_THIS = NULL; + struct mem_pool *tmp_pool = NULL; if (fd == NULL){ gf_log ("xlator", GF_LOG_ERROR, "invalid arugument"); @@ -415,6 +416,8 @@ fd_destroy (fd_t *fd) if (!fd->_ctx) goto out; + tmp_pool = fd->inode->table->fd_mem_pool; + if (IA_ISDIR (fd->inode->ia_type)) { for (i = 0; i < fd->inode->table->xl->graph->xl_count; i++) { if (fd->_ctx[i].key) { @@ -444,7 +447,8 @@ fd_destroy (fd_t *fd) GF_FREE (fd->_ctx); inode_unref (fd->inode); fd->inode = (inode_t *)0xaaaaaaaa; - GF_FREE (fd); + mem_put (tmp_pool,fd); + tmp_pool = NULL; out: return; } @@ -505,7 +509,7 @@ fd_create (inode_t *inode, pid_t pid) return NULL; } - fd = GF_CALLOC (1, sizeof (fd_t), gf_common_mt_fd_t); + fd = mem_get (inode->table->fd_mem_pool); if (!fd) goto out; diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 5d35d4cc3..ad65081dc 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -1098,6 +1098,13 @@ inode_table_new (size_t lru_limit, xlator_t *xl) return NULL; } + new->fd_mem_pool = mem_pool_new (fd_t, 16384); + + if (!new->fd_mem_pool) { + GF_FREE (new->inode_hash); + GF_FREE (new); + } + for (i=0; ihashsize; i++) { INIT_LIST_HEAD (&new->inode_hash[i]); } diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h index dbc721546..18081b8f8 100644 --- a/libglusterfs/src/inode.h +++ b/libglusterfs/src/inode.h @@ -65,6 +65,7 @@ struct _inode_table { uint32_t attic_size; struct mem_pool *inode_pool; /* memory pool for inodes */ struct mem_pool *dentry_pool; /* memory pool for dentrys */ + struct mem_pool *fd_mem_pool; /* memory pool for fd_t */ }; diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 3ecb56c8c..61ca2d1e0 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -2060,6 +2060,7 @@ glusterfs_fini (glusterfs_handle_t handle) FREE (ctx->gf_ctx.event_pool); mem_pool_destroy (ctx->itable->inode_pool); mem_pool_destroy (ctx->itable->dentry_pool); + mem_pool_destroy (ctx->itable->fd_mem_pool); /* iobuf_pool_destroy (ctx->gf_ctx.iobuf_pool); */ ((gf_timer_registry_t *)ctx->gf_ctx.timer)->fin = 1; -- cgit