summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2010-08-05 03:59:38 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-06 03:37:32 -0700
commit767b6b7d3f5b5e96e13f459fae6260d7cb129403 (patch)
tree80a8cee5be6b9eed718d5406c52e1d66e6bde5b6 /libglusterfs/src
parent305025fbf823007fe715ea1ae0bbe44102221663 (diff)
Implement mem pool for inode dentry
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
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/inode.c38
-rw-r--r--libglusterfs/src/inode.h2
2 files changed, 33 insertions, 7 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index ba5460de459..5d35d4cc314 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -133,6 +133,8 @@ __dentry_unhash (dentry_t *dentry)
static void
__dentry_unset (dentry_t *dentry)
{
+ struct mem_pool *tmp_pool = dentry->inode->table->dentry_pool;
+
__dentry_unhash (dentry);
list_del_init (&dentry->inode_list);
@@ -145,10 +147,13 @@ __dentry_unset (dentry_t *dentry)
dentry->parent = NULL;
}
- GF_FREE (dentry);
+ mem_put (tmp_pool, dentry);
+ tmp_pool = NULL;
+
}
+
static void
__inode_unhash (inode_t *inode)
{
@@ -277,10 +282,13 @@ __inode_destroy (inode_t *inode)
int index = 0;
xlator_t *xl = NULL;
xlator_t *old_THIS = NULL;
+ struct mem_pool *tmp_pool = NULL;
if (!inode->_ctx)
goto noctx;
+ tmp_pool = inode->table->inode_pool;
+
for (index = 0; index < inode->table->xl->graph->xl_count; index++) {
if (inode->_ctx[index].xl_key) {
xl = (xlator_t *)(long)inode->_ctx[index].xl_key;
@@ -296,7 +304,9 @@ __inode_destroy (inode_t *inode)
noctx:
LOCK_DESTROY (&inode->lock);
// memset (inode, 0xb, sizeof (*inode));
- GF_FREE (inode);
+ mem_put (tmp_pool, inode);
+ tmp_pool = NULL;
+
}
@@ -418,8 +428,8 @@ __dentry_create (inode_t *inode, inode_t *parent, const char *name)
{
dentry_t *newd = NULL;
- newd = (void *) GF_CALLOC (1, sizeof (*newd),
- gf_common_mt_dentry_t);
+ newd = mem_get (parent->table->dentry_pool);
+
if (newd == NULL) {
gf_log ("inode", GF_LOG_ERROR, "out of memory");
goto out;
@@ -431,7 +441,7 @@ __dentry_create (inode_t *inode, inode_t *parent, const char *name)
newd->name = gf_strdup (name);
if (newd->name == NULL) {
gf_log ("inode", GF_LOG_ERROR, "out of memory");
- GF_FREE (newd);
+ mem_put (parent->table->dentry_pool, newd);
newd = NULL;
goto out;
}
@@ -452,7 +462,7 @@ __inode_create (inode_table_t *table)
{
inode_t *newi = NULL;
- newi = (void *) GF_CALLOC (1, sizeof (*newi), gf_common_mt_inode_t);
+ newi = mem_get(table->inode_pool);
if (!newi) {
gf_log ("inode", GF_LOG_ERROR, "out of memory");
goto out;
@@ -474,7 +484,7 @@ __inode_create (inode_table_t *table)
if (newi->_ctx == NULL) {
gf_log ("inode", GF_LOG_ERROR, "out of memory");
LOCK_DESTROY (&newi->lock);
- GF_FREE (newi);
+ mem_put (table->inode_pool, newi);
newi = NULL;
goto out;
}
@@ -1057,6 +1067,20 @@ inode_table_new (size_t lru_limit, xlator_t *xl)
new->hashsize = 14057; /* TODO: Random Number?? */
+ new->inode_pool = mem_pool_new (inode_t, 204654);
+
+ if (!new->inode_pool) {
+ GF_FREE (new);
+ return NULL;
+ }
+
+ new->dentry_pool = mem_pool_new (dentry_t, 204654);
+
+ if (!new->dentry_pool) {
+ GF_FREE (new);
+ return NULL;
+ }
+
new->inode_hash = (void *)GF_CALLOC (new->hashsize,
sizeof (struct list_head),
gf_common_mt_list_head);
diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h
index ef7866b0986..dbc721546f7 100644
--- a/libglusterfs/src/inode.h
+++ b/libglusterfs/src/inode.h
@@ -63,6 +63,8 @@ struct _inode_table {
number. inode_t's @hash is linked with @attic. It is
otherwise linked with @inode_hash */
uint32_t attic_size;
+ struct mem_pool *inode_pool; /* memory pool for inodes */
+ struct mem_pool *dentry_pool; /* memory pool for dentrys */
};