mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-31 01:41:41 +00:00
btrfs-progs: Introduce function to initialize fs tree
Introudce new function, setup_temp_fs_tree(), to setup temporary fs tree for make_btrfs_v2(). Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
f0a81c88d0
commit
b2da12034a
26
utils.c
26
utils.c
@ -656,6 +656,28 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int setup_temp_fs_tree(int fd, struct btrfs_mkfs_config *cfg,
|
||||
u64 fs_bytenr)
|
||||
{
|
||||
struct extent_buffer *buf = NULL;
|
||||
int ret;
|
||||
|
||||
buf = malloc(sizeof(*buf) + cfg->nodesize);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
ret = setup_temp_extent_buffer(buf, cfg, fs_bytenr,
|
||||
BTRFS_FS_TREE_OBJECTID);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
/*
|
||||
* Temporary fs tree is completely empty.
|
||||
*/
|
||||
ret = write_temp_extent_buffer(fd, buf, fs_bytenr);
|
||||
out:
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Improved version of make_btrfs().
|
||||
*
|
||||
@ -751,6 +773,10 @@ static int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
|
||||
goto out;
|
||||
ret = setup_temp_dev_tree(fd, cfg, sys_chunk_start, meta_chunk_start,
|
||||
dev_bytenr);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
ret = setup_temp_fs_tree(fd, cfg, fs_bytenr);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user