From: Richard Weinberger <richard@nod.at>
To: viro@zeniv.linux.org.uk
Cc: dchinner@redhat.com, hch@lst.de, eric.dumazet@gmail.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Richard Weinberger <richard@nod.at>
Subject: [PATCH] fs/inode: No need to take ->i_lock right after alloc_inode()
Date: Sat, 14 Dec 2013 21:54:55 +0100 [thread overview]
Message-ID: <1387054495-31498-1-git-send-email-richard@nod.at> (raw)
In all three cases, new_inode_pseudo(), iget_locked() and iget5_locked(),
we own the new inode exclusively at this point and therefore taking
->i_lock to protect ->i_state/->i_hash against concurrent access is superfluous.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
fs/inode.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 4bcdad3..5f2a735 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -869,9 +869,7 @@ struct inode *new_inode_pseudo(struct super_block *sb)
struct inode *inode = alloc_inode(sb);
if (inode) {
- spin_lock(&inode->i_lock);
inode->i_state = 0;
- spin_unlock(&inode->i_lock);
INIT_LIST_HEAD(&inode->i_sb_list);
}
return inode;
@@ -1025,10 +1023,8 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval,
if (set(inode, data))
goto set_failed;
- spin_lock(&inode->i_lock);
inode->i_state = I_NEW;
hlist_add_head(&inode->i_hash, head);
- spin_unlock(&inode->i_lock);
inode_sb_list_add(inode);
spin_unlock(&inode_hash_lock);
@@ -1092,10 +1088,8 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino)
old = find_inode_fast(sb, head, ino);
if (!old) {
inode->i_ino = ino;
- spin_lock(&inode->i_lock);
inode->i_state = I_NEW;
hlist_add_head(&inode->i_hash, head);
- spin_unlock(&inode->i_lock);
inode_sb_list_add(inode);
spin_unlock(&inode_hash_lock);
--
1.8.4.2
next reply other threads:[~2013-12-14 20:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-14 20:54 Richard Weinberger [this message]
2014-01-08 10:21 ` [PATCH] fs/inode: No need to take ->i_lock right after alloc_inode() Richard Weinberger
2014-01-10 9:22 ` Christoph Hellwig
2014-01-10 9:48 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387054495-31498-1-git-send-email-richard@nod.at \
--to=richard@nod.at \
--cc=dchinner@redhat.com \
--cc=eric.dumazet@gmail.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).