Skip to content

Commit

Permalink
bcachefs: add no_invalid_checks flag
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Bertschinger authored and Kent Overstreet committed May 9, 2024
1 parent bceacfa commit 07f9a27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/bcachefs/bcachefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions fs/bcachefs/bkey_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 07f9a27

Please sign in to comment.