lkml.org 
[lkml]   [2012]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/4] fs/inode.c: always take i_lock before calling filesystem's test() method
Date
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


\
 
 \ /
  Last update: 2012-09-21 12:21    [W:0.071 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site