2021-03-16 00:42:25 -04:00
/* SPDX-License-Identifier: GPL-2.0 */
# ifndef _BCACHEFS_SUBVOLUME_H
# define _BCACHEFS_SUBVOLUME_H
2022-03-29 15:48:45 -04:00
# include "darray.h"
2021-10-11 12:03:19 -04:00
# include "subvolume_types.h"
2024-05-08 18:40:42 -04:00
enum bch_validate_flags ;
2023-07-06 21:16:10 -04:00
2023-07-07 02:42:28 -04:00
int bch2_check_subvols ( struct bch_fs * ) ;
2024-01-21 06:00:07 -05:00
int bch2_check_subvol_children ( struct bch_fs * ) ;
2022-07-14 01:10:24 -04:00
2023-10-24 20:44:36 -04:00
int bch2_subvolume_invalid ( struct bch_fs * , struct bkey_s_c ,
2024-05-08 18:40:42 -04:00
enum bch_validate_flags , struct printbuf * ) ;
2021-03-16 00:42:25 -04:00
void bch2_subvolume_to_text ( struct printbuf * , struct bch_fs * , struct bkey_s_c ) ;
2024-01-21 06:00:07 -05:00
int bch2_subvolume_trigger ( struct btree_trans * , enum btree_id , unsigned ,
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-23 11:58:09 -07:00
struct bkey_s_c , struct bkey_s ,
enum btree_iter_update_trigger_flags ) ;
2021-03-16 00:42:25 -04:00
2022-10-22 15:59:53 -04:00
# define bch2_bkey_ops_subvolume ((struct bkey_ops) { \
2021-03-16 00:42:25 -04:00
. key_invalid = bch2_subvolume_invalid , \
. val_to_text = bch2_subvolume_to_text , \
2024-01-21 06:00:07 -05:00
. trigger = bch2_subvolume_trigger , \
2023-04-29 13:24:18 -04:00
. min_val_size = 16 , \
2022-10-22 15:59:53 -04:00
} )
2021-03-16 00:42:25 -04:00
2024-02-09 21:01:04 -05:00
int bch2_subvol_has_children ( struct btree_trans * , u32 ) ;
2021-09-30 19:46:23 -04:00
int bch2_subvolume_get ( struct btree_trans * , unsigned ,
bool , int , struct bch_subvolume * ) ;
2021-03-16 00:42:25 -04:00
int bch2_subvolume_get_snapshot ( struct btree_trans * , u32 , u32 * ) ;
2023-12-29 21:16:32 -05:00
int bch2_subvol_is_ro_trans ( struct btree_trans * , u32 ) ;
int bch2_subvol_is_ro ( struct bch_fs * , u32 ) ;
2022-07-14 01:10:24 -04:00
int bch2_delete_dead_snapshots ( struct bch_fs * ) ;
void bch2_delete_dead_snapshots_async ( struct bch_fs * ) ;
2021-10-11 12:03:19 -04:00
int bch2_subvolume_unlink ( struct btree_trans * , u32 ) ;
2024-02-08 18:39:42 -05:00
int bch2_subvolume_create ( struct btree_trans * , u64 , u32 , u32 , u32 * , u32 * , bool ) ;
2021-03-16 00:42:25 -04:00
2024-03-23 20:07:46 -04:00
int bch2_initialize_subvolumes ( struct bch_fs * ) ;
int bch2_fs_upgrade_for_subvolumes ( struct bch_fs * ) ;
2021-03-16 00:42:25 -04:00
int bch2_fs_subvolumes_init ( struct bch_fs * ) ;
# endif /* _BCACHEFS_SUBVOLUME_H */