]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/reflink.h
Update bcachefs sources to e48731a188 bcachefs: Fix BTREE_TRIGGER_WANTS_OLD_AND_NEW
[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 bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
9
10 #define bch2_bkey_ops_reflink_p (struct bkey_ops) {             \
11         .key_invalid    = bch2_reflink_p_invalid,               \
12         .val_to_text    = bch2_reflink_p_to_text,               \
13         .key_merge      = bch2_reflink_p_merge,                 \
14         .trans_trigger  = bch2_trans_mark_reflink_p,            \
15         .atomic_trigger = bch2_mark_reflink_p,                  \
16 }
17
18 const char *bch2_reflink_v_invalid(const struct bch_fs *, struct bkey_s_c);
19 void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *,
20                             struct bkey_s_c);
21
22 #define bch2_bkey_ops_reflink_v (struct bkey_ops) {             \
23         .key_invalid    = bch2_reflink_v_invalid,               \
24         .val_to_text    = bch2_reflink_v_to_text,               \
25         .swab           = bch2_ptr_swab,                        \
26         .trans_trigger  = bch2_trans_mark_extent,               \
27         .atomic_trigger = bch2_mark_extent,                     \
28 }
29
30 const char *bch2_indirect_inline_data_invalid(const struct bch_fs *,
31                                               struct bkey_s_c);
32 void bch2_indirect_inline_data_to_text(struct printbuf *,
33                                 struct bch_fs *, struct bkey_s_c);
34
35 #define bch2_bkey_ops_indirect_inline_data (struct bkey_ops) {  \
36         .key_invalid    = bch2_indirect_inline_data_invalid,    \
37         .val_to_text    = bch2_indirect_inline_data_to_text,    \
38 }
39
40 static inline const __le64 *bkey_refcount_c(struct bkey_s_c k)
41 {
42         switch (k.k->type) {
43         case KEY_TYPE_reflink_v:
44                 return &bkey_s_c_to_reflink_v(k).v->refcount;
45         case KEY_TYPE_indirect_inline_data:
46                 return &bkey_s_c_to_indirect_inline_data(k).v->refcount;
47         default:
48                 return NULL;
49         }
50 }
51
52 static inline __le64 *bkey_refcount(struct bkey_i *k)
53 {
54         switch (k->k.type) {
55         case KEY_TYPE_reflink_v:
56                 return &bkey_i_to_reflink_v(k)->v.refcount;
57         case KEY_TYPE_indirect_inline_data:
58                 return &bkey_i_to_indirect_inline_data(k)->v.refcount;
59         default:
60                 return NULL;
61         }
62 }
63
64 s64 bch2_remap_range(struct bch_fs *, subvol_inum, u64,
65                      subvol_inum, u64, u64, u64, s64 *);
66
67 #endif /* _BCACHEFS_REFLINK_H */