bcachefs: Check for bad key version number

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2020-02-18 20:02:41 -05:00 committed by Kent Overstreet
parent 1f49dafcd3
commit a9bc0a5173
2 changed files with 6 additions and 2 deletions

View File

@ -126,7 +126,11 @@ static int bch2_gc_mark_key(struct bch_fs *c, struct bkey_s_c k,
BUG_ON(journal_seq_verify(c) &&
k.k->version.lo > journal_cur_seq(&c->journal));
if (k.k->version.lo > atomic64_read(&c->key_version))
/* XXX change to fsck check */
if (fsck_err_on(k.k->version.lo > atomic64_read(&c->key_version), c,
"key version number higher than recorded: %llu > %llu",
k.k->version.lo,
atomic64_read(&c->key_version)))
atomic64_set(&c->key_version, k.k->version.lo);
if (test_bit(BCH_FS_REBUILD_REPLICAS, &c->flags) ||

View File

@ -943,7 +943,7 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp,
if (bch2_csum_type_is_encryption(op->csum_type)) {
if (bversion_zero(version)) {
version.lo = atomic64_inc_return(&c->key_version) + 1;
version.lo = atomic64_inc_return(&c->key_version);
} else {
crc.nonce = op->nonce;
op->nonce += src_len >> 9;