]> git.dujemihanovic.xyz Git - linux.git/commitdiff
bcachefs: add no_invalid_checks flag
authorThomas Bertschinger <tahbertschinger@gmail.com>
Thu, 9 May 2024 18:37:24 +0000 (12:37 -0600)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 9 May 2024 20:24:30 +0000 (16:24 -0400)
Setting this flag on a filesystem results in validity checks being
skipped when writing bkeys. This flag will be used by tooling that
deliberately injects corruption into a filesystem in order to exercise
fsck. It shouldn't be set outside of testing/debugging code.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs.h
fs/bcachefs/bkey_methods.c

index ab2dc2c70da21a0473353fa55288042a5420bd00..bc0ea2c4efef25fce089f4b3ca24e3cf6b2f5bdb 100644 (file)
@@ -637,7 +637,8 @@ struct bch_dev {
        x(error)                        \
        x(topology_error)               \
        x(errors_fixed)                 \
-       x(errors_not_fixed)
+       x(errors_not_fixed)             \
+       x(no_invalid_checks)
 
 enum bch_fs_flags {
 #define x(n)           BCH_FS_##n,
index f692f9d8f00da4067e7bd48b4e05643274d59a27..c2c3dae521865c70d5d86074ae74488b178c231d 100644 (file)
@@ -126,6 +126,9 @@ int bch2_bkey_val_invalid(struct bch_fs *c, struct bkey_s_c k,
                          enum bch_validate_flags flags,
                          struct printbuf *err)
 {
+       if (test_bit(BCH_FS_no_invalid_checks, &c->flags))
+               return 0;
+
        const struct bkey_ops *ops = bch2_bkey_type_ops(k.k->type);
        int ret = 0;
 
@@ -162,6 +165,9 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
                        enum bch_validate_flags flags,
                        struct printbuf *err)
 {
+       if (test_bit(BCH_FS_no_invalid_checks, &c->flags))
+               return 0;
+
        int ret = 0;
 
        bkey_fsck_err_on(k.k->u64s < BKEY_U64s, c, err,