diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2016-01-29 13:03:14 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-06-07 18:15:19 +0200 |
commit | 330ca2d6dfe074fd14798ba7a60d6fda43ab932a (patch) | |
tree | 4b90f39c8946c56ec449fbb374d8bc686f1bfda4 /utils.h | |
parent | 522ef705e38fdb9ae952344b454da392e60dc90d (diff) |
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 <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -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, |