Check gcksum during traversals, harder ckmeta/ckdata tests

This adds a check that the on-disk gcksum matches the in-RAM gcksum
in lfsr_mtree_traverse, so ckmeta/ckdata scans should now be able to
at least detect global-rollback issues that occur while mounted.

This also moves the LFS_I_CKMETA/CKDATA flag clearing logic from
lfsr_mtree_gc -> lfsr_mtree_traverse. There's no reason to not clear
these flags if we've made a successful traversal. We weren't actually
calling lfsr_mtree_traverse with the right flags for this to matter, but
it does let us drop an explicit flag clear in lfsr_fs_ck.

---

These changes were a part of adding the harder versions of our ckmeta/
ckdata tests, where we flip individual bits instead of clobbering the
entire block. These are more realistic errors and stress our gcksum
system.

Recalculating the gcksum required another gcksum copy in
lfsr_traversal_t, which adds a bit of code and ctx to our incremental-gc
build:

                   code          stack          ctx
  default before: 38428           2640          644
  default after:  38560 (+0.3%)   2640 (+0.0%)  644 (+0.0%)

  gc before:      38484           2640          788
  gc after:       38616 (+0.3%)   2640 (+0.0%)  792 (+0.5%)

Unfortunately we can't easily abuse the copies in lfs_t since
multiple traversals may be open at once.
This commit is contained in:
Christopher Haster
2025-01-15 03:34:44 -06:00
parent 1c5adf71b3
commit 57e9c3b706
4 changed files with 886 additions and 34 deletions
+2
View File
@@ -776,6 +776,8 @@ typedef struct lfsr_traversal {
lfsr_btraversal_t bt;
} u;
// recalculate gcksum when traversing with ckmeta
uint32_t gcksum;
// pending blocks, only used in lfsr_traversal_read
lfs_sblock_t blocks[2];
} lfsr_traversal_t;