Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 276746
b: refs/heads/master
c: 39fb26c
h: refs/heads/master
v: v3
  • Loading branch information
Miao Xie authored and Chris Mason committed Dec 15, 2011
1 parent bf95451 commit 30b4781
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 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: 3642320e07444cc46327b24977d752f99706dac2
refs/heads/master: 39fb26c398ddf8d7794a85e896cfe1a42e55524b
19 changes: 13 additions & 6 deletions trunk/fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
u64 avail_space;
u64 used_space;
u64 min_stripe_size;
int min_stripes = 1;
int min_stripes = 1, num_stripes = 1;
int i = 0, nr_devices;
int ret;

Expand All @@ -1093,12 +1093,16 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)

/* calc min stripe number for data space alloction */
type = btrfs_get_alloc_profile(root, 1);
if (type & BTRFS_BLOCK_GROUP_RAID0)
if (type & BTRFS_BLOCK_GROUP_RAID0) {
min_stripes = 2;
else if (type & BTRFS_BLOCK_GROUP_RAID1)
num_stripes = nr_devices;
} else if (type & BTRFS_BLOCK_GROUP_RAID1) {
min_stripes = 2;
else if (type & BTRFS_BLOCK_GROUP_RAID10)
num_stripes = 2;
} else if (type & BTRFS_BLOCK_GROUP_RAID10) {
min_stripes = 4;
num_stripes = 4;
}

if (type & BTRFS_BLOCK_GROUP_DUP)
min_stripe_size = 2 * BTRFS_STRIPE_LEN;
Expand Down Expand Up @@ -1167,13 +1171,16 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
i = nr_devices - 1;
avail_space = 0;
while (nr_devices >= min_stripes) {
if (num_stripes > nr_devices)
num_stripes = nr_devices;

if (devices_info[i].max_avail >= min_stripe_size) {
int j;
u64 alloc_size;

avail_space += devices_info[i].max_avail * min_stripes;
avail_space += devices_info[i].max_avail * num_stripes;
alloc_size = devices_info[i].max_avail;
for (j = i + 1 - min_stripes; j <= i; j++)
for (j = i + 1 - num_stripes; j <= i; j++)
devices_info[j].max_avail -= alloc_size;
}
i--;
Expand Down

0 comments on commit 30b4781

Please sign in to comment.