提交 9f680ce0 编写于 作者: C Chris Mason

Btrfs: make sure the chunk allocator doesn't create zero length chunks

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: NChris Mason <chris.mason@oracle.com>
上级 ab6e2410
...@@ -2249,6 +2249,12 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, ...@@ -2249,6 +2249,12 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
if (!looped) if (!looped)
calc_size = max_t(u64, min_stripe_size, calc_size); 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); do_div(calc_size, stripe_len);
calc_size *= stripe_len; calc_size *= stripe_len;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册