diff options
author | David Sterba <dsterba@suse.com> | 2019-08-21 12:54:28 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-09-09 08:59:15 -0400 |
commit | 784352fe0bb4814bd969fb390c3d03486a5aaafa (patch) | |
tree | 50ef76b70d0aa12b35a214f1fa2dd1cc92996c0b | |
parent | 602cbe91fb012a923a9fea880e600e004eb1543b (diff) |
btrfs: move math functions to misc.h
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/block-group.c | 2 | ||||
-rw-r--r-- | fs/btrfs/block-rsv.c | 2 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 1 | ||||
-rw-r--r-- | fs/btrfs/math.h | 28 | ||||
-rw-r--r-- | fs/btrfs/misc.h | 17 | ||||
-rw-r--r-- | fs/btrfs/space-info.c | 2 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 2 |
7 files changed, 21 insertions, 33 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index c912ee26e85d..9a09f459337b 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c | |||
@@ -1,5 +1,6 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | 2 | ||
3 | #include "misc.h" | ||
3 | #include "ctree.h" | 4 | #include "ctree.h" |
4 | #include "block-group.h" | 5 | #include "block-group.h" |
5 | #include "space-info.h" | 6 | #include "space-info.h" |
@@ -13,7 +14,6 @@ | |||
13 | #include "sysfs.h" | 14 | #include "sysfs.h" |
14 | #include "tree-log.h" | 15 | #include "tree-log.h" |
15 | #include "delalloc-space.h" | 16 | #include "delalloc-space.h" |
16 | #include "math.h" | ||
17 | 17 | ||
18 | /* | 18 | /* |
19 | * Return target flags in extended format or 0 if restripe for this chunk_type | 19 | * Return target flags in extended format or 0 if restripe for this chunk_type |
diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c index 698470b9f32d..ef8b8ae27386 100644 --- a/fs/btrfs/block-rsv.c +++ b/fs/btrfs/block-rsv.c | |||
@@ -1,9 +1,9 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | 2 | ||
3 | #include "misc.h" | ||
3 | #include "ctree.h" | 4 | #include "ctree.h" |
4 | #include "block-rsv.h" | 5 | #include "block-rsv.h" |
5 | #include "space-info.h" | 6 | #include "space-info.h" |
6 | #include "math.h" | ||
7 | #include "transaction.h" | 7 | #include "transaction.h" |
8 | 8 | ||
9 | static u64 block_rsv_release_bytes(struct btrfs_fs_info *fs_info, | 9 | static u64 block_rsv_release_bytes(struct btrfs_fs_info *fs_info, |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 795b592e5269..2bf5dad82bf1 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include "locking.h" | 25 | #include "locking.h" |
26 | #include "free-space-cache.h" | 26 | #include "free-space-cache.h" |
27 | #include "free-space-tree.h" | 27 | #include "free-space-tree.h" |
28 | #include "math.h" | ||
29 | #include "sysfs.h" | 28 | #include "sysfs.h" |
30 | #include "qgroup.h" | 29 | #include "qgroup.h" |
31 | #include "ref-verify.h" | 30 | #include "ref-verify.h" |
diff --git a/fs/btrfs/math.h b/fs/btrfs/math.h deleted file mode 100644 index 75246f2f56ba..000000000000 --- a/fs/btrfs/math.h +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | /* | ||
3 | * Copyright (C) 2012 Fujitsu. All rights reserved. | ||
4 | * Written by Miao Xie <miaox@cn.fujitsu.com> | ||
5 | */ | ||
6 | |||
7 | #ifndef BTRFS_MATH_H | ||
8 | #define BTRFS_MATH_H | ||
9 | |||
10 | #include <asm/div64.h> | ||
11 | |||
12 | static inline u64 div_factor(u64 num, int factor) | ||
13 | { | ||
14 | if (factor == 10) | ||
15 | return num; | ||
16 | num *= factor; | ||
17 | return div_u64(num, 10); | ||
18 | } | ||
19 | |||
20 | static inline u64 div_factor_fine(u64 num, int factor) | ||
21 | { | ||
22 | if (factor == 100) | ||
23 | return num; | ||
24 | num *= factor; | ||
25 | return div_u64(num, 100); | ||
26 | } | ||
27 | |||
28 | #endif | ||
diff --git a/fs/btrfs/misc.h b/fs/btrfs/misc.h index ef3901238ddd..7d564924dfeb 100644 --- a/fs/btrfs/misc.h +++ b/fs/btrfs/misc.h | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
7 | #include <linux/wait.h> | 7 | #include <linux/wait.h> |
8 | #include <asm/div64.h> | ||
8 | 9 | ||
9 | #define in_range(b, first, len) ((b) >= (first) && (b) < (first) + (len)) | 10 | #define in_range(b, first, len) ((b) >= (first) && (b) < (first) + (len)) |
10 | 11 | ||
@@ -30,4 +31,20 @@ static inline void cond_wake_up_nomb(struct wait_queue_head *wq) | |||
30 | wake_up(wq); | 31 | wake_up(wq); |
31 | } | 32 | } |
32 | 33 | ||
34 | static inline u64 div_factor(u64 num, int factor) | ||
35 | { | ||
36 | if (factor == 10) | ||
37 | return num; | ||
38 | num *= factor; | ||
39 | return div_u64(num, 10); | ||
40 | } | ||
41 | |||
42 | static inline u64 div_factor_fine(u64 num, int factor) | ||
43 | { | ||
44 | if (factor == 100) | ||
45 | return num; | ||
46 | num *= factor; | ||
47 | return div_u64(num, 100); | ||
48 | } | ||
49 | |||
33 | #endif | 50 | #endif |
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index 13a4326c8821..bea7ae0a9739 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c | |||
@@ -1,5 +1,6 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2 | 2 | ||
3 | #include "misc.h" | ||
3 | #include "ctree.h" | 4 | #include "ctree.h" |
4 | #include "space-info.h" | 5 | #include "space-info.h" |
5 | #include "sysfs.h" | 6 | #include "sysfs.h" |
@@ -7,7 +8,6 @@ | |||
7 | #include "free-space-cache.h" | 8 | #include "free-space-cache.h" |
8 | #include "ordered-data.h" | 9 | #include "ordered-data.h" |
9 | #include "transaction.h" | 10 | #include "transaction.h" |
10 | #include "math.h" | ||
11 | #include "block-group.h" | 11 | #include "block-group.h" |
12 | 12 | ||
13 | u64 btrfs_space_info_used(struct btrfs_space_info *s_info, | 13 | u64 btrfs_space_info_used(struct btrfs_space_info *s_info, |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8bfc41f1b3b6..02976c174f32 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/semaphore.h> | 14 | #include <linux/semaphore.h> |
15 | #include <linux/uuid.h> | 15 | #include <linux/uuid.h> |
16 | #include <linux/list_sort.h> | 16 | #include <linux/list_sort.h> |
17 | #include "misc.h" | ||
17 | #include "ctree.h" | 18 | #include "ctree.h" |
18 | #include "extent_map.h" | 19 | #include "extent_map.h" |
19 | #include "disk-io.h" | 20 | #include "disk-io.h" |
@@ -24,7 +25,6 @@ | |||
24 | #include "async-thread.h" | 25 | #include "async-thread.h" |
25 | #include "check-integrity.h" | 26 | #include "check-integrity.h" |
26 | #include "rcu-string.h" | 27 | #include "rcu-string.h" |
27 | #include "math.h" | ||
28 | #include "dev-replace.h" | 28 | #include "dev-replace.h" |
29 | #include "sysfs.h" | 29 | #include "sysfs.h" |
30 | #include "tree-checker.h" | 30 | #include "tree-checker.h" |