summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2010-08-05 04:00:14 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-06 03:37:36 -0700
commitf9431f330e8f304e82d9b1443018987a926d56b6 (patch)
treee5f91f4f8f0cb9b3387f209944127022d915b598
parent767b6b7d3f5b5e96e13f459fae6260d7cb129403 (diff)
mem pool for fd_t
Ran posix compliance test and sanity test Signed-off-by: shishir gowda <shishirng@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 329 (Replacing memory allocation functions with mem-type functions) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=329
-rw-r--r--libglusterfs/src/fd.c8
-rw-r--r--libglusterfs/src/inode.c7
-rw-r--r--libglusterfs/src/inode.h1
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c1
4 files changed, 15 insertions, 2 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 9269e5cf838..231b7c5b00c 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 5d35d4cc314..ad65081dcfe 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; i<new->hashsize; i++) {
INIT_LIST_HEAD (&new->inode_hash[i]);
}
diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h
index dbc721546f7..18081b8f8ce 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 3ecb56c8c1f..61ca2d1e0f8 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;