linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "fs/ntfs3: Replace inode_trylock with inode_lock"
@ 2025-07-07 12:47 Konstantin Komarov
  2025-07-07 13:00 ` Christoph Hellwig
  2025-07-07 13:44 ` Lorenzo Stoakes
  0 siblings, 2 replies; 5+ messages in thread
From: Konstantin Komarov @ 2025-07-07 12:47 UTC (permalink / raw)
  To: ntfs3
  Cc: linux-kernel, linux-fsdevel, Konstantin Komarov,
	syzbot+a5d1c9dfa91705cd2f6d, Lorenzo Stoakes

This reverts commit 69505fe98f198ee813898cbcaf6770949636430b.

Make lock acquiring conditional to avoid the deadlock.

Fixes: 69505fe98f19 ("fs/ntfs3: Replace inode_trylock with inode_lock")
Reported-by: syzbot+a5d1c9dfa91705cd2f6d@syzkaller.appspotmail.com
Suggested-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/file.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 65fb27d1e17c..2e321b84a1ed 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -322,7 +322,10 @@ static int ntfs_file_mmap(struct file *file, struct vm_area_struct *vma)
 		}
 
 		if (ni->i_valid < to) {
-			inode_lock(inode);
+			if (!inode_trylock(inode)) {
+				err = -EAGAIN;
+				goto out;
+			}
 			err = ntfs_extend_initialized_size(file, ni,
 							   ni->i_valid, to);
 			inode_unlock(inode);
-- 
2.43.0


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

* Re: [PATCH] Revert "fs/ntfs3: Replace inode_trylock with inode_lock"
  2025-07-07 12:47 [PATCH] Revert "fs/ntfs3: Replace inode_trylock with inode_lock" Konstantin Komarov
@ 2025-07-07 13:00 ` Christoph Hellwig
  2025-07-07 13:44 ` Lorenzo Stoakes
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2025-07-07 13:00 UTC (permalink / raw)
  To: Konstantin Komarov
  Cc: ntfs3, linux-kernel, linux-fsdevel, syzbot+a5d1c9dfa91705cd2f6d,
	Lorenzo Stoakes

On Mon, Jul 07, 2025 at 02:47:38PM +0200, Konstantin Komarov wrote:
> This reverts commit 69505fe98f198ee813898cbcaf6770949636430b.
> 
> Make lock acquiring conditional to avoid the deadlock.

This is not a very useful commit message for a locking change.
Please explain the problem this solves, and why the original reason
for the locking change isn't valid any more, or less important than
the newly arising issue.


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

* Re: [PATCH] Revert "fs/ntfs3: Replace inode_trylock with inode_lock"
  2025-07-07 12:47 [PATCH] Revert "fs/ntfs3: Replace inode_trylock with inode_lock" Konstantin Komarov
  2025-07-07 13:00 ` Christoph Hellwig
@ 2025-07-07 13:44 ` Lorenzo Stoakes
  2025-07-08  7:57   ` [PATCH v2] " Konstantin Komarov
  1 sibling, 1 reply; 5+ messages in thread
From: Lorenzo Stoakes @ 2025-07-07 13:44 UTC (permalink / raw)
  To: Konstantin Komarov
  Cc: ntfs3, linux-kernel, linux-fsdevel, syzbot+a5d1c9dfa91705cd2f6d,
	Christoph Hellwig

+cc hch given his response

On Mon, Jul 07, 2025 at 02:47:38PM +0200, Konstantin Komarov wrote:
> This reverts commit 69505fe98f198ee813898cbcaf6770949636430b.
>
> Make lock acquiring conditional to avoid the deadlock.
>
> Fixes: 69505fe98f19 ("fs/ntfs3: Replace inode_trylock with inode_lock")
> Reported-by: syzbot+a5d1c9dfa91705cd2f6d@syzkaller.appspotmail.com
> Suggested-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

OK you made me have to go searching to figure out where I suggested this :) it
was in:

https://lore.kernel.org/all/2076fb41-4017-4ae4-99df-acfb6148a408@lucifer.local/

Which is in fact syzbot+a91fcdbd2698f99db8f4@syzkaller.appspotmail.com ...

I'm guessing the reported-by you've mentioned here is the same thing but would
have been helpful to link the original report.

Anyway I'm with Christoph here - your commit message is really not great,
esp. since you don't link the report where I provided you with an analysis.

So I suggest you:

- Summarise what I said there in commit message

- Provide a Reported-by tag for the syzkaller report I gave, since it's more
  useful than the other one (which is presumably a dupe anyway)

- Provide a Closes tag linking that report so it's easy for people to see.

Thanks!

> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
> ---
>  fs/ntfs3/file.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
> index 65fb27d1e17c..2e321b84a1ed 100644
> --- a/fs/ntfs3/file.c
> +++ b/fs/ntfs3/file.c
> @@ -322,7 +322,10 @@ static int ntfs_file_mmap(struct file *file, struct vm_area_struct *vma)
>  		}
>
>  		if (ni->i_valid < to) {
> -			inode_lock(inode);
> +			if (!inode_trylock(inode)) {
> +				err = -EAGAIN;
> +				goto out;
> +			}
>  			err = ntfs_extend_initialized_size(file, ni,
>  							   ni->i_valid, to);
>  			inode_unlock(inode);
> --
> 2.43.0
>

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

* [PATCH v2] Revert "fs/ntfs3: Replace inode_trylock with inode_lock"
  2025-07-07 13:44 ` Lorenzo Stoakes
@ 2025-07-08  7:57   ` Konstantin Komarov
  2025-07-09 14:16     ` Lorenzo Stoakes
  0 siblings, 1 reply; 5+ messages in thread
From: Konstantin Komarov @ 2025-07-08  7:57 UTC (permalink / raw)
  To: ntfs3
  Cc: linux-kernel, linux-fsdevel, Konstantin Komarov,
	syzbot+a91fcdbd2698f99db8f4, Lorenzo Stoakes

This reverts commit 69505fe98f198ee813898cbcaf6770949636430b.

Initially, conditional lock acquisition was removed to fix an xfstest bug
that was observed during internal testing. The deadlock reported by syzbot
is resolved by reintroducing conditional acquisition. The xfstest bug no
longer occurs on kernel version 6.16-rc1 during internal testing. I
assume that changes in other modules may have contributed to this.

Fixes: 69505fe98f19 ("fs/ntfs3: Replace inode_trylock with inode_lock")
Reported-by: syzbot+a91fcdbd2698f99db8f4@syzkaller.appspotmail.com
Suggested-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/file.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 65fb27d1e17c..2e321b84a1ed 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -322,7 +322,10 @@ static int ntfs_file_mmap(struct file *file, struct vm_area_struct *vma)
 		}
 
 		if (ni->i_valid < to) {
-			inode_lock(inode);
+			if (!inode_trylock(inode)) {
+				err = -EAGAIN;
+				goto out;
+			}
 			err = ntfs_extend_initialized_size(file, ni,
 							   ni->i_valid, to);
 			inode_unlock(inode);
-- 
2.43.0


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

* Re: [PATCH v2] Revert "fs/ntfs3: Replace inode_trylock with inode_lock"
  2025-07-08  7:57   ` [PATCH v2] " Konstantin Komarov
@ 2025-07-09 14:16     ` Lorenzo Stoakes
  0 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Stoakes @ 2025-07-09 14:16 UTC (permalink / raw)
  To: Konstantin Komarov
  Cc: ntfs3, linux-kernel, linux-fsdevel, syzbot+a91fcdbd2698f99db8f4

On Tue, Jul 08, 2025 at 09:57:09AM +0200, Konstantin Komarov wrote:
> This reverts commit 69505fe98f198ee813898cbcaf6770949636430b.
>
> Initially, conditional lock acquisition was removed to fix an xfstest bug
> that was observed during internal testing. The deadlock reported by syzbot
> is resolved by reintroducing conditional acquisition. The xfstest bug no
> longer occurs on kernel version 6.16-rc1 during internal testing. I
> assume that changes in other modules may have contributed to this.

Great to have additional info about xfstest there.

>
> Fixes: 69505fe98f19 ("fs/ntfs3: Replace inode_trylock with inode_lock")
> Reported-by: syzbot+a91fcdbd2698f99db8f4@syzkaller.appspotmail.com

Thanks for swapping out the reported-by!

> Suggested-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>

LGTM so:

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

> ---
>  fs/ntfs3/file.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
> index 65fb27d1e17c..2e321b84a1ed 100644
> --- a/fs/ntfs3/file.c
> +++ b/fs/ntfs3/file.c
> @@ -322,7 +322,10 @@ static int ntfs_file_mmap(struct file *file, struct vm_area_struct *vma)
>  		}
>
>  		if (ni->i_valid < to) {
> -			inode_lock(inode);
> +			if (!inode_trylock(inode)) {
> +				err = -EAGAIN;
> +				goto out;
> +			}
>  			err = ntfs_extend_initialized_size(file, ni,
>  							   ni->i_valid, to);
>  			inode_unlock(inode);
> --
> 2.43.0
>

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

end of thread, other threads:[~2025-07-09 14:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07 12:47 [PATCH] Revert "fs/ntfs3: Replace inode_trylock with inode_lock" Konstantin Komarov
2025-07-07 13:00 ` Christoph Hellwig
2025-07-07 13:44 ` Lorenzo Stoakes
2025-07-08  7:57   ` [PATCH v2] " Konstantin Komarov
2025-07-09 14:16     ` Lorenzo Stoakes

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).