]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/bkey.h
Disable pristine-tar option in gbp.conf, since there is no pristine-tar branch.
[bcachefs-tools-debian] / libbcachefs / bkey.h
index e81fb3e00c602dfca2e544ac85de7b4584c5b92d..831be01809f2c9271d4db159377decd1b8686bb6 100644 (file)
@@ -9,6 +9,12 @@
 #include "util.h"
 #include "vstructs.h"
 
+enum bkey_invalid_flags {
+       BKEY_INVALID_WRITE              = (1U << 0),
+       BKEY_INVALID_COMMIT             = (1U << 1),
+       BKEY_INVALID_JOURNAL            = (1U << 2),
+};
+
 #if 0
 
 /*
@@ -46,7 +52,7 @@ struct bkey_s {
 
 static inline struct bkey_i *bkey_next(struct bkey_i *k)
 {
-       return (struct bkey_i *) (k->_data + k->k.u64s);
+       return (struct bkey_i *) ((u64 *) k->_data + k->k.u64s);
 }
 
 #define bkey_val_u64s(_k)      ((_k)->u64s - BKEY_U64s)
@@ -86,19 +92,15 @@ enum bkey_lr_packed {
 #define bkey_lr_packed(_l, _r)                                         \
        ((_l)->format + ((_r)->format << 1))
 
-#define bkey_copy(_dst, _src)                                  \
-do {                                                           \
-       BUILD_BUG_ON(!type_is(_dst, struct bkey_i *) &&         \
-                    !type_is(_dst, struct bkey_packed *));     \
-       BUILD_BUG_ON(!type_is(_src, struct bkey_i *) &&         \
-                    !type_is(_src, struct bkey_packed *));     \
-       EBUG_ON((u64 *) (_dst) > (u64 *) (_src) &&              \
-               (u64 *) (_dst) < (u64 *) (_src) +               \
-               ((struct bkey *) (_src))->u64s);                \
-                                                               \
-       memcpy_u64s_small((_dst), (_src),                       \
-                         ((struct bkey *) (_src))->u64s);      \
-} while (0)
+static inline void bkey_p_copy(struct bkey_packed *dst, const struct bkey_packed *src)
+{
+       memcpy_u64s_small(dst, src, src->u64s);
+}
+
+static inline void bkey_copy(struct bkey_i *dst, const struct bkey_i *src)
+{
+       memcpy_u64s_small(dst, src, src->k.u64s);
+}
 
 struct btree;
 
@@ -391,7 +393,7 @@ static inline void set_bkeyp_val_u64s(const struct bkey_format *format,
 }
 
 #define bkeyp_val(_format, _k)                                         \
-        ((struct bch_val *) ((_k)->_data + bkeyp_key_u64s(_format, _k)))
+        ((struct bch_val *) ((u64 *) (_k)->_data + bkeyp_key_u64s(_format, _k)))
 
 extern const struct bkey_format bch2_bkey_format_current;
 
@@ -726,7 +728,7 @@ static inline unsigned high_word_offset(const struct bkey_format *f)
 #error edit for your odd byteorder.
 #endif
 
-#define high_word(f, k)                ((k)->_data + high_word_offset(f))
+#define high_word(f, k)                ((u64 *) (k)->_data + high_word_offset(f))
 #define next_word(p)           nth_word(p, 1)
 #define prev_word(p)           nth_word(p, -1)
 
@@ -769,6 +771,8 @@ static inline void bch2_bkey_format_add_key(struct bkey_format_state *s, const s
 
 void bch2_bkey_format_add_pos(struct bkey_format_state *, struct bpos);
 struct bkey_format bch2_bkey_format_done(struct bkey_format_state *);
-const char *bch2_bkey_format_validate(struct bkey_format *);
+int bch2_bkey_format_invalid(struct bch_fs *, struct bkey_format *,
+                            enum bkey_invalid_flags, struct printbuf *);
+void bch2_bkey_format_to_text(struct printbuf *, const struct bkey_format *);
 
 #endif /* _BCACHEFS_BKEY_H */