mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 14:44:10 +08:00
btrfs: convert btrfs_block_group::needs_free_space to runtime flag
We already have flags in block group to track various status bits, convert needs_free_space as well and reduce size of btrfs_block_group. Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
fd463ac461
commit
0d7764ff58
@ -2553,7 +2553,7 @@ struct btrfs_block_group *btrfs_make_block_group(struct btrfs_trans_handle *tran
|
|||||||
cache->global_root_id = calculate_global_root_id(fs_info, cache->start);
|
cache->global_root_id = calculate_global_root_id(fs_info, cache->start);
|
||||||
|
|
||||||
if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE))
|
if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE))
|
||||||
cache->needs_free_space = 1;
|
set_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &cache->runtime_flags);
|
||||||
|
|
||||||
ret = btrfs_load_block_group_zone_info(cache, true);
|
ret = btrfs_load_block_group_zone_info(cache, true);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -55,6 +55,8 @@ enum btrfs_block_group_flags {
|
|||||||
BLOCK_GROUP_FLAG_CHUNK_ITEM_INSERTED,
|
BLOCK_GROUP_FLAG_CHUNK_ITEM_INSERTED,
|
||||||
BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE,
|
BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE,
|
||||||
BLOCK_GROUP_FLAG_ZONED_DATA_RELOC,
|
BLOCK_GROUP_FLAG_ZONED_DATA_RELOC,
|
||||||
|
/* Does the block group need to be added to the free space tree? */
|
||||||
|
BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum btrfs_caching_type {
|
enum btrfs_caching_type {
|
||||||
@ -208,12 +210,6 @@ struct btrfs_block_group {
|
|||||||
/* Lock for free space tree operations. */
|
/* Lock for free space tree operations. */
|
||||||
struct mutex free_space_lock;
|
struct mutex free_space_lock;
|
||||||
|
|
||||||
/*
|
|
||||||
* Does the block group need to be added to the free space tree?
|
|
||||||
* Protected by free_space_lock.
|
|
||||||
*/
|
|
||||||
int needs_free_space;
|
|
||||||
|
|
||||||
/* Flag indicating this block group is placed on a sequential zone */
|
/* Flag indicating this block group is placed on a sequential zone */
|
||||||
bool seq_zone;
|
bool seq_zone;
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
|
|||||||
u32 flags;
|
u32 flags;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (block_group->needs_free_space) {
|
if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) {
|
||||||
ret = __add_block_group_free_space(trans, block_group, path);
|
ret = __add_block_group_free_space(trans, block_group, path);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
@ -1001,7 +1001,7 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
|
|||||||
u32 flags;
|
u32 flags;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (block_group->needs_free_space) {
|
if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) {
|
||||||
ret = __add_block_group_free_space(trans, block_group, path);
|
ret = __add_block_group_free_space(trans, block_group, path);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
@ -1304,7 +1304,7 @@ static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
block_group->needs_free_space = 0;
|
clear_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags);
|
||||||
|
|
||||||
ret = add_new_free_space_info(trans, block_group, path);
|
ret = add_new_free_space_info(trans, block_group, path);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -1326,7 +1326,7 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mutex_lock(&block_group->free_space_lock);
|
mutex_lock(&block_group->free_space_lock);
|
||||||
if (!block_group->needs_free_space)
|
if (!test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
@ -1359,7 +1359,7 @@ int remove_block_group_free_space(struct btrfs_trans_handle *trans,
|
|||||||
if (!btrfs_fs_compat_ro(trans->fs_info, FREE_SPACE_TREE))
|
if (!btrfs_fs_compat_ro(trans->fs_info, FREE_SPACE_TREE))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (block_group->needs_free_space) {
|
if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) {
|
||||||
/* We never added this block group to the free space tree. */
|
/* We never added this block group to the free space tree. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
|
|||||||
}
|
}
|
||||||
cache->bitmap_low_thresh = 0;
|
cache->bitmap_low_thresh = 0;
|
||||||
cache->bitmap_high_thresh = (u32)-1;
|
cache->bitmap_high_thresh = (u32)-1;
|
||||||
cache->needs_free_space = 1;
|
set_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &cache->runtime_flags);
|
||||||
cache->fs_info = root->fs_info;
|
cache->fs_info = root->fs_info;
|
||||||
|
|
||||||
btrfs_init_dummy_trans(&trans, root->fs_info);
|
btrfs_init_dummy_trans(&trans, root->fs_info);
|
||||||
|
Loading…
Reference in New Issue
Block a user