btrfs: convert nodesize macros to static inlines
This patch converts the macros used to calculate various node size limits to static inlines. That way we get type checking for free. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
14a1e067b4
commit
1db1ff92b6
|
@ -145,21 +145,6 @@ struct btrfs_header {
|
||||||
u8 level;
|
u8 level;
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \
|
|
||||||
sizeof(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_MAX_ITEM_SIZE(r) - \
|
|
||||||
BTRFS_FILE_EXTENT_INLINE_DATA_START)
|
|
||||||
#define BTRFS_MAX_XATTR_SIZE(r) (BTRFS_MAX_ITEM_SIZE(r) - \
|
|
||||||
sizeof(struct btrfs_dir_item))
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this is a very generous portion of the super block, giving us
|
* this is a very generous portion of the super block, giving us
|
||||||
* room to translate 14 chunks with 3 stripes each.
|
* room to translate 14 chunks with 3 stripes each.
|
||||||
|
@ -1261,6 +1246,39 @@ struct btrfs_root {
|
||||||
atomic_t qgroup_meta_rsv;
|
atomic_t qgroup_meta_rsv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline u32 __BTRFS_LEAF_DATA_SIZE(u32 blocksize)
|
||||||
|
{
|
||||||
|
return blocksize - sizeof(struct btrfs_header);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32 BTRFS_LEAF_DATA_SIZE(const struct btrfs_root *root)
|
||||||
|
{
|
||||||
|
return __BTRFS_LEAF_DATA_SIZE(root->nodesize);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32 BTRFS_MAX_ITEM_SIZE(const struct btrfs_root *root)
|
||||||
|
{
|
||||||
|
return BTRFS_LEAF_DATA_SIZE(root) - sizeof(struct btrfs_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_root *root)
|
||||||
|
{
|
||||||
|
return BTRFS_LEAF_DATA_SIZE(root) / sizeof(struct btrfs_key_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BTRFS_FILE_EXTENT_INLINE_DATA_START \
|
||||||
|
(offsetof(struct btrfs_file_extent_item, disk_bytenr))
|
||||||
|
static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_root *root)
|
||||||
|
{
|
||||||
|
return BTRFS_MAX_ITEM_SIZE(root) -
|
||||||
|
BTRFS_FILE_EXTENT_INLINE_DATA_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_root *root)
|
||||||
|
{
|
||||||
|
return BTRFS_MAX_ITEM_SIZE(root) - sizeof(struct btrfs_dir_item);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flags for mount options.
|
* Flags for mount options.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue