linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: scrub: skip PREALLOC extents on RAID stripe-tree
@ 2024-09-12 14:33 Johannes Thumshirn
  2024-09-12 21:32 ` Qu Wenruo
  0 siblings, 1 reply; 12+ messages in thread
From: Johannes Thumshirn @ 2024-09-12 14:33 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba,
	open list:BTRFS FILE SYSTEM, open list
  Cc: Johannes Thumshirn, Qu Wenru

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

When scrubbing a RAID stripe-tree based filesystem with preallocated
extents, the btrfs_map_block() called by
scrub_submit_extent_sector_read() will return ENOENT, because there is
no RAID stripe-tree entry for preallocated extents. This then causes
the sector to be marked as a sector with an I/O error.

To prevent this false alert don't mark secotors for that
btrfs_map_block() returned an ENOENT as I/O errors but skip them.

This results for example in errors in fstests' btrfs/060 .. btrfs/074
which all perform fsstress and scrub operations. Whit this fix, these
errors are gone and the tests pass again.

Cc: Qu Wenru <wqu@suse.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/scrub.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 3a3427428074..b195c41676e3 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1657,7 +1657,7 @@ static u32 stripe_length(const struct scrub_stripe *stripe)
 }
 
 static void scrub_submit_extent_sector_read(struct scrub_ctx *sctx,
-					    struct scrub_stripe *stripe)
+					   struct scrub_stripe *stripe)
 {
 	struct btrfs_fs_info *fs_info = stripe->bg->fs_info;
 	struct btrfs_bio *bbio = NULL;
@@ -1703,10 +1703,21 @@ static void scrub_submit_extent_sector_read(struct scrub_ctx *sctx,
 			err = btrfs_map_block(fs_info, BTRFS_MAP_READ, logical,
 					      &stripe_len, &bioc, &io_stripe, &mirror);
 			btrfs_put_bioc(bioc);
-			if (err < 0) {
+			if (err < 0 && err != -ENOENT) {
 				set_bit(i, &stripe->io_error_bitmap);
 				set_bit(i, &stripe->error_bitmap);
 				continue;
+			} else if (err == -ENOENT) {
+				/*
+				 * btrfs_map_block() returns -ENOENT if it can't
+				 * find the logical  address in the RAID stripe
+				 * tree. This can happens on PREALLOC  extents.
+				 * As we know the extent tree  has an extent
+				 * recorded there, we can be sure this is a
+				 * PREALLOC  extent, so skip this sector and
+				 * continue to the next.
+				 */
+				continue;
 			}
 
 			bbio = btrfs_bio_alloc(stripe->nr_sectors, REQ_OP_READ,
-- 
2.43.0


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

end of thread, other threads:[~2024-09-23 15:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 14:33 [PATCH] btrfs: scrub: skip PREALLOC extents on RAID stripe-tree Johannes Thumshirn
2024-09-12 21:32 ` Qu Wenruo
2024-09-13  5:42   ` Johannes Thumshirn
2024-09-13  5:47     ` Qu Wenruo
2024-09-18 14:08       ` [RFC 0/2] Add dummy RAID stripe tree entries for PREALLOC data Johannes Thumshirn
2024-09-18 14:08         ` [RFC 1/2] btrfs: introduce dummy RAID stripes for preallocated data Johannes Thumshirn
2024-09-18 14:08         ` [RFC 2/2] btrfs: insert dummy RAID stripe extents " Johannes Thumshirn
2024-09-18 23:45         ` [RFC 0/2] Add dummy RAID stripe tree entries for PREALLOC data Qu Wenruo
2024-09-19 15:42           ` Johannes Thumshirn
2024-09-19 16:57         ` Gerhard Wiesinger
2024-09-20  9:50           ` Johannes Thumshirn
2024-09-23 15:27         ` Josef Bacik

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