btrfs-progs: chunk-recover: use btrfs_bg_type_to_nparity in calc_data_offset

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-10-07 00:12:06 +02:00
parent daa08f42c9
commit 14d53ce450
1 changed files with 1 additions and 5 deletions

View File

@ -1871,11 +1871,7 @@ static u64 calc_data_offset(struct btrfs_key *key,
data_offset = key->offset + csum_offset * blocksize - chunk->offset;
nr_data_stripes = chunk->num_stripes;
if (chunk->type_flags & BTRFS_BLOCK_GROUP_RAID5)
nr_data_stripes -= 1;
else if (chunk->type_flags & BTRFS_BLOCK_GROUP_RAID6)
nr_data_stripes -= 2;
nr_data_stripes -= btrfs_bg_type_to_nparity(chunk->type_flags);
logical_stripe_nr = data_offset / chunk->stripe_len;
dev_stripe_nr = logical_stripe_nr / nr_data_stripes;