Commit 2ccf545e authored by David Sterba's avatar David Sterba

btrfs: get fs_info from block group in search_free_space_info

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: default avatarDavid Sterba <dsterba@suse.com>
parent 2ceeae2e
...@@ -76,10 +76,11 @@ static int add_new_free_space_info(struct btrfs_trans_handle *trans, ...@@ -76,10 +76,11 @@ static int add_new_free_space_info(struct btrfs_trans_handle *trans,
EXPORT_FOR_TESTS EXPORT_FOR_TESTS
struct btrfs_free_space_info *search_free_space_info( 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_block_group_cache *block_group,
struct btrfs_path *path, int cow) 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_root *root = fs_info->free_space_root;
struct btrfs_key key; struct btrfs_key key;
int ret; int ret;
...@@ -253,7 +254,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, ...@@ -253,7 +254,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
btrfs_release_path(path); 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)) { if (IS_ERR(info)) {
ret = PTR_ERR(info); ret = PTR_ERR(info);
goto out; goto out;
...@@ -398,7 +399,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans, ...@@ -398,7 +399,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
btrfs_release_path(path); 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)) { if (IS_ERR(info)) {
ret = PTR_ERR(info); ret = PTR_ERR(info);
goto out; goto out;
...@@ -463,8 +464,7 @@ static int update_free_space_extent_count(struct btrfs_trans_handle *trans, ...@@ -463,8 +464,7 @@ static int update_free_space_extent_count(struct btrfs_trans_handle *trans,
if (new_extents == 0) if (new_extents == 0)
return 0; return 0;
info = search_free_space_info(trans, trans->fs_info, block_group, path, info = search_free_space_info(trans, block_group, path, 1);
1);
if (IS_ERR(info)) { if (IS_ERR(info)) {
ret = PTR_ERR(info); ret = PTR_ERR(info);
goto out; goto out;
...@@ -793,8 +793,7 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans, ...@@ -793,8 +793,7 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
info = search_free_space_info(NULL, trans->fs_info, block_group, path, info = search_free_space_info(NULL, block_group, path, 0);
0);
if (IS_ERR(info)) if (IS_ERR(info))
return PTR_ERR(info); return PTR_ERR(info);
flags = btrfs_free_space_flags(path->nodes[0], 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, ...@@ -977,7 +976,6 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, u64 start, u64 size) struct btrfs_path *path, u64 start, u64 size)
{ {
struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_free_space_info *info; struct btrfs_free_space_info *info;
u32 flags; u32 flags;
int ret; int ret;
...@@ -988,7 +986,7 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans, ...@@ -988,7 +986,7 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
return ret; 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)) if (IS_ERR(info))
return PTR_ERR(info); return PTR_ERR(info);
flags = btrfs_free_space_flags(path->nodes[0], info); flags = btrfs_free_space_flags(path->nodes[0], info);
...@@ -1534,14 +1532,12 @@ static int load_free_space_extents(struct btrfs_caching_control *caching_ctl, ...@@ -1534,14 +1532,12 @@ static int load_free_space_extents(struct btrfs_caching_control *caching_ctl,
int load_free_space_tree(struct btrfs_caching_control *caching_ctl) int load_free_space_tree(struct btrfs_caching_control *caching_ctl)
{ {
struct btrfs_block_group_cache *block_group; struct btrfs_block_group_cache *block_group;
struct btrfs_fs_info *fs_info;
struct btrfs_free_space_info *info; struct btrfs_free_space_info *info;
struct btrfs_path *path; struct btrfs_path *path;
u32 extent_count, flags; u32 extent_count, flags;
int ret; int ret;
block_group = caching_ctl->block_group; block_group = caching_ctl->block_group;
fs_info = block_group->fs_info;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
...@@ -1555,7 +1551,7 @@ int load_free_space_tree(struct btrfs_caching_control *caching_ctl) ...@@ -1555,7 +1551,7 @@ int load_free_space_tree(struct btrfs_caching_control *caching_ctl)
path->search_commit_root = 1; path->search_commit_root = 1;
path->reada = READA_FORWARD; 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)) { if (IS_ERR(info)) {
ret = PTR_ERR(info); ret = PTR_ERR(info);
goto out; goto out;
......
...@@ -30,7 +30,6 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans, ...@@ -30,7 +30,6 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
struct btrfs_free_space_info * struct btrfs_free_space_info *
search_free_space_info(struct btrfs_trans_handle *trans, search_free_space_info(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_path *path, int cow); struct btrfs_path *path, int cow);
int __add_to_free_space_tree(struct btrfs_trans_handle *trans, int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
......
...@@ -30,7 +30,7 @@ static int __check_free_space_extents(struct btrfs_trans_handle *trans, ...@@ -30,7 +30,7 @@ static int __check_free_space_extents(struct btrfs_trans_handle *trans,
unsigned int i; unsigned int i;
int ret; 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)) { if (IS_ERR(info)) {
test_err("could not find free space info"); test_err("could not find free space info");
ret = PTR_ERR(info); ret = PTR_ERR(info);
...@@ -115,7 +115,7 @@ static int check_free_space_extents(struct btrfs_trans_handle *trans, ...@@ -115,7 +115,7 @@ static int check_free_space_extents(struct btrfs_trans_handle *trans,
u32 flags; u32 flags;
int ret; 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)) { if (IS_ERR(info)) {
test_err("could not find free space info"); test_err("could not find free space info");
btrfs_release_path(path); btrfs_release_path(path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment