@@ -859,7 +859,14 @@ struct btrfs_root_item {
* this root.
*/
__le64 global_tree_id;
- __le64 reserved[7]; /* for future */
+
+ /*
+ * Indicates the current snapshot id, every time we are snapshotted this
+ * is increased.
+ */
+ __le64 snapshot_id;
+
+ __le64 reserved[6]; /* for future */
} __attribute__ ((__packed__));
/*
@@ -2262,6 +2269,8 @@ BTRFS_SETGET_STACK_FUNCS(root_stransid, struct btrfs_root_item,
stransid, 64);
BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item,
rtransid, 64);
+BTRFS_SETGET_STACK_FUNCS(root_snapshot_id, struct btrfs_root_item,
+ snapshot_id, 64);
static inline struct btrfs_timespec* btrfs_root_ctime(
struct btrfs_root_item *root_item)
@@ -2480,6 +2480,9 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
memset(root->root_item.uuid, 0, BTRFS_UUID_SIZE);
root->root_item.drop_level = 0;
+ /* This is safe to do on both versions since we used a reserved area. */
+ btrfs_set_root_snapshot_id(&root->root_item, 0);
+
ret = btrfs_insert_root(trans, tree_root, &root->root_key,
&root->root_item);
if (ret)
This is going to be used to keep track of when a snapshot of this root was taken last. Any time we are snapshotted we will increase this value and set the new extent buffers to this snapshot_id. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- kernel-shared/ctree.h | 11 ++++++++++- kernel-shared/disk-io.c | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-)