bcachefs: Change check for invalid key types
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 7 Jul 2023 01:16:10 +0000 (21:16 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:06 +0000 (17:10 -0400)
As part of the forward compatibility patch series, we need to allow for
new key types without complaining loudly when running an old version.

This patch changes the flags parameter of bkey_invalid to an enum, and
adds a new flag to indicate we're being called from the transaction
commit path.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
26 files changed:
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_background.h
fs/bcachefs/backpointers.c
fs/bcachefs/backpointers.h
fs/bcachefs/bkey_methods.c
fs/bcachefs/bkey_methods.h
fs/bcachefs/btree_update_leaf.c
fs/bcachefs/dirent.c
fs/bcachefs/dirent.h
fs/bcachefs/ec.c
fs/bcachefs/ec.h
fs/bcachefs/extents.c
fs/bcachefs/extents.h
fs/bcachefs/inode.c
fs/bcachefs/inode.h
fs/bcachefs/journal_io.c
fs/bcachefs/lru.c
fs/bcachefs/lru.h
fs/bcachefs/quota.c
fs/bcachefs/quota.h
fs/bcachefs/reflink.c
fs/bcachefs/reflink.h
fs/bcachefs/subvolume.c
fs/bcachefs/subvolume.h
fs/bcachefs/xattr.c
fs/bcachefs/xattr.h

index 782086afde54b5bd1145367f745597c71e404e38..b07c09a7708984415ce58b8c82e1910faad81d7e 100644 (file)
@@ -223,7 +223,8 @@ static unsigned bch_alloc_v1_val_u64s(const struct bch_alloc *a)
 }
 
 int bch2_alloc_v1_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                         unsigned flags, struct printbuf *err)
+                         enum bkey_invalid_flags flags,
+                         struct printbuf *err)
 {
        struct bkey_s_c_alloc a = bkey_s_c_to_alloc(k);
 
@@ -238,7 +239,8 @@ int bch2_alloc_v1_invalid(const struct bch_fs *c, struct bkey_s_c k,
 }
 
 int bch2_alloc_v2_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                         unsigned flags, struct printbuf *err)
+                         enum bkey_invalid_flags flags,
+                         struct printbuf *err)
 {
        struct bkey_alloc_unpacked u;
 
@@ -251,7 +253,8 @@ int bch2_alloc_v2_invalid(const struct bch_fs *c, struct bkey_s_c k,
 }
 
 int bch2_alloc_v3_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                         unsigned flags, struct printbuf *err)
+                         enum bkey_invalid_flags flags,
+                         struct printbuf *err)
 {
        struct bkey_alloc_unpacked u;
 
@@ -264,7 +267,7 @@ int bch2_alloc_v3_invalid(const struct bch_fs *c, struct bkey_s_c k,
 }
 
 int bch2_alloc_v4_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                         unsigned flags, struct printbuf *err)
+                         enum bkey_invalid_flags flags, struct printbuf *err)
 {
        struct bkey_s_c_alloc_v4 a = bkey_s_c_to_alloc_v4(k);
        int rw = flags & WRITE;
@@ -282,7 +285,7 @@ int bch2_alloc_v4_invalid(const struct bch_fs *c, struct bkey_s_c k,
        }
 
        if (rw == WRITE &&
-           !(flags & BKEY_INVALID_FROM_JOURNAL) &&
+           !(flags & BKEY_INVALID_JOURNAL) &&
            test_bit(BCH_FS_CHECK_BACKPOINTERS_DONE, &c->flags)) {
                unsigned i, bp_len = 0;
 
@@ -605,7 +608,8 @@ static unsigned alloc_gen(struct bkey_s_c k, unsigned offset)
 }
 
 int bch2_bucket_gens_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                            unsigned flags, struct printbuf *err)
