Fixed test_ck_spam*'s open file bshrub/btree issues
- In lfsr_mtree_traverse, we traverse open file bshrubs/btrees before
we validate the gcksum, which means bugs/asserts can slip through
before we have a chance to detect something is wrong.
To work around this, I've added an explicit mdir cksum check right
before we start traversing an open mdir's bshrubs/btrees. If an open
mdir doesn't match the on-disk state, the on-disk state must contain
an error (or the RAM, but that's a different story and wayyy out of
scope).
It might be better to rearrange lfsr_mtree_traverse to check gcksums
first, but this will require another look at our traversal clobbering
logic.
- For a similar reason, ckfetches can't detect open bshrub/btree
corruption as is. As its name suggests, ckfetches only checks fetches,
so any corruption after we've fetched bshrubs/btrees in lfsr_file_open
will go undetected.
Fortunately this just means we need a full ckmeta-scan in
test_ck_spam* tests that keep open files.
In real use, full ckmeta-scans should be preferred anyways. Limiting
these scans to mtreeonly was just an attempt to better stress btree
ckfetches.
At least we're still testing ckmeta+mtreeonly+ckfetches in
test_ck_spam_dir_fuzz and test_ck_spam_file_fuzz.
This gets the test_ck_spam* tests running under all of the current
interesting ck-modes.
Code changes:
code stack ctx
before: 38560 2640 644
after 38572 (+0.0%) 2640 (+0.0%) 644 (+0.0%)
This commit is contained in:
@@ -9477,6 +9477,20 @@ static int lfsr_mtree_traverse_(lfs_t *lfs, lfsr_traversal_t *t,
|
||||
continue;
|
||||
}
|
||||
|
||||
// hold on, does our mdir cksum match? if not we found some
|
||||
// sort of error
|
||||
if (t->ot->mdir.rbyd.cksum != t->o.o.mdir.rbyd.cksum) {
|
||||
LFS_DEBUG("Found mdir cksum mismatch %"PRId32" "
|
||||
"0x{%"PRIx32",%"PRIx32"}, "
|
||||
"cksum %08"PRIx32" (!= %08"PRIx32")",
|
||||
t->o.o.mdir.mid >> lfs->mdir_bits,
|
||||
t->o.o.mdir.rbyd.blocks[0],
|
||||
t->o.o.mdir.rbyd.blocks[1],
|
||||
t->o.o.mdir.rbyd.cksum,
|
||||
t->ot->mdir.rbyd.cksum);
|
||||
return LFS_ERR_CORRUPT;
|
||||
}
|
||||
|
||||
// start traversing the file
|
||||
const lfsr_file_t *file = (const lfsr_file_t*)t->ot;
|
||||
t->o.bshrub = file->o.bshrub;
|
||||
|
||||
Reference in New Issue
Block a user