From 714cda6136b90b3159bed9f077ede9608fbca49f Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 22 Feb 2017 16:46:18 +0800 Subject: [PATCH] btrfs-progs: convert: Introduce simple range structure for convert reserved ranges Introduce a new strucutre, simple_range, to present one contingous range. Also, use such structure to define btrfs_reserved_ranges(), which convert and rollback will use. Suggested-by: David Sterba Signed-off-by: Qu Wenruo [ split hunks to new file structure ] Signed-off-by: David Sterba --- convert/source-fs.c | 6 ++++++ convert/source-fs.h | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/convert/source-fs.c b/convert/source-fs.c index 8217c893..7cf515b0 100644 --- a/convert/source-fs.c +++ b/convert/source-fs.c @@ -22,6 +22,12 @@ #include "convert/common.h" #include "convert/source-fs.h" +struct simple_range btrfs_reserved_ranges[3] = { + { 0, SZ_1M }, + { BTRFS_SB_MIRROR_OFFSET(1), SZ_64K }, + { BTRFS_SB_MIRROR_OFFSET(2), SZ_64K } +}; + static int intersect_with_sb(u64 bytenr, u64 num_bytes) { int i; diff --git a/convert/source-fs.h b/convert/source-fs.h index f3f96d07..9f611150 100644 --- a/convert/source-fs.h +++ b/convert/source-fs.h @@ -21,6 +21,19 @@ #define CONV_IMAGE_SUBVOL_OBJECTID BTRFS_FIRST_FREE_OBJECTID +/* + * Reresents a simple contiguous range. + * + * For multiple or non-contiguous ranges, use extent_cache_tree from + * extent-cache.c + */ +struct simple_range { + u64 start; + u64 len; +}; + +extern struct simple_range btrfs_reserved_ranges[3]; + struct task_info; struct task_ctx { @@ -89,4 +102,14 @@ int read_disk_extent(struct btrfs_root *root, u64 bytenr, int record_file_blocks(struct blk_iterate_data *data, u64 file_block, u64 disk_block, u64 num_blocks); +/* + * Simple range functions + * + * Get range end (exclusive) + */ +static inline u64 range_end(struct simple_range *range) +{ + return (range->start + range->len); +} + #endif -- 2.11.4.GIT