diff mbox series

[03/11] btrfs: add snapshot_id to the btrfs_root_item

Message ID b11dd3023680d84fea2c821dabea1f6fe40c824a.1646692474.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs: add snapshot_id to btrfs_header and root_item | expand

Commit Message

Josef Bacik March 7, 2022, 10:36 p.m. UTC
This will be incremented on every snapshot in order to keep track of
which blocks belong to which snapshots.

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

Patch

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 222c5dda9079..6f446cdf05c2 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2414,6 +2414,8 @@  BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item,
 			 rtransid, 64);
 BTRFS_SETGET_STACK_FUNCS(root_global_tree_id, struct btrfs_root_item,
 			 global_tree_id, 64);
+BTRFS_SETGET_STACK_FUNCS(root_snapshot_id, struct btrfs_root_item,
+			 snapshot_id, 64);
 
 static inline bool btrfs_root_readonly(const struct btrfs_root *root)
 {
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index cd62ca1950cb..91dd7feae9aa 100644
--- a/include/uapi/linux/btrfs_tree.h
+++ b/include/uapi/linux/btrfs_tree.h
@@ -686,7 +686,13 @@  struct btrfs_root_item {
 	/* If we want to use a specific set of global roots for this root. */
 	__le64 global_tree_id;
 
-	__le64 reserved[7]; /* for future */
+	/*
+	 * The current snapshot id of this root, increases every time we are
+	 * snapshotted.
+	 */
+	__le64 snapshot_id;
+
+	__le64 reserved[6]; /* for future */
 } __attribute__ ((__packed__));
 
 /*