[PATCH v2 20/22] btrfs-progs: mkfs: set chunk_item_objectid properly for extent tree v2
From: Josef Bacik <josef@toxicpanda.com>
Date: 2021-12-01 18:17:58
Subsystem:
the rest · Maintainer:
Linus Torvalds
Our initial block group will use global root id 0 with extent tree v2, so adjust the helper to take the chunk_objectid as an argument, as we'll set this to 0 for extent tree v2 and then BTRFS_FIRST_CHUNK_TREE_OBJECTID for extent tree v1. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- mkfs/common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mkfs/common.c b/mkfs/common.c
index d91b1e6f..a4412a1f 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c@@ -192,7 +192,7 @@ static int create_free_space_tree(int fd, struct btrfs_mkfs_config *cfg, static void write_block_group_item(struct extent_buffer *buf, u32 nr, u64 objectid, u64 offset, u64 used, - u32 itemoff) + u64 chunk_objectid, u32 itemoff) { struct btrfs_block_group_item *bg_item; struct btrfs_disk_key disk_key;
@@ -207,8 +207,7 @@ static void write_block_group_item(struct extent_buffer *buf, u32 nr, bg_item = btrfs_item_ptr(buf, nr, struct btrfs_block_group_item); btrfs_set_block_group_used(buf, bg_item, used); btrfs_set_block_group_flags(buf, bg_item, BTRFS_BLOCK_GROUP_SYSTEM); - btrfs_set_block_group_chunk_objectid(buf, bg_item, - BTRFS_FIRST_CHUNK_TREE_OBJECTID); + btrfs_set_block_group_chunk_objectid(buf, bg_item, chunk_objectid); } static int create_block_group_tree(int fd, struct btrfs_mkfs_config *cfg,
@@ -219,7 +218,7 @@ static int create_block_group_tree(int fd, struct btrfs_mkfs_config *cfg, memset(buf->data + sizeof(struct btrfs_header), 0, cfg->nodesize - sizeof(struct btrfs_header)); - write_block_group_item(buf, 0, bg_offset, bg_size, bg_used, + write_block_group_item(buf, 0, bg_offset, bg_size, bg_used, 0, __BTRFS_LEAF_DATA_SIZE(cfg->nodesize) - sizeof(struct btrfs_block_group_item)); btrfs_set_header_bytenr(buf, cfg->blocks[MKFS_BLOCK_GROUP_TREE]);
@@ -405,6 +404,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg) write_block_group_item(buf, nritems, system_group_offset, system_group_size, total_used, + BTRFS_FIRST_CHUNK_TREE_OBJECTID, itemoff); add_block_group = false; nritems++;
--
2.26.3