]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/bcachefs_format.h
Update bcachefs sources to 7c0fe6f104 bcachefs: Fix bch2_fsck_ask_yn()
[bcachefs-tools-debian] / libbcachefs / bcachefs_format.h
index 7d1c0b1e3c54939d7f5fba2eb734e2059b3c176b..4d142b2e3bf6691dc136b10d22ed1f61f7b47f51 100644 (file)
@@ -250,6 +250,11 @@ struct bkey_packed {
        __u8            pad[sizeof(struct bkey) - 3];
 } __packed __aligned(8);
 
+typedef struct {
+       __le64                  lo;
+       __le64                  hi;
+} bch_le128;
+
 #define BKEY_U64s                      (sizeof(struct bkey) / sizeof(__u64))
 #define BKEY_U64s_MAX                  U8_MAX
 #define BKEY_VAL_U64s_MAX              (BKEY_U64s_MAX - BKEY_U64s)
@@ -360,7 +365,8 @@ static inline void bkey_init(struct bkey *k)
        x(alloc_v4,             27)                     \
        x(backpointer,          28)                     \
        x(inode_v3,             29)                     \
-       x(bucket_gens,          30)
+       x(bucket_gens,          30)                     \
+       x(snapshot_tree,        31)
 
 enum bch_bkey_type {
 #define x(name, nr) KEY_TYPE_##name    = nr,
@@ -1101,6 +1107,9 @@ struct bch_subvolume {
        __le32                  flags;
        __le32                  snapshot;
        __le64                  inode;
+       __le32                  parent;
+       __le32                  pad;
+       bch_le128               otime;
 };
 
 LE32_BITMASK(BCH_SUBVOLUME_RO,         struct bch_subvolume, flags,  0,  1)
@@ -1119,7 +1128,7 @@ struct bch_snapshot {
        __le32                  parent;
        __le32                  children[2];
        __le32                  subvol;
-       __le32                  pad;
+       __le32                  tree;
 };
 
 LE32_BITMASK(BCH_SNAPSHOT_DELETED,     struct bch_snapshot, flags,  0,  1)
@@ -1127,6 +1136,19 @@ LE32_BITMASK(BCH_SNAPSHOT_DELETED,       struct bch_snapshot, flags,  0,  1)
 /* True if a subvolume points to this snapshot node: */
 LE32_BITMASK(BCH_SNAPSHOT_SUBVOL,      struct bch_snapshot, flags,  1,  2)
 
+/*
+ * Snapshot trees:
+ *
+ * The snapshot_trees btree gives us persistent indentifier for each tree of
+ * bch_snapshot nodes, and allow us to record and easily find the root/master
+ * subvolume that other snapshots were created from:
+ */
+struct bch_snapshot_tree {
+       struct bch_val          v;
+       __le32                  master_subvol;
+       __le32                  root_snapshot;
+};
+
 /* LRU btree: */
 
 struct bch_lru {
@@ -1555,7 +1577,8 @@ struct bch_sb_field_journal_seq_blacklist {
        x(bucket_gens,                  25)             \
        x(lru_v2,                       26)             \
        x(fragmentation_lru,            27)             \
-       x(no_bps_in_alloc_keys,         28)
+       x(no_bps_in_alloc_keys,         28)             \
+       x(snapshot_trees,               29)
 
 enum bcachefs_metadata_version {
        bcachefs_metadata_version_min = 9,
@@ -1565,6 +1588,8 @@ enum bcachefs_metadata_version {
        bcachefs_metadata_version_max
 };
 
+static const unsigned bcachefs_metadata_required_upgrade_below = bcachefs_metadata_version_snapshot_trees;
+
 #define bcachefs_metadata_version_current      (bcachefs_metadata_version_max - 1)
 
 #define BCH_SB_SECTOR                  8
@@ -2091,7 +2116,8 @@ LE32_BITMASK(JSET_NO_FLUSH,       struct jset, flags, 5, 6);
        x(freespace,            11)             \
        x(need_discard,         12)             \
        x(backpointers,         13)             \
-       x(bucket_gens,          14)
+       x(bucket_gens,          14)             \
+       x(snapshot_trees,       15)
 
 enum btree_id {
 #define x(kwd, val) BTREE_ID_##kwd = val,