Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _BCACHEFS_REFLINK_H
3#define _BCACHEFS_REFLINK_H
4
5int bch2_reflink_p_validate(struct bch_fs *, struct bkey_s_c,
6 struct bkey_validate_context);
7void bch2_reflink_p_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
8bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
9int bch2_trigger_reflink_p(struct btree_trans *, enum btree_id, unsigned,
10 struct bkey_s_c, struct bkey_s,
11 enum btree_iter_update_trigger_flags);
12
13#define bch2_bkey_ops_reflink_p ((struct bkey_ops) { \
14 .key_validate = bch2_reflink_p_validate, \
15 .val_to_text = bch2_reflink_p_to_text, \
16 .key_merge = bch2_reflink_p_merge, \
17 .trigger = bch2_trigger_reflink_p, \
18 .min_val_size = 16, \
19})
20
21int bch2_reflink_v_validate(struct bch_fs *, struct bkey_s_c,
22 struct bkey_validate_context);
23void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
24int bch2_trigger_reflink_v(struct btree_trans *, enum btree_id, unsigned,
25 struct bkey_s_c, struct bkey_s,
26 enum btree_iter_update_trigger_flags);
27
28#define bch2_bkey_ops_reflink_v ((struct bkey_ops) { \
29 .key_validate = bch2_reflink_v_validate, \
30 .val_to_text = bch2_reflink_v_to_text, \
31 .swab = bch2_ptr_swab, \
32 .trigger = bch2_trigger_reflink_v, \
33 .min_val_size = 8, \
34})
35
36int bch2_indirect_inline_data_validate(struct bch_fs *, struct bkey_s_c,
37 struct bkey_validate_context);
38void bch2_indirect_inline_data_to_text(struct printbuf *,
39 struct bch_fs *, struct bkey_s_c);
40int bch2_trigger_indirect_inline_data(struct btree_trans *,
41 enum btree_id, unsigned,
42 struct bkey_s_c, struct bkey_s,
43 enum btree_iter_update_trigger_flags);
44
45#define bch2_bkey_ops_indirect_inline_data ((struct bkey_ops) { \
46 .key_validate = bch2_indirect_inline_data_validate, \
47 .val_to_text = bch2_indirect_inline_data_to_text, \
48 .trigger = bch2_trigger_indirect_inline_data, \
49 .min_val_size = 8, \
50})
51
52static inline const __le64 *bkey_refcount_c(struct bkey_s_c k)
53{
54 switch (k.k->type) {
55 case KEY_TYPE_reflink_v:
56 return &bkey_s_c_to_reflink_v(k).v->refcount;
57 case KEY_TYPE_indirect_inline_data:
58 return &bkey_s_c_to_indirect_inline_data(k).v->refcount;
59 default:
60 return NULL;
61 }
62}
63
64static inline __le64 *bkey_refcount(struct bkey_s k)
65{
66 switch (k.k->type) {
67 case KEY_TYPE_reflink_v:
68 return &bkey_s_to_reflink_v(k).v->refcount;
69 case KEY_TYPE_indirect_inline_data:
70 return &bkey_s_to_indirect_inline_data(k).v->refcount;
71 default:
72 return NULL;
73 }
74}
75
76struct bkey_s_c bch2_lookup_indirect_extent(struct btree_trans *, struct btree_iter *,
77 s64 *, struct bkey_s_c_reflink_p,
78 bool, unsigned);
79
80s64 bch2_remap_range(struct bch_fs *, subvol_inum, u64,
81 subvol_inum, u64, u64, u64, s64 *,
82 bool);
83
84int bch2_gc_reflink_done(struct bch_fs *);
85int bch2_gc_reflink_start(struct bch_fs *);
86
87#endif /* _BCACHEFS_REFLINK_H */