Extended lfsr_format with some gc flags
These fall out quite naturally when you consider that we call
lfsr_mountinited internally to check that our format was successful.
That being said... they don't really do anything right now since we only
write a single mdir:
- LFS_F_COMPACT - The only gc operation that _might_ actually do
something is LFS_F_COMPACT, but only if our fs config exceeds >1/2 the
block size. But I'm not sure littlefs will even be able to write file
metadata if this happens...
- LFS_F_CKMETA - We already check the only mdir by calling
lfsr_mountinited, which implicitly fetches the mrootanchor.
- LFS_F_CKDATA - We uh, don't have any data immediately after
lfsr_format. But I guess it doesn't hurt to keep this around for
consistency, it at least implies CKMETA.
Hopefully these flags will be more interesting if/when we start adding
auxiliary trees to the filesystem, otherwise they may be worth reverting
in the future...
Until then, they at least provide some consistency, and I guess a way to
triply check that format was successful.
---
This could probably be better deduplicated, but calling lfsr_fs_gc from
both lfsr_mount and lfsr_format provides a bit better code organization:
code stack
before: 36448 2680
after: 36480 (+0.1%) 2680 (+0.0%)
This commit is contained in:
+39
-7
@@ -11,14 +11,28 @@ code = '''
|
||||
lfsr_unmount(&lfs) => 0;
|
||||
'''
|
||||
|
||||
# test that various mount flags are returned by lfsr_fs_stat
|
||||
# test that various mount flags don't assert and are returned by
|
||||
# lfsr_fs_stat
|
||||
[cases.test_mount_flags]
|
||||
defines.RDONLY = [false, true]
|
||||
defines.CKPROGS = [false, true]
|
||||
defines.CKREADS = [false, true]
|
||||
defines.FLUSH = [false, true]
|
||||
defines.SYNC = [false, true]
|
||||
if = 'LFS_IFDEF_CKREADS(true, !CKREADS)'
|
||||
defines.MTREEONLY = [false, true]
|
||||
defines.MKCONSISTENT = [false, true]
|
||||
defines.LOOKAHEAD = [false, true]
|
||||
defines.COMPACT = [false, true]
|
||||
defines.CKMETA = [false, true]
|
||||
defines.CKDATA = [false, true]
|
||||
if = [
|
||||
'LFS_IFDEF_CKREADS(true, !CKREADS)',
|
||||
'!RDONLY || !MKCONSISTENT',
|
||||
'!RDONLY || !LOOKAHEAD',
|
||||
'!RDONLY || !COMPACT',
|
||||
'!MTREEONLY || !LOOKAHEAD',
|
||||
'!MTREEONLY || !CKDATA',
|
||||
]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
@@ -27,9 +41,16 @@ code = '''
|
||||
| ((CKPROGS) ? LFS_M_CKPROGS : 0)
|
||||
| ((CKREADS) ? LFS_IFDEF_CKREADS(LFS_M_CKREADS, 0) : 0)
|
||||
| ((FLUSH) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC) ? LFS_M_SYNC : 0),
|
||||
| ((SYNC) ? LFS_M_SYNC : 0)
|
||||
| ((MTREEONLY) ? LFS_M_MTREEONLY : 0)
|
||||
| ((MKCONSISTENT) ? LFS_M_MKCONSISTENT : 0)
|
||||
| ((LOOKAHEAD) ? LFS_M_LOOKAHEAD : 0)
|
||||
| ((COMPACT) ? LFS_M_COMPACT : 0)
|
||||
| ((CKMETA) ? LFS_M_CKMETA : 0)
|
||||
| ((CKDATA) ? LFS_M_CKDATA : 0),
|
||||
CFG) => 0;
|
||||
|
||||
// lfsr_fs_stat only returns some flags
|
||||
struct lfs_fsinfo fsinfo;
|
||||
lfsr_fs_stat(&lfs, &fsinfo) => 0;
|
||||
assert(fsinfo.flags == (
|
||||
@@ -38,8 +59,8 @@ code = '''
|
||||
| ((CKREADS) ? LFS_IFDEF_CKREADS(LFS_I_CKREADS, 0) : 0)
|
||||
| ((FLUSH) ? LFS_I_FLUSH : 0)
|
||||
| ((SYNC) ? LFS_I_SYNC : 0)
|
||||
| LFS_I_CANLOOKAHEAD
|
||||
| LFS_I_UNCOMPACTED));
|
||||
| ((!LOOKAHEAD) ? LFS_I_CANLOOKAHEAD : 0)
|
||||
| ((!COMPACT) ? LFS_I_UNCOMPACTED : 0)));
|
||||
|
||||
lfsr_unmount(&lfs) => 0;
|
||||
'''
|
||||
@@ -50,13 +71,24 @@ code = '''
|
||||
[cases.test_mount_format_flags]
|
||||
defines.CKPROGS = [false, true]
|
||||
defines.CKREADS = [false, true]
|
||||
if = 'LFS_IFDEF_CKREADS(true, !CKREADS)'
|
||||
defines.MTREEONLY = [false, true]
|
||||
defines.COMPACT = [false, true]
|
||||
defines.CKMETA = [false, true]
|
||||
defines.CKDATA = [false, true]
|
||||
if = [
|
||||
'LFS_IFDEF_CKREADS(true, !CKREADS)',
|
||||
'!MTREEONLY || !CKDATA',
|
||||
]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs,
|
||||
LFS_F_RDWR
|
||||
| ((CKPROGS) ? LFS_F_CKPROGS : 0)
|
||||
| ((CKREADS) ? LFS_IFDEF_CKREADS(LFS_F_CKREADS, 0) : 0),
|
||||
| ((CKREADS) ? LFS_IFDEF_CKREADS(LFS_F_CKREADS, 0) : 0)
|
||||
| ((MTREEONLY) ? LFS_M_MTREEONLY : 0)
|
||||
| ((COMPACT) ? LFS_M_COMPACT : 0)
|
||||
| ((CKMETA) ? LFS_M_CKMETA : 0)
|
||||
| ((CKDATA) ? LFS_M_CKDATA : 0),
|
||||
CFG) => 0;
|
||||
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
Reference in New Issue
Block a user