summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2010-04-06 15:37:47 +0200
committerChris Mason <chris.mason@oracle.com>2010-04-06 15:37:47 +0200
commit9f680ce04ea19dabbbafe01b57b61930a9b70741 (patch)
tree30447eb92851fe8542469a69cfd126bec30f9dd2 /fs
parentBtrfs: fix data enospc check overflow (diff)
downloadlinux-9f680ce04ea19dabbbafe01b57b61930a9b70741.tar.xz
linux-9f680ce04ea19dabbbafe01b57b61930a9b70741.zip
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: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/volumes.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 9bf1f581b872..b584e9a2add2 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2249,6 +2249,12 @@ again:
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;