btrfs-progs: mkfs: use the btrfs_block_group_root helper

Instead of accessing the extent root directory for modifying block
groups, use the helper which will do the correct thing based on the
flags of the file system.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2022-03-07 17:10:48 -05:00 committed by David Sterba
parent cab7570ccc
commit 360103e610
2 changed files with 3 additions and 3 deletions

View File

@ -9426,6 +9426,7 @@ static int reinit_global_roots(struct btrfs_trans_handle *trans, u64 objectid)
static int reinit_extent_tree(struct btrfs_trans_handle *trans, bool pin)
{
struct btrfs_root *bg_root = btrfs_block_group_root(trans->fs_info);
u64 start = 0;
int ret;
@ -9499,7 +9500,6 @@ again:
while (1) {
struct btrfs_block_group_item bgi;
struct btrfs_block_group *cache;
struct btrfs_root *extent_root = btrfs_extent_root(gfs_info, 0);
struct btrfs_key key;
cache = btrfs_lookup_first_block_group(gfs_info, start);
@ -9513,7 +9513,7 @@ again:
key.objectid = cache->start;
key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
key.offset = cache->length;
ret = btrfs_insert_item(trans, extent_root, &key, &bgi,
ret = btrfs_insert_item(trans, bg_root, &key, &bgi,
sizeof(bgi));
if (ret) {
fprintf(stderr, "Error adding block group\n");

View File

@ -596,7 +596,7 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info,
{
struct btrfs_trans_handle *trans = NULL;
struct btrfs_block_group_item *bgi;
struct btrfs_root *root = btrfs_extent_root(fs_info, 0);
struct btrfs_root *root = btrfs_block_group_root(fs_info);
struct btrfs_key key;
struct btrfs_key found_key;
struct btrfs_path path;