1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_REFLINK_H
3 #define _BCACHEFS_REFLINK_H
5 enum bkey_invalid_flags;
7 int bch2_reflink_p_invalid(struct bch_fs *, struct bkey_s_c,
8 enum bkey_invalid_flags, struct printbuf *);
9 void bch2_reflink_p_to_text(struct printbuf *, struct bch_fs *,
11 bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
12 int bch2_trigger_reflink_p(struct btree_trans *, enum btree_id, unsigned,
13 struct bkey_s_c, struct bkey_s, unsigned);
15 #define bch2_bkey_ops_reflink_p ((struct bkey_ops) { \
16 .key_invalid = bch2_reflink_p_invalid, \
17 .val_to_text = bch2_reflink_p_to_text, \
18 .key_merge = bch2_reflink_p_merge, \
19 .trigger = bch2_trigger_reflink_p, \
23 int bch2_reflink_v_invalid(struct bch_fs *, struct bkey_s_c,
24 enum bkey_invalid_flags, struct printbuf *);
25 void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *,
27 int bch2_trigger_reflink_v(struct btree_trans *, enum btree_id, unsigned,
28 struct bkey_s_c, struct bkey_s, unsigned);
30 #define bch2_bkey_ops_reflink_v ((struct bkey_ops) { \
31 .key_invalid = bch2_reflink_v_invalid, \
32 .val_to_text = bch2_reflink_v_to_text, \
33 .swab = bch2_ptr_swab, \
34 .trigger = bch2_trigger_reflink_v, \
38 int bch2_indirect_inline_data_invalid(struct bch_fs *, struct bkey_s_c,
39 enum bkey_invalid_flags, struct printbuf *);
40 void bch2_indirect_inline_data_to_text(struct printbuf *,
41 struct bch_fs *, struct bkey_s_c);
42 int bch2_trigger_indirect_inline_data(struct btree_trans *,
43 enum btree_id, unsigned,
44 struct bkey_s_c, struct bkey_s,
47 #define bch2_bkey_ops_indirect_inline_data ((struct bkey_ops) { \
48 .key_invalid = bch2_indirect_inline_data_invalid, \
49 .val_to_text = bch2_indirect_inline_data_to_text, \
50 .trigger = bch2_trigger_indirect_inline_data, \
54 static inline const __le64 *bkey_refcount_c(struct bkey_s_c k)
57 case KEY_TYPE_reflink_v:
58 return &bkey_s_c_to_reflink_v(k).v->refcount;
59 case KEY_TYPE_indirect_inline_data:
60 return &bkey_s_c_to_indirect_inline_data(k).v->refcount;
66 static inline __le64 *bkey_refcount(struct bkey_s k)
69 case KEY_TYPE_reflink_v:
70 return &bkey_s_to_reflink_v(k).v->refcount;
71 case KEY_TYPE_indirect_inline_data:
72 return &bkey_s_to_indirect_inline_data(k).v->refcount;
78 s64 bch2_remap_range(struct bch_fs *, subvol_inum, u64,
79 subvol_inum, u64, u64, u64, s64 *);
81 #endif /* _BCACHEFS_REFLINK_H */