]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/bkey.h
Update bcachefs sources to 7c0fe6f104 bcachefs: Fix bch2_fsck_ask_yn()
[bcachefs-tools-debian] / libbcachefs / bkey.h
index 983572efd0814688d6fb1f6a184c1d247d70739d..e81fb3e00c602dfca2e544ac85de7b4584c5b92d 100644 (file)
@@ -9,9 +9,17 @@
 #include "util.h"
 #include "vstructs.h"
 
+#if 0
+
+/*
+ * compiled unpack functions are disabled, pending a new interface for
+ * dynamically allocating executable memory:
+ */
+
 #ifdef CONFIG_X86_64
 #define HAVE_BCACHEFS_COMPILED_UNPACK  1
 #endif
+#endif
 
 void bch2_bkey_packed_to_binary_text(struct printbuf *,
                                     const struct bkey_format *,
@@ -497,7 +505,7 @@ static inline struct bpos bkey_unpack_pos(const struct btree *b,
 
 /* Disassembled bkeys */
 
-static inline struct bkey_s_c bkey_disassemble(struct btree *b,
+static inline struct bkey_s_c bkey_disassemble(const struct btree *b,
                                               const struct bkey_packed *k,
                                               struct bkey *u)
 {
@@ -507,7 +515,7 @@ static inline struct bkey_s_c bkey_disassemble(struct btree *b,
 }
 
 /* non const version: */
-static inline struct bkey_s __bkey_disassemble(struct btree *b,
+static inline struct bkey_s __bkey_disassemble(const struct btree *b,
                                               struct bkey_packed *k,
                                               struct bkey *u)
 {
@@ -611,20 +619,20 @@ struct bkey_s_##name {                                                    \
                                                                        \
 static inline struct bkey_i_##name *bkey_i_to_##name(struct bkey_i *k) \
 {                                                                      \
-       EBUG_ON(k->k.type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name);    \
        return container_of(&k->k, struct bkey_i_##name, k);            \
 }                                                                      \
                                                                        \
 static inline const struct bkey_i_##name *                             \
 bkey_i_to_##name##_c(const struct bkey_i *k)                           \
 {                                                                      \
-       EBUG_ON(k->k.type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name);    \
        return container_of(&k->k, struct bkey_i_##name, k);            \
 }                                                                      \
                                                                        \
 static inline struct bkey_s_##name bkey_s_to_##name(struct bkey_s k)   \
 {                                                                      \
-       EBUG_ON(k.k->type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k.k) && k.k->type != KEY_TYPE_##name);  \
        return (struct bkey_s_##name) {                                 \
                .k = k.k,                                               \
                .v = container_of(k.v, struct bch_##name, v),           \
@@ -633,7 +641,7 @@ static inline struct bkey_s_##name bkey_s_to_##name(struct bkey_s k)        \
                                                                        \
 static inline struct bkey_s_c_##name bkey_s_c_to_##name(struct bkey_s_c k)\
 {                                                                      \
-       EBUG_ON(k.k->type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k.k) && k.k->type != KEY_TYPE_##name);  \
        return (struct bkey_s_c_##name) {                               \
                .k = k.k,                                               \
                .v = container_of(k.v, struct bch_##name, v),           \
@@ -659,7 +667,7 @@ name##_i_to_s_c(const struct bkey_i_##name *k)                              \
                                                                        \
 static inline struct bkey_s_##name bkey_i_to_s_##name(struct bkey_i *k)        \
 {                                                                      \
-       EBUG_ON(k->k.type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name);    \
        return (struct bkey_s_##name) {                                 \
                .k = &k->k,                                             \
                .v = container_of(&k->v, struct bch_##name, v),         \
@@ -669,7 +677,7 @@ static inline struct bkey_s_##name bkey_i_to_s_##name(struct bkey_i *k)     \
 static inline struct bkey_s_c_##name                                   \
 bkey_i_to_s_c_##name(const struct bkey_i *k)                           \
 {                                                                      \
-       EBUG_ON(k->k.type != KEY_TYPE_##name);                          \
+       EBUG_ON(!IS_ERR_OR_NULL(k) && k->k.type != KEY_TYPE_##name);    \
        return (struct bkey_s_c_##name) {                               \
                .k = &k->k,                                             \
                .v = container_of(&k->v, struct bch_##name, v),         \