mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-07 17:51:23 +00:00
btrfs-progs: mkfs: set chunk_item_objectid properly for extent tree v2
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> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
02fb308bdc
commit
1f89a5d461
@ -191,7 +191,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;
|
||||
@ -206,8 +206,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,
|
||||
@ -218,7 +217,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,
|
||||
cfg->leaf_data_size -
|
||||
sizeof(struct btrfs_block_group_item));
|
||||
btrfs_set_header_bytenr(buf, cfg->blocks[MKFS_BLOCK_GROUP_TREE]);
|
||||
@ -396,6 +395,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++;
|
||||
|
Loading…
Reference in New Issue
Block a user