btrfs-progs: mkfs/convert: separate the convert part from make_btrfs

The regulare mkfs_btrfs does not anything special about convert and just
passes the arguments. Make that two functions.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2017-01-24 19:36:15 +01:00
parent 78e1787c55
commit c855e60f7e
4 changed files with 7 additions and 9 deletions

View File

@ -2431,7 +2431,7 @@ static int do_convert(const char *devname, int datacsum, int packing,
memset(mkfs_cfg.chunk_uuid, 0, BTRFS_UUID_UNPARSED_SIZE); memset(mkfs_cfg.chunk_uuid, 0, BTRFS_UUID_UNPARSED_SIZE);
memset(mkfs_cfg.fs_uuid, 0, BTRFS_UUID_UNPARSED_SIZE); memset(mkfs_cfg.fs_uuid, 0, BTRFS_UUID_UNPARSED_SIZE);
ret = make_btrfs(fd, &mkfs_cfg, &cctx); ret = make_convert_btrfs(fd, &mkfs_cfg, &cctx);
if (ret) { if (ret) {
error("unable to create initial ctree: %s", strerror(-ret)); error("unable to create initial ctree: %s", strerror(-ret));
goto fail; goto fail;

View File

@ -1740,7 +1740,7 @@ int main(int argc, char **argv)
mkfs_cfg.stripesize = stripesize; mkfs_cfg.stripesize = stripesize;
mkfs_cfg.features = features; mkfs_cfg.features = features;
ret = make_btrfs(fd, &mkfs_cfg, NULL); ret = make_btrfs(fd, &mkfs_cfg);
if (ret) { if (ret) {
error("error during mkfs: %s", strerror(-ret)); error("error during mkfs: %s", strerror(-ret));
exit(1); exit(1);

View File

@ -943,7 +943,7 @@ out:
* Split into small blocks and reuse codes. * Split into small blocks and reuse codes.
* TODO: Reuse tree operation facilities by introducing new flags * TODO: Reuse tree operation facilities by introducing new flags
*/ */
static int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg, int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
struct btrfs_convert_context *cctx) struct btrfs_convert_context *cctx)
{ {
struct cache_tree *free = &cctx->free; struct cache_tree *free = &cctx->free;
@ -1052,8 +1052,7 @@ out:
* The superblock signature is not valid, denotes a partially created * The superblock signature is not valid, denotes a partially created
* filesystem, needs to be finalized. * filesystem, needs to be finalized.
*/ */
int make_btrfs(int fd, struct btrfs_mkfs_config *cfg, int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
struct btrfs_convert_context *cctx)
{ {
struct btrfs_super_block super; struct btrfs_super_block super;
struct extent_buffer *buf; struct extent_buffer *buf;
@ -1078,8 +1077,6 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg,
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA); BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
u64 num_bytes; u64 num_bytes;
if (cctx)
return make_convert_btrfs(fd, cfg, cctx);
buf = malloc(sizeof(*buf) + max(cfg->sectorsize, cfg->nodesize)); buf = malloc(sizeof(*buf) + max(cfg->sectorsize, cfg->nodesize));
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;

View File

@ -155,7 +155,8 @@ struct btrfs_convert_context {
#define PREP_DEVICE_DISCARD (1U << 1) #define PREP_DEVICE_DISCARD (1U << 1)
#define PREP_DEVICE_VERBOSE (1U << 2) #define PREP_DEVICE_VERBOSE (1U << 2)
int make_btrfs(int fd, struct btrfs_mkfs_config *cfg, int make_btrfs(int fd, struct btrfs_mkfs_config *cfg);
int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg,
struct btrfs_convert_context *cctx); struct btrfs_convert_context *cctx);
int btrfs_make_root_dir(struct btrfs_trans_handle *trans, int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 objectid); struct btrfs_root *root, u64 objectid);