summaryrefslogtreecommitdiff
path: root/fs/bcachefs/bcachefs_format.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-02-07 13:38:02 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:35 -0400
commit548b3d209fa5c6aaa9db58a69d9f6cf4ce8978b6 (patch)
tree9f96fb50cf49b7b72070011ec1ab6260cd1d9610 /fs/bcachefs/bcachefs_format.h
parent237e80483a6466f3c1968c2a8bb115b3e24d951b (diff)
downloadlwn-548b3d209fa5c6aaa9db58a69d9f6cf4ce8978b6.tar.gz
lwn-548b3d209fa5c6aaa9db58a69d9f6cf4ce8978b6.zip
bcachefs: btree_ptr_v2
Add a new btree ptr type which contains the sequence number (random 64 bit cookie, actually) for that btree node - this lets us verify that when we read in a btree node it really is the btree node we wanted. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/bcachefs_format.h')
-rw-r--r--fs/bcachefs/bcachefs_format.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h
index dbc9c15514bd..575fb7143cc0 100644
--- a/fs/bcachefs/bcachefs_format.h
+++ b/fs/bcachefs/bcachefs_format.h
@@ -343,7 +343,8 @@ static inline void bkey_init(struct bkey *k)
x(stripe, 14) \
x(reflink_p, 15) \
x(reflink_v, 16) \
- x(inline_data, 17)
+ x(inline_data, 17) \
+ x(btree_ptr_v2, 18)
enum bch_bkey_type {
#define x(name, nr) KEY_TYPE_##name = nr,
@@ -599,6 +600,19 @@ struct bch_btree_ptr {
struct bch_extent_ptr start[];
} __attribute__((packed, aligned(8)));
+struct bch_btree_ptr_v2 {
+ struct bch_val v;
+
+ __u64 mem_ptr;
+ __le64 seq;
+ __le16 sectors_written;
+ /* In case we ever decide to do variable size btree nodes: */
+ __le16 sectors;
+ struct bpos min_key;
+ __u64 _data[0];
+ struct bch_extent_ptr start[];
+} __attribute__((packed, aligned(8)));
+
struct bch_extent {
struct bch_val v;
@@ -630,7 +644,8 @@ struct bch_reservation {
/* Btree pointers don't carry around checksums: */
#define BKEY_BTREE_PTR_VAL_U64s_MAX \
- ((sizeof(struct bch_extent_ptr)) / sizeof(u64) * BCH_REPLICAS_MAX)
+ ((sizeof(struct bch_btree_ptr_v2) + \
+ sizeof(struct bch_extent_ptr) * BCH_REPLICAS_MAX) / sizeof(u64))
#define BKEY_BTREE_PTR_U64s_MAX \
(BKEY_U64s + BKEY_BTREE_PTR_VAL_U64s_MAX)
@@ -1299,7 +1314,8 @@ LE64_BITMASK(BCH_SB_ERASURE_CODE, struct bch_sb, flags[3], 0, 16);
x(new_siphash, 7) \
x(inline_data, 8) \
x(new_extent_overwrite, 9) \
- x(incompressible, 10)
+ x(incompressible, 10) \
+ x(btree_ptr_v2, 11)
enum bch_sb_feature {
#define x(f, n) BCH_FEATURE_##f,