+                            enum bkey_invalid_flags flags,
+                            struct printbuf *err)
 {
        if (bkey_val_bytes(k.k) != sizeof(struct bch_bucket_gens)) {
                prt_printf(err, "bad val size (%lu != %zu)",
index 3c4d6d40b1202683f1e6f3de02f42d17a13bf74a..d1bf45a4b404aaaeca4b11289bad4ba4b89f4b3d 100644 (file)
@@ -8,6 +8,8 @@
 #include "debug.h"
 #include "super.h"
 
+enum bkey_invalid_flags;
+
 /* How out of date a pointer gen is allowed to be: */
 #define BUCKET_GC_GEN_MAX      96U
 
@@ -147,10 +149,14 @@ struct bkey_i_alloc_v4 *bch2_alloc_to_v4_mut(struct btree_trans *, struct bkey_s
 
 int bch2_bucket_io_time_reset(struct btree_trans *, unsigned, size_t, int);
 
-int bch2_alloc_v1_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
-int bch2_alloc_v2_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
-int bch2_alloc_v3_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
-int bch2_alloc_v4_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
+int bch2_alloc_v1_invalid(const struct bch_fs *, struct bkey_s_c,
+                         enum bkey_invalid_flags, struct printbuf *);
+int bch2_alloc_v2_invalid(const struct bch_fs *, struct bkey_s_c,
+                         enum bkey_invalid_flags, struct printbuf *);
+int bch2_alloc_v3_invalid(const struct bch_fs *, struct bkey_s_c,
+                         enum bkey_invalid_flags, struct printbuf *);
+int bch2_alloc_v4_invalid(const struct bch_fs *, struct bkey_s_c,
+                         enum bkey_invalid_flags, struct printbuf *);
 void bch2_alloc_v4_swab(struct bkey_s);
 void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
@@ -187,7 +193,8 @@ void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
        .min_val_size   = 48,                           \
 })
 
-int bch2_bucket_gens_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
+int bch2_bucket_gens_invalid(const struct bch_fs *, struct bkey_s_c,
+                            enum bkey_invalid_flags, struct printbuf *);
 void bch2_bucket_gens_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 #define bch2_bkey_ops_bucket_gens ((struct bkey_ops) { \
index 760c4cc16a50e3b6cb82b833103df596eb3eff37..571a7d19bea7ff4280b7493c9911a1906e173b9e 100644 (file)
@@ -38,7 +38,8 @@ static bool extent_matches_bp(struct bch_fs *c,
 }
 
 int bch2_backpointer_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                            unsigned flags, struct printbuf *err)
+                            enum bkey_invalid_flags flags,
+                            struct printbuf *err)
 {
        struct bkey_s_c_backpointer bp = bkey_s_c_to_backpointer(k);
        struct bpos bucket = bp_pos_to_bucket(c, bp.k->p);
index 3994bc83d69df31e90df8fd7c48677e217be42d7..87e31aa1975c26e910ee1c6c603669b77c86ff9d 100644 (file)
@@ -8,7 +8,7 @@
 #include "super.h"
 
 int bch2_backpointer_invalid(const struct bch_fs *, struct bkey_s_c k,
-                            unsigned, struct printbuf *);
+                            enum bkey_invalid_flags, struct printbuf *);
 void bch2_backpointer_to_text(struct printbuf *, const struct bch_backpointer *);
 void bch2_backpointer_k_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 void bch2_backpointer_swab(struct bkey_s);
