summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorDavid Sterba2017-01-04 11:09:51 +0100
committerDavid Sterba2017-02-14 15:50:51 +0100
commit823bb20ab47071dc8a98acf272a470ccdcfcf6d1 (patch)
treeba1864d6c1472b33acbe0d6d991cb91cf4d69f74 /fs/btrfs/ctree.h
parentbtrfs: remove unused logic of limiting async delalloc pages (diff)
downloadkernel-qcow2-linux-823bb20ab47071dc8a98acf272a470ccdcfcf6d1.tar.gz
kernel-qcow2-linux-823bb20ab47071dc8a98acf272a470ccdcfcf6d1.tar.xz
kernel-qcow2-linux-823bb20ab47071dc8a98acf272a470ccdcfcf6d1.zip
btrfs: add wrapper for counting BTRFS_MAX_EXTENT_SIZE
The expression is open-coded in several places, this asks for a wrapper. As we know the MAX_EXTENT fits to u32, we can use the appropirate division helper. This cascades to the result type updates. Compiler is clever enough to use shift instead of integer division, so there's no change in the generated assembly. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 6a823719b6c5..6ebbccf41f46 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -97,6 +97,14 @@ static const int btrfs_csum_sizes[] = { 4 };
#define BTRFS_MAX_EXTENT_SIZE SZ_128M
+/*
+ * Count how many BTRFS_MAX_EXTENT_SIZE cover the @size
+ */
+static inline u32 count_max_extents(u64 size)
+{
+ return div_u64(size + BTRFS_MAX_EXTENT_SIZE - 1, BTRFS_MAX_EXTENT_SIZE);
+}
+
struct btrfs_mapping_tree {
struct extent_map_tree map_tree;
};