- scrub_ctx::stripes[] stripe_len updates
We always pre-initialize scrub_ctx::stripes[] at the very beginning of
scrub, without holding any btrfs_chunk_map.
So init_scrub_stripe() still uses BTRFS_STRIPE_LEN, and all allocated
memory are based on that stripe length.
But before scrubbing each chunk, update_scrub_stripe_len() will be
called to update the scrub_stripe::stripe_len.
- Stripe_len should not exceed BTRFS_STRIPE_LEN
Since scrub_stripe's heap memory are all based on BTRFS_STRIPE_LEN,
any stripe_len larger than BTRFS_STRIPE_LEN will cause
access-beyond-boundary.
Thankfully there is no plan to support such stripe_len >
BTRFS_STRIPE_LEN any time soon.
- alloc_scrub_bbio() changes
Previously we ensure BTRFS_STRIPE_LEN >= PAGE_SIZE, so
BTRFS_STRIPE_LEN >> PAGE_SHIFT can never be zero.
But now stripe_len can be smaller than PAGE_SIZE. E.g. stripe_len 4K,
page size 64K.
So we have to use "round_up(stripe_len, PAGE_SIZE) >> PAGE_SHIFT"
instead.
Finally alloc_scrub_bbio() is always called with a scrub_stripe
pointer as the @private parameter, change the type from (void *) to
(struct scrub_stripe *), so that we can grab the stripe_len without
a new parameter.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>