index 985ea2daa886173b94e50ebb2ec99fa3def5049c..1381166bfc55b7cad8600a1d313ed267f95dfa27 100644 (file)
@@ -123,7 +123,8 @@ const struct bkey_ops bch2_bkey_null_ops = {
 };
 
 int bch2_bkey_val_invalid(struct bch_fs *c, struct bkey_s_c k,
-                         unsigned flags, struct printbuf *err)
+                         enum bkey_invalid_flags flags,
+                         struct printbuf *err)
 {
        const struct bkey_ops *ops = bch2_bkey_type_ops(k.k->type);
 
@@ -215,14 +216,16 @@ static unsigned bch2_key_types_allowed[] = {
 
 int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
                        enum btree_node_type type,
-                       unsigned flags, struct printbuf *err)
+                       enum bkey_invalid_flags flags,
+                       struct printbuf *err)
 {
        if (k.k->u64s < BKEY_U64s) {
                prt_printf(err, "u64s too small (%u < %zu)", k.k->u64s, BKEY_U64s);
                return -BCH_ERR_invalid_bkey;
        }
 
-       if (!(bch2_key_types_allowed[type] & (1U << k.k->type))) {
+       if (flags & BKEY_INVALID_COMMIT  &&
+           !(bch2_key_types_allowed[type] & (1U << k.k->type))) {
                prt_printf(err, "invalid key type for btree %s (%s)",
                           bch2_btree_ids[type], bch2_bkey_types[k.k->type]);
                return -BCH_ERR_invalid_bkey;
@@ -246,24 +249,23 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
                }
        }
 
-       if (type != BKEY_TYPE_btree &&
-           !btree_type_has_snapshots(type) &&
-           k.k->p.snapshot) {
-               prt_printf(err, "nonzero snapshot");
-               return -BCH_ERR_invalid_bkey;
-       }
+       if (type != BKEY_TYPE_btree) {
+               if (!btree_type_has_snapshots((enum btree_id) type) &&
+                   k.k->p.snapshot) {
+                       prt_printf(err, "nonzero snapshot");
+                       return -BCH_ERR_invalid_bkey;
+               }
 
-       if (type != BKEY_TYPE_btree &&
-           btree_type_has_snapshots(type) &&
-           !k.k->p.snapshot) {
-               prt_printf(err, "snapshot == 0");
-               return -BCH_ERR_invalid_bkey;
-       }
+               if (btree_type_has_snapshots((enum btree_id) type) &&
+                   !k.k->p.snapshot) {
+                       prt_printf(err, "snapshot == 0");
+                       return -BCH_ERR_invalid_bkey;
+               }
 
-       if (type != BKEY_TYPE_btree &&
-           bkey_eq(k.k->p, POS_MAX)) {
-               prt_printf(err, "key at POS_MAX");
-               return -BCH_ERR_invalid_bkey;
+               if (bkey_eq(k.k->p, POS_MAX)) {
+                       prt_printf(err, "key at POS_MAX");
+                       return -BCH_ERR_invalid_bkey;
+               }
        }
 
        return 0;
@@ -271,7 +273,8 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
 
 int bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
                      enum btree_node_type type,
-                     unsigned flags, struct printbuf *err)
+                     enum bkey_invalid_flags flags,
+                     struct printbuf *err)
 {
        return __bch2_bkey_invalid(c, k, type, flags, err) ?:
                bch2_bkey_val_invalid(c, k, flags, err);
index 32b86c74cc9a7c3cf65e642fad9726f9cb418b63..d1ff83a73511d8663a0551f16b4557f0ab648e2a 100644 (file)
@@ -13,6 +13,12 @@ enum btree_node_type;
 extern const char * const bch2_bkey_types[];
 extern const struct bkey_ops bch2_bkey_null_ops;
 
+enum bkey_invalid_flags {
+       BKEY_INVALID_WRITE              = (1U << 0),
+       BKEY_INVALID_COMMIT             = (1U << 1),
+       BKEY_INVALID_JOURNAL            = (1U << 2),
+};
+
 /*
  * key_invalid: checks validity of @k, returns 0 if good or -EINVAL if bad. If
  * invalid, entire key will be deleted.
@@ -22,7 +28,7 @@ extern const struct bkey_ops bch2_bkey_null_ops;
  */
 struct bkey_ops {
        int             (*key_invalid)(const struct bch_fs *c, struct bkey_s_c k,
-                                      unsigned flags, struct printbuf *err);
+                                      enum bkey_invalid_flags flags, struct printbuf *err);
        void            (*val_to_text)(struct printbuf *, struct bch_fs *,
                                       struct bkey_s_c);
        void            (*swab)(struct bkey_s);
@@ -49,13 +55,12 @@ static inline const struct bkey_ops *bch2_bkey_type_ops(enum bch_bkey_type type)
                : &bch2_bkey_null_ops;
 }
 
