summaryrefslogtreecommitdiff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>2023-12-13 06:43:05 -0800
committerDavid Sterba <dsterba@suse.com>2023-12-15 23:03:59 +0100
commitb55b307785ad88298914bc5c18c7d37bc5b88cb7 (patch)
treed93ac40815f1858b73f8ccf9e526521beb17a156 /fs/btrfs
parenta16fb8c6f61863f18fab61eeba10a457ff6d71d2 (diff)
btrfs: change block mapping to switch/case in btrfs_map_block
Now that all the per-profile if/else statement blocks have been converted to calls to helper the conversion to switch/case is straightforward. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/volumes.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 046f5f6345eb..c79708df2a12 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6575,26 +6575,36 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
if (!dev_replace_is_ongoing)
up_read(&dev_replace->rwsem);
- if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
+ switch (map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
+ case BTRFS_BLOCK_GROUP_RAID0:
map_blocks_raid0(map, &io_geom);
- } else if (map->type & BTRFS_BLOCK_GROUP_RAID1_MASK) {
+ break;
+ case BTRFS_BLOCK_GROUP_RAID1:
+ case BTRFS_BLOCK_GROUP_RAID1C3:
+ case BTRFS_BLOCK_GROUP_RAID1C4:
map_blocks_raid1(fs_info, map, &io_geom, dev_replace_is_ongoing);
- } else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
+ break;
+ case BTRFS_BLOCK_GROUP_DUP:
map_blocks_dup(map, &io_geom);
- } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
+ break;
+ case BTRFS_BLOCK_GROUP_RAID10:
map_blocks_raid10(fs_info, map, &io_geom, dev_replace_is_ongoing);
- } else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
+ break;
+ case BTRFS_BLOCK_GROUP_RAID5:
+ case BTRFS_BLOCK_GROUP_RAID6:
if (op != BTRFS_MAP_READ || io_geom.mirror_num > 1)
map_blocks_raid56_write(map, &io_geom, logical, length);
else
map_blocks_raid56_read(map, &io_geom);
- } else {
+ break;
+ default:
/*
* After this, stripe_nr is the number of stripes on this
* device we have to walk to find the data, and stripe_index is
* the number of our device in the stripe array
*/
map_blocks_single(map, &io_geom);
+ break;
}
if (io_geom.stripe_index >= map->num_stripes) {
btrfs_crit(fs_info,