Commit fef998d1 authored by David Sterba's avatar David Sterba

btrfs: use btrfs_is_testing() everywhere

There are open coded tests of BTRFS_FS_STATE_DUMMY_FS_INFO and we have a
wrapper for that that's a compile-time constant when self-tests are not
built in. As this is only for development we can save some bytes and
conditions on release configs by using the helper in the remaining
cases.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 905a95f3
...@@ -646,7 +646,7 @@ struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr, ...@@ -646,7 +646,7 @@ struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info, static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
u64 objectid) u64 objectid)
{ {
bool dummy = test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state); bool dummy = btrfs_is_testing(fs_info);
memset(&root->root_key, 0, sizeof(root->root_key)); memset(&root->root_key, 0, sizeof(root->root_key));
memset(&root->root_item, 0, sizeof(root->root_item)); memset(&root->root_item, 0, sizeof(root->root_item));
...@@ -1075,7 +1075,7 @@ static struct btrfs_root *read_tree_root_path(struct btrfs_root *tree_root, ...@@ -1075,7 +1075,7 @@ static struct btrfs_root *read_tree_root_path(struct btrfs_root *tree_root,
* For real fs, and not log/reloc trees, root owner must * For real fs, and not log/reloc trees, root owner must
* match its root node owner * match its root node owner
*/ */
if (!test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state) && if (!btrfs_is_testing(fs_info) &&
btrfs_root_id(root) != BTRFS_TREE_LOG_OBJECTID && btrfs_root_id(root) != BTRFS_TREE_LOG_OBJECTID &&
btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID && btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID &&
btrfs_root_id(root) != btrfs_header_owner(root->node)) { btrfs_root_id(root) != btrfs_header_owner(root->node)) {
......
...@@ -2339,7 +2339,7 @@ int btrfs_sysfs_add_one_qgroup(struct btrfs_fs_info *fs_info, ...@@ -2339,7 +2339,7 @@ int btrfs_sysfs_add_one_qgroup(struct btrfs_fs_info *fs_info,
struct kobject *qgroups_kobj = fs_info->qgroups_kobj; struct kobject *qgroups_kobj = fs_info->qgroups_kobj;
int ret; int ret;
if (test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state)) if (btrfs_is_testing(fs_info))
return 0; return 0;
if (qgroup->kobj.state_initialized) if (qgroup->kobj.state_initialized)
return 0; return 0;
...@@ -2360,7 +2360,7 @@ void btrfs_sysfs_del_qgroups(struct btrfs_fs_info *fs_info) ...@@ -2360,7 +2360,7 @@ void btrfs_sysfs_del_qgroups(struct btrfs_fs_info *fs_info)
struct btrfs_qgroup *qgroup; struct btrfs_qgroup *qgroup;
struct btrfs_qgroup *next; struct btrfs_qgroup *next;
if (test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state)) if (btrfs_is_testing(fs_info))
return; return;
rbtree_postorder_for_each_entry_safe(qgroup, next, rbtree_postorder_for_each_entry_safe(qgroup, next,
...@@ -2381,7 +2381,7 @@ int btrfs_sysfs_add_qgroups(struct btrfs_fs_info *fs_info) ...@@ -2381,7 +2381,7 @@ int btrfs_sysfs_add_qgroups(struct btrfs_fs_info *fs_info)
struct btrfs_qgroup *next; struct btrfs_qgroup *next;
int ret = 0; int ret = 0;
if (test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state)) if (btrfs_is_testing(fs_info))
return 0; return 0;
ASSERT(fsid_kobj); ASSERT(fsid_kobj);
...@@ -2413,7 +2413,7 @@ int btrfs_sysfs_add_qgroups(struct btrfs_fs_info *fs_info) ...@@ -2413,7 +2413,7 @@ int btrfs_sysfs_add_qgroups(struct btrfs_fs_info *fs_info)
void btrfs_sysfs_del_one_qgroup(struct btrfs_fs_info *fs_info, void btrfs_sysfs_del_one_qgroup(struct btrfs_fs_info *fs_info,
struct btrfs_qgroup *qgroup) struct btrfs_qgroup *qgroup)
{ {
if (test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state)) if (btrfs_is_testing(fs_info))
return; return;
if (qgroup->kobj.state_initialized) { if (qgroup->kobj.state_initialized) {
......
...@@ -160,8 +160,7 @@ void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info) ...@@ -160,8 +160,7 @@ void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info)
if (!fs_info) if (!fs_info)
return; return;
if (WARN_ON(!test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, if (WARN_ON(!btrfs_is_testing(fs_info)))
&fs_info->fs_state)))
return; return;
test_mnt->mnt_sb->s_fs_info = NULL; test_mnt->mnt_sb->s_fs_info = NULL;
......
...@@ -2021,7 +2021,7 @@ int btrfs_check_eb_owner(const struct extent_buffer *eb, u64 root_owner) ...@@ -2021,7 +2021,7 @@ int btrfs_check_eb_owner(const struct extent_buffer *eb, u64 root_owner)
* Skip dummy fs, as selftests don't create unique ebs for each dummy * Skip dummy fs, as selftests don't create unique ebs for each dummy
* root. * root.
*/ */
if (test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &eb->fs_info->fs_state)) if (btrfs_is_testing(eb->fs_info))
return 0; return 0;
/* /*
* There are several call sites (backref walking, qgroup, and data * There are several call sites (backref walking, qgroup, and data
......
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