Dropped the HASORPHAN scan in lfsr_mount
The motivation here is to simplify lfsr_mount, but there's a number of
knock-on effects.
For one, lfsr_mount should now be faster on filesystems with large
blocks:
O(nb(log b)(log_b n)) -> O(nb(log_b n))
But we now no longer check if our filesystem contains orphaned
stickynotes or unknown filetypes:
- Orphaned stickynotes turned out to not be a big deal. If we find
orphans we'd need to do a second traversal to remove them anyways (no
mutation allowed in lfsr_mount), so this actually ends up a net
improvement in the found-orphan case.
If anything, doing a traversal on first write sets user expectations
correctly, and can be offloaded with lfsr_fs_mkconsistent or
lfsr_fs_gc.
- Unknown filetypes are a bit more annoying (I actually forgot about
this check), but unknown filetypes that require special care should
probably set WCOMPAT/RCOMPAT flags.
Allowing unknown filetypes is a bit more flexible in cases where a
filesystem image is being shared between drivers with different
features (bootloader + app for example).
Though we should probably add more checks/tests that we're handling
these correctly now that we no longer just bail during mount...
Also renamed LFS_I_HASORPHANS -> LFS_I_UNTIDY.
Not doing something is cheaper than doing something, so this saves a bit
of code:
code stack ctx
before: 38120 2624 752
after: 38020 (-0.3%) 2624 (+0.0%) 752 (+0.0%)
This commit is contained in:
+12
-10
@@ -1680,7 +1680,8 @@ code = '''
|
||||
struct lfs_fsinfo fsinfo;
|
||||
lfsr_fs_stat(&lfs, &fsinfo) => 0;
|
||||
assert(fsinfo.flags == (
|
||||
LFS_I_CANLOOKAHEAD
|
||||
LFS_I_INCONSISTENT
|
||||
| LFS_I_CANLOOKAHEAD
|
||||
| LFS_I_UNCOMPACTED));
|
||||
|
||||
// try traversing
|
||||
@@ -1704,7 +1705,8 @@ code = '''
|
||||
// check flags after
|
||||
lfsr_fs_stat(&lfs, &fsinfo) => 0;
|
||||
assert(fsinfo.flags == (
|
||||
((!LOOKAHEAD) ? LFS_I_CANLOOKAHEAD : 0)
|
||||
((!MKCONSISTENT) ? LFS_I_INCONSISTENT : 0)
|
||||
| ((!LOOKAHEAD) ? LFS_I_CANLOOKAHEAD : 0)
|
||||
| ((!COMPACT) ? LFS_I_UNCOMPACTED : 0)));
|
||||
|
||||
lfsr_unmount(&lfs) => 0;
|
||||
@@ -6327,7 +6329,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_HASORPHANS));
|
||||
assert(!(lfs.flags & LFS_I_UNTIDY));
|
||||
|
||||
// which means there shouldn't be that many files left
|
||||
assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits));
|
||||
@@ -6466,7 +6468,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_HASORPHANS);
|
||||
assert(lfs.flags & LFS_I_UNTIDY);
|
||||
}
|
||||
|
||||
// if we introduced actual orphans, we _must_ be marked as inconsistent
|
||||
@@ -6618,7 +6620,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_HASORPHANS));
|
||||
assert(!(lfs.flags & LFS_I_UNTIDY));
|
||||
|
||||
// which means there shouldn't be that many files left
|
||||
assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits));
|
||||
@@ -6771,7 +6773,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_HASORPHANS));
|
||||
assert(!(lfs.flags & LFS_I_UNTIDY));
|
||||
|
||||
// which means there shouldn't be that many files left
|
||||
assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits));
|
||||
@@ -6935,7 +6937,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_HASORPHANS));
|
||||
assert(!(lfs.flags & LFS_I_UNTIDY));
|
||||
|
||||
// which means there shouldn't be that many files left
|
||||
assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits));
|
||||
@@ -7097,7 +7099,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_HASORPHANS));
|
||||
assert(!(lfs.flags & LFS_I_UNTIDY));
|
||||
|
||||
// which means there shouldn't be that many files left
|
||||
assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits));
|
||||
@@ -7257,7 +7259,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_HASORPHANS));
|
||||
assert(!(lfs.flags & LFS_I_UNTIDY));
|
||||
|
||||
// which means there shouldn't be that many files left
|
||||
assert((lfs.mtree.u.weight & 0x7fffffff) <= (2 << lfs.mdir_bits));
|
||||
@@ -7445,7 +7447,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_HASORPHANS);
|
||||
assert(lfs.flags & LFS_I_UNTIDY);
|
||||
}
|
||||
|
||||
// mdirs should have been compacted
|
||||
|
||||
Reference in New Issue
Block a user