Skip to content

Commit

Permalink
Btrfs: make sure the chunk allocator doesn't create zero length chunks
Browse files Browse the repository at this point in the history
A recent commit allowed for smaller chunks to be created, but didn't
make sure they were always bigger than a stripe.  After some divides,
this led to zero length stripes.

Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
chrismason-xx committed Apr 6, 2010
1 parent ab6e241 commit 9f680ce
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,12 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
if (!looped)
calc_size = max_t(u64, min_stripe_size, calc_size);

/*
* we're about to do_div by the stripe_len so lets make sure
* we end up with something bigger than a stripe
*/
calc_size = max_t(u64, calc_size, stripe_len * 4);

do_div(calc_size, stripe_len);
calc_size *= stripe_len;

Expand Down

0 comments on commit 9f680ce

Please sign in to comment.