From 80ef963bece0e600eb80bf4d04ce0cd696f175da Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 12 Aug 2024 15:42:05 -0500 Subject: [PATCH] Renamed LFS_I_ORPHANS -> LFS_I_HASORPHANS This better matches how other flags sometimes include the relevant verb, LFS_RBYD_ISSHRUB, LFSR_DATA_ONDISK, etc, and feels a bit more consistent. --- lfs.c | 12 ++++++------ lfs.h | 3 ++- tests/test_forphans.toml | 6 +++--- tests/test_traversal.toml | 16 ++++++++-------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lfs.c b/lfs.c index 88ef79c3..52655737 100644 --- a/lfs.c +++ b/lfs.c @@ -6701,7 +6701,7 @@ static inline bool lfsr_m_issync(uint32_t flags) { // internal fs flags static inline bool lfsr_i_hasorphans(uint32_t flags) { - return flags & LFS_I_ORPHANS; + return flags & LFS_I_HASORPHANS; } static inline bool lfsr_i_isuncompacted(uint32_t flags) { @@ -9529,7 +9529,7 @@ eot:; // was mkconsistent successful? if (lfsr_t_ismkconsistent(t->o.o.flags) && !lfsr_t_isdirty(t->o.o.flags)) { - lfs->flags &= ~LFS_I_ORPHANS; + lfs->flags &= ~LFS_I_HASORPHANS; } // was compaction successful? note we may need multiple passes if @@ -10817,7 +10817,7 @@ int lfsr_file_close(lfs_t *lfs, lfsr_file_t *file) { // fallback to just marking the filesystem as orphaned } else { - lfs->flags |= LFS_I_ORPHANS; + lfs->flags |= LFS_I_HASORPHANS; } } @@ -13275,7 +13275,7 @@ static int lfsr_mountinited(lfs_t *lfs) { "%"PRId32".%"PRId32, lfsr_mid_bid(lfs, mdir->mid) >> lfs->mdir_bits, rid); - lfs->flags |= LFS_I_ORPHANS; + lfs->flags |= LFS_I_HASORPHANS; // found an unknown file type? } else if (lfsr_tag_isunknown(tag)) { @@ -13830,7 +13830,7 @@ int lfsr_fs_gc(lfs_t *lfs, lfs_soff_t steps, uint32_t flags) { // do we have any pending work? uint32_t pending = flags & ( ((lfs->flags & ( - LFS_I_ORPHANS + LFS_I_HASORPHANS | LFS_I_UNCOMPACTED)) >> 16) | ((lfsr_fs_canlookahead(lfs)) ? LFS_GC_LOOKAHEAD : 0) | LFS_GC_CKMETA @@ -13895,7 +13895,7 @@ int lfsr_fs_gc(lfs_t *lfs, lfs_soff_t steps, uint32_t flags) { // clear any pending flags we make progress on pending &= ( ((lfs->flags & ( - LFS_I_ORPHANS + LFS_I_HASORPHANS | LFS_I_UNCOMPACTED)) >> 16) | ((lfsr_fs_canlookahead(lfs)) ? LFS_GC_LOOKAHEAD : 0) // only consider our filesystem checked if we diff --git a/lfs.h b/lfs.h index f396edca..927a256e 100644 --- a/lfs.h +++ b/lfs.h @@ -198,7 +198,8 @@ enum lfs_type { 0x08000000 // Filesystem may have uncompacted metadata // internally used flags, don't use these -#define LFS_I_ORPHANS 0x01000000 // Filesystem may have untracked orphans +#define LFS_I_HASORPHANS \ + 0x01000000 // Filesystem may have untracked orphans // Block types diff --git a/tests/test_forphans.toml b/tests/test_forphans.toml index 3ee9c581..62280b48 100644 --- a/tests/test_forphans.toml +++ b/tests/test_forphans.toml @@ -4701,7 +4701,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_ORPHANS)); + assert(!(lfs.flags & LFS_I_HASORPHANS)); struct lfs_fsinfo fsinfo; lfsr_fs_stat(&lfs, &fsinfo) => 0; @@ -4835,7 +4835,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_ORPHANS)); + assert(!(lfs.flags & LFS_I_HASORPHANS)); struct lfs_fsinfo fsinfo; lfsr_fs_stat(&lfs, &fsinfo) => 0; @@ -4983,7 +4983,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_ORPHANS)); + assert(!(lfs.flags & LFS_I_HASORPHANS)); struct lfs_fsinfo fsinfo; lfsr_fs_stat(&lfs, &fsinfo) => 0; diff --git a/tests/test_traversal.toml b/tests/test_traversal.toml index 41b786be..8c9c4304 100644 --- a/tests/test_traversal.toml +++ b/tests/test_traversal.toml @@ -6327,7 +6327,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_ORPHANS)); + assert(!(lfs.flags & LFS_I_HASORPHANS)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -6466,7 +6466,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_ORPHANS); + assert(lfs.flags & LFS_I_HASORPHANS); } // if we introduced actual orphans, we _must_ be marked as inconsistent @@ -6618,7 +6618,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_ORPHANS)); + assert(!(lfs.flags & LFS_I_HASORPHANS)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -6771,7 +6771,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_ORPHANS)); + assert(!(lfs.flags & LFS_I_HASORPHANS)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -6935,7 +6935,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_ORPHANS)); + assert(!(lfs.flags & LFS_I_HASORPHANS)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -7097,7 +7097,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_ORPHANS)); + assert(!(lfs.flags & LFS_I_HASORPHANS)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -7257,7 +7257,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_ORPHANS)); + assert(!(lfs.flags & LFS_I_HASORPHANS)); // which means there shouldn't be that many files left assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits)); @@ -7445,7 +7445,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_ORPHANS); + assert(lfs.flags & LFS_I_HASORPHANS); } // mdirs should have been compacted