diff options
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 9df8e3f1ccab..aa7dc36dac78 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -17,6 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/bio.h> | 19 | #include <linux/bio.h> |
20 | #include <linux/slab.h> | ||
20 | #include <linux/buffer_head.h> | 21 | #include <linux/buffer_head.h> |
21 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
22 | #include <linux/random.h> | 23 | #include <linux/random.h> |
@@ -2198,9 +2199,9 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | |||
2198 | min_stripes = 2; | 2199 | min_stripes = 2; |
2199 | } | 2200 | } |
2200 | if (type & (BTRFS_BLOCK_GROUP_RAID1)) { | 2201 | if (type & (BTRFS_BLOCK_GROUP_RAID1)) { |
2201 | num_stripes = min_t(u64, 2, fs_devices->rw_devices); | 2202 | if (fs_devices->rw_devices < 2) |
2202 | if (num_stripes < 2) | ||
2203 | return -ENOSPC; | 2203 | return -ENOSPC; |
2204 | num_stripes = 2; | ||
2204 | min_stripes = 2; | 2205 | min_stripes = 2; |
2205 | } | 2206 | } |
2206 | if (type & (BTRFS_BLOCK_GROUP_RAID10)) { | 2207 | if (type & (BTRFS_BLOCK_GROUP_RAID10)) { |
@@ -2244,8 +2245,10 @@ again: | |||
2244 | do_div(calc_size, stripe_len); | 2245 | do_div(calc_size, stripe_len); |
2245 | calc_size *= stripe_len; | 2246 | calc_size *= stripe_len; |
2246 | } | 2247 | } |
2248 | |||
2247 | /* we don't want tiny stripes */ | 2249 | /* we don't want tiny stripes */ |
2248 | calc_size = max_t(u64, min_stripe_size, calc_size); | 2250 | if (!looped) |
2251 | calc_size = max_t(u64, min_stripe_size, calc_size); | ||
2249 | 2252 | ||
2250 | do_div(calc_size, stripe_len); | 2253 | do_div(calc_size, stripe_len); |
2251 | calc_size *= stripe_len; | 2254 | calc_size *= stripe_len; |
@@ -3389,6 +3392,8 @@ int btrfs_read_chunk_tree(struct btrfs_root *root) | |||
3389 | key.type = 0; | 3392 | key.type = 0; |
3390 | again: | 3393 | again: |
3391 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | 3394 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
3395 | if (ret < 0) | ||
3396 | goto error; | ||
3392 | while (1) { | 3397 | while (1) { |
3393 | leaf = path->nodes[0]; | 3398 | leaf = path->nodes[0]; |
3394 | slot = path->slots[0]; | 3399 | slot = path->slots[0]; |