Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: set start on clone before calling copy_extent_buffer_full
@ 2024-04-14  5:49 Josef Bacik
  2024-04-14 10:22 ` Filipe Manana
  0 siblings, 1 reply; 3+ messages in thread
From: Josef Bacik @ 2024-04-14  5:49 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

Our subpage testing started hanging on generic/560 and I bisected it
down to Fixes: 1cab1375ba6d ("btrfs: reuse cloned extent buffer during
fiemap to avoid re-allocations").  This is subtle because we use
eb->start to figure out where in the folio we're copying to when we're
subpage, as our ->start may refer to an area inside of the folio.

We were copying with ->start set to the previous value, and then
re-setting ->start in order to be used later on by fiemap.  However this
changed the offset into the eb that we would read from, which would
cause us to not emit EOF sometimes for fiemap.  Thanks to a bug in the
duperemove that the CI vms are using this manifested as a hung test.

Fix this by setting start before we co copy_extent_buffer_full to make
sure that we're copying into the same offset inside of the folio that we
will read from later.

With this fix we now pass generic/560 on our subpage tests.

Fixes: 1cab1375ba6d ("btrfs: reuse cloned extent buffer during fiemap toavoid re-allocations")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/extent_io.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 49f7161a6578..a3d0befaa461 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2809,13 +2809,17 @@ static int fiemap_next_leaf_item(struct btrfs_inode *inode, struct btrfs_path *p
 		goto out;
 	}
 
-	/* See the comment at fiemap_search_slot() about why we clone. */
-	copy_extent_buffer_full(clone, path->nodes[0]);
 	/*
 	 * Important to preserve the start field, for the optimizations when
 	 * checking if extents are shared (see extent_fiemap()).
+	 *
+	 * Additionally it needs to be set before we call
+	 * copy_extent_buffer_full because for subpagesize we need to make sure
+	 * we have the correctly calculated offset.
 	 */
 	clone->start = path->nodes[0]->start;
+	/* See the comment at fiemap_search_slot() about why we clone. */
+	copy_extent_buffer_full(clone, path->nodes[0]);
 
 	slot = path->slots[0];
 	btrfs_release_path(path);
-- 
2.43.0


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

end of thread, other threads:[~2024-04-14 12:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-14  5:49 [PATCH] btrfs: set start on clone before calling copy_extent_buffer_full Josef Bacik
2024-04-14 10:22 ` Filipe Manana
2024-04-14 12:54   ` Josef Bacik

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