btrfs: reduce div64 calls for __btrfs_map_block() and its variants
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 1 replyIn review
- v22 patches 1 replySuperseded
- v12 patches 9 repliesSuperseded
Changes in v3 from the cover letter
- Move more BTRFS_STRIPE_LEN_SHIFT cleanup to patch 1
- Use const_ilog2() to define BTRFS_STRIPE_LEN_SHIFT
- Introduce BTRFS_STRIPE_LEN_MASK to make offset calculation easier.
- Convert all "u64 stripe_nr" to "u32 stripe_nr" Previously there is one in get_raid56_logic_offset() not converted.
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | btrfs: remove map_lookup->stripe_lenfs/ fs/ fs/ +2 more | +53 | 1 reply | |
| 2/2 | btrfs: reduce div64 calls by limiting the number of stripes of a chunk to u32fs/ fs/ fs/ +2 more | +64 | 0 replies |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | Johannes Thumshirn | Christoph Hellwig | Anand Jain |
|---|---|---|---|
| 1/2 | R-b | R-b | R-b |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v3 0/2] btrfs: reduce div64 calls for __btrfs_map_block() and its variants
Changelog:
v3:
- Move more BTRFS_STRIPE_LEN_SHIFT cleanup to patch 1
- Use const_ilog2() to define BTRFS_STRIPE_LEN_SHIFT
- Introduce BTRFS_STRIPE_LEN_MASK to make offset calculation easier.
- Convert all "u64 stripe_nr" to "u32 stripe_nr" Previously there is one in get_raid56_logic_offset() not converted.
v2:
- Fix a linkage error for 32bits platform in block-group.c We have a line "stripe_nr = (stripe_nr * num_stripes + i) / sub_stripes."
In that case, @stripe_nr itself is already u64, thus the division is dividing u64 with u32.
And we can not easily do a forced u32 conversion, as we only have ensured @stripe_nr can be contained in u32.
Even with 10G chunk size in mined, if the RAID10 array has over 26 devices, then we can overflow U32 and cause problems.
For now, keeps the old div_u64 call.
Div64 is much slower than 32 bit division, and only get improved in the most recent CPUs, that's why we have dedicated div64* helpers.
One usage of div64 is in __btrfs_map_block() and its variants, where we got @stripe_nr as u64, and all later division has to go the div64 helpers.
But the truth is, with our current chunk size limit (10G) and fixed stripe length (64K), we can have at most 160K stripes in a chunk, which is small enough for u32 already.
So this patchset would reduce div64 calls by:
- Remove map_lookup::stripe_len first
So now we don't need to call div64 to calculate @stripe_nr, just a simple right shift, then truncate to u32.
This is a prerequisite for the 2nd patch, without the fixed stripe length, we have to rely on div64.
- Reduce the width of various @stripe_nr from u64 to u32
- Use regular division and modulo to do the calculation Now we can get rid of the fear that we missed some div64 helpers.
Qu Wenruo (2):
btrfs: remove map_lookup->stripe_len
btrfs: reduce div64 calls by limiting the number of stripes of a chunk
to u32
fs/btrfs/block-group.c | 22 +++--- fs/btrfs/scrub.c | 55 +++++++------- fs/btrfs/tests/extent-map-tests.c | 1 - fs/btrfs/tree-checker.c | 14 ++++ fs/btrfs/volumes.c | 118 +++++++++++++++--------------- fs/btrfs/volumes.h | 6 +- 6 files changed, 116 insertions(+), 100 deletions(-)
Signature · 1 line
2.39.1