-#define BKEY_INVALID_FROM_JOURNAL              (1 << 1)
-
-int bch2_bkey_val_invalid(struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
-int __bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c,
-                       enum btree_node_type, unsigned, struct printbuf *);
-int bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c,
-                     enum btree_node_type, unsigned, struct printbuf *);
+int bch2_bkey_val_invalid(struct bch_fs *, struct bkey_s_c,
+                         enum bkey_invalid_flags, struct printbuf *);
+int __bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c, enum btree_node_type,
+                       enum bkey_invalid_flags, struct printbuf *);
+int bch2_bkey_invalid(struct bch_fs *, struct bkey_s_c, enum btree_node_type,
+                     enum bkey_invalid_flags, struct printbuf *);
 int bch2_bkey_in_btree_node(struct btree *, struct bkey_s_c, struct printbuf *);
 
 void bch2_bpos_to_text(struct printbuf *, struct bpos);
index 1474dca26dde469f2614c0af775ffb9e3d7d23d8..2b43f02fc455387b98c89a571271b9e7e3589b3d 100644 (file)
@@ -856,10 +856,13 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans, unsigned flags
        struct printbuf buf = PRINTBUF;
 
        trans_for_each_update(trans, i) {
-               int rw = (flags & BTREE_INSERT_JOURNAL_REPLAY) ? READ : WRITE;
+               enum bkey_invalid_flags invalid_flags = 0;
+
+               if (!(flags & BTREE_INSERT_JOURNAL_REPLAY))
+                       invalid_flags |= BKEY_INVALID_WRITE|BKEY_INVALID_COMMIT;
 
                if (unlikely(bch2_bkey_invalid(c, bkey_i_to_s_c(i->k),
-                                              i->bkey_type, rw, &buf)))
+                                              i->bkey_type, invalid_flags, &buf)))
                        return bch2_trans_commit_bkey_invalid(trans, flags, i, &buf);
                btree_insert_entry_checks(trans, i);
        }
index ef3f1f9b7e8d14c2ebf300a85a306102ec1d52a0..065ea59ee9fa5ecd8dcd68f12dd2ef8bd8e29497 100644 (file)
@@ -85,7 +85,8 @@ const struct bch_hash_desc bch2_dirent_hash_desc = {
 };
 
 int bch2_dirent_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                       unsigned flags, struct printbuf *err)
+                       enum bkey_invalid_flags flags,
+                       struct printbuf *err)
 {
        struct bkey_s_c_dirent d = bkey_s_c_to_dirent(k);
        unsigned len;
index bf9ea2e35faeb9a87c42be340e1d17e4fbb6e136..b42f4a13bc551debad140c8a6e59e39d2006a774 100644 (file)
@@ -4,9 +4,11 @@
 
 #include "str_hash.h"
 
+enum bkey_invalid_flags;
 extern const struct bch_hash_desc bch2_dirent_hash_desc;
 
-int bch2_dirent_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
+int bch2_dirent_invalid(const struct bch_fs *, struct bkey_s_c,
+                       enum bkey_invalid_flags, struct printbuf *);
 void bch2_dirent_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 #define bch2_bkey_ops_dirent ((struct bkey_ops) {      \
index e0d49fe493106cf626241c84b0b0c09728535848..d35a59e2d0e9cf780f8ad52aca05387f62e6a29d 100644 (file)
@@ -105,7 +105,8 @@ struct ec_bio {
 /* Stripes btree keys: */
 
 int bch2_stripe_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                       unsigned flags, struct printbuf *err)
+                       enum bkey_invalid_flags flags,
+                       struct printbuf *err)
 {
        const struct bch_stripe *s = bkey_s_c_to_stripe(k).v;
 
index 64ca277ca1a6dbf6606d3b724f15598c9ee96f49..1b1848e5fa5e78facd340cf194264f575c2952b0 100644 (file)
@@ -6,8 +6,10 @@
 #include "buckets_types.h"
 #include "extents_types.h"
 
+enum bkey_invalid_flags;
+
 int bch2_stripe_invalid(const struct bch_fs *, struct bkey_s_c,
-                       unsigned, struct printbuf *);
+                       enum bkey_invalid_flags, struct printbuf *);
 void bch2_stripe_to_text(struct printbuf *, struct bch_fs *,
                         struct bkey_s_c);
 
