]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/reflink.h
Update bcachefs sources to 3913e0cac3 bcachefs: Journal space calculation fix
[bcachefs-tools-debian] / libbcachefs / reflink.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_REFLINK_H
3 #define _BCACHEFS_REFLINK_H
4
5 const char *bch2_reflink_p_invalid(const struct bch_fs *, struct bkey_s_c);
6 void bch2_reflink_p_to_text(struct printbuf *, struct bch_fs *,
7                             struct bkey_s_c);
8 enum merge_result bch2_reflink_p_merge(struct bch_fs *,
9                                        struct bkey_s, struct bkey_s);
10
11 #define bch2_bkey_ops_reflink_p (struct bkey_ops) {             \
12         .key_invalid    = bch2_reflink_p_invalid,               \
13         .val_to_text    = bch2_reflink_p_to_text,               \
14         .key_merge      = bch2_reflink_p_merge,         \
15 }
16
17 const char *bch2_reflink_v_invalid(const struct bch_fs *, struct bkey_s_c);
18 void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *,
19                             struct bkey_s_c);
20
21 #define bch2_bkey_ops_reflink_v (struct bkey_ops) {             \
22         .key_invalid    = bch2_reflink_v_invalid,               \
23         .val_to_text    = bch2_reflink_v_to_text,               \
24         .swab           = bch2_ptr_swab,                        \
25 }
26
27 const char *bch2_indirect_inline_data_invalid(const struct bch_fs *,
28                                               struct bkey_s_c);
29 void bch2_indirect_inline_data_to_text(struct printbuf *,
30                                 struct bch_fs *, struct bkey_s_c);
31
32 #define bch2_bkey_ops_indirect_inline_data (struct bkey_ops) {  \
33         .key_invalid    = bch2_indirect_inline_data_invalid,    \
34         .val_to_text    = bch2_indirect_inline_data_to_text,    \
35 }
36
37 static inline const __le64 *bkey_refcount_c(struct bkey_s_c k)
38 {
39         switch (k.k->type) {
40         case KEY_TYPE_reflink_v:
41                 return &bkey_s_c_to_reflink_v(k).v->refcount;
42         case KEY_TYPE_indirect_inline_data:
43                 return &bkey_s_c_to_indirect_inline_data(k).v->refcount;
44         default:
45                 return NULL;
46         }
47 }
48
49 static inline __le64 *bkey_refcount(struct bkey_i *k)
50 {
51         switch (k->k.type) {
52         case KEY_TYPE_reflink_v:
53                 return &bkey_i_to_reflink_v(k)->v.refcount;
54         case KEY_TYPE_indirect_inline_data:
55                 return &bkey_i_to_indirect_inline_data(k)->v.refcount;
56         default:
57                 return NULL;
58         }
59 }
60
61 s64 bch2_remap_range(struct bch_fs *, struct bpos, struct bpos,
62                      u64, u64 *, u64, s64 *);
63
64 #endif /* _BCACHEFS_REFLINK_H */