diff options
| author | Qu Wenruo <wqu@suse.com> | 2026-07-05 21:24:48 +0930 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-08-07 19:17:16 +0200 |
| commit | 36c9fddcf8b7a6e3c66d7bc12d5b5eed9b9e54d3 (patch) | |
| tree | be9900cc710d56913ea87179c506ccdfbb5941f8 /tools/perf/scripts/python/bin/export-to-postgresql-record | |
| parent | 1462637d55eb25dd0cb6bc35a2c14bb1d5c635e1 (diff) | |
btrfs: scrub: implement calc_sector_number() in a faster way
Currently calc_sector_number() is implemented by comparing the first
bvec of the bbio against all blocks inside a scrub_stripe.
This implementation is a little inefficient, and depends on how the
scrub buffer is implemented.
One of the reason implementing such complex function is that, we do not
save the original bvec_iter inside a write btrfs_bio.
Although a read bbio has btrfs_bio::saved_iter to get the original
logical bytenr, it's not implemented for write bios.
On the other hand, since commit 81cea6cd7041 ("btrfs: remove
btrfs_bio::fs_info by extracting it from btrfs_bio::inode"), we always
set the btrfs_bio::file_offset as the logical bytenr for scrub, and that
member will not be modified during IO.
So this means we have a stable way to determine the logical bytenr for a
scrub bio, now calc_sector_number() is just as simple as:
return (bbio->file_offset - stripe->logical) >> sectorsize_bits;
Since we're here, also add an ASSERT() to make sure the bbio is inside
the stripe, and change the return type to unsigned int to be extra safe.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python/bin/export-to-postgresql-record')
0 files changed, 0 insertions, 0 deletions
