diff mbox

[v3,2/7] btrfs-progs: convert: Introduce simple range structure for convert reserved ranges

Message ID 20170314080509.31163-3-quwenruo@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Qu Wenruo March 14, 2017, 8:05 a.m. UTC
Introduce a new strucutre, simple_range, to present one continuous
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>
---
 convert/common.h | 27 +++++++++++++++++++++++++++
 convert/main.c   |  1 +
 2 files changed, 28 insertions(+)
diff mbox

Patch

diff --git a/convert/common.h b/convert/common.h
index 0d3adeaa..28ca1461 100644
--- a/convert/common.h
+++ b/convert/common.h
@@ -26,6 +26,33 @@ 
 #include "common-defs.h"
 #include "extent-cache.h"
 
+/*
+ * Presents one simple continuous range.
+ *
+ * For multiple or non-continuous ranges, use extent_cache_tree from
+ * extent-cache.c
+ */
+struct simple_range {
+	u64 start;
+	u64 len;
+};
+
+const static struct simple_range btrfs_reserved_ranges[] = {
+	{0, SZ_1M},
+	{BTRFS_SB_MIRROR_OFFSET(1), SZ_64K},
+	{BTRFS_SB_MIRROR_OFFSET(2), SZ_64K}
+};
+
+/*
+ * Simple range functions
+ *
+ * Get range end (exclusive)
+ */
+static inline u64 range_end(const struct simple_range *range)
+{
+	return (range->start + range->len);
+}
+
 struct btrfs_mkfs_config;
 
 struct btrfs_convert_context {
diff --git a/convert/main.c b/convert/main.c
index 079c1ebd..41309645 100644
--- a/convert/main.c
+++ b/convert/main.c
@@ -81,6 +81,7 @@ 
 #include <fcntl.h>
 #include <unistd.h>
 #include <getopt.h>
+#include <stdbool.h>
 
 #include "ctree.h"
 #include "disk-io.h"