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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1348219866-1799-4-git-send-email-yan@linux.vnet.ibm.com>
Date:	Fri, 21 Sep 2012 17:31:05 +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 3/4] fs/inode.c: do not take i_lock when identify an inode

Identity of an inode, which is defined by i_sb and i_ino or by individual
filesystem specific way, is not expected to be changed during inode's life
time. When identify an inode, taking i_lock _seems_ unnecessary. In source
code, we do have functions identifying an inode without i_lock held,
e.g. test_inode_iunique().

Then, fix those functions which take i_lock, e.g. find_inode_fast().

Note this change still put individual filesystem's test() method under
i_lock's protection. See next patch for more.

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

diff --git a/fs/inode.c b/fs/inode.c
index 54e4b29..89d2bcc 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -786,11 +786,9 @@ static struct inode *find_inode(struct super_block *sb,
 
 repeat:
 	hlist_for_each_entry(inode, node, head, i_hash) {
-		spin_lock(&inode->i_lock);
-		if (inode->i_sb != sb) {
-			spin_unlock(&inode->i_lock);
+		if (inode->i_sb != sb)
 			continue;
-		}
+		spin_lock(&inode->i_lock);
 		if (!test(inode, data)) {
 			spin_unlock(&inode->i_lock);
 			continue;
@@ -818,15 +816,11 @@ static struct inode *find_inode_fast(struct super_block *sb,
 
 repeat:
 	hlist_for_each_entry(inode, node, head, i_hash) {
-		spin_lock(&inode->i_lock);
-		if (inode->i_ino != ino) {
-			spin_unlock(&inode->i_lock);
+		if (inode->i_ino != ino)
 			continue;
-		}
-		if (inode->i_sb != sb) {
-			spin_unlock(&inode->i_lock);
+		if (inode->i_sb != sb)
 			continue;
-		}
+		spin_lock(&inode->i_lock);
 		if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
 			__wait_on_freeing_inode(inode);
 			goto repeat;
-- 
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