From 330ca2d6dfe074fd14798ba7a60d6fda43ab932a Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 29 Jan 2016 13:03:14 +0800 Subject: btrfs-progs: utils: Introduce new function for convert Introduce new function make_convert_btrfs() for convert. This new function will have the following features: 1) Allocate temporary sb/metadata/system chunk, avoiding old used data 2) More structured functions No more over 1000 lines function, better function split and code reuse This will finally replace current make_btrfs(), but now only used for convert. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- utils.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'utils.h') diff --git a/utils.h b/utils.h index 4fee4692..c79f81e6 100644 --- a/utils.h +++ b/utils.h @@ -46,6 +46,8 @@ | BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA \ | BTRFS_FEATURE_INCOMPAT_NO_HOLES) +#define BTRFS_CONVERT_META_GROUP_SIZE (32 * 1024 * 1024) + #define BTRFS_FEATURE_LIST_ALL (1ULL << 63) #define BTRFS_SCAN_MOUNTED (1ULL << 0) @@ -123,7 +125,30 @@ struct btrfs_mkfs_config { u64 super_bytenr; }; -int make_btrfs(int fd, struct btrfs_mkfs_config *cfg); +struct btrfs_convert_context { + u32 blocksize; + u32 first_data_block; + u32 block_count; + u32 inodes_count; + u32 free_inodes_count; + u64 total_bytes; + char *volume_name; + const struct btrfs_convert_operations *convert_ops; + + /* The accurate used space of old filesystem */ + struct cache_tree used; + + /* Batched ranges which must be covered by data chunks */ + struct cache_tree data_chunks; + + /* Free space which is not covered by data_chunks */ + struct cache_tree free; + + void *fs_data; +}; + +int make_btrfs(int fd, struct btrfs_mkfs_config *cfg, + struct btrfs_convert_context *cctx); int btrfs_make_root_dir(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 objectid); int btrfs_prepare_device(int fd, const char *file, int zero_end, -- cgit v1.2.3