1 #ifndef _BCACHEFS_BKEY_METHODS_H
2 #define _BCACHEFS_BKEY_METHODS_H
6 #define DEF_BTREE_ID(kwd, val, name) BKEY_TYPE_##kwd = val,
15 /* Type of a key in btree @id at level @level: */
16 static inline enum bkey_type bkey_type(unsigned level, enum btree_id id)
18 return level ? BKEY_TYPE_BTREE : (enum bkey_type) id;
21 static inline bool btree_type_has_ptrs(enum bkey_type type)
25 case BKEY_TYPE_EXTENTS:
40 * The keys were mergeable, but would have overflowed size - so instead
41 * l was changed to the maximum size, and both keys were modified:
47 typedef bool (*key_filter_fn)(struct bch_fs *, struct btree *,
49 typedef enum merge_result (*key_merge_fn)(struct bch_fs *,
51 struct bkey_i *, struct bkey_i *);
54 /* Returns reason for being invalid if invalid, else NULL: */
55 const char * (*key_invalid)(const struct bch_fs *,
57 void (*key_debugcheck)(struct bch_fs *, struct btree *,
59 void (*val_to_text)(struct bch_fs *, char *,
60 size_t, struct bkey_s_c);
61 void (*swab)(const struct bkey_format *, struct bkey_packed *);
62 key_filter_fn key_normalize;
63 key_merge_fn key_merge;
67 const char *bch2_bkey_val_invalid(struct bch_fs *, enum bkey_type,
69 const char *__bch2_bkey_invalid(struct bch_fs *, enum bkey_type, struct bkey_s_c);
70 const char *bch2_bkey_invalid(struct bch_fs *, enum bkey_type, struct bkey_s_c);
71 const char *bch2_bkey_in_btree_node(struct btree *, struct bkey_s_c);
73 void bch2_bkey_debugcheck(struct bch_fs *, struct btree *, struct bkey_s_c);
75 int bch2_bkey_to_text(char *, size_t, const struct bkey *);
76 int bch2_val_to_text(struct bch_fs *, enum bkey_type,
77 char *, size_t, struct bkey_s_c);
78 int bch2_bkey_val_to_text(struct bch_fs *, enum bkey_type,
79 char *, size_t, struct bkey_s_c);
81 void bch2_bkey_swab(enum bkey_type, const struct bkey_format *,
82 struct bkey_packed *);
84 extern const struct bkey_ops *bch2_bkey_ops[];
86 #endif /* _BCACHEFS_BKEY_METHODS_H */