Added simple lfsr_fs_ckmeta/ckdata functions

These functions provide an easy API for checking all metadata/data
checksums in the filesystem:

  // Check the filesystem for metadata errors
  int lfsr_fs_ckmeta(lfs_t *lfs);

  // Check the filesystem for metadata + data errors
  int lfsr_fs_ckdata(lfs_t *lfs);

These are more-or-less the same as calling lfsr_fs_gc with
LFS_GC_CKMETA/CKDATA, but don't involve the gc/traversal-invalidation
machinery, and may be a bit easier for users to pick up.

---

Unfortunately, for simple wrappers, we're again hit with a somewhat
surprising code cost:

           code          stack
  before: 36288           2680
  after:  36472 (+0.5%)   2680 (+0.0%)

But I think we can again blame the high overhead of LFS_TRAVERSAL/
lfsr_mtree_gc. We should look into reducing/deduplicating this logic...
This commit is contained in:
Christopher Haster
2024-07-15 18:05:21 -05:00
parent 83f2a3c7fc
commit 4fe46a983f
3 changed files with 324 additions and 1 deletions
+17 -1
View File
@@ -1165,7 +1165,23 @@ int lfsr_fs_mkconsistent(lfs_t *lfs);
#endif
#ifndef LFS_READONLY
// Attempt any janitorial work that may be pending.
// Check the filesystem for metadata errors
//
// Returns LFS_ERR_CORRUPT if a checksum mismatch is found, or a negative
// error code on failure.
int lfsr_fs_ckmeta(lfs_t *lfs);
#endif
#ifndef LFS_READONLY
// Check the filesystem for metadata + data errors
//
// Returns LFS_ERR_CORRUPT if a checksum mismatch is found, or a negative
// error code on failure.
int lfsr_fs_ckdata(lfs_t *lfs);
#endif
#ifndef LFS_READONLY
// Perform any janitorial work that may be pending.
//
// The exact janitorial work depends on the provided flags. Note multiple
// calls may be required to complete all janitorial work.