iget/iget5: don't bother with ->i_lock until we find a match
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 6 Nov 2013 14:54:52 +0000 (09:54 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 9 Nov 2013 05:16:31 +0000 (00:16 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Documentation/filesystems/porting
drivers/staging/lustre/lustre/llite/namei.c
fs/inode.c
fs/ntfs/inode.c

index f0890581f7f65a14d8451e85dcb2f59912db1d3d..fe2b7ae6f96224b7110b3576080d2aef4b7fef31 100644 (file)
@@ -455,3 +455,11 @@ in your dentry operations instead.
        vfs_follow_link has been removed.  Filesystems must use nd_set_link
        from ->follow_link for normal symlinks, or nd_jump_link for magic
        /proc/<pid> style links.
+--
+[mandatory]
+       iget5_locked()/ilookup5()/ilookup5_nowait() test() callback used to be
+       called with both ->i_lock and inode_hash_lock held; the former is *not*
+       taken anymore, so verify that your callbacks do not rely on it (none
+       of the in-tree instances did).  inode_hash_lock is still held,
+       of course, so they are still serialized wrt removal from inode hash,
+       as well as wrt set() callback of iget5_locked().
index 34815b550e71248ce7c578c3417cec570c35a26d..90bbdae824ac522064d89515acbbc89ef6be4300 100644 (file)
@@ -83,7 +83,7 @@ int ll_unlock(__u32 mode, struct lustre_handle *lockh)
 }
 
 
-/* called from iget5_locked->find_inode() under inode_lock spinlock */
+/* called from iget5_locked->find_inode() under inode_hash_lock spinlock */
 static int ll_test_inode(struct inode *inode, void *opaque)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
index b33ba8e021cc286d500d94abd64d8f85115ebcd2..bf7a8b3ab937644a5fa7eb9e3cb87d1cb118fa21 100644 (file)
@@ -773,15 +773,11 @@ static struct inode *find_inode(struct super_block *sb,
 
 repeat:
        hlist_for_each_entry(inode, head, i_hash) {
-               spin_lock(&inode->i_lock);
-               if (inode->i_sb != sb) {
-                       spin_unlock(&inode->i_lock);
+               if (inode->i_sb != sb)
                        continue;
-               }
-               if (!test(inode, data)) {
-                       spin_unlock(&inode->i_lock);
+               if (!test(inode, data))
                        continue;
-               }
+               spin_lock(&inode->i_lock);
                if (inode->i_state & (I_FREEING|I_WILL_FREE)) {
                        __wait_on_freeing_inode(inode);
                        goto repeat;
@@ -804,15 +800,11 @@ static struct inode *find_inode_fast(struct super_block *sb,
 
 repeat:
        hlist_for_each_entry(inode, 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;
index 2778b0255dc6c0c845f2b222ac45605f77737442..ffb9b3675736334182e29b2b6e337f29efd8c5a7 100644 (file)
@@ -55,7 +55,7 @@
  *
  * Return 1 if the attributes match and 0 if not.
  *
- * NOTE: This function runs with the inode->i_lock spin lock held so it is not
+ * NOTE: This function runs with the inode_hash_lock spin lock held so it is not
  * allowed to sleep.
  */
 int ntfs_test_inode(struct inode *vi, ntfs_attr *na)