From a63b8e15275c7483649b913f0590869e3d9824ef Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sat, 18 Jan 2025 02:52:55 -0600 Subject: [PATCH] Dropped internal LFS_i_UNTIDY pseudo-alias flag We really shouldn't have two names for the same thing, it just makes things more confusing, even if the public name doesn't quite match the internal usage. Especially now that we internally rely on these being the same flag. This renames LFS_i_UNTIDY -> LFS_I_MKCONSISTENT and drops the untidy/ mktidy naming internally. No code changes. --- lfs.c | 33 ++++++++++++++------------------- lfs.h | 3 --- scripts/dbgflags.py | 2 -- tests/test_forphans.toml | 8 ++++---- tests/test_traversal.toml | 16 ++++++++-------- 5 files changed, 26 insertions(+), 36 deletions(-) diff --git a/lfs.c b/lfs.c index a87b7764..60e16b6d 100644 --- a/lfs.c +++ b/lfs.c @@ -6727,11 +6727,6 @@ static inline bool lfsr_m_isckdatacksums(uint32_t flags) { } #endif -// internal fs flags -static inline bool lfsr_i_isuntidy(uint32_t flags) { - return flags & LFS_i_UNTIDY; -} - /// opened mdir things /// @@ -9625,7 +9620,7 @@ eot:; } // needed in lfsr_mtree_gc -static int lfsr_fs_mktidy_(lfs_t *lfs, lfsr_mdir_t *mdir); +static int lfsr_mdir_mkconsistent(lfs_t *lfs, lfsr_mdir_t *mdir); static void lfs_alloc_ckpoint(lfs_t *lfs); static void lfs_alloc_markfree(lfs_t *lfs); @@ -9656,10 +9651,10 @@ dropped:; // mkconsistencing mdirs? if (lfsr_t_ismkconsistent(t->o.o.flags) - && lfsr_i_isuntidy(lfs->flags) + && lfsr_t_ismkconsistent(lfs->flags) && tag == LFSR_TAG_MDIR) { lfsr_mdir_t *mdir = (lfsr_mdir_t*)bptr.data.u.buffer; - err = lfsr_fs_mktidy_(lfs, mdir); + err = lfsr_mdir_mkconsistent(lfs, mdir); if (err) { goto failed; } @@ -9728,7 +9723,7 @@ eot:; // was mkconsistent successful? if (lfsr_t_ismkconsistent(t->o.o.flags) && !lfsr_t_isdirty(t->o.o.flags)) { - lfs->flags &= ~LFS_i_UNTIDY; + lfs->flags &= ~LFS_I_MKCONSISTENT; } // was compaction successful? note we may need multiple passes if @@ -11298,9 +11293,9 @@ static void lfsr_file_close_(lfs_t *lfs, const lfsr_file_t *file) { if (lfsr_grm_count(lfs) < 2) { lfsr_grm_push(lfs, file->o.o.mdir.mid); - // fallback to just marking the filesystem as untidy + // fallback to just marking the filesystem as inconsistent } else { - lfs->flags |= LFS_i_UNTIDY; + lfs->flags |= LFS_I_MKCONSISTENT; } } } @@ -13297,7 +13292,7 @@ static int lfs_init(lfs_t *lfs, uint32_t flags, // setup flags lfs->flags = flags // assume we contain orphans until proven otherwise - | LFS_i_UNTIDY + | LFS_I_MKCONSISTENT // default to an empty lookahead | LFS_I_LOOKAHEAD // default to assuming we need compaction somewhere, worst case @@ -14324,7 +14319,7 @@ int lfsr_fs_stat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) { | LFS_IFDEF_CKFETCHES(LFS_I_CKFETCHES, 0) | LFS_IFDEF_CKPARITY(LFS_I_CKPARITY, 0) | LFS_IFDEF_CKDATACKSUMS(LFS_I_CKDATACKSUMS, 0) - | LFS_I_MKCONSISTENT // synonym for LFS_i_UNTIDY + | LFS_I_MKCONSISTENT | LFS_I_LOOKAHEAD | LFS_I_COMPACT | LFS_I_CKMETA @@ -14424,7 +14419,7 @@ static int lfsr_fs_fixgrm(lfs_t *lfs) { return 0; } -static int lfsr_fs_mktidy_(lfs_t *lfs, lfsr_mdir_t *mdir) { +static int lfsr_mdir_mkconsistent(lfs_t *lfs, lfsr_mdir_t *mdir) { // save the current mid lfsr_mid_t mid = mdir->mid; @@ -14472,7 +14467,7 @@ failed:; return err; } -static int lfsr_fs_mktidy(lfs_t *lfs) { +static int lfsr_fs_fixorphans(lfs_t *lfs) { // LFS_T_MKCONSISTENT really just removes orphans lfsr_traversal_t t; lfsr_traversal_init(&t, LFS_T_MTREEONLY | LFS_T_MKCONSISTENT); @@ -14508,8 +14503,8 @@ int lfsr_fs_mkconsistent(lfs_t *lfs) { // this must happen after fixgrm, since removing orphaned // stickynotes risks outdating the grm // - if (lfsr_i_isuntidy(lfs->flags)) { - int err = lfsr_fs_mktidy(lfs); + if (lfsr_t_ismkconsistent(lfs->flags)) { + int err = lfsr_fs_fixorphans(lfs); if (err) { return err; } @@ -14581,7 +14576,7 @@ static int lfsr_fs_gc_(lfs_t *lfs, lfsr_traversal_t *t, // do we have any pending work? uint32_t pending = flags & ( (lfs->flags & ( - LFS_i_UNTIDY + LFS_I_MKCONSISTENT | LFS_I_LOOKAHEAD | LFS_I_COMPACT | LFS_I_CKMETA @@ -14635,7 +14630,7 @@ static int lfsr_fs_gc_(lfs_t *lfs, lfsr_traversal_t *t, // clear any pending flags we make progress on pending &= lfs->flags & ( - LFS_i_UNTIDY + LFS_I_MKCONSISTENT | LFS_I_LOOKAHEAD | LFS_I_COMPACT | LFS_I_CKMETA diff --git a/lfs.h b/lfs.h index 621459d3..c6fa5870 100644 --- a/lfs.h +++ b/lfs.h @@ -231,9 +231,6 @@ enum lfs_type { #define LFS_I_CKMETA 0x00100000 // Metadata checksums not checked recently #define LFS_I_CKDATA 0x00200000 // Data checksums not checked recently -// internally used flags, don't use these -#define LFS_i_UNTIDY 0x00010000 // Filesystem may have orphaned stickynotes - // Block types enum lfs_btype { diff --git a/scripts/dbgflags.py b/scripts/dbgflags.py index a4b649fa..30443767 100755 --- a/scripts/dbgflags.py +++ b/scripts/dbgflags.py @@ -85,8 +85,6 @@ FLAGS = [ ('M', 'CKMETA', 0x00100000, "Check metadata checksums" ), ('M', 'CKDATA', 0x00200000, "Check metadata + data checksums" ), - ('m', 'UNTIDY', 0x00010000, "Filesystem may have orphaned stickynotes" ), - # GC flags ('GC', 'MKCONSISTENT', 0x00010000, "Make the filesystem consistent" ), diff --git a/tests/test_forphans.toml b/tests/test_forphans.toml index 5551e231..ab006ea6 100644 --- a/tests/test_forphans.toml +++ b/tests/test_forphans.toml @@ -5314,7 +5314,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); struct lfs_fsinfo fsinfo; lfsr_fs_stat(&lfs, &fsinfo) => 0; @@ -5450,7 +5450,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); struct lfs_fsinfo fsinfo; lfsr_fs_stat(&lfs, &fsinfo) => 0; @@ -5600,7 +5600,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); struct lfs_fsinfo fsinfo; lfsr_fs_stat(&lfs, &fsinfo) => 0; @@ -5756,7 +5756,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); struct lfs_fsinfo fsinfo; lfsr_fs_stat(&lfs, &fsinfo) => 0; diff --git a/tests/test_traversal.toml b/tests/test_traversal.toml index 4db31ce3..5c1d6479 100644 --- a/tests/test_traversal.toml +++ b/tests/test_traversal.toml @@ -6458,7 +6458,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -6602,7 +6602,7 @@ code = ''' assert(lfs.grm.mids[1] == -1); // if we introduce actual orphans, me _must not_ clear the orphan flag if (ORPHANS >= 3) { - assert(lfs.flags & LFS_i_UNTIDY); + assert(lfs.flags & LFS_I_MKCONSISTENT); } // if we introduced actual orphans, we _must_ be marked as inconsistent @@ -6759,7 +6759,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -6917,7 +6917,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -7086,7 +7086,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -7253,7 +7253,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -7418,7 +7418,7 @@ code = ''' // we should have cleaned up all grms/orphans assert(lfs.grm.mids[0] == -1); assert(lfs.grm.mids[1] == -1); - assert(!(lfs.flags & LFS_i_UNTIDY)); + assert(!(lfs.flags & LFS_I_MKCONSISTENT)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -7613,7 +7613,7 @@ code = ''' assert(lfs.grm.mids[1] == -1); // if we introduce actual orphans, me _must not_ clear the orphan flag if (ORPHANS >= 3) { - assert(lfs.flags & LFS_i_UNTIDY); + assert(lfs.flags & LFS_I_MKCONSISTENT); } // mdirs should have been compacted