btrfs: RST scrub fixes for prealloc
cover btrfs: RST scrub fixes for prealloc
From: Johannes Thumshirn <[email protected]>
When scrubbing a non-zoned RAID stripe tree filesystem, the RST specific scrub code finds false positives becuase preallocated extents are not backed by the stripe-tree and so the lookup failes.
These patches address the issue by a) changing RST lookup failures from ENOENT to ENODATA and b) skipping ENODATA on RST mapping errors from the scrub side.
This aproach was suggested by Josef in
https://lore.kernel.org/linux-btrfs/20240923152705.GB159452@perftesting/
Johannes Thumshirn (2):
btrfs: return ENODATA in case RST lookup fails
btrfs: scrub: skip initial RAID stripe-tree lookup errors
fs/btrfs/raid-stripe-tree.c | 6 +++--- fs/btrfs/scrub.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 btrfs: return ENODATA in case RST lookup fails
From: Johannes Thumshirn <[email protected]>
In case a lookup in the RAID stripe-tree fails, return ENODATA instead of ENOENT to better distinguish stripe-tree lookups from other code paths where we return ENOENT.
--- fs/btrfs/raid-stripe-tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/raid-stripe-tree.c +3 -3
@@ -234,7 +234,7 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info, found_end = found_logical + found_length;if (found_logical > end) { - ret = -ENOENT ; + ret = -ENODATA ; goto out; }
@@ -280,10 +280,10 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info, }/* If we're here, we haven't found the requested devid in the stripe. */ - ret = -ENOENT ; + ret = -ENODATA ; out:if (ret >0 ) - ret = -ENOENT ; + ret = -ENODATA ;if (ret && ret != -EIO && !stripe->rst_search_commit_root) { btrfs_debug(fs_info, "cannot find raid-stripe for logical [%llu, %llu] devid %llu, profile %s",
Signature · 1 line
2.43.0
PATCH 2/2 btrfs: scrub: skip initial RAID stripe-tree lookup errors
In reply to Johannes ThumshirnFrom: Johannes Thumshirn <[email protected]>
Performing the initial extent sector read on a RAID stripe-tree backed filesystem with pre-allocated extents will cause the RAID stripe-tree lookup code to return ENODATA, as pre-allocated extents do not have any on-disk bytes and thus no RAID stripe-tree entries.
But the current scrub read code marks these extens as errors, because the lookup fails.
If btrfs_map_block() returns -ENODATA, it means that the call to btrfs_get_raid_extent_offset() returned -ENODATA, because there is no entry for the corresponding range in the RAID stripe-tree. But as this range is in the extent-tree it means we've hit a pre-allocated extent. In this case, don't mark the sector in the stripe's error bitmaps as faulty and carry on to the next.
--- fs/btrfs/scrub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/scrub.c +4 -2
@@ -1704,8 +1704,10 @@ static void scrub_submit_extent_sector_read(struct scrub_ctx *sctx, &stripe_len, &bioc, &io_stripe, &mirror);btrfs_put_bioc (bioc);if (err <0 ) { -set_bit (i, &stripe->io_error_bitmap); -set_bit (i, &stripe->error_bitmap); +if (err != -ENODATA ) { +set_bit (i, &stripe->io_error_bitmap); +set_bit (i, &stripe->error_bitmap); + }continue ; }
Signature · 1 line
2.43.0
Re: [PATCH 2/2] btrfs: scrub: skip initial RAID stripe-tree lookup errors
Quoted 10 lines · Johannes Thumshirn
From: Johannes Thumshirn <[email protected]>
Performing the initial extent sector read on a RAID stripe-tree backed filesystem with pre-allocated extents will cause the RAID stripe-tree lookup code to return ENODATA, as pre-allocated extents do not have any on-disk bytes and thus no RAID stripe-tree entries.
But the current scrub read code marks these extens as errors, because the lookup fails.
Quoted 6 lines
If
btrfs_map_block()returns-ENODATA, it means that the call tobtrfs_get_raid_extent_offset()returned-ENODATA, because there is no entry for the corresponding range in the RAID stripe-tree. But as this range is in the extent-tree it means we've hit a pre-allocated extent. In this case, don't mark the sector in the stripe's error bitmaps as faulty and carry on to the next.
I've added summary of this paragraph as a comment to the code, using the ENODATA for a specific relations in the trees is quite unobvious.
Quoted 10 lines · Johannes Thumshirn
From: Johannes Thumshirn <[email protected]>
When scrubbing a non-zoned RAID stripe tree filesystem, the RST specific scrub code finds false positives becuase preallocated extents are not backed by the stripe-tree and so the lookup failes.
These patches address the issue by a) changing RST lookup failures from ENOENT to ENODATA and b) skipping ENODATA on RST mapping errors from the scrub side.
Quoted 7 lines
This aproach was suggested by Josef in
https://lore.kernel.org/linux-btrfs/20240923152705.GB159452@perftesting/Johannes Thumshirn (2):
btrfs: return ENODATA in case RST lookup fails
btrfs: scrub: skip initial RAID stripe-tree lookup errors
Thanks,
Josef