2019-08-16 13:59:56 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _BCACHEFS_REFLINK_H
|
|
|
|
#define _BCACHEFS_REFLINK_H
|
|
|
|
|
2023-07-07 01:16:10 +00:00
|
|
|
enum bkey_invalid_flags;
|
|
|
|
|
2023-10-25 00:44:36 +00:00
|
|
|
int bch2_reflink_p_invalid(struct bch_fs *, struct bkey_s_c,
|
2023-07-07 01:16:10 +00:00
|
|
|
enum bkey_invalid_flags, struct printbuf *);
|
2019-08-16 13:59:56 +00:00
|
|
|
void bch2_reflink_p_to_text(struct printbuf *, struct bch_fs *,
|
|
|
|
struct bkey_s_c);
|
2021-04-29 03:49:30 +00:00
|
|
|
bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
|
2023-12-28 05:15:58 +00:00
|
|
|
int bch2_trigger_reflink_p(struct btree_trans *, enum btree_id, unsigned,
|
|
|
|
struct bkey_s_c, struct bkey_s, unsigned);
|
2019-08-16 13:59:56 +00:00
|
|
|
|
2022-10-22 19:59:53 +00:00
|
|
|
#define bch2_bkey_ops_reflink_p ((struct bkey_ops) { \
|
2019-08-16 13:59:56 +00:00
|
|
|
.key_invalid = bch2_reflink_p_invalid, \
|
|
|
|
.val_to_text = bch2_reflink_p_to_text, \
|
2022-03-13 05:26:52 +00:00
|
|
|
.key_merge = bch2_reflink_p_merge, \
|
2024-01-01 02:01:06 +00:00
|
|
|
.trigger = bch2_trigger_reflink_p, \
|
2023-04-29 17:24:18 +00:00
|
|
|
.min_val_size = 16, \
|
2022-10-22 19:59:53 +00:00
|
|
|
})
|
2019-08-16 13:59:56 +00:00
|
|
|
|
2023-10-25 00:44:36 +00:00
|
|
|
int bch2_reflink_v_invalid(struct bch_fs *, struct bkey_s_c,
|
2023-07-07 01:16:10 +00:00
|
|
|
enum bkey_invalid_flags, struct printbuf *);
|
2019-08-16 13:59:56 +00:00
|
|
|
void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *,
|
|
|
|
struct bkey_s_c);
|
2024-01-07 22:14:46 +00:00
|
|
|
int bch2_trigger_reflink_v(struct btree_trans *, enum btree_id, unsigned,
|
2023-12-28 04:19:09 +00:00
|
|
|
struct bkey_s_c, struct bkey_s, unsigned);
|
2019-08-16 13:59:56 +00:00
|
|
|
|
2022-10-22 19:59:53 +00:00
|
|
|
#define bch2_bkey_ops_reflink_v ((struct bkey_ops) { \
|
2019-08-16 13:59:56 +00:00
|
|
|
.key_invalid = bch2_reflink_v_invalid, \
|
|
|
|
.val_to_text = bch2_reflink_v_to_text, \
|
2020-02-07 01:15:15 +00:00
|
|
|
.swab = bch2_ptr_swab, \
|
2024-01-07 22:14:46 +00:00
|
|
|
.trigger = bch2_trigger_reflink_v, \
|
2023-04-29 17:24:18 +00:00
|
|
|
.min_val_size = 8, \
|
2022-10-22 19:59:53 +00:00
|
|
|
})
|
2019-08-16 13:59:56 +00:00
|
|
|
|
2023-10-25 00:44:36 +00:00
|
|
|
int bch2_indirect_inline_data_invalid(struct bch_fs *, struct bkey_s_c,
|
2023-07-07 01:16:10 +00:00
|
|
|
enum bkey_invalid_flags, struct printbuf *);
|
2020-10-24 23:51:34 +00:00
|
|
|
void bch2_indirect_inline_data_to_text(struct printbuf *,
|
|
|
|
struct bch_fs *, struct bkey_s_c);
|
2024-01-07 22:14:46 +00:00
|
|
|
int bch2_trigger_indirect_inline_data(struct btree_trans *,
|
2022-04-01 01:44:55 +00:00
|
|
|
enum btree_id, unsigned,
|
2023-12-28 04:19:09 +00:00
|
|
|
struct bkey_s_c, struct bkey_s,
|
2022-03-31 04:03:37 +00:00
|
|
|
unsigned);
|
2020-10-24 23:51:34 +00:00
|
|
|
|
2022-10-22 19:59:53 +00:00
|
|
|
#define bch2_bkey_ops_indirect_inline_data ((struct bkey_ops) { \
|
2020-10-24 23:51:34 +00:00
|
|
|
.key_invalid = bch2_indirect_inline_data_invalid, \
|
|
|
|
.val_to_text = bch2_indirect_inline_data_to_text, \
|
2024-01-07 22:14:46 +00:00
|
|
|
.trigger = bch2_trigger_indirect_inline_data, \
|
2023-04-29 17:24:18 +00:00
|
|
|
.min_val_size = 8, \
|
2022-10-22 19:59:53 +00:00
|
|
|
})
|
2020-10-24 23:51:34 +00:00
|
|
|
|
2021-05-23 06:31:33 +00: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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-28 04:19:09 +00:00
|
|
|
static inline __le64 *bkey_refcount(struct bkey_s k)
|
2021-05-23 06:31:33 +00:00
|
|
|
{
|
2023-12-28 04:19:09 +00:00
|
|
|
switch (k.k->type) {
|
2021-05-23 06:31:33 +00:00
|
|
|
case KEY_TYPE_reflink_v:
|
2023-12-28 04:19:09 +00:00
|
|
|
return &bkey_s_to_reflink_v(k).v->refcount;
|
2021-05-23 06:31:33 +00:00
|
|
|
case KEY_TYPE_indirect_inline_data:
|
2023-12-28 04:19:09 +00:00
|
|
|
return &bkey_s_to_indirect_inline_data(k).v->refcount;
|
2021-05-23 06:31:33 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 04:28:17 +00:00
|
|
|
s64 bch2_remap_range(struct bch_fs *, subvol_inum, u64,
|
2021-11-05 19:17:13 +00:00
|
|
|
subvol_inum, u64, u64, u64, s64 *);
|
2019-08-16 13:59:56 +00:00
|
|
|
|
|
|
|
#endif /* _BCACHEFS_REFLINK_H */
|