bcachefs: Fix type of flags parameter for some ->trigger() implementations
authorNathan Chancellor <nathan@kernel.org>
Tue, 23 Apr 2024 18:58:09 +0000 (11:58 -0700)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 8 May 2024 21:29:21 +0000 (17:29 -0400)
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>
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_background.h
fs/bcachefs/inode.c
fs/bcachefs/inode.h
fs/bcachefs/reflink.c
fs/bcachefs/reflink.h
fs/bcachefs/snapshot.c
fs/bcachefs/snapshot.h
fs/bcachefs/subvolume.c
fs/bcachefs/subvolume.h

index 6fa51ee16cc3368e48d738130973949f746bc8f7..63bcba995ca2d0b9d400b5bd82d59045d49011bb 100644 (file)
@@ -724,7 +724,7 @@ static noinline int bch2_bucket_gen_update(struct btree_trans *trans,
 int bch2_trigger_alloc(struct btree_trans *trans,
                       enum btree_id btree, unsigned level,
                       struct bkey_s_c old, struct bkey_s new,
-                      unsigned flags)
+                      enum btree_iter_update_trigger_flags flags)
 {
        struct bch_fs *c = trans->c;
        int ret = 0;
index e94432ced6a66584653d99da251cdc74e4c3ec35..e0e0d72db03bcbb2046f453ba65e8d0d9934d4cd 100644 (file)
@@ -245,7 +245,8 @@ static inline bool bkey_is_alloc(const struct bkey *k)
 int bch2_alloc_read(struct bch_fs *);
 
 int bch2_trigger_alloc(struct btree_trans *, enum btree_id, unsigned,
-                      struct bkey_s_c, struct bkey_s, unsigned);
+                      struct bkey_s_c, struct bkey_s,
+                      enum btree_iter_update_trigger_flags);
 int bch2_check_alloc_info(struct bch_fs *);
 int bch2_check_alloc_to_lru_refs(struct bch_fs *);
 void bch2_do_discards(struct bch_fs *);
