diff options
author | David Sterba <dsterba@suse.com> | 2021-07-26 14:15:24 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-08-23 13:19:03 +0200 |
commit | d58ede8d1d9fb0f70d6aa51fa6550d2d580f8c17 (patch) | |
tree | 574b87ff59d57aa5cdd6c41af428d76faca992ce /fs/btrfs | |
parent | fe4f46d40c1c2ff78a8a7280e455f115c32e6b41 (diff) | |
download | linux-d58ede8d1d9fb0f70d6aa51fa6550d2d580f8c17.tar.gz linux-d58ede8d1d9fb0f70d6aa51fa6550d2d580f8c17.tar.bz2 linux-d58ede8d1d9fb0f70d6aa51fa6550d2d580f8c17.zip |
btrfs: simplify data stripe calculation helpers
There are two helpers doing the same calculations based on nparity and
ncopies. calc_data_stripes can be simplified into one expression, so far
we don't have profile with both copies and parity, so there's no
effective change. calc_stripe_length should reuse the helper and not
repeat the same calculation.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/volumes.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 23159bd29c6d..c7339f163bda 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3568,10 +3568,7 @@ static u64 calc_data_stripes(u64 type, int num_stripes) const int ncopies = btrfs_raid_array[index].ncopies; const int nparity = btrfs_raid_array[index].nparity; - if (nparity) - return num_stripes - nparity; - else - return num_stripes / ncopies; + return (num_stripes - nparity) / ncopies; } /* [pstart, pend) */ @@ -6879,15 +6876,7 @@ static void btrfs_report_missing_device(struct btrfs_fs_info *fs_info, 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; - - if (nparity) - data_stripes = num_stripes - nparity; - else - data_stripes = num_stripes / ncopies; + const int data_stripes = calc_data_stripes(type, num_stripes); return div_u64(chunk_len, data_stripes); } |