mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-11-16 00:34:32 +08:00
update mkfs.btrfs for the new space balancing code
The new space balancing code needs a subvol to store the temporary inode for data extent relocation. Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
parent
428b7fa630
commit
09ab0365ff
29
mkfs.c
29
mkfs.c
@ -232,6 +232,32 @@ static int create_raid_groups(struct btrfs_trans_handle *trans,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int create_data_reloc_tree(struct btrfs_trans_handle *trans,
|
||||
struct btrfs_root *root)
|
||||
{
|
||||
struct btrfs_key location;
|
||||
struct btrfs_root_item root_item;
|
||||
struct extent_buffer *tmp;
|
||||
u64 objectid = BTRFS_DATA_RELOC_TREE_OBJECTID;
|
||||
int ret;
|
||||
|
||||
ret = btrfs_copy_root(trans, root, root->node, &tmp, objectid);
|
||||
BUG_ON(ret);
|
||||
|
||||
memcpy(&root_item, &root->root_item, sizeof(root_item));
|
||||
btrfs_set_root_bytenr(&root_item, tmp->start);
|
||||
btrfs_set_root_level(&root_item, btrfs_header_level(tmp));
|
||||
free_extent_buffer(tmp);
|
||||
|
||||
location.objectid = objectid;
|
||||
location.type = BTRFS_ROOT_ITEM_KEY;
|
||||
location.offset = trans->transid;
|
||||
ret = btrfs_insert_root(trans, root->fs_info->tree_root,
|
||||
&location, &root_item);
|
||||
BUG_ON(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void print_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: mkfs.btrfs [options] dev [ dev ... ]\n");
|
||||
@ -459,6 +485,9 @@ raid_groups:
|
||||
metadata_profile);
|
||||
BUG_ON(ret);
|
||||
|
||||
ret = create_data_reloc_tree(trans, root);
|
||||
BUG_ON(ret);
|
||||
|
||||
printf("fs created label %s on %s\n\tnodesize %u leafsize %u "
|
||||
"sectorsize %u size %s\n",
|
||||
label, first_file, nodesize, leafsize, sectorsize,
|
||||
|
Loading…
Reference in New Issue
Block a user