aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-01-17 00:38:51 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-02-20 09:37:19 -0500
commite6ec716f0ddbe51741ef261d0804f0c28038dda4 (patch)
tree3339ba3503a5bac32c5cf7835a153f73d5eecd06 /fs/btrfs/extent-tree.c
parenta1897fddd28daf6b23d05a30dc2a18836f77f8e3 (diff)
Btrfs: make raid attr array more readable
The current code of raid attr arry is hard to understand and it is easy to introduce some problem if we modify the array. So I changed it and made it more readable. Cc: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 82400b2b2517..174c4d5c692c 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5545,20 +5545,16 @@ wait_block_group_cache_done(struct btrfs_block_group_cache *cache)
5545 5545
5546int __get_raid_index(u64 flags) 5546int __get_raid_index(u64 flags)
5547{ 5547{
5548 int index;
5549
5550 if (flags & BTRFS_BLOCK_GROUP_RAID10) 5548 if (flags & BTRFS_BLOCK_GROUP_RAID10)
5551 index = 0; 5549 return BTRFS_RAID_RAID10;
5552 else if (flags & BTRFS_BLOCK_GROUP_RAID1) 5550 else if (flags & BTRFS_BLOCK_GROUP_RAID1)
5553 index = 1; 5551 return BTRFS_RAID_RAID1;
5554 else if (flags & BTRFS_BLOCK_GROUP_DUP) 5552 else if (flags & BTRFS_BLOCK_GROUP_DUP)
5555 index = 2; 5553 return BTRFS_RAID_DUP;
5556 else if (flags & BTRFS_BLOCK_GROUP_RAID0) 5554 else if (flags & BTRFS_BLOCK_GROUP_RAID0)
5557 index = 3; 5555 return BTRFS_RAID_RAID0;
5558 else 5556 else
5559 index = 4; 5557 return BTRFS_RAID_SINGLE;
5560
5561 return index;
5562} 5558}
5563 5559
5564static int get_block_group_index(struct btrfs_block_group_cache *cache) 5560static int get_block_group_index(struct btrfs_block_group_cache *cache)
@@ -7518,16 +7514,16 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
7518 index = get_block_group_index(block_group); 7514 index = get_block_group_index(block_group);
7519 } 7515 }
7520 7516
7521 if (index == 0) { 7517 if (index == BTRFS_RAID_RAID10) {
7522 dev_min = 4; 7518 dev_min = 4;
7523 /* Divide by 2 */ 7519 /* Divide by 2 */
7524 min_free >>= 1; 7520 min_free >>= 1;
7525 } else if (index == 1) { 7521 } else if (index == BTRFS_RAID_RAID1) {
7526 dev_min = 2; 7522 dev_min = 2;
7527 } else if (index == 2) { 7523 } else if (index == BTRFS_RAID_DUP) {
7528 /* Multiply by 2 */ 7524 /* Multiply by 2 */
7529 min_free <<= 1; 7525 min_free <<= 1;
7530 } else if (index == 3) { 7526 } else if (index == BTRFS_RAID_RAID0) {
7531 dev_min = fs_devices->rw_devices; 7527 dev_min = fs_devices->rw_devices;
7532 do_div(min_free, dev_min); 7528 do_div(min_free, dev_min);
7533 } 7529 }