Skip to content

Commit

Permalink
btrfs: raid56: make alloc_rbio_essential_pages() subpage compatible
Browse files Browse the repository at this point in the history
The non-compatible part is only the bitmap iteration part, now the
bitmap size is extended to rbio::stripe_nsectors, not the old
rbio::stripe_npages.

Since we're here, also slightly improve the function by:

- Rename @i to @stripe
- Rename @bit to @sectornr
- Move @page and @index into the inner loop

Signed-off-by: Qu Wenruo <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
adam900710 authored and kdave committed May 16, 2022
1 parent d4e28d9 commit 3907ce2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions fs/btrfs/raid56.c
Original file line number Diff line number Diff line change
Expand Up @@ -2415,14 +2415,16 @@ void raid56_add_scrub_pages(struct btrfs_raid_bio *rbio, struct page *page,
*/
static int alloc_rbio_essential_pages(struct btrfs_raid_bio *rbio)
{
int i;
int bit;
int index;
struct page *page;
const u32 sectorsize = rbio->bioc->fs_info->sectorsize;
int stripe;
int sectornr;

for_each_set_bit(sectornr, rbio->dbitmap, rbio->stripe_nsectors) {
for (stripe = 0; stripe < rbio->real_stripes; stripe++) {
struct page *page;
int index = (stripe * rbio->stripe_nsectors + sectornr) *
sectorsize >> PAGE_SHIFT;

for_each_set_bit(bit, rbio->dbitmap, rbio->stripe_npages) {
for (i = 0; i < rbio->real_stripes; i++) {
index = i * rbio->stripe_npages + bit;
if (rbio->stripe_pages[index])
continue;

Expand Down

0 comments on commit 3907ce2

Please sign in to comment.