]> 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 f29e3e7e95258b2d1639491372f258edbfa3c204..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)
@@ -290,16 +295,8 @@ enum bch_bkey_fields {
 struct bkey_i {
        __u64                   _data[0];
 
-       union {
-       struct {
-               /* Size of combined key and value, in u64s */
-               __u8            u64s;
-       };
-       struct {
-               struct bkey     k;
-               struct bch_val  v;
-       };
-       };
+       struct bkey     k;
+       struct bch_val  v;
 };
 
 #define KEY(_inode, _offset, _size)                                    \
@@ -318,7 +315,7 @@ static inline void bkey_init(struct bkey *k)
 #define bkey_bytes(_k)         ((_k)->u64s * sizeof(__u64))
 
 #define __BKEY_PADDED(key, pad)                                        \
-       struct { struct bkey_i key; __u64 key ## _pad[pad]; }
+       struct bkey_i key; __u64 key ## _pad[pad]
 
 /*
  * - DELETED keys are used internally to mark keys that should be ignored but
@@ -367,7 +364,9 @@ static inline void bkey_init(struct bkey *k)
        x(lru,                  26)                     \
        x(alloc_v4,             27)                     \
        x(backpointer,          28)                     \
-       x(inode_v3,             29)
+       x(inode_v3,             29)                     \
+       x(bucket_gens,          30)                     \
+       x(snapshot_tree,        31)
 
 enum bch_bkey_type {
 #define x(name, nr) KEY_TYPE_##name    = nr,
@@ -987,6 +986,7 @@ struct bch_alloc_v4 {
        __u64                   io_time[2];
        __u32                   stripe;
        __u32                   nr_external_backpointers;
+       __u64                   fragmentation_lru;
 } __packed __aligned(8);
 
 #define BCH_ALLOC_V4_U64s_V0   6
@@ -1009,6 +1009,15 @@ struct bch_backpointer {
        struct bpos             pos;
 } __packed __aligned(8);
 
+#define KEY_TYPE_BUCKET_GENS_BITS      8
+#define KEY_TYPE_BUCKET_GENS_NR                (1U << KEY_TYPE_BUCKET_GENS_BITS)
+#define KEY_TYPE_BUCKET_GENS_MASK      (KEY_TYPE_BUCKET_GENS_NR - 1)
+
+struct bch_bucket_gens {
+       struct bch_val          v;
+       u8                      gens[KEY_TYPE_BUCKET_GENS_NR];
+} __packed __aligned(8);
+
 /* Quotas: */
 
 enum quota_types {
@@ -1098,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)
@@ -1116,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)
@@ -1124,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 {
@@ -1347,7 +1372,7 @@ struct bch_replicas_entry {
 
 struct bch_sb_field_replicas {
        struct bch_sb_field     field;
-       struct bch_replicas_entry entries[0];
+       struct bch_replicas_entry entries[];
 } __packed __aligned(8);
 
 /* BCH_SB_FIELD_quota: */
@@ -1426,7 +1451,7 @@ struct bch_sb_field_disk_groups {
        x(move_extent_read,                             35)     \
        x(move_extent_write,                            36)     \
        x(move_extent_finish,                           37)     \
-       x(move_extent_race,                             38)     \
+       x(move_extent_fail,                             38)     \
        x(move_extent_alloc_mem_fail,                   39)     \
        x(copygc,                                       40)     \
        x(copygc_wait,                                  41)     \
@@ -1462,7 +1487,9 @@ struct bch_sb_field_disk_groups {
        x(trans_traverse_all,                           71)     \
        x(transaction_commit,                           72)     \
        x(write_super,                                  73)     \
-       x(trans_restart_would_deadlock_recursion_limit, 74)
+       x(trans_restart_would_deadlock_recursion_limit, 74)     \
+       x(trans_restart_write_buffer_flush,             75)     \
+       x(trans_restart_split_race,                     76)
 
 enum bch_persistent_counters {
 #define x(t, n, ...) BCH_COUNTER_##t,
@@ -1546,7 +1573,12 @@ struct bch_sb_field_journal_seq_blacklist {
        x(new_data_types,               21)             \
        x(backpointers,                 22)             \
        x(inode_v3,                     23)             \
-       x(unwritten_extents,            24)
+       x(unwritten_extents,            24)             \
+       x(bucket_gens,                  25)             \
+       x(lru_v2,                       26)             \
+       x(fragmentation_lru,            27)             \
+       x(no_bps_in_alloc_keys,         28)             \
+       x(snapshot_trees,               29)
 
 enum bcachefs_metadata_version {
        bcachefs_metadata_version_min = 9,
@@ -1556,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
@@ -1693,9 +1727,9 @@ LE64_BITMASK(BCH_SB_INODES_USE_KEY_CACHE,struct bch_sb, flags[3], 29, 30);
 LE64_BITMASK(BCH_SB_JOURNAL_FLUSH_DELAY,struct bch_sb, flags[3], 30, 62);
 LE64_BITMASK(BCH_SB_JOURNAL_FLUSH_DISABLED,struct bch_sb, flags[3], 62, 63);
 LE64_BITMASK(BCH_SB_JOURNAL_RECLAIM_DELAY,struct bch_sb, flags[4], 0, 32);
-/* Obsolete, always enabled: */
 LE64_BITMASK(BCH_SB_JOURNAL_TRANSACTION_NAMES,struct bch_sb, flags[4], 32, 33);
 LE64_BITMASK(BCH_SB_NOCOW,             struct bch_sb, flags[4], 33, 34);
+LE64_BITMASK(BCH_SB_WRITE_BUFFER_SIZE, struct bch_sb, flags[4], 34, 54);
 
 /*
  * Features:
@@ -2068,20 +2102,22 @@ LE32_BITMASK(JSET_NO_FLUSH,     struct jset, flags, 5, 6);
 /* Btree: */
 
 #define BCH_BTREE_IDS()                                \
-       x(extents,      0)                      \
-       x(inodes,       1)                      \
-       x(dirents,      2)                      \
-       x(xattrs,       3)                      \
-       x(alloc,        4)                      \
-       x(quotas,       5)                      \
-       x(stripes,      6)                      \
-       x(reflink,      7)                      \
-       x(subvolumes,   8)                      \
-       x(snapshots,    9)                      \
-       x(lru,          10)                     \
-       x(freespace,    11)                     \
-       x(need_discard, 12)                     \
-       x(backpointers, 13)
+       x(extents,              0)              \
+       x(inodes,               1)              \
+       x(dirents,              2)              \
+       x(xattrs,               3)              \
+       x(alloc,                4)              \
+       x(quotas,               5)              \
+       x(stripes,              6)              \
+       x(reflink,              7)              \
+       x(subvolumes,           8)              \
+       x(snapshots,            9)              \
+       x(lru,                  10)             \
+       x(freespace,            11)             \
+       x(need_discard,         12)             \
+       x(backpointers,         13)             \
+       x(bucket_gens,          14)             \
+       x(snapshot_trees,       15)
 
 enum btree_id {
 #define x(kwd, val) BTREE_ID_##kwd = val,