@@ -1313,7 +1313,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
const bool async_trim_enabled = btrfs_test_opt(fs_info, DISCARD_ASYNC);
int ret = 0;
- if (!test_bit(BTRFS_FS_OPEN, &fs_info->flags))
+ if (!btrfs_fs_state_is_open_rw(fs_info))
return;
/*
@@ -1552,7 +1552,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
struct btrfs_block_group *bg;
struct btrfs_space_info *space_info;
- if (!test_bit(BTRFS_FS_OPEN, &fs_info->flags))
+ if (!btrfs_fs_state_is_open_rw(fs_info))
return;
if (!btrfs_should_reclaim(fs_info))
@@ -4039,6 +4039,11 @@ static inline bool btrfs_is_data_reloc_root(const struct btrfs_root *root)
return root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID;
}
+static inline bool btrfs_fs_state_is_open_rw(const struct btrfs_fs_info *fs_info)
+{
+ return test_bit(BTRFS_FS_OPEN, &fs_info->flags);
+}
+
/*
* We use page status Private2 to indicate there is an ordered extent with
* unfinished IO.
@@ -1984,7 +1984,7 @@ static int cleaner_kthread(void *arg)
* Do not do anything if we might cause open_ctree() to block
* before we have finished mounting the filesystem.
*/
- if (!test_bit(BTRFS_FS_OPEN, &fs_info->flags))
+ if (!btrfs_fs_state_is_open_rw(fs_info))
goto sleep;
if (!mutex_trylock(&fs_info->cleaner_mutex))
@@ -7610,7 +7610,7 @@ int btrfs_read_chunk_tree(struct btrfs_fs_info *fs_info)
* and at this point there can't be any concurrent task modifying the
* chunk tree, to keep it simple, just skip locking on the chunk tree.
*/
- ASSERT(!test_bit(BTRFS_FS_OPEN, &fs_info->flags));
+ ASSERT(!btrfs_fs_state_is_open_rw(fs_info));
path->skip_locking = 1;
/*
2nd patch in preparation to make the BTRFS_FS_OPEN flag work irrespective of the type of mount (rdonly or read-write-able). Bring the check for the BTRFS_FS_OPEN flag into an inline function btrfs_fs_state_is_open_rw(). Signed-off-by: Anand Jain <anand.jain@oracle.com> --- fs/btrfs/block-group.c | 4 ++-- fs/btrfs/ctree.h | 5 +++++ fs/btrfs/disk-io.c | 2 +- fs/btrfs/volumes.c | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-)