]> git.baikalelectronics.ru Git - kernel.git/commitdiff
afs: Fix the nlink handling of dir-over-dir rename
authorDavid Howells <dhowells@redhat.com>
Thu, 27 May 2021 10:24:33 +0000 (11:24 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 27 May 2021 16:23:58 +0000 (06:23 -1000)
Fix rename of one directory over another such that the nlink on the deleted
directory is cleared to 0 rather than being decremented to 1.

This was causing the generic/035 xfstest to fail.

Fixes: 511b1ded7178 ("afs: Build an abstraction around an "operation" concept")
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
Link: https://lore.kernel.org/r/162194384460.3999479.7605572278074191079.stgit@warthog.procyon.org.uk/
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/afs/dir.c

index 9fbe5a5ec9bd493e35394c84e4c4ce6f8fd1b541..78719f2f567e9fbce41a927f012f0dffa45329a4 100644 (file)
@@ -1919,7 +1919,9 @@ static void afs_rename_edit_dir(struct afs_operation *op)
        new_inode = d_inode(new_dentry);
        if (new_inode) {
                spin_lock(&new_inode->i_lock);
-               if (new_inode->i_nlink > 0)
+               if (S_ISDIR(new_inode->i_mode))
+                       clear_nlink(new_inode);
+               else if (new_inode->i_nlink > 0)
                        drop_nlink(new_inode);
                spin_unlock(&new_inode->i_lock);
        }