index 4e89a8be5cb76e12d4b936f3db4fa5003ea80bd7..7a3f42f3bc5bfa8c61d6b35f6092cb91ca4a7add 100644 (file)
@@ -163,7 +163,8 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
 /* KEY_TYPE_btree_ptr: */
 
 int bch2_btree_ptr_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                          unsigned flags, struct printbuf *err)
+                          enum bkey_invalid_flags flags,
+                          struct printbuf *err)
 {
        if (bkey_val_u64s(k.k) > BCH_REPLICAS_MAX) {
                prt_printf(err, "value too big (%zu > %u)",
@@ -181,7 +182,8 @@ void bch2_btree_ptr_to_text(struct printbuf *out, struct bch_fs *c,
 }
 
 int bch2_btree_ptr_v2_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                             unsigned flags, struct printbuf *err)
+                             enum bkey_invalid_flags flags,
+                             struct printbuf *err)
 {
        if (bkey_val_u64s(k.k) > BKEY_BTREE_PTR_VAL_U64s_MAX) {
                prt_printf(err, "value too big (%zu > %zu)",
@@ -371,7 +373,8 @@ bool bch2_extent_merge(struct bch_fs *c, struct bkey_s l, struct bkey_s_c r)
 /* KEY_TYPE_reservation: */
 
 int bch2_reservation_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                            unsigned flags, struct printbuf *err)
+                            enum bkey_invalid_flags flags,
+                            struct printbuf *err)
 {
        struct bkey_s_c_reservation r = bkey_s_c_to_reservation(k);
 
@@ -1103,7 +1106,8 @@ static int extent_ptr_invalid(const struct bch_fs *c,
 }
 
 int bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                          unsigned flags, struct printbuf *err)
+                          enum bkey_invalid_flags flags,
+                          struct printbuf *err)
 {
        struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
        const union bch_extent_entry *entry;
index f6411d63f298e529bf72ad23ef27baad036276b3..7ee8d031bb6c50c809114107dbf79c7aadc17bf7 100644 (file)
@@ -8,6 +8,7 @@
 
 struct bch_fs;
 struct btree_trans;
+enum bkey_invalid_flags;
 
 /* extent entries: */
 
@@ -382,11 +383,13 @@ int bch2_bkey_pick_read_device(struct bch_fs *, struct bkey_s_c,
 
 /* KEY_TYPE_btree_ptr: */
 
-int bch2_btree_ptr_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
+int bch2_btree_ptr_invalid(const struct bch_fs *, struct bkey_s_c,
+                          enum bkey_invalid_flags, struct printbuf *);
 void bch2_btree_ptr_to_text(struct printbuf *, struct bch_fs *,
                            struct bkey_s_c);
 
-int bch2_btree_ptr_v2_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
+int bch2_btree_ptr_v2_invalid(const struct bch_fs *, struct bkey_s_c,
+                             enum bkey_invalid_flags, struct printbuf *);
 void bch2_btree_ptr_v2_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 void bch2_btree_ptr_v2_compat(enum btree_id, unsigned, unsigned,
                              int, struct bkey_s);
@@ -426,7 +429,7 @@ bool bch2_extent_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
 /* KEY_TYPE_reservation: */
 
 int bch2_reservation_invalid(const struct bch_fs *, struct bkey_s_c,
-                            unsigned, struct printbuf *);
+                            enum bkey_invalid_flags, struct printbuf *);
 void bch2_reservation_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 bool bch2_reservation_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
 
@@ -685,7 +688,7 @@ bool bch2_extent_normalize(struct bch_fs *, struct bkey_s);
 void bch2_bkey_ptrs_to_text(struct printbuf *, struct bch_fs *,
                            struct bkey_s_c);
 int bch2_bkey_ptrs_invalid(const struct bch_fs *, struct bkey_s_c,
-                          unsigned, struct printbuf *);
+                          enum bkey_invalid_flags, struct printbuf *);
 
 void bch2_ptr_swab(struct bkey_s);
 
index 64e8d1f8a2fa791885891e071f67656f1e1774f0..fa435d8655de8e512aacd7a718c51677a384bb54 100644 (file)
@@ -432,7 +432,8 @@ static int __bch2_inode_invalid(struct bkey_s_c k, struct printbuf *err)
 }
 
 int bch2_inode_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                      unsigned flags, struct printbuf *err)
