]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/bkey_methods.h
Update bcachefs sources to 62de7539dc bcachefs: Make bkey types globally unique
[bcachefs-tools-debian] / libbcachefs / bkey_methods.h
1 #ifndef _BCACHEFS_BKEY_METHODS_H
2 #define _BCACHEFS_BKEY_METHODS_H
3
4 #include "bkey.h"
5
6 struct bch_fs;
7 struct btree;
8 struct bkey;
9 enum btree_node_type;
10
11 extern const char * const bch_bkey_types[];
12
13 enum merge_result {
14         BCH_MERGE_NOMERGE,
15
16         /*
17          * The keys were mergeable, but would have overflowed size - so instead
18          * l was changed to the maximum size, and both keys were modified:
19          */
20         BCH_MERGE_PARTIAL,
21         BCH_MERGE_MERGE,
22 };
23
24 struct bkey_ops {
25         /* Returns reason for being invalid if invalid, else NULL: */
26         const char *    (*key_invalid)(const struct bch_fs *,
27                                        struct bkey_s_c);
28         void            (*key_debugcheck)(struct bch_fs *, struct btree *,
29                                           struct bkey_s_c);
30         void            (*val_to_text)(struct printbuf *, struct bch_fs *,
31                                        struct bkey_s_c);
32         void            (*swab)(const struct bkey_format *, struct bkey_packed *);
33         bool            (*key_normalize)(struct bch_fs *, struct bkey_s);
34         enum merge_result (*key_merge)(struct bch_fs *,
35                                        struct bkey_i *, struct bkey_i *);
36 };
37
38 const char *bch2_bkey_val_invalid(struct bch_fs *, struct bkey_s_c);
39 const char *__bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c,
40                                 enum btree_node_type);
41 const char *bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c,
42                               enum btree_node_type);
43 const char *bch2_bkey_in_btree_node(struct btree *, struct bkey_s_c);
44
45 void bch2_bkey_debugcheck(struct bch_fs *, struct btree *, struct bkey_s_c);
46
47 void bch2_bpos_to_text(struct printbuf *, struct bpos);
48 void bch2_bkey_to_text(struct printbuf *, const struct bkey *);
49 void bch2_val_to_text(struct printbuf *, struct bch_fs *,
50                       struct bkey_s_c);
51 void bch2_bkey_val_to_text(struct printbuf *, struct bch_fs *,
52                            struct bkey_s_c);
53
54 void bch2_bkey_swab(const struct bkey_format *, struct bkey_packed *);
55
56 bool bch2_bkey_normalize(struct bch_fs *, struct bkey_s);
57
58 enum merge_result bch2_bkey_merge(struct bch_fs *,
59                                   struct bkey_i *, struct bkey_i *);
60
61 void bch2_bkey_renumber(enum btree_node_type, struct bkey_packed *, int);
62
63 #endif /* _BCACHEFS_BKEY_METHODS_H */