rdonly: Dropped LFS3_TSTATE_OMDIRS/OBTREE when LFS3_RDONLY
If we can't write to the filesystem, we can't out out-of-sync files, so
there's no need to traverse open file handles at all.
Saves a bit of code in LFS3_RDONLY mode:
code stack ctx
rdonly before: 10776 840 524
rdonly after: 10664 (-1.0%) 840 (+0.0%) 524 (+0.0%)
In theory we could also skip this check when mounted LFS3_M_RDONLY, but
checking for that flag would add code and we don't really care about
CPU-related performance here.
No code changes in default mode.
This commit is contained in:
@@ -9458,7 +9458,6 @@ enum {
|
|||||||
LFS3_TSTATE_MDIRS = 3,
|
LFS3_TSTATE_MDIRS = 3,
|
||||||
LFS3_TSTATE_MDIR = 4,
|
LFS3_TSTATE_MDIR = 4,
|
||||||
LFS3_TSTATE_BTREE = 5,
|
LFS3_TSTATE_BTREE = 5,
|
||||||
// TODO can we skip open-things when LFS3_RDONLY?
|
|
||||||
LFS3_TSTATE_OMDIRS = 6,
|
LFS3_TSTATE_OMDIRS = 6,
|
||||||
LFS3_TSTATE_OBTREE = 7,
|
LFS3_TSTATE_OBTREE = 7,
|
||||||
LFS3_TSTATE_DONE = 8,
|
LFS3_TSTATE_DONE = 8,
|
||||||
@@ -9673,12 +9672,16 @@ static int lfs3_mtree_traverse_(lfs3_t *lfs3, lfs3_traversal_t *t,
|
|||||||
// scan for blocks/btrees in our opened file list
|
// scan for blocks/btrees in our opened file list
|
||||||
case LFS3_TSTATE_OMDIRS:;
|
case LFS3_TSTATE_OMDIRS:;
|
||||||
// reached end of opened files? return to mdir traversal
|
// reached end of opened files? return to mdir traversal
|
||||||
if (!t->ot) {
|
if (LFS3_IFDEF_RDONLY(
|
||||||
|
// we don't need to traverse these if rdonly
|
||||||
|
true,
|
||||||
|
!t->ot)) {
|
||||||
t->b.o.mdir.mid += 1;
|
t->b.o.mdir.mid += 1;
|
||||||
lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_MDIR);
|
lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_MDIR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef LFS3_RDONLY
|
||||||
// skip unrelated files, we only care about unsync reg files
|
// skip unrelated files, we only care about unsync reg files
|
||||||
// associated with the current mid
|
// associated with the current mid
|
||||||
//
|
//
|
||||||
@@ -9708,6 +9711,7 @@ static int lfs3_mtree_traverse_(lfs3_t *lfs3, lfs3_traversal_t *t,
|
|||||||
*bptr = file->leaf.bptr;
|
*bptr = file->leaf.bptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -9740,11 +9744,15 @@ static int lfs3_mtree_traverse_(lfs3_t *lfs3, lfs3_traversal_t *t,
|
|||||||
lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_OMDIRS);
|
lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_OMDIRS);
|
||||||
continue;
|
continue;
|
||||||
// end of opened btree? go to next opened file
|
// end of opened btree? go to next opened file
|
||||||
} else if (lfs3_t_tstate(t->b.o.flags)
|
} else if (LFS3_IFDEF_RDONLY(
|
||||||
== LFS3_TSTATE_OBTREE) {
|
false,
|
||||||
|
lfs3_t_tstate(t->b.o.flags)
|
||||||
|
== LFS3_TSTATE_OBTREE)) {
|
||||||
|
#ifndef LFS3_RDONLY
|
||||||
t->ot = t->ot->next;
|
t->ot = t->ot->next;
|
||||||
lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_OMDIRS);
|
lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_OMDIRS);
|
||||||
continue;
|
continue;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
LFS3_UNREACHABLE();
|
LFS3_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user