Added mount-time LFS_M_FLUSH/SYNC
These simply imply LFS_O_FLUSH/SYNC on all open writable files.
LFS_M_SYNC is equivalent to MS_SYNCHRONOUS in Linux/etc, while
LFS_M_FLUSH is just provided for consistency.
As pure conveniences, these may seem a bit out of scope for littlefs,
except they are _very_ cheap:
code stack
before: 36356 2664
after: 36356 (+0.0%) 2664 (+0.0%)
Ok, they're not _completely_ free! It just turns out they cost 8 bytes,
and a bit of simplification around flag checking in lfsr_mount saved
8 bytes:
code stack
before: 36356 2664
m_flush/sync: 36364 (+0.0%) 2664 (+0.0%)
mount-no-mask: 36356 (+0.0%) 2664 (+0.0%)
This commit is contained in:
@@ -6028,6 +6028,14 @@ static inline bool lfsr_m_isckprogs(uint32_t flags) {
|
||||
return flags & LFS_M_CKPROGS;
|
||||
}
|
||||
|
||||
static inline bool lfsr_m_isflush(uint32_t flags) {
|
||||
return flags & LFS_M_FLUSH;
|
||||
}
|
||||
|
||||
static inline bool lfsr_m_issync(uint32_t flags) {
|
||||
return flags & LFS_M_SYNC;
|
||||
}
|
||||
|
||||
// internal fs flags
|
||||
static inline bool lfsr_f_hasorphans(uint32_t flags) {
|
||||
return flags & LFS_F_ORPHANS;
|
||||
@@ -9933,7 +9941,9 @@ int lfsr_file_opencfg(lfs_t *lfs, lfsr_file_t *file,
|
||||
}
|
||||
|
||||
// setup file state
|
||||
file->o.o.flags = lfsr_f_settype(flags, LFS_TYPE_REG);
|
||||
file->o.o.flags = lfsr_f_settype(flags, LFS_TYPE_REG)
|
||||
// mounted with LFS_M_FLUSH/SYNC? implies LFS_O_FLUSH/SYNC
|
||||
| (lfs->flags & (LFS_M_FLUSH | LFS_M_SYNC));
|
||||
file->cfg = cfg;
|
||||
file->pos = 0;
|
||||
file->eblock = 0;
|
||||
@@ -11839,12 +11849,6 @@ static int lfs_init(lfs_t *lfs, uint32_t flags,
|
||||
lfs->cfg = cfg;
|
||||
int err = 0;
|
||||
|
||||
// unknown flags?
|
||||
LFS_ASSERT((flags & ~(
|
||||
LFS_M_RDWR
|
||||
| LFS_M_RDONLY
|
||||
| LFS_M_CKPROGS)) == 0);
|
||||
|
||||
// validate that the lfs-cfg sizes were initiated properly before
|
||||
// performing any arithmetic logics with them
|
||||
LFS_ASSERT(lfs->cfg->read_size != 0);
|
||||
@@ -12632,6 +12636,8 @@ int lfsr_mount(lfs_t *lfs, uint32_t flags,
|
||||
LFS_M_RDWR
|
||||
| LFS_M_RDONLY
|
||||
| LFS_M_CKPROGS
|
||||
| LFS_M_FLUSH
|
||||
| LFS_M_SYNC
|
||||
| LFS_M_MTREEONLY
|
||||
| LFS_M_MKCONSISTENT
|
||||
| LFS_M_LOOKAHEAD
|
||||
@@ -12639,16 +12645,7 @@ int lfsr_mount(lfs_t *lfs, uint32_t flags,
|
||||
| LFS_M_CKMETA
|
||||
| LFS_M_CKDATA)) == 0);
|
||||
|
||||
int err = lfs_init(lfs,
|
||||
// strip out the one-time traversal flags
|
||||
flags & ~(
|
||||
LFS_M_MTREEONLY
|
||||
| LFS_M_MKCONSISTENT
|
||||
| LFS_M_LOOKAHEAD
|
||||
| LFS_M_COMPACT
|
||||
| LFS_M_CKMETA
|
||||
| LFS_M_CKDATA),
|
||||
cfg);
|
||||
int err = lfs_init(lfs, flags, cfg);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
@@ -12811,6 +12808,8 @@ int lfsr_fs_stat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
|
||||
fsinfo->flags = lfs->flags & (
|
||||
LFS_I_RDONLY
|
||||
| LFS_I_CKPROGS
|
||||
| LFS_I_FLUSH
|
||||
| LFS_I_SYNC
|
||||
| LFS_I_UNCOMPACTED);
|
||||
// some flags we calculate on demand
|
||||
fsinfo->flags |= (lfsr_fs_isinconsistent(lfs)) ? LFS_I_INCONSISTENT : 0;
|
||||
|
||||
@@ -155,6 +155,8 @@ enum lfs_type {
|
||||
#define LFS_M_RDWR 0 // Mount the filesystem as read and write
|
||||
#define LFS_M_RDONLY 1 // Mount the filesystem as read only
|
||||
#define LFS_M_CKPROGS 0x00000010 // Check progs by reading back progged data
|
||||
#define LFS_M_FLUSH 0x00000040 // Open all files with LFS_O_FLUSH
|
||||
#define LFS_M_SYNC 0x00000080 // Open all files with LFS_O_SYNC
|
||||
|
||||
#define LFS_M_MTREEONLY \
|
||||
0x00010000 // Only traverse the mtree
|
||||
@@ -173,7 +175,9 @@ enum lfs_type {
|
||||
|
||||
// Filesystem info flags
|
||||
#define LFS_I_RDONLY 0x00000001 // Filesystem mounted read only
|
||||
#define LFS_I_CKPROGS 0x00000010 // Check progs by reading back progged data
|
||||
#define LFS_I_CKPROGS 0x00000010 // Filesystem mounted with LFS_M_CKPROGS
|
||||
#define LFS_I_FLUSH 0x00000040 // Filesystem mounted with LFS_M_FLUSH
|
||||
#define LFS_I_SYNC 0x00000080 // Filesystem mounted with LFS_M_SYNC
|
||||
|
||||
#define LFS_I_INCONSISTENT \
|
||||
0x01000000 // Filesystem needs mkconsistent to write
|
||||
|
||||
+138
-78
@@ -592,14 +592,16 @@ code = '''
|
||||
# Test one writer, multiple readers
|
||||
[cases.test_fsync_wrrr]
|
||||
defines.R = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
'2*FILE_BUFFER_SIZE',
|
||||
@@ -612,7 +614,11 @@ defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
// create a file
|
||||
uint32_t prng = 42;
|
||||
@@ -680,14 +686,16 @@ code = '''
|
||||
|
||||
[cases.test_fsync_wrrr_fuzz]
|
||||
defines.R = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.N = 20
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
@@ -703,7 +711,11 @@ fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
// create a file
|
||||
uint32_t prng = 42;
|
||||
@@ -784,14 +796,16 @@ code = '''
|
||||
# Test multiple writers
|
||||
[cases.test_fsync_wwww]
|
||||
defines.W = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
'2*FILE_BUFFER_SIZE',
|
||||
@@ -804,7 +818,11 @@ defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
// create a file
|
||||
uint32_t prng = 42;
|
||||
@@ -867,14 +885,16 @@ code = '''
|
||||
|
||||
[cases.test_fsync_wwww_fuzz]
|
||||
defines.W = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.N = 20
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
@@ -890,7 +910,11 @@ fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
// create a file
|
||||
uint32_t prng = 42;
|
||||
@@ -961,14 +985,16 @@ code = '''
|
||||
[cases.test_fsync_wwrr]
|
||||
defines.W = 4
|
||||
defines.R = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
'2*FILE_BUFFER_SIZE',
|
||||
@@ -981,7 +1007,11 @@ defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
// create a file
|
||||
uint32_t prng = 42;
|
||||
@@ -1061,14 +1091,16 @@ code = '''
|
||||
[cases.test_fsync_wwrr_fuzz]
|
||||
defines.W = 4
|
||||
defines.R = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.N = 20
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
@@ -1084,7 +1116,11 @@ fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
// create a file
|
||||
uint32_t prng = 42;
|
||||
@@ -1176,14 +1212,16 @@ code = '''
|
||||
# Test multiple rd/wrers
|
||||
[cases.test_fsync_rwrw]
|
||||
defines.RW = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
'2*FILE_BUFFER_SIZE',
|
||||
@@ -1196,7 +1234,11 @@ defines.CHUNK = '(SIZE+16-1) / 16'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
// create a file
|
||||
uint32_t prng = 42;
|
||||
@@ -1275,14 +1317,16 @@ code = '''
|
||||
|
||||
[cases.test_fsync_rwrw_fuzz]
|
||||
defines.RW = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.N = 20
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
@@ -1298,7 +1342,11 @@ fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
// create a file
|
||||
uint32_t prng = 42;
|
||||
@@ -1388,14 +1436,16 @@ code = '''
|
||||
# Test multiple rw files without fixed size
|
||||
[cases.test_fsync_rwrw_sparse_fuzz]
|
||||
defines.RW = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.N = 40
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
@@ -1411,7 +1461,11 @@ fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
uint32_t prng = 42;
|
||||
uint8_t between[RW][SIZE];
|
||||
@@ -1523,14 +1577,16 @@ code = '''
|
||||
# Test multiple rw files while also truncating/fruncating
|
||||
[cases.test_fsync_rwtfrwtf_sparse_fuzz]
|
||||
defines.RW = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
# SYNC=3 => sync via LFS_M_SYNC
|
||||
defines.SYNC = [0, 1, 2, 3]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
# FLUSH=2 => flush via LFS_O_FLUSH
|
||||
defines.FLUSH = [0, 1, 2]
|
||||
# FLUSH=3 => flush via LFS_M_FLUSH
|
||||
defines.FLUSH = [0, 1, 2, 3]
|
||||
defines.N = 40
|
||||
defines.SIZE = [
|
||||
'FILE_BUFFER_SIZE/2',
|
||||
@@ -1546,7 +1602,11 @@ fuzz = 'SEED'
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs, LFS_M_RDWR, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
LFS_M_RDWR
|
||||
| ((FLUSH == 3) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC == 3) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
uint32_t prng = 42;
|
||||
uint8_t between[RW][SIZE];
|
||||
@@ -2332,9 +2392,9 @@ code = '''
|
||||
# Test one desynced writer, multiple readers
|
||||
[cases.test_fsync_drrr]
|
||||
defines.R = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
@@ -2425,9 +2485,9 @@ code = '''
|
||||
|
||||
[cases.test_fsync_drrr_fuzz]
|
||||
defines.R = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
@@ -2534,9 +2594,9 @@ code = '''
|
||||
# Test one writer, multiple desynced readers
|
||||
[cases.test_fsync_wddd]
|
||||
defines.R = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
@@ -2619,9 +2679,9 @@ code = '''
|
||||
|
||||
[cases.test_fsync_wddd_fuzz]
|
||||
defines.R = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
@@ -2720,9 +2780,9 @@ code = '''
|
||||
# Test multiple desynced rd/wrers
|
||||
[cases.test_fsync_rwdrwd]
|
||||
defines.RW = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
@@ -2828,9 +2888,9 @@ code = '''
|
||||
|
||||
[cases.test_fsync_rwdrwd_fuzz]
|
||||
defines.RW = 4
|
||||
# FLUSH=0 => no sync, readers not updated
|
||||
# FLUSH=1 => sync via lfsr_file_sync
|
||||
# FLUSH=2 => sync via LFS_O_SYNC
|
||||
# SYNC=0 => no sync, readers not updated
|
||||
# SYNC=1 => sync via lfsr_file_sync
|
||||
# SYNC=2 => sync via LFS_O_SYNC
|
||||
defines.SYNC = [0, 1, 2]
|
||||
# FLUSH=0 => no flush
|
||||
# FLUSH=1 => flush via lfsr_file_flush
|
||||
|
||||
@@ -14,12 +14,16 @@ code = '''
|
||||
[cases.test_mount_flags]
|
||||
defines.RDONLY = [false, true]
|
||||
defines.CKPROGS = [false, true]
|
||||
defines.FLUSH = [false, true]
|
||||
defines.SYNC = [false, true]
|
||||
code = '''
|
||||
lfs_t lfs;
|
||||
lfsr_format(&lfs, CFG) => 0;
|
||||
lfsr_mount(&lfs,
|
||||
((RDONLY) ? LFS_M_RDONLY : LFS_M_RDWR)
|
||||
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
|
||||
| ((CKPROGS) ? LFS_M_CKPROGS : 0)
|
||||
| ((FLUSH) ? LFS_M_FLUSH : 0)
|
||||
| ((SYNC) ? LFS_M_SYNC : 0),
|
||||
CFG) => 0;
|
||||
|
||||
struct lfs_fsinfo fsinfo;
|
||||
@@ -27,6 +31,8 @@ code = '''
|
||||
assert(fsinfo.flags == (
|
||||
((RDONLY) ? LFS_I_RDONLY : 0)
|
||||
| ((CKPROGS) ? LFS_I_CKPROGS : 0)
|
||||
| ((FLUSH) ? LFS_I_FLUSH : 0)
|
||||
| ((SYNC) ? LFS_I_SYNC : 0)
|
||||
| LFS_I_CANLOOKAHEAD
|
||||
| LFS_I_UNCOMPACTED));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user