2019-08-16 21:59:56 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _BCACHEFS_REFLINK_H
|
|
|
|
#define _BCACHEFS_REFLINK_H
|
|
|
|
|
2024-05-09 06:40:42 +08:00
|
|
|
enum bch_validate_flags;
|
2023-07-07 09:16:10 +08:00
|
|
|
|
2023-10-25 08:44:36 +08:00
|
|
|
int bch2_reflink_p_invalid(struct bch_fs *, struct bkey_s_c,
|
2024-05-09 06:40:42 +08:00
|
|
|
enum bch_validate_flags, struct printbuf *);
|
2019-08-16 21:59:56 +08:00
|
|
|
void bch2_reflink_p_to_text(struct printbuf *, struct bch_fs *,
|
|
|
|
struct bkey_s_c);
|
2021-04-29 11:49:30 +08:00
|
|
|
bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
|
2023-12-28 13:15:58 +08:00
|
|
|
int bch2_trigger_reflink_p(struct btree_trans *, enum btree_id, unsigned,
|
2024-04-08 06:05:34 +08:00
|
|
|
struct bkey_s_c, struct bkey_s,
|
|
|
|
enum btree_iter_update_trigger_flags);
|
2019-08-16 21:59:56 +08:00
|
|
|
|
2022-10-23 03:59:53 +08:00
|
|
|
#define bch2_bkey_ops_reflink_p ((struct bkey_ops) { \
|
2019-08-16 21:59:56 +08:00
|
|
|
.key_invalid = bch2_reflink_p_invalid, \
|
|
|
|
.val_to_text = bch2_reflink_p_to_text, \
|
2022-03-13 13:26:52 +08:00
|
|
|
.key_merge = bch2_reflink_p_merge, \
|
2024-01-01 10:01:06 +08:00
|
|
|
.trigger = bch2_trigger_reflink_p, \
|
2023-04-30 01:24:18 +08:00
|
|
|
.min_val_size = 16, \
|
2022-10-23 03:59:53 +08:00
|
|
|
})
|
2019-08-16 21:59:56 +08:00
|
|
|
|
2023-10-25 08:44:36 +08:00
|
|
|
int bch2_reflink_v_invalid(struct bch_fs *, struct bkey_s_c,
|
2024-05-09 06:40:42 +08:00
|
|
|
enum bch_validate_flags, struct printbuf *);
|
2019-08-16 21:59:56 +08:00
|
|
|
void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *,
|
|
|
|
struct bkey_s_c);
|
2024-01-08 06:14:46 +08:00
|
|
|
int bch2_trigger_reflink_v(struct btree_trans *, enum btree_id, unsigned,
|
2024-04-08 06:05:34 +08:00
|
|
|
struct bkey_s_c, struct bkey_s,
|
|
|
|
enum btree_iter_update_trigger_flags);
|
2019-08-16 21:59:56 +08:00
|
|
|
|
2022-10-23 03:59:53 +08:00
|
|
|
#define bch2_bkey_ops_reflink_v ((struct bkey_ops) { \
|
2019-08-16 21:59:56 +08:00
|
|
|
.key_invalid = bch2_reflink_v_invalid, \
|
|
|
|
.val_to_text = bch2_reflink_v_to_text, \
|
2020-02-07 09:15:15 +08:00
|
|
|
.swab = bch2_ptr_swab, \
|
2024-01-08 06:14:46 +08:00
|
|
|
.trigger = bch2_trigger_reflink_v, \
|
2023-04-30 01:24:18 +08:00
|
|
|
.min_val_size = 8, \
|
2022-10-23 03:59:53 +08:00
|
|
|
})
|
2019-08-16 21:59:56 +08:00
|
|
|
|
2023-10-25 08:44:36 +08:00
|
|
|
int bch2_indirect_inline_data_invalid(struct bch_fs *, struct bkey_s_c,
|
2024-05-09 06:40:42 +08:00
|
|
|
enum bch_validate_flags, struct printbuf *);
|
2020-10-25 07:51:34 +08:00
|
|
|
void bch2_indirect_inline_data_to_text(struct printbuf *,
|
|
|
|
struct bch_fs *, struct bkey_s_c);
|
2024-01-08 06:14:46 +08:00
|
|
|
int bch2_trigger_indirect_inline_data(struct btree_trans *,
|
2022-04-01 09:44:55 +08:00
|
|
|
enum btree_id, unsigned,
|
2023-12-28 12:19:09 +08:00
|
|
|
struct bkey_s_c, struct bkey_s,
|
bcachefs: Fix type of flags parameter for some ->trigger() implementations
When building with clang's -Wincompatible-function-pointer-types-strict
(a warning designed to catch potential kCFI failures at build time),
there are several warnings along the lines of:
fs/bcachefs/bkey_methods.c:118:2: error: incompatible function pointer types initializing 'int (*)(struct btree_trans *, enum btree_id, unsigned int, struct bkey_s_c, struct bkey_s, enum btree_iter_update_trigger_flags)' with an expression of type 'int (struct btree_trans *, enum btree_id, unsigned int, struct bkey_s_c, struct bkey_s, unsigned int)' [-Werror,-Wincompatible-function-pointer-types-strict]
118 | BCH_BKEY_TYPES()
| ^~~~~~~~~~~~~~~~
fs/bcachefs/bcachefs_format.h:394:2: note: expanded from macro 'BCH_BKEY_TYPES'
394 | x(inode, 8) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
fs/bcachefs/bkey_methods.c:117:41: note: expanded from macro 'x'
117 | #define x(name, nr) [KEY_TYPE_##name] = bch2_bkey_ops_##name,
| ^~~~~~~~~~~~~~~~~~~~
<scratch space>:277:1: note: expanded from here
277 | bch2_bkey_ops_inode
| ^~~~~~~~~~~~~~~~~~~
fs/bcachefs/inode.h:26:13: note: expanded from macro 'bch2_bkey_ops_inode'
26 | .trigger = bch2_trigger_inode, \
| ^~~~~~~~~~~~~~~~~~
There are several functions that did not have their flags parameter
converted to 'enum btree_iter_update_trigger_flags' in the recent
unification, which will cause kCFI failures at runtime because the
types, while ABI compatible (hence no warning from the non-strict
version of this warning), do not match exactly.
Fix up these functions (as well as a few other obvious functions that
should have it, even if there are no warnings currently) to resolve the
warnings and potential kCFI runtime failures.
Fixes: 31e4ef3280c8 ("bcachefs: iter/update/trigger/str_hash flag cleanup")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-04-24 02:58:09 +08:00
|
|
|
enum btree_iter_update_trigger_flags);
|
2020-10-25 07:51:34 +08:00
|
|
|
|
2022-10-23 03:59:53 +08:00
|
|
|
#define bch2_bkey_ops_indirect_inline_data ((struct bkey_ops) { \
|
2020-10-25 07:51:34 +08:00
|
|
|
.key_invalid = bch2_indirect_inline_data_invalid, \
|
|
|
|
.val_to_text = bch2_indirect_inline_data_to_text, \
|
2024-01-08 06:14:46 +08:00
|
|
|
.trigger = bch2_trigger_indirect_inline_data, \
|
2023-04-30 01:24:18 +08:00
|
|
|
.min_val_size = 8, \
|
2022-10-23 03:59:53 +08:00
|
|
|
})
|
2020-10-25 07:51:34 +08:00
|
|
|
|
2021-05-23 14:31:33 +08: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 12:19:09 +08:00
|
|
|
static inline __le64 *bkey_refcount(struct bkey_s k)
|
2021-05-23 14:31:33 +08:00
|
|
|
{
|
2023-12-28 12:19:09 +08:00
|
|
|
switch (k.k->type) {
|
2021-05-23 14:31:33 +08:00
|
|
|
case KEY_TYPE_reflink_v:
|
2023-12-28 12:19:09 +08:00
|
|
|
return &bkey_s_to_reflink_v(k).v->refcount;
|
2021-05-23 14:31:33 +08:00
|
|
|
case KEY_TYPE_indirect_inline_data:
|
2023-12-28 12:19:09 +08:00
|
|
|
return &bkey_s_to_indirect_inline_data(k).v->refcount;
|
2021-05-23 14:31:33 +08:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-16 12:28:17 +08:00
|
|
|
s64 bch2_remap_range(struct bch_fs *, subvol_inum, u64,
|
2021-11-06 03:17:13 +08:00
|
|
|
subvol_inum, u64, u64, u64, s64 *);
|
2019-08-16 21:59:56 +08:00
|
|
|
|
|
|
|
#endif /* _BCACHEFS_REFLINK_H */
|