Messages in this thread Patch in this message | | | 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 |
| |
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 <yan@linux.vnet.ibm.com> --- 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
| |