diff mbox series

[07/12] btrfs: add snapshot_id to the btrfs_header and related defs

Message ID bd2657da9c3dc802902b0aa3a5546f3c2166f9ce.1646692306.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs: item helper prep work for snapshot_id | expand

Commit Message

Josef Bacik March 7, 2022, 10:33 p.m. UTC
This adds the snapshot_id field to the btrfs_header, the HEADER_FLAG
that we're going to use to indicate that we have the larger header, as
well as the set/get helpers.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/ctree.h                | 19 +++++++++++++++++++
 include/uapi/linux/btrfs_tree.h |  1 +
 2 files changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 0551bd500ce0..7261c5c8f672 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -179,6 +179,11 @@  struct btrfs_header {
 	u8 level;
 } __attribute__ ((__packed__));
 
+struct btrfs_header_v2 {
+	struct btrfs_header header_v1;
+	__le64 snapshot_id;
+} __attribute__ ((__packed__));
+
 /*
  * this is a very generous portion of the super block, giving us
  * room to translate 14 chunks with 3 stripes each.
@@ -373,6 +378,11 @@  struct btrfs_leaf {
 	struct btrfs_item items[];
 } __attribute__ ((__packed__));
 
+struct btrfs_leaf_v2 {
+	struct btrfs_header_v2 header;
+	struct btrfs_item items[];
+} __attribute__ ((__packed__));
+
 /*
  * all non-leaf blocks are nodes, they hold only keys and pointers to
  * other blocks
@@ -388,6 +398,11 @@  struct btrfs_node {
 	struct btrfs_key_ptr ptrs[];
 } __attribute__ ((__packed__));
 
+struct btrfs_node_v2 {
+	struct btrfs_header_v2 header;
+	struct btrfs_key_ptr ptrs[];
+} __attribute__ ((__packed__));
+
 /* Read ahead values for struct btrfs_path.reada */
 enum {
 	READA_NONE,
@@ -2235,12 +2250,16 @@  BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64);
 BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32);
 BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64);
 BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8);
+BTRFS_SETGET_HEADER_FUNCS(header_snapshot_id, struct btrfs_header_v2,
+			  snapshot_id, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_header_generation, struct btrfs_header,
 			 generation, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_header_owner, struct btrfs_header, owner, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_header_nritems, struct btrfs_header,
 			 nritems, 32);
 BTRFS_SETGET_STACK_FUNCS(stack_header_bytenr, struct btrfs_header, bytenr, 64);
+BTRFS_SETGET_STACK_FUNCS(stack_header_snapshot_id, struct btrfs_header_v2,
+			 snapshot_id, 64);
 
 static inline int btrfs_header_flag(const struct extent_buffer *eb, u64 flag)
 {
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index 4a363289c90e..92760ea4b448 100644
--- a/include/uapi/linux/btrfs_tree.h
+++ b/include/uapi/linux/btrfs_tree.h
@@ -496,6 +496,7 @@  struct btrfs_free_space_header {
 
 #define BTRFS_HEADER_FLAG_WRITTEN	(1ULL << 0)
 #define BTRFS_HEADER_FLAG_RELOC		(1ULL << 1)
+#define BTRFS_HEADER_FLAG_V2		(1ULL << 2)
 
 /* Super block flags */
 /* Errors detected */