diff options
author | Anand Jain <anand.jain@oracle.com> | 2021-08-24 08:27:42 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2021-10-26 20:03:57 +0300 |
commit | a09f23c3554eec3451ce5d8891729b29b089e59f (patch) | |
tree | 6416b4d079b520ef1cd6ffb197ace0925dbadf9a /fs/btrfs/block-group.c | |
parent | 44bee215f72f13874c0e734a0712c2e3264c0108 (diff) | |
download | linux-a09f23c3554eec3451ce5d8891729b29b089e59f.tar.xz |
btrfs: rename and switch to bool btrfs_chunk_readonly
btrfs_chunk_readonly() checks if the given chunk is writeable. It
returns 1 for readonly, and 0 for writeable. So the return argument type
bool shall suffice instead of the current type int.
Also, rename btrfs_chunk_readonly() to btrfs_chunk_writeable() as we
check if the bg is writeable, and helps to keep the logic at the parent
function simpler to understand.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/block-group.c')
-rw-r--r-- | fs/btrfs/block-group.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 1f8b06afbd03..64c4685bd770 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -2062,15 +2062,18 @@ static int read_one_block_group(struct btrfs_fs_info *info, link_block_group(cache); set_avail_alloc_bits(info, cache->flags); - if (btrfs_chunk_readonly(info, cache->start)) { + if (btrfs_chunk_writeable(info, cache->start)) { + if (cache->used == 0) { + ASSERT(list_empty(&cache->bg_list)); + if (btrfs_test_opt(info, DISCARD_ASYNC)) + btrfs_discard_queue_work(&info->discard_ctl, cache); + else + btrfs_mark_bg_unused(cache); + } + } else { inc_block_group_ro(cache, 1); - } else if (cache->used == 0) { - ASSERT(list_empty(&cache->bg_list)); - if (btrfs_test_opt(info, DISCARD_ASYNC)) - btrfs_discard_queue_work(&info->discard_ctl, cache); - else - btrfs_mark_bg_unused(cache); } + return 0; error: btrfs_put_block_group(cache); |