]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Interior known are required to have known key types
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Apr 2024 03:59:28 +0000 (23:59 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Apr 2024 22:01:12 +0000 (18:01 -0400)
For forwards compatibilyt, we allow bkeys of unknown type in leaf nodes;
we can simply ignore metadata we don't understand. Pointers to btree
nodes must always be of known types, howwever.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bkey_methods.c

index e4481e4d5f38f9c8e41d157c80da6a6f5d324a7c..db336a43fc083a79615e81ce9da37ff4877005f9 100644 (file)
@@ -171,7 +171,8 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
        if (type >= BKEY_TYPE_NR)
                return 0;
 
-       bkey_fsck_err_on((flags & BKEY_INVALID_COMMIT) &&
+       bkey_fsck_err_on((type == BKEY_TYPE_btree ||
+                         (flags & BKEY_INVALID_COMMIT)) &&
                         !(bch2_key_types_allowed[type] & BIT_ULL(k.k->type)), c, err,
                         bkey_invalid_type_for_btree,
                         "invalid key type for btree %s (%s)",