Skip to content

Commit 5a3cd99

Browse files
author
Al Viro
committed
iget/iget5: don't bother with ->i_lock until we find a match
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent b18825a commit 5a3cd99

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎Documentation/filesystems/porting‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,11 @@ in your dentry operations instead.
455455
vfs_follow_link has been removed. Filesystems must use nd_set_link
456456
from ->follow_link for normal symlinks, or nd_jump_link for magic
457457
/proc/<pid> style links.
458+
--
459+
[mandatory]
460+
iget5_locked()/ilookup5()/ilookup5_nowait() test() callback used to be
461+
called with both ->i_lock and inode_hash_lock held; the former is *not*
462+
taken anymore, so verify that your callbacks do not rely on it (none
463+
of the in-tree instances did). inode_hash_lock is still held,
464+
of course, so they are still serialized wrt removal from inode hash,
465+
as well as wrt set() callback of iget5_locked().

‎drivers/staging/lustre/lustre/llite/namei.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int ll_unlock(__u32 mode, struct lustre_handle *lockh)
8383
}
8484

8585

86-
/* called from iget5_locked->find_inode() under inode_lock spinlock */
86+
/* called from iget5_locked->find_inode() under inode_hash_lock spinlock */
8787
static int ll_test_inode(struct inode *inode, void *opaque)
8888
{
8989
struct ll_inode_info *lli = ll_i2info(inode);

‎fs/inode.c‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -773,15 +773,11 @@ static struct inode *find_inode(struct super_block *sb,
773773

774774
repeat:
775775
hlist_for_each_entry(inode, head, i_hash) {
776-
spin_lock(&inode->i_lock);
777-
if (inode->i_sb != sb) {
778-
spin_unlock(&inode->i_lock);
776+
if (inode->i_sb != sb)
779777
continue;
780-
}
781-
if (!test(inode, data)) {
782-
spin_unlock(&inode->i_lock);
778+
if (!test(inode, data))
783779
continue;
784-
}
780+
spin_lock(&inode->i_lock);
785781
if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
786782
__wait_on_freeing_inode(inode);
787783
goto repeat;
@@ -804,15 +800,11 @@ static struct inode *find_inode_fast(struct super_block *sb,
804800

805801
repeat:
806802
hlist_for_each_entry(inode, head, i_hash) {
807-
spin_lock(&inode->i_lock);
808-
if (inode->i_ino != ino) {
809-
spin_unlock(&inode->i_lock);
803+
if (inode->i_ino != ino)
810804
continue;
811-
}
812-
if (inode->i_sb != sb) {
813-
spin_unlock(&inode->i_lock);
805+
if (inode->i_sb != sb)
814806
continue;
815-
}
807+
spin_lock(&inode->i_lock);
816808
if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
817809
__wait_on_freeing_inode(inode);
818810
goto repeat;

‎fs/ntfs/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
* Return 1 if the attributes match and 0 if not.
5757
*
58-
* NOTE: This function runs with the inode->i_lock spin lock held so it is not
58+
* NOTE: This function runs with the inode_hash_lock spin lock held so it is not
5959
* allowed to sleep.
6060
*/
6161
int ntfs_test_inode(struct inode *vi, ntfs_attr *na)

0 commit comments

Comments
 (0)