Skip to content

Commit b55b307

Browse files
morbidrsakdave
authored andcommitted
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>
1 parent a16fb8c commit b55b307

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

fs/btrfs/volumes.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6575,26 +6575,36 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
65756575
if (!dev_replace_is_ongoing)
65766576
up_read(&dev_replace->rwsem);
65776577

6578-
if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
6578+
switch (map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
6579+
case BTRFS_BLOCK_GROUP_RAID0:
65796580
map_blocks_raid0(map, &io_geom);
6580-
} else if (map->type & BTRFS_BLOCK_GROUP_RAID1_MASK) {
6581+
break;
6582+
case BTRFS_BLOCK_GROUP_RAID1:
6583+
case BTRFS_BLOCK_GROUP_RAID1C3:
6584+
case BTRFS_BLOCK_GROUP_RAID1C4:
65816585
map_blocks_raid1(fs_info, map, &io_geom, dev_replace_is_ongoing);
6582-
} else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
6586+
break;
6587+
case BTRFS_BLOCK_GROUP_DUP:
65836588
map_blocks_dup(map, &io_geom);
6584-
} else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
6589+
break;
6590+
case BTRFS_BLOCK_GROUP_RAID10:
65856591
map_blocks_raid10(fs_info, map, &io_geom, dev_replace_is_ongoing);
6586-
} else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
6592+
break;
6593+
case BTRFS_BLOCK_GROUP_RAID5:
6594+
case BTRFS_BLOCK_GROUP_RAID6:
65876595
if (op != BTRFS_MAP_READ || io_geom.mirror_num > 1)
65886596
map_blocks_raid56_write(map, &io_geom, logical, length);
65896597
else
65906598
map_blocks_raid56_read(map, &io_geom);
6591-
} else {
6599+
break;
6600+
default:
65926601
/*
65936602
* After this, stripe_nr is the number of stripes on this
65946603
* device we have to walk to find the data, and stripe_index is
65956604
* the number of our device in the stripe array
65966605
*/
65976606
map_blocks_single(map, &io_geom);
6607+
break;
65986608
}
65996609
if (io_geom.stripe_index >= map->num_stripes) {
66006610
btrfs_crit(fs_info,

0 commit comments

Comments
 (0)