summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2013-01-21 15:15:56 +0200
committerChris Mason <chris.mason@fusionio.com>2013-01-21 20:40:27 -0500
commita105bb88f46b60de2adf1ee98745bd59362b09ab (patch)
tree85131c41a1cd80b1365b75ecc4d164873d70b059
parent83bfccb5c085658b0ad1450a6fc13b0bb5440970 (diff)
downloadop-kernel-dev-a105bb88f46b60de2adf1ee98745bd59362b09ab.zip
op-kernel-dev-a105bb88f46b60de2adf1ee98745bd59362b09ab.tar.gz
Btrfs: fix a regression in balance usage filter
Commit 3fed40cc ("Btrfs: cleanup duplicated division functions"), which was merged into 3.8-rc1, has introduced a regression by removing logic that was guarding us against bad user input. Bring it back. Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--fs/btrfs/volumes.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 9c84dbe..4696098 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2614,7 +2614,14 @@ static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset,
cache = btrfs_lookup_block_group(fs_info, chunk_offset);
chunk_used = btrfs_block_group_used(&cache->item);
- user_thresh = div_factor_fine(cache->key.offset, bargs->usage);
+ if (bargs->usage == 0)
+ user_thresh = 0;
+ else if (bargs->usage > 100)
+ user_thresh = cache->key.offset;
+ else
+ user_thresh = div_factor_fine(cache->key.offset,
+ bargs->usage);
+
if (chunk_used < user_thresh)
ret = 0;
OpenPOWER on IntegriCloud