Added format flags to lfsr_format
This is mainly to solve the weird check-hole where passing CKPROGS/
CKREADS as mount flags has no effect on lfsr_format (I mean, it'd be a
bit silly if it did somehow):
LFS_F_RDWR 0 // Format the filesystem as read and write
LFS_F_CKPROGS 0x00000010 // Check progs by reading back progged data
LFS_F_CKREADS 0x00000020 // Check reads via parity bits/checksums
This makes lfsr_format a more cumbersome interface, but I don't know if
this is necessarily a bad thing. There's always risk of data loss when
calling lfsr_format, so maybe it should be a pain to call.
At the very least, format flags may be useful in the future for
enabling/disabling format-time things such as the planned block-map,
parity-tree, etc. Though it's unclear if such significant settings
should be format flags or somehow encoded as fields in our config
struct.
---
The LFS_F_* format flags of course ended up conflicting with our
internal LFS_F_* flags, so I renamed most of the internal flags to match
the closest flag set they participate in:
- LFS_F_TYPE -> LFS_O_TYPE
- LFS_F_UNFLUSH -> LFS_O_UNFLUSH
- LFS_F_UNSYNC -> LFS_O_UNSYNC
- LFS_F_ORPHAN -> LFS_O_ORPHAN
- LFS_F_ZOMBIE -> LFS_O_ZOMBIE
- LFS_F_ORPHANS -> LFS_I_ORPHANS
- LFS_F_UNCOMPACTED -> LFS_I_UNCOMPACTED
- LFS_F_TSTATE -> LFS_T_TSTATE
- LFS_F_BTYPE -> LFS_T_BTYPE
- LFS_F_DIRTY -> LFS_T_DIRTY
- LFS_F_MUTATED -> LFS_T_MUTATED
This may make it a bit less clear which flags are a part of the public
API, vs intended only for internal use, but at the very least our asserts
in format/mount/open/etc should catch most of these mistakes.
---
Code cost ended up being pretty minimal. Actually negative. This is the
second time we're _adding_ a feature that somehow saves code, though the
reality for this one is we're really just pushing constants up into the
user's stack frame. Still, it's a good indication the cost of format
flags is small:
code stack
before: 36452 2680
after: 36448 (-0.0%) 2680 (+0.0%)
This commit is contained in:
+30
-30
@@ -6,7 +6,7 @@ after = 'test_fwrite'
|
||||
[cases.test_fsync_sync_wrr]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -107,7 +107,7 @@ code = '''
|
||||
[cases.test_fsync_sync_wwrr]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -227,7 +227,7 @@ code = '''
|
||||
[cases.test_fsync_sync_wwrr_noop]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -361,7 +361,7 @@ code = '''
|
||||
[cases.test_fsync_sync_wwrr_append]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -497,7 +497,7 @@ defines.SIZE = [
|
||||
defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// create a file
|
||||
@@ -548,7 +548,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// create a file
|
||||
@@ -613,7 +613,7 @@ defines.SIZE = [
|
||||
defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -710,7 +710,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -817,7 +817,7 @@ defines.SIZE = [
|
||||
defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -909,7 +909,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -1006,7 +1006,7 @@ defines.SIZE = [
|
||||
defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -1115,7 +1115,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -1233,7 +1233,7 @@ defines.SIZE = [
|
||||
defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -1341,7 +1341,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -1460,7 +1460,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -1601,7 +1601,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
@@ -1773,7 +1773,7 @@ code = '''
|
||||
[cases.test_fsync_desync_wdrr]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -1860,7 +1860,7 @@ code = '''
|
||||
[cases.test_fsync_desync_wrrd]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -1940,7 +1940,7 @@ code = '''
|
||||
[cases.test_fsync_desync_wdwdrr]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -2061,7 +2061,7 @@ code = '''
|
||||
[cases.test_fsync_desync_wdwdrr_noop]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -2163,7 +2163,7 @@ code = '''
|
||||
[cases.test_fsync_desync_wrrd_noop]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -2265,7 +2265,7 @@ code = '''
|
||||
[cases.test_fsync_desync_wdwdrr_append]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// a - writer
|
||||
@@ -2411,7 +2411,7 @@ defines.SIZE = [
|
||||
defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// create a file
|
||||
@@ -2507,7 +2507,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// create a file
|
||||
@@ -2613,7 +2613,7 @@ defines.SIZE = [
|
||||
defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// create a file
|
||||
@@ -2701,7 +2701,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// create a file
|
||||
@@ -2799,7 +2799,7 @@ defines.SIZE = [
|
||||
defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// create a file
|
||||
@@ -2910,7 +2910,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
// create a file
|
||||
@@ -3028,7 +3028,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
uint32_t prng = 42;
|
||||
@@ -3178,7 +3178,7 @@ defines.SEED = 'range(20)'
|
||||
fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_format(&lfs, LFS_F_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
|
||||
uint32_t prng = 42;
|
||||
|
||||
Reference in New Issue
Block a user