Skip to content

btrfs: scrub: reduce memory usage for each scrub_stripe

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2btrfs: scrub: fix a wrong error type when metadata bytenr mismatchesfs/btrfs/scrub.c+1 -10 replies
2/2btrfs: scrub: aggregate small bitmaps into a larger onefs/btrfs/scrub.c+196 -911 reply

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDavid Sterba
SeriesR-b
1/2
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] btrfs: scrub: reduce memory usage for each scrub_stripe

The first patch fixes a scrub error reporting bug that metadata bytenr mismatch is reported as csum error, not a metadata error.

The second patch reduces the memory usage of each scrub_stripe by 24 bytes (on systems with 64 bits LONG), this is done by aggregating all the small bitmaps (at most 16 bits, as we can have at most STRIPE_LEN / blocksize blocks per stripe) into a larger bitmap.
Just like what we do with subpage helpers.

This will introduce a lot of small helpers:

- Set/clear bitmap range
- Set/clear/test single bit
- Bitmap weight
- Bitmap empty check
- Bitmap read
The last one allows us to read out a unsigned long and use it for various bitmap operations directly.
In fact the above weight/empty are just a wrapper around the read helper.

Those helpers are small enough thus can be inlined, this will slightly increase the overhead but saves 24 bytes per scrub_stripe, and we have 128 scrub_stripes for one device, saving around 3KB for scrub/dev-replace per device.

Qu Wenruo (2):
btrfs: scrub: fix a wrong error type when metadata bytenr mismatches
btrfs: scrub: aggregate small bitmaps into a larger one

 fs/btrfs/scrub.c | 287 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 196 insertions(+), 91 deletions(-)
Signature · 1 line
2.49.0