Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 231756
b: refs/heads/master
c: 1974a3b
h: refs/heads/master
v: v3
  • Loading branch information
Miao Xie authored and Chris Mason committed Jan 16, 2011
1 parent 5f4d918 commit 4eb819b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d52a5b5f1fa40804f681cf9868d4a8f90661bdf3
refs/heads/master: 1974a3b42d8cf7a9c74f1e0310c593023617037a
10 changes: 8 additions & 2 deletions trunk/fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
int num_stripes = 1;
int min_stripes = 1;
int sub_stripes = 0;
int ncopies = 1;
int looped = 0;
int ret;
int index;
Expand All @@ -2197,19 +2198,22 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
if (type & (BTRFS_BLOCK_GROUP_DUP)) {
num_stripes = 2;
min_stripes = 2;
ncopies = 2;
}
if (type & (BTRFS_BLOCK_GROUP_RAID1)) {
if (fs_devices->rw_devices < 2)
return -ENOSPC;
num_stripes = 2;
min_stripes = 2;
ncopies = 2;
}
if (type & (BTRFS_BLOCK_GROUP_RAID10)) {
num_stripes = fs_devices->rw_devices;
if (num_stripes < 4)
return -ENOSPC;
num_stripes &= ~(u32)1;
sub_stripes = 2;
ncopies = 2;
min_stripes = 4;
}

Expand Down Expand Up @@ -2239,8 +2243,8 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
map->num_stripes = num_stripes;
}

if (calc_size * num_stripes > max_chunk_size) {
calc_size = max_chunk_size;
if (calc_size * num_stripes > max_chunk_size * ncopies) {
calc_size = max_chunk_size * ncopies;
do_div(calc_size, num_stripes);
do_div(calc_size, stripe_len);
calc_size *= stripe_len;
Expand Down Expand Up @@ -2321,6 +2325,8 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
if (!looped && max_avail > 0) {
looped = 1;
calc_size = max_avail;
if (type & BTRFS_BLOCK_GROUP_DUP)
do_div(calc_size, 2);
goto again;
}
kfree(map);
Expand Down

0 comments on commit 4eb819b

Please sign in to comment.