gc: Renamed lfsr_gc -> lfsr_fs_gc, keep lfsr_fs_unck in non-gc

- lfsr_gc -> lfsr_fs_gc
- lfsr_gc_unck -> lfsr_fs_unck

lfsr_fs_unck is surprisingly still useful in non-gc builds, since we
still have ckmeta/ckdata state. These flags can still be queried with
lfsr_fs_stat and cleared with lfsr_fs_ckmeta/ckdata/lfsr_traversal_t, so
it seems useful to keep this function around.

It's also a relatively cheap function.

Though this does mean it deserves a rename. Dropping the gc prefix
hopefully makes it clearer this function is not entirely gc-specific.

And since we no longer have lfsr_gc_setflags/setsteps, it makes sense to
rename lfsr_gc back to lfsr_fs_gc, to be consistent with the other
filesystem-wide utilities.

Code changes, apparently lfsr_fs_unck costs 12 bytes:

                   code          stack          ctx
  default before: 37792           2608          620
  default after:  37804 (+0.0%)   2608 (+0.0%)  620 (+0.0%)

  gc before:      37938           2608          768
  gc after:       37940 (+0.0%)   2608 (+0.0%)  768 (+0.0%)
This commit is contained in:
Christopher Haster
2025-01-08 02:31:49 -06:00
parent 39d488a1ef
commit 9c9a23e27b
5 changed files with 126 additions and 131 deletions
+24 -29
View File
@@ -1258,35 +1258,6 @@ int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *t,
int lfsr_traversal_rewind(lfs_t *lfs, lfsr_traversal_t *t);
/// Incremental gc operations ///
#ifdef LFS_GC
// Perform any janitorial work that may be pending.
//
// The exact janitorial work depends on the configured flags and steps.
//
// Calling this function is not required, but may allow the offloading of
// expensive janitorial work to a less time-critical code path.
//
// Returns a negative error code on failure.
int lfsr_gc(lfs_t *lfs);
#endif
#ifdef LFS_GC
// Mark janitorial work as incomplete.
//
// Any info flags passed to lfsr_gc_unck will be reset internally,
// forcing the work to be redone.
//
// This is most useful for triggering new ckmeta/ckdata scans with
// LFS_I_CANCKMETA and LFS_I_CANCKDATA. Otherwise littlefs will perform
// only one scan after mount.
//
// Returns a negative error code on failure.
int lfsr_gc_unck(lfs_t *lfs, uint32_t flags);
#endif
/// Filesystem-level filesystem operations
// Find on-disk info about the filesystem
@@ -1341,6 +1312,30 @@ int lfsr_fs_ckmeta(lfs_t *lfs);
int lfsr_fs_ckdata(lfs_t *lfs);
#endif
#ifdef LFS_GC
// Perform any janitorial work that may be pending
//
// The exact janitorial work depends on the configured flags and steps.
//
// Calling this function is not required, but may allow the offloading of
// expensive janitorial work to a less time-critical code path.
//
// Returns a negative error code on failure.
int lfsr_fs_gc(lfs_t *lfs);
#endif
// Mark janitorial work as incomplete
//
// Any info flags passed to lfsr_gc_unck will be reset internally,
// forcing the work to be redone.
//
// This is most useful for triggering new ckmeta/ckdata scans with
// LFS_I_CANCKMETA and LFS_I_CANCKDATA. Otherwise littlefs will perform
// only one scan after mount.
//
// Returns a negative error code on failure.
int lfsr_fs_unck(lfs_t *lfs, uint32_t flags);
#ifndef LFS_READONLY
// Change the number of blocks used by the filesystem
//