aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2014-06-04 13:22:26 -0400
committerChris Mason <clm@fb.com>2014-09-17 16:37:14 -0400
commit707e8a071528385a87b63a72a37c2322e463c7b8 (patch)
tree02fa581efa4d2a05b4e786a553cf9e88bd6274b3 /fs/btrfs/ctree.h
parent962a298f35110edd8f326814ae41a3dd306ecb64 (diff)
btrfs: use nodesize everywhere, kill leafsize
The nodesize and leafsize were never of different values. Unify the usage and make nodesize the one. Cleanup the redundant checks and helpers. Shaves a few bytes from .text: text data bss dec hex filename 852418 24560 23112 900090 dbbfa btrfs.ko.before 851074 24584 23112 898770 db6d2 btrfs.ko.after Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h21
1 files changed, 4 insertions, 17 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index a835a548e47e..6fc16d22d27d 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -391,7 +391,7 @@ struct btrfs_header {
391 sizeof(struct btrfs_header)) / \ 391 sizeof(struct btrfs_header)) / \
392 sizeof(struct btrfs_key_ptr)) 392 sizeof(struct btrfs_key_ptr))
393#define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) 393#define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
394#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize)) 394#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize))
395#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ 395#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
396 sizeof(struct btrfs_item) - \ 396 sizeof(struct btrfs_item) - \
397 sizeof(struct btrfs_file_extent_item)) 397 sizeof(struct btrfs_file_extent_item))
@@ -474,7 +474,7 @@ struct btrfs_super_block {
474 __le64 num_devices; 474 __le64 num_devices;
475 __le32 sectorsize; 475 __le32 sectorsize;
476 __le32 nodesize; 476 __le32 nodesize;
477 __le32 leafsize; 477 __le32 __unused_leafsize;
478 __le32 stripesize; 478 __le32 stripesize;
479 __le32 sys_chunk_array_size; 479 __le32 sys_chunk_array_size;
480 __le64 chunk_root_generation; 480 __le64 chunk_root_generation;
@@ -1806,9 +1806,6 @@ struct btrfs_root {
1806 /* node allocations are done in nodesize units */ 1806 /* node allocations are done in nodesize units */
1807 u32 nodesize; 1807 u32 nodesize;
1808 1808
1809 /* leaf allocations are done in leafsize units */
1810 u32 leafsize;
1811
1812 u32 stripesize; 1809 u32 stripesize;
1813 1810
1814 u32 type; 1811 u32 type;
@@ -2995,8 +2992,6 @@ BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block,
2995 sectorsize, 32); 2992 sectorsize, 32);
2996BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block, 2993BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block,
2997 nodesize, 32); 2994 nodesize, 32);
2998BTRFS_SETGET_STACK_FUNCS(super_leafsize, struct btrfs_super_block,
2999 leafsize, 32);
3000BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block, 2995BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block,
3001 stripesize, 32); 2996 stripesize, 32);
3002BTRFS_SETGET_STACK_FUNCS(super_root_dir, struct btrfs_super_block, 2997BTRFS_SETGET_STACK_FUNCS(super_root_dir, struct btrfs_super_block,
@@ -3232,13 +3227,6 @@ static inline struct btrfs_fs_info *btrfs_sb(struct super_block *sb)
3232 return sb->s_fs_info; 3227 return sb->s_fs_info;
3233} 3228}
3234 3229
3235static inline u32 btrfs_level_size(struct btrfs_root *root, int level)
3236{
3237 if (level == 0)
3238 return root->leafsize;
3239 return root->nodesize;
3240}
3241
3242/* helper function to cast into the data area of the leaf. */ 3230/* helper function to cast into the data area of the leaf. */
3243#define btrfs_item_ptr(leaf, slot, type) \ 3231#define btrfs_item_ptr(leaf, slot, type) \
3244 ((type *)(btrfs_leaf_data(leaf) + \ 3232 ((type *)(btrfs_leaf_data(leaf) + \
@@ -3263,7 +3251,7 @@ static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping)
3263static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root, 3251static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
3264 unsigned num_items) 3252 unsigned num_items)
3265{ 3253{
3266 return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) * 3254 return (root->nodesize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
3267 2 * num_items; 3255 2 * num_items;
3268} 3256}
3269 3257
@@ -3274,8 +3262,7 @@ static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
3274static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_root *root, 3262static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_root *root,
3275 unsigned num_items) 3263 unsigned num_items)
3276{ 3264{
3277 return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) * 3265 return root->nodesize * BTRFS_MAX_LEVEL * num_items;
3278 num_items;
3279} 3266}
3280 3267
3281int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans, 3268int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,