Skip to content

Commit 07f9a27

Browse files
bertschingertKent Overstreet
authored andcommitted
bcachefs: add no_invalid_checks flag
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>
1 parent bceacfa commit 07f9a27

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

fs/bcachefs/bcachefs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,8 @@ struct bch_dev {
637637
x(error) \
638638
x(topology_error) \
639639
x(errors_fixed) \
640-
x(errors_not_fixed)
640+
x(errors_not_fixed) \
641+
x(no_invalid_checks)
641642

642643
enum bch_fs_flags {
643644
#define x(n) BCH_FS_##n,

fs/bcachefs/bkey_methods.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ int bch2_bkey_val_invalid(struct bch_fs *c, struct bkey_s_c k,
126126
enum bch_validate_flags flags,
127127
struct printbuf *err)
128128
{
129+
if (test_bit(BCH_FS_no_invalid_checks, &c->flags))
130+
return 0;
131+
129132
const struct bkey_ops *ops = bch2_bkey_type_ops(k.k->type);
130133
int ret = 0;
131134

@@ -162,6 +165,9 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
162165
enum bch_validate_flags flags,
163166
struct printbuf *err)
164167
{
168+
if (test_bit(BCH_FS_no_invalid_checks, &c->flags))
169+
return 0;
170+
165171
int ret = 0;
166172

167173
bkey_fsck_err_on(k.k->u64s < BKEY_U64s, c, err,

0 commit comments

Comments
 (0)