2019-08-21 20:17:42 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _BCACHEFS_REFLINK_H
|
|
|
|
#define _BCACHEFS_REFLINK_H
|
|
|
|
|
2022-04-06 21:13:15 +03:00
|
|
|
int bch2_reflink_p_invalid(const struct bch_fs *, struct bkey_s_c,
|
2023-02-10 02:34:08 +03:00
|
|
|
unsigned, struct printbuf *);
|
2019-08-21 20:17:42 +03:00
|
|
|
void bch2_reflink_p_to_text(struct printbuf *, struct bch_fs *,
|
|
|
|
struct bkey_s_c);
|
2021-06-11 03:21:18 +03:00
|
|
|
bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
|
2019-08-21 20:17:42 +03:00
|
|
|
|
2022-10-24 00:39:22 +03:00
|
|
|
#define bch2_bkey_ops_reflink_p ((struct bkey_ops) { \
|
2019-08-21 20:17:42 +03:00
|
|
|
.key_invalid = bch2_reflink_p_invalid, \
|
|
|
|
.val_to_text = bch2_reflink_p_to_text, \
|
2022-03-14 02:14:01 +03:00
|
|
|
.key_merge = bch2_reflink_p_merge, \
|
|
|
|
.trans_trigger = bch2_trans_mark_reflink_p, \
|
|
|
|
.atomic_trigger = bch2_mark_reflink_p, \
|
2023-04-26 23:34:57 +03:00
|
|
|
.min_val_size = 16, \
|
2022-10-24 00:39:22 +03:00
|
|
|
})
|
2019-08-21 20:17:42 +03:00
|
|
|
|
2022-04-06 21:13:15 +03:00
|
|
|
int bch2_reflink_v_invalid(const struct bch_fs *, struct bkey_s_c,
|
2023-02-10 02:34:08 +03:00
|
|
|
unsigned, struct printbuf *);
|
2019-08-21 20:17:42 +03:00
|
|
|
void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *,
|
|
|
|
struct bkey_s_c);
|
2022-05-03 01:39:16 +03:00
|
|
|
int bch2_trans_mark_reflink_v(struct btree_trans *, enum btree_id, unsigned,
|
|
|
|
struct bkey_s_c, struct bkey_i *, unsigned);
|
2019-08-21 20:17:42 +03:00
|
|
|
|
2022-10-24 00:39:22 +03:00
|
|
|
#define bch2_bkey_ops_reflink_v ((struct bkey_ops) { \
|
2019-08-21 20:17:42 +03:00
|
|
|
.key_invalid = bch2_reflink_v_invalid, \
|
|
|
|
.val_to_text = bch2_reflink_v_to_text, \
|
2020-02-23 00:21:32 +03:00
|
|
|
.swab = bch2_ptr_swab, \
|
2022-03-31 23:57:08 +03:00
|
|
|
.trans_trigger = bch2_trans_mark_reflink_v, \
|
2022-03-14 02:14:01 +03:00
|
|
|
.atomic_trigger = bch2_mark_extent, \
|
2023-04-26 23:34:57 +03:00
|
|
|
.min_val_size = 8, \
|
2022-10-24 00:39:22 +03:00
|
|
|
})
|
2019-08-21 20:17:42 +03:00
|
|
|
|
2022-04-06 21:13:15 +03:00
|
|
|
int bch2_indirect_inline_data_invalid(const struct bch_fs *, struct bkey_s_c,
|
2023-02-10 02:34:08 +03:00
|
|
|
unsigned, struct printbuf *);
|
2020-10-25 04:00:59 +03:00
|
|
|
void bch2_indirect_inline_data_to_text(struct printbuf *,
|
|
|
|
struct bch_fs *, struct bkey_s_c);
|
2022-03-31 23:57:08 +03:00
|
|
|
int bch2_trans_mark_indirect_inline_data(struct btree_trans *,
|
2022-05-03 01:39:16 +03:00
|
|
|
enum btree_id, unsigned,
|
2022-03-31 23:57:08 +03:00
|
|
|
struct bkey_s_c, struct bkey_i *,
|
|
|
|
unsigned);
|
2020-10-25 04:00:59 +03:00
|
|
|
|
2022-10-24 00:39:22 +03:00
|
|
|
#define bch2_bkey_ops_indirect_inline_data ((struct bkey_ops) { \
|
2020-10-25 04:00:59 +03:00
|
|
|
.key_invalid = bch2_indirect_inline_data_invalid, \
|
|
|
|
.val_to_text = bch2_indirect_inline_data_to_text, \
|
2022-03-31 23:57:08 +03:00
|
|
|
.trans_trigger = bch2_trans_mark_indirect_inline_data, \
|
2023-04-26 23:34:57 +03:00
|
|
|
.min_val_size = 8, \
|
2022-10-24 00:39:22 +03:00
|
|
|
})
|
2020-10-25 04:00:59 +03:00
|
|
|
|
2021-05-31 22:05:33 +03:00
|
|
|
static inline const __le64 *bkey_refcount_c(struct bkey_s_c k)
|
|
|
|
{
|
|
|
|
switch (k.k->type) {
|
|
|
|
case KEY_TYPE_reflink_v:
|
|
|
|
return &bkey_s_c_to_reflink_v(k).v->refcount;
|
|
|
|
case KEY_TYPE_indirect_inline_data:
|
|
|
|
return &bkey_s_c_to_indirect_inline_data(k).v->refcount;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline __le64 *bkey_refcount(struct bkey_i *k)
|
|
|
|
{
|
|
|
|
switch (k->k.type) {
|
|
|
|
case KEY_TYPE_reflink_v:
|
|
|
|
return &bkey_i_to_reflink_v(k)->v.refcount;
|
|
|
|
case KEY_TYPE_indirect_inline_data:
|
|
|
|
return &bkey_i_to_indirect_inline_data(k)->v.refcount;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-27 01:19:46 +03:00
|
|
|
s64 bch2_remap_range(struct bch_fs *, subvol_inum, u64,
|
2021-11-06 19:46:36 +03:00
|
|
|
subvol_inum, u64, u64, u64, s64 *);
|
2019-08-21 20:17:42 +03:00
|
|
|
|
|
|
|
#endif /* _BCACHEFS_REFLINK_H */
|