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 <dsterba@suse.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ split hunks to new file structure ]
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2017-02-22 16:46:18 +08:00 committed by David Sterba
parent 0117fdf1fc
commit 714cda6136
2 changed files with 29 additions and 0 deletions

View File

@ -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;

View File

@ -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