btrfs: scrub: limit RST scrub to chunk boundary
authorQu Wenruo <wqu@suse.com>
Wed, 17 Jan 2024 00:32:26 +0000 (11:02 +1030)
committerDavid Sterba <dsterba@suse.com>
Thu, 18 Jan 2024 22:43:08 +0000 (23:43 +0100)
commit7f2d219e78e95a137a9c76fddac7ff8228260439
treef6d2ba99e3f8148706efd6f580a9ed9378cf0bb7
parentf546c4282673497a06ecb6190b50ae7f6c85b02f
btrfs: scrub: limit RST scrub to chunk boundary

[BUG]
If there is an extent beyond chunk boundary, currently RST scrub would
error out.

[CAUSE]
In scrub_submit_extent_sector_read(), we completely rely on
extent_sector_bitmap, which is populated using extent tree.

The extent tree can be corrupted that there is an extent item beyond a
chunk.

In that case, RST scrub would fail and error out.

[FIX]
Despite the extent_sector_bitmap usage, also limit the read to chunk
boundary.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/scrub.c