From 7ab25973f11cf4eedcf3cf1a628f03937536391b Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Tue, 24 Jul 2012 02:31:05 +0530 Subject: libglusterfs: fix creation of spurious root inodes Suppose lookup is sent on a newly created inode (gfid is root gfid), and in the call back inode_link is done, where if there is an inode already present in the inode table for that gfid, then we start using the present inode and the newly created inode supposedly gets destroyed when refcount comes down to zero through inode_unref calls. But inodes with root gfid are not unrefed. Now since in inode_link, the gfid has already been copied to the new inode and later the actual inode is found from the inode table, the new inode does not gets unrefed if its gfid is root gfid. Thus those spurious inodes with root gfid will be present throughout the lifetime of the filesystem. To fix this first search the inode table for an inode, with the gfid, present in the stat structure received as an argument. If the inode is not found, then copy the gfid to the newly created inode. Now whenever unref is called on on the new inode it gets unrefed and thus eventually gets destroyed Change-Id: I0f25f0a8dca3245abda1c322c216f063b52cf842 BUG: 841188 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.com/3716 Reviewed-by: Amar Tumballi Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/inode.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 2efcd89cc73..886491292a8 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -829,14 +829,13 @@ __inode_link (inode_t *inode, inode_t *parent, const char *name, if (uuid_is_null (iatt->ia_gfid)) return NULL; - uuid_copy (inode->gfid, iatt->ia_gfid); - inode->ia_type = iatt->ia_type; - - old_inode = __inode_find (table, inode->gfid); + old_inode = __inode_find (table, iatt->ia_gfid); if (old_inode) { link_inode = old_inode; } else { + uuid_copy (inode->gfid, iatt->ia_gfid); + inode->ia_type = iatt->ia_type; __inode_hash (inode); } } @@ -1300,8 +1299,8 @@ __inode_table_init_root (inode_table_t *table) iatt.ia_ino = 1; iatt.ia_type = IA_IFDIR; - table->root = root; __inode_link (root, NULL, NULL, &iatt); + table->root = root; } -- cgit