]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
btrfs: introduce BTRFS_MAX_ITEM_SIZE
authorJeff Mahoney <jeffm@suse.com>
Wed, 15 Jun 2016 14:25:38 +0000 (10:25 -0400)
committerDavid Sterba <dsterba@suse.com>
Tue, 26 Jul 2016 11:54:24 +0000 (13:54 +0200)
We use BTRFS_LEAF_DATA_SIZE - sizeof(struct btrfs_item) in
several places.  This introduces a BTRFS_MAX_ITEM_SIZE macro to do the
same.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/file-item.c
fs/btrfs/volumes.c

index 950e4ee6b66e7855cc8d10100d10c052a6e407fc..1d46ceec1fc0872f6c9ba6e6824a9fdfccdc4cf9 100644 (file)
@@ -150,13 +150,13 @@ struct btrfs_header {
                                     sizeof(struct btrfs_key_ptr))
 #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
 #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize))
+#define BTRFS_MAX_ITEM_SIZE(r) \
+       (BTRFS_LEAF_DATA_SIZE(r) - sizeof(struct btrfs_item))
 #define BTRFS_FILE_EXTENT_INLINE_DATA_START            \
                (offsetof(struct btrfs_file_extent_item, disk_bytenr))
-#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
-                                       sizeof(struct btrfs_item) - \
+#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_MAX_ITEM_SIZE(r) - \
                                        BTRFS_FILE_EXTENT_INLINE_DATA_START)
-#define BTRFS_MAX_XATTR_SIZE(r)        (BTRFS_LEAF_DATA_SIZE(r) - \
-                                sizeof(struct btrfs_item) -\
+#define BTRFS_MAX_XATTR_SIZE(r)        (BTRFS_MAX_ITEM_SIZE(r) - \
                                 sizeof(struct btrfs_dir_item))
 
 
index c4487e177234051f0b1562c69441e54f85c9fa69..44549d706dcd1ea20466d1f4b7805fd3dbd2640e 100644 (file)
@@ -2779,7 +2779,7 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_root *root, u64 csum_bytes)
        u64 num_csums_per_leaf;
        u64 num_csums;
 
-       csum_size = BTRFS_LEAF_DATA_SIZE(root) - sizeof(struct btrfs_item);
+       csum_size = BTRFS_MAX_ITEM_SIZE(root);
        num_csums_per_leaf = div64_u64(csum_size,
                        (u64)btrfs_super_csum_size(root->fs_info->super_copy));
        num_csums = div64_u64(csum_bytes, root->sectorsize);
index 6b58d0620e2fb095cc16f2e7cac0853bac1b7a0e..cdbbf85a269bfdb9f30e7d88c490d6c0a77fa2fd 100644 (file)
@@ -27,9 +27,8 @@
 #include "print-tree.h"
 #include "compression.h"
 
-#define __MAX_CSUM_ITEMS(r, size) ((unsigned long)(((BTRFS_LEAF_DATA_SIZE(r) - \
-                                  sizeof(struct btrfs_item) * 2) / \
-                                 size) - 1))
+#define __MAX_CSUM_ITEMS(r, size) \
+       ((unsigned long)(((BTRFS_MAX_ITEM_SIZE(r) * 2) / size) - 1))
 
 #define MAX_CSUM_ITEMS(r, size) (min_t(u32, __MAX_CSUM_ITEMS(r, size), \
                                       PAGE_SIZE))
index 5e409e28a5c01c42d62137a2410401e237faf524..104a2e42ed71cf28da186bd5187d704bf5f7cf79 100644 (file)
@@ -4573,8 +4573,7 @@ static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type)
        btrfs_set_fs_incompat(info, RAID56);
 }
 
-#define BTRFS_MAX_DEVS(r) ((BTRFS_LEAF_DATA_SIZE(r)            \
-                       - sizeof(struct btrfs_item)             \
+#define BTRFS_MAX_DEVS(r) ((BTRFS_MAX_ITEM_SIZE(r)             \
                        - sizeof(struct btrfs_chunk))           \
                        / sizeof(struct btrfs_stripe) + 1)