diff options
author | Chris Mason <clm@fb.com> | 2017-06-23 12:48:21 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-06-29 14:17:02 -0400 |
commit | 6374e57ad8091b9c2db2eecc536c7f0166ce099e (patch) | |
tree | f4a5c584983c110e0b2ddc9e3b51c25e11801353 /fs/btrfs/dev-replace.c | |
parent | ded56184a562b925a588b6e78688e2e60757b425 (diff) |
btrfs: fix integer overflow in calc_reclaim_items_nr
Dave Jones hit a WARN_ON(nr < 0) in btrfs_wait_ordered_roots() with
v4.12-rc6. This was because commit 70e7af244 made it possible for
calc_reclaim_items_nr() to return a negative number. It's not really a
bug in that commit, it just didn't go far enough down the stack to find
all the possible 64->32 bit overflows.
This switches calc_reclaim_items_nr() to return a u64 and changes everyone
that uses the results of that math to u64 as well.
Reported-by: Dave Jones <davej@codemonkey.org.uk>
Fixes: 70e7af2 ("Btrfs: fix delalloc accounting leak caused by u32 overflow")
Signed-off-by: Chris Mason <clm@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r-- | fs/btrfs/dev-replace.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 5fe1ca8abc70..bee3edeea7a3 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -388,7 +388,7 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, | |||
388 | if (ret) | 388 | if (ret) |
389 | btrfs_err(fs_info, "kobj add dev failed %d", ret); | 389 | btrfs_err(fs_info, "kobj add dev failed %d", ret); |
390 | 390 | ||
391 | btrfs_wait_ordered_roots(fs_info, -1, 0, (u64)-1); | 391 | btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); |
392 | 392 | ||
393 | /* force writing the updated state information to disk */ | 393 | /* force writing the updated state information to disk */ |
394 | trans = btrfs_start_transaction(root, 0); | 394 | trans = btrfs_start_transaction(root, 0); |
@@ -507,7 +507,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
507 | mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); | 507 | mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); |
508 | return ret; | 508 | return ret; |
509 | } | 509 | } |
510 | btrfs_wait_ordered_roots(fs_info, -1, 0, (u64)-1); | 510 | btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); |
511 | 511 | ||
512 | trans = btrfs_start_transaction(root, 0); | 512 | trans = btrfs_start_transaction(root, 0); |
513 | if (IS_ERR(trans)) { | 513 | if (IS_ERR(trans)) { |