diff options
author | David Sterba <dsterba@suse.com> | 2019-05-14 01:59:54 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-01-20 16:40:49 +0100 |
commit | e4f6c6be814850249a745ea43d5c49800e7178d4 (patch) | |
tree | e79f26883eed74a32bffe20eae68e0e89a3a68de | |
parent | 0e56315ca147b3e60c7bf240233a301d3c7fb508 (diff) | |
download | linux-e4f6c6be814850249a745ea43d5c49800e7178d4.tar.bz2 |
btrfs: use raid_attr table in calc_stripe_length for nparity
The table is already used for ncopies, replace open coding of stripes
with the raid_attr value.
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/volumes.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 9b78e720c697..687eacbef9d6 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -6480,19 +6480,14 @@ static u64 calc_stripe_length(u64 type, u64 chunk_len, int num_stripes) { int index = btrfs_bg_flags_to_raid_index(type); int ncopies = btrfs_raid_array[index].ncopies; + const int nparity = btrfs_raid_array[index].nparity; int data_stripes; - switch (type & BTRFS_BLOCK_GROUP_PROFILE_MASK) { - case BTRFS_BLOCK_GROUP_RAID5: - data_stripes = num_stripes - 1; - break; - case BTRFS_BLOCK_GROUP_RAID6: - data_stripes = num_stripes - 2; - break; - default: + if (nparity) + data_stripes = num_stripes - nparity; + else data_stripes = num_stripes / ncopies; - break; - } + return div_u64(chunk_len, data_stripes); } |