From 360103e610018192d3d9a7e1997b090f85fc6619 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Mon, 7 Mar 2022 17:10:48 -0500 Subject: [PATCH] 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 Signed-off-by: David Sterba --- check/main.c | 4 ++-- mkfs/main.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/check/main.c b/check/main.c index d213b335..519a8318 100644 --- a/check/main.c +++ b/check/main.c @@ -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"); diff --git a/mkfs/main.c b/mkfs/main.c index 3dd06979..20dc0436 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -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;