btrfs: use ncopies from btrfs_raid_array in btrfs_num_copies()
For all non-RAID56 profiles, we can use btrfs_raid_array[].ncopies directly, only for RAID5 and RAID6 we need some extra handling as there's no table value for that. For RAID10 there's a change from sub_stripes to ncopies. The values are the same but semantically we want to use number of copies, as this is what btrfs_num_copies does. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
0b30f71945
commit
6d322b4839
|
@ -5717,7 +5717,8 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
|
|||
{
|
||||
struct extent_map *em;
|
||||
struct map_lookup *map;
|
||||
int ret;
|
||||
enum btrfs_raid_types index;
|
||||
int ret = 1;
|
||||
|
||||
em = btrfs_get_chunk_map(fs_info, logical, len);
|
||||
if (IS_ERR(em))
|
||||
|
@ -5730,10 +5731,11 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
|
|||
return 1;
|
||||
|
||||
map = em->map_lookup;
|
||||
if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1_MASK))
|
||||
ret = map->num_stripes;
|
||||
else if (map->type & BTRFS_BLOCK_GROUP_RAID10)
|
||||
ret = map->sub_stripes;
|
||||
index = btrfs_bg_flags_to_raid_index(map->type);
|
||||
|
||||
/* Non-RAID56, use their ncopies from btrfs_raid_array. */
|
||||
if (!(map->type & BTRFS_BLOCK_GROUP_RAID56_MASK))
|
||||
ret = btrfs_raid_array[index].ncopies;
|
||||
else if (map->type & BTRFS_BLOCK_GROUP_RAID5)
|
||||
ret = 2;
|
||||
else if (map->type & BTRFS_BLOCK_GROUP_RAID6)
|
||||
|
@ -5745,8 +5747,6 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
|
|||
* stripe under reconstruction.
|
||||
*/
|
||||
ret = map->num_stripes;
|
||||
else
|
||||
ret = 1;
|
||||
free_extent_map(em);
|
||||
|
||||
down_read(&fs_info->dev_replace.rwsem);
|
||||
|
|
Loading…
Reference in New Issue