public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: dont loop for nowait writes when checking for cross references
@ 2024-11-15 15:52 fdmanana
  2024-11-15 16:10 ` Josef Bacik
  0 siblings, 1 reply; 2+ messages in thread
From: fdmanana @ 2024-11-15 15:52 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

When checking for delayed refs when verifying if there are cross
references for a data extent, we stop if the path has nowait set and we
can't try lock the delayed ref head's mutex, returning -EAGAIN with the
goal of making a write fallback to a blocking context. However we ignore
the -EAGAIN at btrfs_cross_ref_exist() when check_delayed_ref() returns
it, and keep looping instead of immediately returning the -EGAIN to the
caller.

Fix this by not looping if we get -EAGAIN and we have a nowait path.

Fixes: 26ce91144631 ("btrfs: make can_nocow_extent nowait compatible")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/extent-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 412e318e4a22..bd09dd3ad1a0 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2422,7 +2422,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
 			goto out;
 
 		ret = check_delayed_ref(root, path, objectid, offset, bytenr);
-	} while (ret == -EAGAIN);
+	} while (ret == -EAGAIN && !path->nowait);
 
 out:
 	btrfs_release_path(path);
-- 
2.45.2


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

* Re: [PATCH] btrfs: dont loop for nowait writes when checking for cross references
  2024-11-15 15:52 [PATCH] btrfs: dont loop for nowait writes when checking for cross references fdmanana
@ 2024-11-15 16:10 ` Josef Bacik
  0 siblings, 0 replies; 2+ messages in thread
From: Josef Bacik @ 2024-11-15 16:10 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Fri, Nov 15, 2024 at 03:52:38PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> When checking for delayed refs when verifying if there are cross
> references for a data extent, we stop if the path has nowait set and we
> can't try lock the delayed ref head's mutex, returning -EAGAIN with the
> goal of making a write fallback to a blocking context. However we ignore
> the -EAGAIN at btrfs_cross_ref_exist() when check_delayed_ref() returns
> it, and keep looping instead of immediately returning the -EGAIN to the
> caller.
> 
> Fix this by not looping if we get -EAGAIN and we have a nowait path.
> 
> Fixes: 26ce91144631 ("btrfs: make can_nocow_extent nowait compatible")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

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

end of thread, other threads:[~2024-11-15 16:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 15:52 [PATCH] btrfs: dont loop for nowait writes when checking for cross references fdmanana
2024-11-15 16:10 ` Josef Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox