diff options
author | David Sterba <dsterba@suse.com> | 2015-07-01 19:15:35 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-07-01 19:20:11 +0200 |
commit | 3161806153aac00810a2a5c656c14d6b6bd937df (patch) | |
tree | 328fced6691639949d7cd559dd9cef7648390555 /mkfs.c | |
parent | 21f26887cdde8e16a55031782a99a3c4fb4cfc11 (diff) |
btrfs-progs: move transaction start/commit out of make_root_dir
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'mkfs.c')
-rw-r--r-- | mkfs.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -121,18 +121,13 @@ err: return ret; } -static int make_root_dir(struct btrfs_root *root, int mixed, - struct mkfs_allocation *allocation) +static int make_root_dir(struct btrfs_trans_handle *trans, struct btrfs_root *root, + int mixed, struct mkfs_allocation *allocation) { - struct btrfs_trans_handle *trans; - struct btrfs_key location; u64 chunk_start = 0; u64 chunk_size = 0; int ret; - trans = btrfs_start_transaction(root, 1); - BUG_ON(!trans); - if (!mixed) { ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root, &chunk_start, &chunk_size, @@ -172,7 +167,6 @@ static int make_root_dir(struct btrfs_root *root, int mixed, if (ret) goto err; - btrfs_commit_transaction(trans, root); err: return ret; } @@ -1549,12 +1543,17 @@ int main(int ac, char **av) exit(1); } - ret = make_root_dir(root, mixed, &allocation); + trans = btrfs_start_transaction(root, 1); + BUG_ON(!trans); + + ret = make_root_dir(trans, root, mixed, &allocation); if (ret) { fprintf(stderr, "failed to setup the root directory\n"); exit(1); } + btrfs_commit_transaction(trans, root); + trans = btrfs_start_transaction(root, 1); if (is_block_device(file)) |