Skip to content

Commit

Permalink
Btrfs: fix a regression in balance usage filter
Browse files Browse the repository at this point in the history
Commit 3fed40c ("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>
  • Loading branch information
Ilya Dryomov authored and Chris Mason committed Jan 22, 2013
1 parent 83bfccb commit a105bb8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit a105bb8

Please sign in to comment.