Commit f3eae7e8 authored by Zhao Lei's avatar Zhao Lei Committed by Chris Mason
Browse files

Btrfs: Simplify num_stripes's calculation logical for __btrfs_alloc_chunk()



We can use this simple method to make source more readable.
Signed-off-by: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent ab59381e
...@@ -2198,9 +2198,9 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, ...@@ -2198,9 +2198,9 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
min_stripes = 2; min_stripes = 2;
} }
if (type & (BTRFS_BLOCK_GROUP_RAID1)) { if (type & (BTRFS_BLOCK_GROUP_RAID1)) {
num_stripes = min_t(u64, 2, fs_devices->rw_devices); if (fs_devices->rw_devices < 2)
if (num_stripes < 2)
return -ENOSPC; return -ENOSPC;
num_stripes = 2;
min_stripes = 2; min_stripes = 2;
} }
if (type & (BTRFS_BLOCK_GROUP_RAID10)) { if (type & (BTRFS_BLOCK_GROUP_RAID10)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment