Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360478
b: refs/heads/master
c: 86db257
h: refs/heads/master
v: v3
  • Loading branch information
Chris Mason committed Feb 20, 2013
1 parent 53d1f5f commit a7df81c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 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: 24542bf7ea5e4fdfdb5157ff544c093fa4dcb536
refs/heads/master: 86db25785a6e7cacc1ee868fe437e8a2957eae94
25 changes: 21 additions & 4 deletions trunk/fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3837,10 +3837,6 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
*/
data_stripes = num_stripes / ncopies;

if (stripe_size * ndevs > max_chunk_size * ncopies) {
stripe_size = max_chunk_size * ncopies;
do_div(stripe_size, ndevs);
}
if (type & BTRFS_BLOCK_GROUP_RAID5) {
raid_stripe_len = find_raid56_stripe_len(ndevs - 1,
btrfs_super_stripesize(info->super_copy));
Expand All @@ -3851,6 +3847,27 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
btrfs_super_stripesize(info->super_copy));
data_stripes = num_stripes - 2;
}

/*
* Use the number of data stripes to figure out how big this chunk
* is really going to be in terms of logical address space,
* and compare that answer with the max chunk size
*/
if (stripe_size * data_stripes > max_chunk_size) {
u64 mask = (1ULL << 24) - 1;
stripe_size = max_chunk_size;
do_div(stripe_size, data_stripes);

/* bump the answer up to a 16MB boundary */
stripe_size = (stripe_size + mask) & ~mask;

/* but don't go higher than the limits we found
* while searching for free extents
*/
if (stripe_size > devices_info[ndevs-1].max_avail)
stripe_size = devices_info[ndevs-1].max_avail;
}

do_div(stripe_size, dev_stripes);

/* align to BTRFS_STRIPE_LEN */
Expand Down

0 comments on commit a7df81c

Please sign in to comment.