+                      enum bkey_invalid_flags flags,
+                      struct printbuf *err)
 {
        struct bkey_s_c_inode inode = bkey_s_c_to_inode(k);
 
@@ -446,7 +447,8 @@ int bch2_inode_invalid(const struct bch_fs *c, struct bkey_s_c k,
 }
 
 int bch2_inode_v2_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                         unsigned flags, struct printbuf *err)
+                         enum bkey_invalid_flags flags,
+                         struct printbuf *err)
 {
        struct bkey_s_c_inode_v2 inode = bkey_s_c_to_inode_v2(k);
 
@@ -460,7 +462,8 @@ int bch2_inode_v2_invalid(const struct bch_fs *c, struct bkey_s_c k,
 }
 
 int bch2_inode_v3_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                         unsigned flags, struct printbuf *err)
+                         enum bkey_invalid_flags flags,
+                         struct printbuf *err)
 {
        struct bkey_s_c_inode_v3 inode = bkey_s_c_to_inode_v3(k);
 
@@ -517,7 +520,8 @@ void bch2_inode_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c
 }
 
 int bch2_inode_generation_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                                 unsigned flags, struct printbuf *err)
+                                 enum bkey_invalid_flags flags,
+                                 struct printbuf *err)
 {
        if (k.k->p.inode) {
                prt_printf(err, "nonzero k.p.inode");
index 0c3022d3f995f00ef0bfe99de85a6f50877e9032..8f9be5e58381994ff8adaff7399e92585a761c3e 100644 (file)
@@ -5,11 +5,15 @@
 #include "bkey.h"
 #include "opts.h"
 
+enum bkey_invalid_flags;
 extern const char * const bch2_inode_opts[];
 
-int bch2_inode_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
-int bch2_inode_v2_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
-int bch2_inode_v3_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
+int bch2_inode_invalid(const struct bch_fs *, struct bkey_s_c,
+                      enum bkey_invalid_flags, struct printbuf *);
+int bch2_inode_v2_invalid(const struct bch_fs *, struct bkey_s_c,
+                         enum bkey_invalid_flags, struct printbuf *);
+int bch2_inode_v3_invalid(const struct bch_fs *, struct bkey_s_c,
+                         enum bkey_invalid_flags, struct printbuf *);
 void bch2_inode_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 #define bch2_bkey_ops_inode ((struct bkey_ops) {       \
@@ -44,7 +48,7 @@ static inline bool bkey_is_inode(const struct bkey *k)
 }
 
 int bch2_inode_generation_invalid(const struct bch_fs *, struct bkey_s_c,
-                                 unsigned, struct printbuf *);
+                                 enum bkey_invalid_flags, struct printbuf *);
 void bch2_inode_generation_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 #define bch2_bkey_ops_inode_generation ((struct bkey_ops) {    \
index a084c6d0fe23f8520bc38df0de7ded9d7f6972ee..c7c2ae326ff7920c7699126b99a1d108ee872acc 100644 (file)
@@ -340,7 +340,8 @@ static int journal_entry_btree_keys_validate(struct bch_fs *c,
                int ret = journal_validate_key(c, jset, entry,
                                               entry->level,
                                               entry->btree_id,
-                                              k, version, big_endian, write|BKEY_INVALID_FROM_JOURNAL);
+                                              k, version, big_endian,
+                                              write|BKEY_INVALID_JOURNAL);
                if (ret == FSCK_DELETED_KEY)
                        continue;
 
index e04c037f0c0115bc188e1b8e327665f2efe1164e..07d1929535b87ce3c2996a88b64ec761d45c2863 100644 (file)
@@ -11,7 +11,8 @@
 
 /* KEY_TYPE_lru is obsolete: */
 int bch2_lru_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                    unsigned flags, struct printbuf *err)
