aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-08-20 08:29:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-08-21 10:02:00 -0400
commit6719db6a23d4b7f1e5052eedae394135e3aef9c1 (patch)
tree2faf96d69696df0edfc0ab4d8f0c980ee0b89986 /fs/btrfs
parentc063d8a60fc912ae198f054608ad461a69dc9a19 (diff)
Btrfs: fix 64 bit divide problem
This fixes a regression introduced by commit cdcb725c05fe ("Btrfs: check if there is enough space for balancing smarter"). We can't do 64-bit divides on 32-bit architectures. In cases where we need to divide/multiply by 2 we should just left/right shift respectively, and in cases where theres N number of devices use do_div. Also make the counters u64 to match up with rw_devices. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Acked-and-tested-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 80d6148f60a..f5be06a2462 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6735,9 +6735,9 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
6735 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; 6735 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
6736 struct btrfs_device *device; 6736 struct btrfs_device *device;
6737 u64 min_free; 6737 u64 min_free;
6738 u64 dev_min = 1;
6739 u64 dev_nr = 0;
6738 int index; 6740 int index;
6739 int dev_nr = 0;
6740 int dev_min = 1;
6741 int full = 0; 6741 int full = 0;
6742 int ret = 0; 6742 int ret = 0;
6743 6743
@@ -6796,14 +6796,16 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
6796 index = get_block_group_index(block_group); 6796 index = get_block_group_index(block_group);
6797 if (index == 0) { 6797 if (index == 0) {
6798 dev_min = 4; 6798 dev_min = 4;
6799 min_free /= 2; 6799 /* Divide by 2 */
6800 min_free >>= 1;
6800 } else if (index == 1) { 6801 } else if (index == 1) {
6801 dev_min = 2; 6802 dev_min = 2;
6802 } else if (index == 2) { 6803 } else if (index == 2) {
6803 min_free *= 2; 6804 /* Multiply by 2 */
6805 min_free <<= 1;
6804 } else if (index == 3) { 6806 } else if (index == 3) {
6805 dev_min = fs_devices->rw_devices; 6807 dev_min = fs_devices->rw_devices;
6806 min_free /= dev_min; 6808 do_div(min_free, dev_min);
6807 } 6809 }
6808 6810
6809 mutex_lock(&root->fs_info->chunk_mutex); 6811 mutex_lock(&root->fs_info->chunk_mutex);