btrfs: get fs_info from block group in search_free_space_info
authorDavid Sterba <dsterba@suse.com>
Wed, 20 Mar 2019 13:11:21 +0000 (14:11 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Apr 2019 17:02:46 +0000 (19:02 +0200)
We can read fs_info from the block group cache structure and can drop it
from the parameters.  Though the transaction is also availabe, it's not
guaranteed to be non-NULL.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/free-space-tree.c
fs/btrfs/free-space-tree.h
fs/btrfs/tests/free-space-tree-tests.c

index 771126bc67bcf8293763b40ec502236fe6043e1f..f5dc115ebba069f70b74131b7627daeeee989f9a 100644 (file)
@@ -76,10 +76,11 @@ out:
 
 EXPORT_FOR_TESTS
 struct btrfs_free_space_info *search_free_space_info(
-               struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info,
+               struct btrfs_trans_handle *trans,
                struct btrfs_block_group_cache *block_group,
                struct btrfs_path *path, int cow)
 {
+       struct btrfs_fs_info *fs_info = block_group->fs_info;
        struct btrfs_root *root = fs_info->free_space_root;
        struct btrfs_key key;
        int ret;
@@ -253,7 +254,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
                btrfs_release_path(path);
        }
 
-       info = search_free_space_info(trans, fs_info, block_group, path, 1);
+       info = search_free_space_info(trans, block_group, path, 1);
        if (IS_ERR(info)) {
                ret = PTR_ERR(info);
                goto out;
@@ -398,7 +399,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
                btrfs_release_path(path);
        }
 
-       info = search_free_space_info(trans, fs_info, block_group, path, 1);
+       info = search_free_space_info(trans, block_group, path, 1);
        if (IS_ERR(info)) {
                ret = PTR_ERR(info);
                goto out;
@@ -463,8 +464,7 @@ static int update_free_space_extent_count(struct btrfs_trans_handle *trans,
        if (new_extents == 0)
                return 0;
 
-       info = search_free_space_info(trans, trans->fs_info, block_group, path,
-                                     1);
+       info = search_free_space_info(trans, block_group, path, 1);
        if (IS_ERR(info)) {
                ret = PTR_ERR(info);
                goto out;
@@ -793,8 +793,7 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
                        return ret;
        }
 
-       info = search_free_space_info(NULL, trans->fs_info, block_group, path,
-                                     0);
+       info = search_free_space_info(NULL, block_group, path, 0);
        if (IS_ERR(info))
                return PTR_ERR(info);
        flags = btrfs_free_space_flags(path->nodes[0], info);
@@ -977,7 +976,6 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
                             struct btrfs_block_group_cache *block_group,
                             struct btrfs_path *path, u64 start, u64 size)
 {
-       struct btrfs_fs_info *fs_info = trans->fs_info;
        struct btrfs_free_space_info *info;
        u32 flags;
        int ret;
@@ -988,7 +986,7 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
                        return ret;
        }
 
-       info = search_free_space_info(NULL, fs_info, block_group, path, 0);
+       info = search_free_space_info(NULL, block_group, path, 0);
        if (IS_ERR(info))
                return PTR_ERR(info);
        flags = btrfs_free_space_flags(path->nodes[0], info);
@@ -1534,14 +1532,12 @@ out:
 int load_free_space_tree(struct btrfs_caching_control *caching_ctl)
 {
        struct btrfs_block_group_cache *block_group;
-       struct btrfs_fs_info *fs_info;
        struct btrfs_free_space_info *info;
        struct btrfs_path *path;
        u32 extent_count, flags;
        int ret;
 
        block_group = caching_ctl->block_group;
-       fs_info = block_group->fs_info;
 
        path = btrfs_alloc_path();
        if (!path)
@@ -1555,7 +1551,7 @@ int load_free_space_tree(struct btrfs_caching_control *caching_ctl)
        path->search_commit_root = 1;
        path->reada = READA_FORWARD;
 
-       info = search_free_space_info(NULL, fs_info, block_group, path, 0);
+       info = search_free_space_info(NULL, block_group, path, 0);
        if (IS_ERR(info)) {
                ret = PTR_ERR(info);
                goto out;
index 3133651d7d706acf0214cae98408604cb888c96a..22b7602bde253f6d5ec6182d765d3d581c3ee520 100644 (file)
@@ -30,7 +30,6 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
 struct btrfs_free_space_info *
 search_free_space_info(struct btrfs_trans_handle *trans,
-                      struct btrfs_fs_info *fs_info,
                       struct btrfs_block_group_cache *block_group,
                       struct btrfs_path *path, int cow);
 int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
index 09c27628e305880e140464816ef49cbe7d12b0a3..9b26ada1873b8dd7bed971a0471f7cf9388ec540 100644 (file)
@@ -30,7 +30,7 @@ static int __check_free_space_extents(struct btrfs_trans_handle *trans,
        unsigned int i;
        int ret;
 
-       info = search_free_space_info(trans, fs_info, cache, path, 0);
+       info = search_free_space_info(trans, cache, path, 0);
        if (IS_ERR(info)) {
                test_err("could not find free space info");
                ret = PTR_ERR(info);
@@ -115,7 +115,7 @@ static int check_free_space_extents(struct btrfs_trans_handle *trans,
        u32 flags;
        int ret;
 
-       info = search_free_space_info(trans, fs_info, cache, path, 0);
+       info = search_free_space_info(trans, cache, path, 0);
        if (IS_ERR(info)) {
                test_err("could not find free space info");
                btrfs_release_path(path);