All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] afs: Fix the nlink handling of dir-over-dir rename
@ 2021-05-27 10:24 David Howells
  0 siblings, 0 replies; 3+ messages in thread
From: David Howells @ 2021-05-27 10:24 UTC (permalink / raw)
  To: torvalds; +Cc: Marc Dionne, linux-afs, dhowells, linux-fsdevel, linux-kernel

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: e49c7b2f6de7 ("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/ # v1
---

 fs/afs/dir.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 9fbe5a5ec9bd..78719f2f567e 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -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);
 	}



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] afs: Fix the nlink handling of dir-over-dir rename
  2021-05-25 11:57 David Howells
@ 2021-05-25 17:26 ` Marc Dionne
  0 siblings, 0 replies; 3+ messages in thread
From: Marc Dionne @ 2021-05-25 17:26 UTC (permalink / raw)
  To: David Howells; +Cc: linux-afs, linux-fsdevel, Linux Kernel Mailing List

On Tue, May 25, 2021 at 8:57 AM David Howells <dhowells@redhat.com> wrote:
>
> 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: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: linux-afs@lists.infradead.org
> ---
>
>  fs/afs/dir.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 9fbe5a5ec9bd..78719f2f567e 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -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);
>         }

Reviewed-by: Marc Dionne <marc.dionne@auristor.com>

Marc

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] afs: Fix the nlink handling of dir-over-dir rename
@ 2021-05-25 11:57 David Howells
  2021-05-25 17:26 ` Marc Dionne
  0 siblings, 1 reply; 3+ messages in thread
From: David Howells @ 2021-05-25 11:57 UTC (permalink / raw)
  To: linux-afs; +Cc: dhowells, linux-fsdevel, linux-kernel

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: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-afs@lists.infradead.org
---

 fs/afs/dir.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 9fbe5a5ec9bd..78719f2f567e 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -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);
 	}



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-27 10:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 10:24 [PATCH] afs: Fix the nlink handling of dir-over-dir rename David Howells
  -- strict thread matches above, loose matches on Subject: below --
2021-05-25 11:57 David Howells
2021-05-25 17:26 ` Marc Dionne

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.