+                    enum bkey_invalid_flags flags,
+                    struct printbuf *err)
 {
        if (!lru_pos_time(k.k->p)) {
                prt_printf(err, "lru entry at time=0");
index adb98429248ef3ceee4b34f34d05417fbe3a1ce8..7a3be20a8523e423b7c03222ebef679893e65f10 100644 (file)
@@ -43,7 +43,8 @@ static inline enum bch_lru_type lru_type(struct bkey_s_c l)
        return BCH_LRU_read;
 }
 
-int bch2_lru_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
+int bch2_lru_invalid(const struct bch_fs *, struct bkey_s_c,
+                    enum bkey_invalid_flags, struct printbuf *);
 void bch2_lru_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 void bch2_lru_pos_to_text(struct printbuf *, struct bpos);
index 1decb7191da21f91922a72882f3709c06bf77330..d90db3fb823ed42fc89c9a47b8b0dc6179721b6a 100644 (file)
@@ -60,7 +60,8 @@ const struct bch_sb_field_ops bch_sb_field_ops_quota = {
 };
 
 int bch2_quota_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                      unsigned flags, struct printbuf *err)
+                      enum bkey_invalid_flags flags,
+                      struct printbuf *err)
 {
        if (k.k->p.inode >= QTYP_NR) {
                prt_printf(err, "invalid quota type (%llu >= %u)",
index b0f7d4ee775e17ae15e0177652c49d8006086558..2f463874a3628238fb62c17f341d698f4fc3f3e6 100644 (file)
@@ -5,9 +5,11 @@
 #include "inode.h"
 #include "quota_types.h"
 
+enum bkey_invalid_flags;
 extern const struct bch_sb_field_ops bch_sb_field_ops_quota;
 
-int bch2_quota_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
+int bch2_quota_invalid(const struct bch_fs *, struct bkey_s_c,
+                      enum bkey_invalid_flags, struct printbuf *);
 void bch2_quota_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 #define bch2_bkey_ops_quota ((struct bkey_ops) {       \
index 26f0275ff0afad6a0c170854b24c409782bd36eb..39f711d5069e9f0f483fa9cfb0ad1d2ffced92be 100644 (file)
@@ -26,7 +26,8 @@ static inline unsigned bkey_type_to_indirect(const struct bkey *k)
 /* reflink pointers */
 
 int bch2_reflink_p_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                          unsigned flags, struct printbuf *err)
+                          enum bkey_invalid_flags flags,
+                          struct printbuf *err)
 {
        struct bkey_s_c_reflink_p p = bkey_s_c_to_reflink_p(k);
 
@@ -72,7 +73,8 @@ bool bch2_reflink_p_merge(struct bch_fs *c, struct bkey_s _l, struct bkey_s_c _r
 /* indirect extents */
 
 int bch2_reflink_v_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                          unsigned flags, struct printbuf *err)
+                          enum bkey_invalid_flags flags,
+                          struct printbuf *err)
 {
        return bch2_bkey_ptrs_invalid(c, k, flags, err);
 }
@@ -117,7 +119,8 @@ int bch2_trans_mark_reflink_v(struct btree_trans *trans,
 /* indirect inline data */
 
 int bch2_indirect_inline_data_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                                     unsigned flags, struct printbuf *err)
+                                     enum bkey_invalid_flags flags,
+                                     struct printbuf *err)
 {
        return 0;
 }
index ba400188f5befeea949f69a95cefc5c876309e44..fe52538efb522940cd6cf7b853bc6d5d4afe3c94 100644 (file)
@@ -2,8 +2,10 @@
 #ifndef _BCACHEFS_REFLINK_H
 #define _BCACHEFS_REFLINK_H
 
+enum bkey_invalid_flags;
+
 int bch2_reflink_p_invalid(const struct bch_fs *, struct bkey_s_c,
-                          unsigned, struct printbuf *);
+                          enum bkey_invalid_flags, struct printbuf *);
 void bch2_reflink_p_to_text(struct printbuf *, struct bch_fs *,
                            struct bkey_s_c);
 bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
