Skip to content

Commit 05ddf35

Browse files
adam900710kdave
authored andcommitted
btrfs: raid56: prepare set_bio_pages_uptodate() to support bs > ps cases
The function set_bio_pages_uptodate() assume each fs block can be mapped by one page, blocking bs > ps support for raid56. Prepare it for bs > ps cases by: - Update find_stripe_sector_nr() to check only the first step paddr We don't need to check each paddr, as the bios are still aligned to fs block size, thus checking the first step is enough. - Use step size to iterate the bio This means we only need to find the sector number for the first step of each fs block, and skip the remaining part. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 64e7b8c commit 05ddf35

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

fs/btrfs/raid56.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ static void set_rbio_range_error(struct btrfs_raid_bio *rbio, struct bio *bio)
15881588
static int find_stripe_sector_nr(struct btrfs_raid_bio *rbio, phys_addr_t paddr)
15891589
{
15901590
for (int i = 0; i < rbio->nr_sectors; i++) {
1591-
if (rbio->stripe_paddrs[i] == paddr)
1591+
if (rbio->stripe_paddrs[i * rbio->sector_nsteps] == paddr)
15921592
return i;
15931593
}
15941594
return -1;
@@ -1600,17 +1600,23 @@ static int find_stripe_sector_nr(struct btrfs_raid_bio *rbio, phys_addr_t paddr)
16001600
*/
16011601
static void set_bio_pages_uptodate(struct btrfs_raid_bio *rbio, struct bio *bio)
16021602
{
1603-
const u32 blocksize = rbio->bioc->fs_info->sectorsize;
1603+
const u32 sectorsize = rbio->bioc->fs_info->sectorsize;
1604+
const u32 step = min(sectorsize, PAGE_SIZE);
1605+
u32 offset = 0;
16041606
phys_addr_t paddr;
16051607

16061608
ASSERT(!bio_flagged(bio, BIO_CLONED));
16071609

1608-
btrfs_bio_for_each_block_all(paddr, bio, blocksize) {
1609-
int sector_nr = find_stripe_sector_nr(rbio, paddr);
1610+
btrfs_bio_for_each_block_all(paddr, bio, step) {
1611+
/* Hitting the first step of a sector. */
1612+
if (IS_ALIGNED(offset, sectorsize)) {
1613+
int sector_nr = find_stripe_sector_nr(rbio, paddr);
16101614

1611-
ASSERT(sector_nr >= 0);
1612-
if (sector_nr >= 0)
1613-
set_bit(sector_nr, rbio->stripe_uptodate_bitmap);
1615+
ASSERT(sector_nr >= 0);
1616+
if (sector_nr >= 0)
1617+
set_bit(sector_nr, rbio->stripe_uptodate_bitmap);
1618+
}
1619+
offset += step;
16141620
}
16151621
}
16161622

0 commit comments

Comments
 (0)