lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1348219866-1799-3-git-send-email-yan@linux.vnet.ibm.com>
Date:	Fri, 21 Sep 2012 17:31:04 +0800
From:	Guo Chao <yan@...ux.vnet.ibm.com>
To:	viro@...iv.linux.org.uk
Cc:	dchinner@...hat.com, hch@...radead.org, jack@...e.cz,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/4] fs/inode.c: do not take i_lock in __(insert|remove)_inode_hash

At the beginning of fs/inode.c, the comment suggests both inode_hash_lock and
i_lock protect i_hash. I wonder why two locks are needed.

Grep the source code shows that i_hash is accessed in limited and
well-defined places:

        1. In inode_unhashed()
        2. In some special cases, as argument to hlist_add_fake()
        3. Traverse inode hash list
        4. Add/remove inode to/from inode hash list.

Case #1, #2 are not in any locking context. Case #3, #4 will hold
inode_hash_lock. i_hash is not accessed by other ways. This suggests that
inode_hash_lock alone protects i_hash well.

In __(insert|remove)_inode_hash(), our only goal is to manipulate i_hash, do
not take i_lock in these functions.

Signed-off-by: Guo Chao <yan@...ux.vnet.ibm.com>
---
 fs/inode.c |    4 ----
 1 file changed, 4 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index d2d15aa..54e4b29 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -463,9 +463,7 @@ void __insert_inode_hash(struct inode *inode, unsigned long hashval)
 	struct hlist_head *b = inode_hashtable + hash(inode->i_sb, hashval);
 
 	spin_lock(&inode_hash_lock);
-	spin_lock(&inode->i_lock);
 	hlist_add_head(&inode->i_hash, b);
-	spin_unlock(&inode->i_lock);
 	spin_unlock(&inode_hash_lock);
 }
 EXPORT_SYMBOL(__insert_inode_hash);
@@ -479,9 +477,7 @@ EXPORT_SYMBOL(__insert_inode_hash);
 void __remove_inode_hash(struct inode *inode)
 {
 	spin_lock(&inode_hash_lock);
-	spin_lock(&inode->i_lock);
 	hlist_del_init(&inode->i_hash);
-	spin_unlock(&inode->i_lock);
 	spin_unlock(&inode_hash_lock);
 }
 EXPORT_SYMBOL(__remove_inode_hash);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