index fc8b30441bbc003ac507c3b1bed85b99aeb02abf..91572e05d5f06bff2ec364aa040ae55a06f73bb9 100644 (file)
@@ -594,7 +594,7 @@ int bch2_trigger_inode(struct btree_trans *trans,
                       enum btree_id btree_id, unsigned level,
                       struct bkey_s_c old,
                       struct bkey_s new,
-                      unsigned flags)
+                      enum btree_iter_update_trigger_flags flags)
 {
        s64 nr = (s64) bkey_is_inode(new.k) - (s64) bkey_is_inode(old.k);
 
index 08e8505dfa33c32a15f3bd6972fe416080721d96..46477a40846c430f590886089de06dcb2ad0256c 100644 (file)
@@ -18,7 +18,8 @@ int bch2_inode_v3_invalid(struct bch_fs *, struct bkey_s_c,
 void bch2_inode_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 int bch2_trigger_inode(struct btree_trans *, enum btree_id, unsigned,
-                         struct bkey_s_c, struct bkey_s, unsigned);
+                      struct bkey_s_c, struct bkey_s,
+                      enum btree_iter_update_trigger_flags);
 
 #define bch2_bkey_ops_inode ((struct bkey_ops) {       \
        .key_invalid    = bch2_inode_invalid,           \
index a8a761d59a5da9bb4431f5dea72971ab995fd9f4..fb31a68148ff9895aae4dff24b515dce5da79283 100644 (file)
@@ -285,7 +285,9 @@ bool bch2_reflink_v_merge(struct bch_fs *c, struct bkey_s _l, struct bkey_s_c _r
 }
 #endif
 
-static inline void check_indirect_extent_deleting(struct bkey_s new, unsigned *flags)
+static inline void
+check_indirect_extent_deleting(struct bkey_s new,
+                              enum btree_iter_update_trigger_flags *flags)
 {
        if ((*flags & BTREE_TRIGGER_insert) && !*bkey_refcount(new)) {
                new.k->type = KEY_TYPE_deleted;
@@ -330,7 +332,7 @@ void bch2_indirect_inline_data_to_text(struct printbuf *out,
 int bch2_trigger_indirect_inline_data(struct btree_trans *trans,
                              enum btree_id btree_id, unsigned level,
                              struct bkey_s_c old, struct bkey_s new,
-                             unsigned flags)
+                             enum btree_iter_update_trigger_flags flags)
 {
        check_indirect_extent_deleting(new, &flags);
 
index e34c4bdf7a76ba200484b334cdc866f4fbd4ceef..59d4dbae3fb1f48d0c5367ebf5f3ebc5c4543bb4 100644 (file)
@@ -44,7 +44,7 @@ void bch2_indirect_inline_data_to_text(struct printbuf *,
 int bch2_trigger_indirect_inline_data(struct btree_trans *,
                                         enum btree_id, unsigned,
                              struct bkey_s_c, struct bkey_s,
-                             unsigned);
+                             enum btree_iter_update_trigger_flags);
 
 #define bch2_bkey_ops_indirect_inline_data ((struct bkey_ops) {        \
        .key_invalid    = bch2_indirect_inline_data_invalid,    \
index 0b26dee17a5ab9279ab9ceef39ed0af9a5f60f3f..2368218070d45c0db66b3874d4e7f03bb353e641 100644 (file)
@@ -298,7 +298,7 @@ static void set_is_ancestor_bitmap(struct bch_fs *c, u32 id)
 static int __bch2_mark_snapshot(struct btree_trans *trans,
                       enum btree_id btree, unsigned level,
                       struct bkey_s_c old, struct bkey_s_c new,
-                      unsigned flags)
+                      enum btree_iter_update_trigger_flags flags)
 {
        struct bch_fs *c = trans->c;
        struct snapshot_t *t;
@@ -352,7 +352,7 @@ err:
 int bch2_mark_snapshot(struct btree_trans *trans,
                       enum btree_id btree, unsigned level,
                       struct bkey_s_c old, struct bkey_s new,
-                      unsigned flags)
+                      enum btree_iter_update_trigger_flags flags)
 {
        return __bch2_mark_snapshot(trans, btree, level, old, new.s_c, flags);
 }
index ccb1f309b8d1622bc265fa4fad4e007564843ffd..b3c43d57954028ea1b70024ce6caf08feeff7913 100644 (file)
@@ -22,7 +22,8 @@ void bch2_snapshot_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 int bch2_snapshot_invalid(struct bch_fs *, struct bkey_s_c,
                          enum bkey_invalid_flags, struct printbuf *);
 int bch2_mark_snapshot(struct btree_trans *, enum btree_id, unsigned,
-                      struct bkey_s_c, struct bkey_s, unsigned);
+                      struct bkey_s_c, struct bkey_s,
+                      enum btree_iter_update_trigger_flags);
 
 #define bch2_bkey_ops_snapshot ((struct bkey_ops) {            \
        .key_invalid    = bch2_snapshot_invalid,                \
index 33292dae4d5096520bfdbfacb666b5e09b93f030..3341285e75317af2c449c79c71296fa8c592ae40 100644 (file)
@@ -245,7 +245,7 @@ static int subvolume_children_mod(struct btree_trans *trans, struct bpos pos, bo
 int bch2_subvolume_trigger(struct btree_trans *trans,
                           enum btree_id btree_id, unsigned level,
                           struct bkey_s_c old, struct bkey_s new,
-                          unsigned flags)
+                          enum btree_iter_update_trigger_flags flags)
 {
        if (flags & BTREE_TRIGGER_transactional) {
                struct bpos children_pos_old = subvolume_children_pos(old);
index d2015d549bd2a33102726c2f4a22cbcd2e64395d..1530a10327ab36432376b0d920a3d93b7df24e1c 100644 (file)
@@ -14,7 +14,8 @@ int bch2_subvolume_invalid(struct bch_fs *, struct bkey_s_c,
                           enum bkey_invalid_flags, struct printbuf *);
 void bch2_subvolume_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 int bch2_subvolume_trigger(struct btree_trans *, enum btree_id, unsigned,
-                          struct bkey_s_c, struct bkey_s, unsigned);
+                          struct bkey_s_c, struct bkey_s,
+                          enum btree_iter_update_trigger_flags);
 
 #define bch2_bkey_ops_subvolume ((struct bkey_ops) {           \
        .key_invalid    = bch2_subvolume_invalid,               \