From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Chinner Subject: [PATCH 11/21] fs: move i_ref increments into find_inode/find_inode_fast Date: Thu, 21 Oct 2010 11:49:36 +1100 Message-ID: <1287622186-1935-12-git-send-email-david@fromorbit.com> References: <1287622186-1935-1-git-send-email-david@fromorbit.com> Cc: linux-kernel@vger.kernel.org To: linux-fsdevel@vger.kernel.org Return-path: In-Reply-To: <1287622186-1935-1-git-send-email-david@fromorbit.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org From: Christoph Hellwig Now that iunique is not abusing find_inode anymore we can move the i_ref increment back to where it belongs. Signed-off-by: Christoph Hellwig Signed-off-by: Dave Chinner --- fs/inode.c | 30 +++++++++++------------------- 1 files changed, 11 insertions(+), 19 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 77ff091..6b97eb7 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -657,11 +657,9 @@ static struct shrinker icache_shrinker = { }; static void __wait_on_freeing_inode(struct inode *inode); + /* * Called with the inode lock held. - * NOTE: we are not increasing the inode-refcount, you must take a reference - * by hand after calling find_inode now! This simplifies iunique and won't - * add any additional branch in the common code. */ static struct inode *find_inode(struct super_block *sb, struct hlist_head *head, @@ -681,9 +679,12 @@ repeat: __wait_on_freeing_inode(inode); goto repeat; } - break; + spin_lock(&inode->i_lock); + inode->i_ref++; + spin_unlock(&inode->i_lock); + return inode; } - return node ? inode : NULL; + return NULL; } /* @@ -706,9 +707,12 @@ repeat: __wait_on_freeing_inode(inode); goto repeat; } - break; + spin_lock(&inode->i_lock); + inode->i_ref++; + spin_unlock(&inode->i_lock); + return inode; } - return node ? inode : NULL; + return NULL; } static inline void @@ -853,9 +857,6 @@ static struct inode *get_new_inode(struct super_block *sb, * us. Use the old inode instead of the one we just * allocated. */ - spin_lock(&old->i_lock); - old->i_ref++; - spin_unlock(&old->i_lock); spin_unlock(&inode_lock); destroy_inode(inode); inode = old; @@ -902,9 +903,6 @@ static struct inode *get_new_inode_fast(struct super_block *sb, * us. Use the old inode instead of the one we just * allocated. */ - spin_lock(&old->i_lock); - old->i_ref++; - spin_unlock(&old->i_lock); spin_unlock(&inode_lock); destroy_inode(inode); inode = old; @@ -1022,9 +1020,6 @@ static struct inode *ifind(struct super_block *sb, spin_lock(&inode_lock); inode = find_inode(sb, head, test, data); if (inode) { - spin_lock(&inode->i_lock); - inode->i_ref++; - spin_unlock(&inode->i_lock); spin_unlock(&inode_lock); if (likely(wait)) wait_on_inode(inode); @@ -1057,9 +1052,6 @@ static struct inode *ifind_fast(struct super_block *sb, spin_lock(&inode_lock); inode = find_inode_fast(sb, head, ino); if (inode) { - spin_lock(&inode->i_lock); - inode->i_ref++; - spin_unlock(&inode->i_lock); spin_unlock(&inode_lock); wait_on_inode(inode); return inode; -- 1.7.1