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
This commit is contained in:
shishir gowda 2010-08-05 04:00:14 +00:00 committed by Anand V. Avati
parent 767b6b7d3f
commit f9431f330e
4 changed files with 15 additions and 2 deletions

View File

@ -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;

View File

@ -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]);
}

View File

@ -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 */
};

View File

@ -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;