@@ -18,7 +20,7 @@ bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
 })
 
 int bch2_reflink_v_invalid(const struct bch_fs *, struct bkey_s_c,
-                          unsigned, struct printbuf *);
+                          enum bkey_invalid_flags, struct printbuf *);
 void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *,
                            struct bkey_s_c);
 int bch2_trans_mark_reflink_v(struct btree_trans *, enum btree_id, unsigned,
@@ -34,7 +36,7 @@ int bch2_trans_mark_reflink_v(struct btree_trans *, enum btree_id, unsigned,
 })
 
 int bch2_indirect_inline_data_invalid(const struct bch_fs *, struct bkey_s_c,
-                                     unsigned, struct printbuf *);
+                                     enum bkey_invalid_flags, struct printbuf *);
 void bch2_indirect_inline_data_to_text(struct printbuf *,
                                struct bch_fs *, struct bkey_s_c);
 int bch2_trans_mark_indirect_inline_data(struct btree_trans *,
index 341c0d1b81d308dc50ccafa2ae80e92ff8c0274e..f26397aa2b31546e68e3da0e629fcb211c46092e 100644 (file)
@@ -23,7 +23,8 @@ void bch2_snapshot_tree_to_text(struct printbuf *out, struct bch_fs *c,
 }
 
 int bch2_snapshot_tree_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                              unsigned flags, struct printbuf *err)
+                              enum bkey_invalid_flags flags,
+                              struct printbuf *err)
 {
        if (bkey_gt(k.k->p, POS(0, U32_MAX)) ||
            bkey_lt(k.k->p, POS(0, 1))) {
@@ -97,7 +98,8 @@ void bch2_snapshot_to_text(struct printbuf *out, struct bch_fs *c,
 }
 
 int bch2_snapshot_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                         unsigned flags, struct printbuf *err)
+                         enum bkey_invalid_flags flags,
+                         struct printbuf *err)
 {
        struct bkey_s_c_snapshot s;
        u32 i, id;
index 1a39f713db87c8731778d297f045a946c6835904..105410e080e059ee73328ad9bc849f3a1973ea6b 100644 (file)
@@ -5,9 +5,11 @@
 #include "darray.h"
 #include "subvolume_types.h"
 
+enum bkey_invalid_flags;
+
 void bch2_snapshot_tree_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 int bch2_snapshot_tree_invalid(const struct bch_fs *, struct bkey_s_c,
-                              unsigned, struct printbuf *);
+                              enum bkey_invalid_flags, struct printbuf *);
 
 #define bch2_bkey_ops_snapshot_tree ((struct bkey_ops) {       \
        .key_invalid    = bch2_snapshot_tree_invalid,           \
@@ -19,7 +21,7 @@ int bch2_snapshot_tree_lookup(struct btree_trans *, u32, struct bch_snapshot_tre
 
 void bch2_snapshot_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 int bch2_snapshot_invalid(const struct bch_fs *, struct bkey_s_c,
-                         unsigned, struct printbuf *);
+                         enum bkey_invalid_flags, struct printbuf *);
 int bch2_mark_snapshot(struct btree_trans *, enum btree_id, unsigned,
                       struct bkey_s_c, struct bkey_s_c, unsigned);
 
index f47a085d14344b346148e27fbdac22de5b53b976..867cc68782483c86d0b6e9a578903f529ce6dd4e 100644 (file)
@@ -70,7 +70,8 @@ const struct bch_hash_desc bch2_xattr_hash_desc = {
 };
 
 int bch2_xattr_invalid(const struct bch_fs *c, struct bkey_s_c k,
-                      unsigned flags, struct printbuf *err)
+                      enum bkey_invalid_flags flags,
+                      struct printbuf *err)
 {
        const struct xattr_handler *handler;
        struct bkey_s_c_xattr xattr = bkey_s_c_to_xattr(k);
index b3e16729bcbba472f15302a3c3bb0b560330c8ce..214cbbaac3045d92da690d7fa18c6489183a702c 100644 (file)
@@ -6,7 +6,8 @@
 
 extern const struct bch_hash_desc bch2_xattr_hash_desc;
 
-int bch2_xattr_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
+int bch2_xattr_invalid(const struct bch_fs *, struct bkey_s_c,
+                      enum bkey_invalid_flags, struct printbuf *);
 void bch2_xattr_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 #define bch2_bkey_ops_xattr ((struct bkey_ops) {       \