@@ -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)
{
@@ -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 */
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(+)