From 0b246afa62b0cf5b09d078121f543135f28492ad Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Wed, 22 Jun 2016 18:54:23 -0400 Subject: btrfs: root->fs_info cleanup, add fs_info convenience variables In routines where someptr->fs_info is referenced multiple times, we introduce a convenience variable. This makes the code considerably more readable. Signed-off-by: Jeff Mahoney Signed-off-by: David Sterba --- fs/btrfs/ctree.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'fs/btrfs/ctree.h') diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 19b6bb2f2368..860103020ac9 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1352,9 +1352,11 @@ static inline int btrfs_should_fragment_free_space(struct btrfs_root *root, struct btrfs_block_group_cache *block_group) { - return (btrfs_test_opt(root->fs_info, FRAGMENT_METADATA) && + struct btrfs_fs_info *fs_info = root->fs_info; + + return (btrfs_test_opt(fs_info, FRAGMENT_METADATA) && block_group->flags & BTRFS_BLOCK_GROUP_METADATA) || - (btrfs_test_opt(root->fs_info, FRAGMENT_DATA) && + (btrfs_test_opt(fs_info, FRAGMENT_DATA) && block_group->flags & BTRFS_BLOCK_GROUP_DATA); } #endif @@ -2312,10 +2314,11 @@ static inline unsigned long btrfs_leaf_data(struct extent_buffer *l) static inline unsigned int leaf_data_end(struct btrfs_root *root, struct extent_buffer *leaf) { + struct btrfs_fs_info *fs_info = root->fs_info; u32 nr = btrfs_header_nritems(leaf); if (nr == 0) - return BTRFS_LEAF_DATA_SIZE(root->fs_info); + return BTRFS_LEAF_DATA_SIZE(fs_info); return btrfs_item_offset_nr(leaf, nr - 1); } @@ -2905,8 +2908,9 @@ static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info) */ static inline int btrfs_need_cleaner_sleep(struct btrfs_root *root) { - return (root->fs_info->sb->s_flags & MS_RDONLY || - btrfs_fs_closing(root->fs_info)); + struct btrfs_fs_info *fs_info = root->fs_info; + + return (fs_info->sb->s_flags & MS_RDONLY || btrfs_fs_closing(fs_info)); } static inline void free_fs_info(struct btrfs_fs_info *fs_info) -- cgit