diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2012-09-13 06:51:36 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2012-12-11 13:31:30 -0500 |
commit | 3fed40cc97f32bebfd34a55364de9b44dcbede59 (patch) | |
tree | e0e991e2d7ff5643c07f2b63395c0d9e744596ba /fs/btrfs/volumes.c | |
parent | 29594404d7fe73cd80eaa4ee8c43dcc53970c60e (diff) |
Btrfs: cleanup duplicated division functions
div_factor{_fine} has been implemented for two times, cleanup it.
And I move them into a independent file named math.h because they are
common math functions.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0f5ebb72a5ea..a8adf2686473 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/capability.h> | 25 | #include <linux/capability.h> |
26 | #include <linux/ratelimit.h> | 26 | #include <linux/ratelimit.h> |
27 | #include <linux/kthread.h> | 27 | #include <linux/kthread.h> |
28 | #include <asm/div64.h> | ||
29 | #include "compat.h" | 28 | #include "compat.h" |
30 | #include "ctree.h" | 29 | #include "ctree.h" |
31 | #include "extent_map.h" | 30 | #include "extent_map.h" |
@@ -36,6 +35,7 @@ | |||
36 | #include "async-thread.h" | 35 | #include "async-thread.h" |
37 | #include "check-integrity.h" | 36 | #include "check-integrity.h" |
38 | #include "rcu-string.h" | 37 | #include "rcu-string.h" |
38 | #include "math.h" | ||
39 | 39 | ||
40 | static int init_first_rw_device(struct btrfs_trans_handle *trans, | 40 | static int init_first_rw_device(struct btrfs_trans_handle *trans, |
41 | struct btrfs_root *root, | 41 | struct btrfs_root *root, |
@@ -2338,18 +2338,6 @@ static int chunk_profiles_filter(u64 chunk_type, | |||
2338 | return 1; | 2338 | return 1; |
2339 | } | 2339 | } |
2340 | 2340 | ||
2341 | static u64 div_factor_fine(u64 num, int factor) | ||
2342 | { | ||
2343 | if (factor <= 0) | ||
2344 | return 0; | ||
2345 | if (factor >= 100) | ||
2346 | return num; | ||
2347 | |||
2348 | num *= factor; | ||
2349 | do_div(num, 100); | ||
2350 | return num; | ||
2351 | } | ||
2352 | |||
2353 | static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset, | 2341 | static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset, |
2354 | struct btrfs_balance_args *bargs) | 2342 | struct btrfs_balance_args *bargs) |
2355 | { | 2343 | { |
@@ -2514,15 +2502,6 @@ static int should_balance_chunk(struct btrfs_root *root, | |||
2514 | return 1; | 2502 | return 1; |
2515 | } | 2503 | } |
2516 | 2504 | ||
2517 | static u64 div_factor(u64 num, int factor) | ||
2518 | { | ||
2519 | if (factor == 10) | ||
2520 | return num; | ||
2521 | num *= factor; | ||
2522 | do_div(num, 10); | ||
2523 | return num; | ||
2524 | } | ||
2525 | |||
2526 | static int __btrfs_balance(struct btrfs_fs_info *fs_info) | 2505 | static int __btrfs_balance(struct btrfs_fs_info *fs_info) |
2527 | { | 2506 | { |
2528 | struct btrfs_balance_control *bctl = fs_info->balance_ctl; | 2507 | struct btrfs_balance_control *bctl = fs_info->balance_ctl; |