summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-07-01 19:19:05 +0200
committerDavid Sterba <dsterba@suse.com>2015-07-02 19:21:39 +0200
commitac2ba40fa0139e5549a7d18e08b0ac4497220e83 (patch)
tree29306178b8b624cd02e10eacc316a1be43a3bb78
parent3161806153aac00810a2a5c656c14d6b6bd937df (diff)
btrfs-progs: split data block group creation out of make_root_dir
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--mkfs.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/mkfs.c b/mkfs.c
index 9da3fa39..166c6a8a 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -121,12 +121,13 @@ err:
return ret;
}
-static int make_root_dir(struct btrfs_trans_handle *trans, struct btrfs_root *root,
- int mixed, struct mkfs_allocation *allocation)
+static int create_data_block_groups(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root, int mixed,
+ struct mkfs_allocation *allocation)
{
u64 chunk_start = 0;
u64 chunk_size = 0;
- int ret;
+ int ret = 0;
if (!mixed) {
ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root,
@@ -145,6 +146,16 @@ static int make_root_dir(struct btrfs_trans_handle *trans, struct btrfs_root *ro
BUG_ON(ret);
}
+err:
+ return ret;
+}
+
+static int make_root_dir(struct btrfs_trans_handle *trans, struct btrfs_root *root,
+ int mixed, struct mkfs_allocation *allocation)
+{
+ struct btrfs_key location;
+ int ret;
+
ret = btrfs_make_root_dir(trans, root->fs_info->tree_root,
BTRFS_ROOT_TREE_DIR_OBJECTID);
if (ret)
@@ -1546,6 +1557,12 @@ int main(int ac, char **av)
trans = btrfs_start_transaction(root, 1);
BUG_ON(!trans);
+ ret = create_data_block_groups(trans, root, mixed, &allocation);
+ if (ret) {
+ fprintf(stderr, "failed to create default data block groups\n");
+ exit(1);
+ }
+
ret = make_root_dir(trans, root, mixed, &allocation);
if (ret) {
fprintf(stderr, "failed to setup the root directory\n");