From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guo Chao Subject: [PATCH 4/4] fs/inode.c: always take i_lock before calling filesystem's test() method Date: Fri, 21 Sep 2012 17:31:06 +0800 Message-ID: <1348219866-1799-5-git-send-email-yan@linux.vnet.ibm.com> References: <1348219866-1799-1-git-send-email-yan@linux.vnet.ibm.com> Cc: dchinner@redhat.com, hch@infradead.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: viro@zeniv.linux.org.uk Return-path: In-Reply-To: <1348219866-1799-1-git-send-email-yan@linux.vnet.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org In insert_inode_locked4(), we call test() without i_lock held, it's inconsistent with other places that calling test(). Though this function is only used by reiserfs, in which case i_lock is unnecessary, we should provide test() a consistent locking context. This patch calls test() under the protection of i_lock in insert_inode_locked4(). Signed-off-by: Guo Chao --- fs/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 89d2bcc..4c7e6e2 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1312,9 +1312,11 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval, hlist_for_each_entry(old, node, head, i_hash) { if (old->i_sb != sb) continue; - if (!test(old, data)) - continue; spin_lock(&old->i_lock); + if (!test(old, data)) { + spin_unlock(&old->i_lock); + continue; + } if (old->i_state & (I_FREEING|I_WILL_FREE)) { spin_unlock(&old->i_lock); continue; -- 1.7.9.5