diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/extent-tree.c | 19 | ||||
-rw-r--r-- | fs/btrfs/math.h | 44 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 23 |
3 files changed, 46 insertions, 40 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 3d3e2c17d8d1..7563db782abf 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "volumes.h" | 33 | #include "volumes.h" |
34 | #include "locking.h" | 34 | #include "locking.h" |
35 | #include "free-space-cache.h" | 35 | #include "free-space-cache.h" |
36 | #include "math.h" | ||
36 | 37 | ||
37 | #undef SCRAMBLE_DELAYED_REFS | 38 | #undef SCRAMBLE_DELAYED_REFS |
38 | 39 | ||
@@ -649,24 +650,6 @@ void btrfs_clear_space_info_full(struct btrfs_fs_info *info) | |||
649 | rcu_read_unlock(); | 650 | rcu_read_unlock(); |
650 | } | 651 | } |
651 | 652 | ||
652 | static u64 div_factor(u64 num, int factor) | ||
653 | { | ||
654 | if (factor == 10) | ||
655 | return num; | ||
656 | num *= factor; | ||
657 | do_div(num, 10); | ||
658 | return num; | ||
659 | } | ||
660 | |||
661 | static u64 div_factor_fine(u64 num, int factor) | ||
662 | { | ||
663 | if (factor == 100) | ||
664 | return num; | ||
665 | num *= factor; | ||
666 | do_div(num, 100); | ||
667 | return num; | ||
668 | } | ||
669 | |||
670 | u64 btrfs_find_block_group(struct btrfs_root *root, | 653 | u64 btrfs_find_block_group(struct btrfs_root *root, |
671 | u64 search_start, u64 search_hint, int owner) | 654 | u64 search_start, u64 search_hint, int owner) |
672 | { | 655 | { |
diff --git a/fs/btrfs/math.h b/fs/btrfs/math.h new file mode 100644 index 000000000000..b7816cefbd13 --- /dev/null +++ b/fs/btrfs/math.h | |||
@@ -0,0 +1,44 @@ | |||
1 | |||
2 | /* | ||
3 | * Copyright (C) 2012 Fujitsu. All rights reserved. | ||
4 | * Written by Miao Xie <miaox@cn.fujitsu.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public | ||
8 | * License v2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public | ||
16 | * License along with this program; if not, write to the | ||
17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | * Boston, MA 021110-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef __BTRFS_MATH_H | ||
22 | #define __BTRFS_MATH_H | ||
23 | |||
24 | #include <asm/div64.h> | ||
25 | |||
26 | static inline u64 div_factor(u64 num, int factor) | ||
27 | { | ||
28 | if (factor == 10) | ||
29 | return num; | ||
30 | num *= factor; | ||
31 | do_div(num, 10); | ||
32 | return num; | ||
33 | } | ||
34 | |||
35 | static inline u64 div_factor_fine(u64 num, int factor) | ||
36 | { | ||
37 | if (factor == 100) | ||
38 | return num; | ||
39 | num *= factor; | ||
40 | do_div(num, 100); | ||
41 | return num; | ||
42 | } | ||
43 | |||
44 | #endif | ||
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; |