gbmap: Added support for gbmap in lfs3_fs_grow

In lfs3_fs_grow, we need to update any gbmaps to match the new disk
size. The actual patch to the gbmap is easy, but it does get a bit
delicate since we need to feed the gbmap with an allocator in the new
disk size.

Fortunately, the opportunistism of the gbmap allocator avoids any
catch-22 issues, as long as we make sure to not trigger any gbmap
rebuilds.

Adds a bit of code, but not much:

                 code          stack          ctx
  before:       37168           2352          684
  after:        37168 (+0.0%)   2352 (+0.0%)  684 (+0.0%)

                 code          stack          ctx
  gbmap before: 39000           2456          800
  gbmap after:  39116 (+0.3%)   2456 (+0.0%)  800 (+0.0%)
This commit is contained in:
Christopher Haster
2025-10-10 13:44:40 -05:00
parent 24d75a24c5
commit 9e45249b29
7 changed files with 196 additions and 112 deletions
+6 -5
View File
@@ -9,7 +9,8 @@
#
after = ['test_mtree', 'test_gbmap', 'test_dirs', 'test_files']
defines.INIT_BLOCKS = 'LFS3_IFDEF_GBMAP(3, 2)'
defines.FORMAT_BLOCK_COUNT = 'LFS3_IFDEF_YES_GBMAP(3, 2)'
# test that we can alloc
[cases.test_alloc_alloc]
@@ -22,7 +23,7 @@ defines.COUNT = [
'2',
]
defines.ERASE = [false, true]
if = 'COUNT >= INIT_BLOCKS'
if = 'COUNT >= FORMAT_BLOCK_COUNT'
in = 'lfs3.c'
code = '''
// test various block counts
@@ -69,7 +70,7 @@ defines.COUNT = [
'2',
]
defines.ERASE = [false, true]
if = 'COUNT >= INIT_BLOCKS'
if = 'COUNT >= FORMAT_BLOCK_COUNT'
in = 'lfs3.c'
code = '''
// test various block counts
@@ -655,7 +656,7 @@ defines.COUNT = [
'5',
'2',
]
if = 'COUNT >= INIT_BLOCKS'
if = 'COUNT >= FORMAT_BLOCK_COUNT'
code = '''
// test various block counts
struct lfs3_cfg cfg = *CFG;
@@ -738,7 +739,7 @@ defines.SIZE = [
'2*BLOCK_SIZE',
'8*BLOCK_SIZE',
]
if = 'COUNT >= INIT_BLOCKS'
if = 'COUNT >= FORMAT_BLOCK_COUNT'
code = '''
// test various block counts
struct lfs3_cfg cfg = *CFG;
+36 -36
View File
@@ -11,7 +11,7 @@ after = [
'test_compat',
]
defines.INIT_BLOCKS = 'LFS3_IFDEF_GBMAP(3, 2)'
defines.FORMAT_BLOCK_COUNT = 'LFS3_IFDEF_YES_GBMAP(3, 2)'
## Single-block badblock tests
@@ -149,7 +149,7 @@ defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
if = 'LFS3_IFDEF_CKPROGS(true, !CKPROGS)'
code = '''
// test all possible bad blocks
for (lfs3_size_t i = INIT_BLOCKS;
for (lfs3_size_t i = FORMAT_BLOCK_COUNT;
i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1);
i++) {
lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK;
@@ -267,7 +267,7 @@ fuzz = 'SEED'
if = 'LFS3_IFDEF_CKPROGS(true, !CKPROGS)'
code = '''
// test all possible bad blocks
for (lfs3_size_t i = INIT_BLOCKS;
for (lfs3_size_t i = FORMAT_BLOCK_COUNT;
i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1);
i++) {
lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK;
@@ -462,7 +462,7 @@ if = [
]
code = '''
// test all possible bad blocks
for (lfs3_size_t i = INIT_BLOCKS;
for (lfs3_size_t i = FORMAT_BLOCK_COUNT;
i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1);
i++) {
lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK;
@@ -576,7 +576,7 @@ if = [
]
code = '''
// test all possible bad blocks
for (lfs3_size_t i = INIT_BLOCKS;
for (lfs3_size_t i = FORMAT_BLOCK_COUNT;
i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1);
i++) {
lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK;
@@ -833,7 +833,7 @@ if = [
]
code = '''
// test all possible bad blocks
for (lfs3_size_t i = INIT_BLOCKS;
for (lfs3_size_t i = FORMAT_BLOCK_COUNT;
i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1);
i++) {
lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK;
@@ -996,7 +996,7 @@ if = [
]
code = '''
// test all possible bad blocks
for (lfs3_size_t i = INIT_BLOCKS;
for (lfs3_size_t i = FORMAT_BLOCK_COUNT;
i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1);
i++) {
lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK;
@@ -1448,7 +1448,7 @@ if = [
]
code = '''
// test all possible bad blocks
for (lfs3_size_t i = INIT_BLOCKS;
for (lfs3_size_t i = FORMAT_BLOCK_COUNT;
i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1);
i++) {
lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK;
@@ -2103,11 +2103,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (i >= INIT_BLOCKS) {
if (i >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i) => 0;
}
} else {
if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) {
if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0;
}
}
@@ -2222,11 +2222,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (i >= INIT_BLOCKS) {
if (i >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i) => 0;
}
} else {
if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) {
if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0;
}
}
@@ -2418,11 +2418,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (i >= INIT_BLOCKS) {
if (i >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i) => 0;
}
} else {
if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) {
if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0;
}
}
@@ -2533,11 +2533,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (i >= INIT_BLOCKS) {
if (i >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i) => 0;
}
} else {
if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) {
if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0;
}
}
@@ -2791,11 +2791,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (i >= INIT_BLOCKS) {
if (i >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i) => 0;
}
} else {
if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) {
if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0;
}
}
@@ -2955,11 +2955,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (i >= INIT_BLOCKS) {
if (i >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i) => 0;
}
} else {
if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) {
if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0;
}
}
@@ -3408,11 +3408,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (i >= INIT_BLOCKS) {
if (i >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i) => 0;
}
} else {
if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) {
if (i+BLOCK_COUNT/2 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0;
}
}
@@ -4060,11 +4060,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (2*i+0 >= INIT_BLOCKS) {
if (2*i+0 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+0) => 0;
}
} else {
if (2*i+1 >= INIT_BLOCKS) {
if (2*i+1 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+1) => 0;
}
}
@@ -4179,11 +4179,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (2*i+0 >= INIT_BLOCKS) {
if (2*i+0 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+0) => 0;
}
} else {
if (2*i+1 >= INIT_BLOCKS) {
if (2*i+1 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+1) => 0;
}
}
@@ -4375,11 +4375,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (2*i+0 >= INIT_BLOCKS) {
if (2*i+0 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+0) => 0;
}
} else {
if (2*i+1 >= INIT_BLOCKS) {
if (2*i+1 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+1) => 0;
}
}
@@ -4490,11 +4490,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (2*i+0 >= INIT_BLOCKS) {
if (2*i+0 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+0) => 0;
}
} else {
if (2*i+1 >= INIT_BLOCKS) {
if (2*i+1 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+1) => 0;
}
}
@@ -4748,11 +4748,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (2*i+0 >= INIT_BLOCKS) {
if (2*i+0 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+0) => 0;
}
} else {
if (2*i+1 >= INIT_BLOCKS) {
if (2*i+1 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+1) => 0;
}
}
@@ -4910,11 +4910,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (2*i+0 >= INIT_BLOCKS) {
if (2*i+0 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+0) => 0;
}
} else {
if (2*i+1 >= INIT_BLOCKS) {
if (2*i+1 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+1) => 0;
}
}
@@ -5363,11 +5363,11 @@ code = '''
for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) {
// mark our badblock as bad
if (!MIRROR) {
if (2*i+0 >= INIT_BLOCKS) {
if (2*i+0 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+0) => 0;
}
} else {
if (2*i+1 >= INIT_BLOCKS) {
if (2*i+1 >= FORMAT_BLOCK_COUNT) {
lfs3_emubd_markbad(CFG, 2*i+1) => 0;
}
}
+84 -50
View File
@@ -8,8 +8,14 @@ after = [
'test_mount',
]
# TODO!! lfs3_fs_grow needs to be able to adjust an on-disk bmaps
ifndef = 'LFS3_GBMAP'
# Test both with and without the gbmap if available
defines.GBMAP = [false, true]
if = '''
LFS3_IFDEF_YES_GBMAP(
GBMAP,
LFS3_IFDEF_GBMAP(true, !GBMAP))
'''
defines.FORMAT_BLOCK_COUNT = '(GBMAP) ? 3 : 2'
# test we can mount a filesystem with fewer blocks
@@ -18,7 +24,7 @@ defines.SMALLER_BLOCK_COUNT = [
'BLOCK_COUNT-1',
'BLOCK_COUNT/2',
'BLOCK_COUNT/4',
'2',
'FORMAT_BLOCK_COUNT',
]
defines.BIGGER_BLOCK_COUNT = [
'BLOCK_COUNT',
@@ -32,7 +38,10 @@ code = '''
struct lfs3_cfg cfg = *CFG;
cfg.block_count = SMALLER_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
lfs3_mount(&lfs3, LFS3_M_RDWR, &cfg) => 0;
// fsstat up to date?
@@ -137,7 +146,7 @@ defines.SMALLER_BLOCK_COUNT = [
'BLOCK_COUNT-1',
'BLOCK_COUNT/2',
'BLOCK_COUNT/4',
'2',
'FORMAT_BLOCK_COUNT',
]
defines.BIGGER_BLOCK_COUNT = [
'BLOCK_COUNT',
@@ -151,7 +160,10 @@ code = '''
struct lfs3_cfg cfg = *CFG;
cfg.block_count = BIGGER_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
lfs3_mount(&lfs3, LFS3_M_RDWR, &cfg) => 0;
// fsstat up to date?
@@ -198,7 +210,7 @@ defines.SMALLER_BLOCK_COUNT = [
'BLOCK_COUNT-1',
'BLOCK_COUNT/2',
'BLOCK_COUNT/4',
'2',
'FORMAT_BLOCK_COUNT',
]
defines.BIGGER_BLOCK_COUNT = [
'BLOCK_COUNT',
@@ -212,7 +224,10 @@ code = '''
struct lfs3_cfg cfg = *CFG;
cfg.block_count = SMALLER_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
lfs3_mount(&lfs3, LFS3_M_RDWR, &cfg) => 0;
// fsstat up to date?
@@ -320,14 +335,17 @@ defines.SMALLER_BLOCK_COUNT = [
'BLOCK_COUNT-1',
'BLOCK_COUNT/2',
'BLOCK_COUNT/4',
'2',
'FORMAT_BLOCK_COUNT',
]
code = '''
// create a smaller fs
struct lfs3_cfg cfg = *CFG;
cfg.block_count = SMALLER_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
lfs3_mount(&lfs3, LFS3_M_RDWR, &cfg) => 0;
// fsstat up to date?
@@ -436,15 +454,17 @@ code = '''
#
[cases.test_grow_incr_spam_dir_many]
defines.INIT_BLOCK_COUNT = 2
defines.REMOUNT = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
code = '''
// start with a small number of blocks
struct lfs3_cfg cfg = *CFG;
cfg.block_count = INIT_BLOCK_COUNT;
cfg.block_count = FORMAT_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
// mount with maximum block count
lfs3_mount(&lfs3, LFS3_M_RDWR, CFG) => 0;
@@ -452,7 +472,7 @@ code = '''
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == INIT_BLOCK_COUNT);
assert(fsinfo.block_count == FORMAT_BLOCK_COUNT);
assert(fsinfo.name_limit == LFS3_NAME_MAX);
assert(fsinfo.file_limit == LFS3_FILE_MAX);
@@ -473,7 +493,7 @@ code = '''
// try growing the filesystem
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_count >= INIT_BLOCK_COUNT);
assert(fsinfo.block_count >= FORMAT_BLOCK_COUNT);
assert(fsinfo.block_count <= BLOCK_COUNT);
lfs3_ssize_t used = lfs3_fs_usage(&lfs3);
assert(used >= 0);
@@ -576,7 +596,6 @@ code = '''
'''
[cases.test_grow_incr_spam_dir_fuzz]
defines.INIT_BLOCK_COUNT = 2
defines.REMOUNT = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256]
defines.OPS = 1024
@@ -585,9 +604,12 @@ fuzz = 'SEED'
code = '''
// start with a small number of blocks
struct lfs3_cfg cfg = *CFG;
cfg.block_count = INIT_BLOCK_COUNT;
cfg.block_count = FORMAT_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
// mount with maximum block count
lfs3_mount(&lfs3, LFS3_M_RDWR, CFG) => 0;
@@ -595,7 +617,7 @@ code = '''
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == INIT_BLOCK_COUNT);
assert(fsinfo.block_count == FORMAT_BLOCK_COUNT);
assert(fsinfo.name_limit == LFS3_NAME_MAX);
assert(fsinfo.file_limit == LFS3_FILE_MAX);
@@ -709,7 +731,7 @@ code = '''
// try growing the filesystem
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_count >= INIT_BLOCK_COUNT);
assert(fsinfo.block_count >= FORMAT_BLOCK_COUNT);
assert(fsinfo.block_count <= BLOCK_COUNT);
lfs3_ssize_t used = lfs3_fs_usage(&lfs3);
assert(used >= 0);
@@ -800,7 +822,6 @@ code = '''
'''
[cases.test_grow_incr_spam_file_many]
defines.INIT_BLOCK_COUNT = 2
defines.REMOUNT = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.SIZE = [
@@ -816,9 +837,12 @@ if = '(SIZE*N)/BLOCK_SIZE <= 32'
code = '''
// start with a small number of blocks
struct lfs3_cfg cfg = *CFG;
cfg.block_count = INIT_BLOCK_COUNT;
cfg.block_count = FORMAT_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
// mount with maximum block count
lfs3_mount(&lfs3, LFS3_M_RDWR, CFG) => 0;
@@ -826,7 +850,7 @@ code = '''
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == INIT_BLOCK_COUNT);
assert(fsinfo.block_count == FORMAT_BLOCK_COUNT);
assert(fsinfo.name_limit == LFS3_NAME_MAX);
assert(fsinfo.file_limit == LFS3_FILE_MAX);
@@ -869,7 +893,7 @@ code = '''
// try growing the filesystem
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_count >= INIT_BLOCK_COUNT);
assert(fsinfo.block_count >= FORMAT_BLOCK_COUNT);
assert(fsinfo.block_count <= BLOCK_COUNT);
lfs3_ssize_t used = lfs3_fs_usage(&lfs3);
assert(used >= 0);
@@ -946,7 +970,6 @@ code = '''
'''
[cases.test_grow_incr_spam_file_fuzz]
defines.INIT_BLOCK_COUNT = 2
defines.REMOUNT = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = 1024
@@ -965,9 +988,12 @@ if = '(SIZE*N)/BLOCK_SIZE <= 16'
code = '''
// start with a small number of blocks
struct lfs3_cfg cfg = *CFG;
cfg.block_count = INIT_BLOCK_COUNT;
cfg.block_count = FORMAT_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
// mount with maximum block count
lfs3_mount(&lfs3, LFS3_M_RDWR, CFG) => 0;
@@ -975,7 +1001,7 @@ code = '''
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == INIT_BLOCK_COUNT);
assert(fsinfo.block_count == FORMAT_BLOCK_COUNT);
assert(fsinfo.name_limit == LFS3_NAME_MAX);
assert(fsinfo.file_limit == LFS3_FILE_MAX);
@@ -1135,7 +1161,7 @@ code = '''
// try growing the filesystem
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_count >= INIT_BLOCK_COUNT);
assert(fsinfo.block_count >= FORMAT_BLOCK_COUNT);
assert(fsinfo.block_count <= BLOCK_COUNT);
lfs3_ssize_t used = lfs3_fs_usage(&lfs3);
assert(used >= 0);
@@ -1241,7 +1267,6 @@ code = '''
'''
[cases.test_grow_incr_spam_uz_fuzz]
defines.INIT_BLOCK_COUNT = 2
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = 1024
defines.SIZE = [
@@ -1259,9 +1284,12 @@ if = '(SIZE*N)/BLOCK_SIZE <= 16'
code = '''
// start with a small number of blocks
struct lfs3_cfg cfg = *CFG;
cfg.block_count = INIT_BLOCK_COUNT;
cfg.block_count = FORMAT_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
// mount with maximum block count
lfs3_mount(&lfs3, LFS3_M_RDWR, CFG) => 0;
@@ -1269,7 +1297,7 @@ code = '''
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == INIT_BLOCK_COUNT);
assert(fsinfo.block_count == FORMAT_BLOCK_COUNT);
assert(fsinfo.name_limit == LFS3_NAME_MAX);
assert(fsinfo.file_limit == LFS3_FILE_MAX);
@@ -1616,7 +1644,7 @@ code = '''
// try growing the filesystem
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_count >= INIT_BLOCK_COUNT);
assert(fsinfo.block_count >= FORMAT_BLOCK_COUNT);
assert(fsinfo.block_count <= BLOCK_COUNT);
lfs3_ssize_t used = lfs3_fs_usage(&lfs3);
assert(used >= 0);
@@ -1741,7 +1769,6 @@ code = '''
'''
[cases.test_grow_incr_spam_uzd_fuzz]
defines.INIT_BLOCK_COUNT = 2
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = 1024
defines.SIZE = [
@@ -1759,9 +1786,12 @@ if = '(SIZE*N)/BLOCK_SIZE <= 16'
code = '''
// start with a small number of blocks
struct lfs3_cfg cfg = *CFG;
cfg.block_count = INIT_BLOCK_COUNT;
cfg.block_count = FORMAT_BLOCK_COUNT;
lfs3_t lfs3;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
// mount with maximum block count
lfs3_mount(&lfs3, LFS3_M_RDWR, CFG) => 0;
@@ -1769,7 +1799,7 @@ code = '''
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == INIT_BLOCK_COUNT);
assert(fsinfo.block_count == FORMAT_BLOCK_COUNT);
assert(fsinfo.name_limit == LFS3_NAME_MAX);
assert(fsinfo.file_limit == LFS3_FILE_MAX);
@@ -2200,7 +2230,7 @@ code = '''
// try growing the filesystem
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_count >= INIT_BLOCK_COUNT);
assert(fsinfo.block_count >= FORMAT_BLOCK_COUNT);
assert(fsinfo.block_count <= BLOCK_COUNT);
lfs3_ssize_t used = lfs3_fs_usage(&lfs3);
assert(used >= 0);
@@ -2350,7 +2380,6 @@ code = '''
# wrong.
#
[cases.test_grow_incr_spam_f_pl_fuzz]
defines.INIT_BLOCK_COUNT = 2
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = 256
defines.SIZE = [
@@ -2373,8 +2402,11 @@ code = '''
if (err) {
// start with a small number of blocks
struct lfs3_cfg cfg = *CFG;
cfg.block_count = INIT_BLOCK_COUNT;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
cfg.block_count = FORMAT_BLOCK_COUNT;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
// mount with maximum block count
lfs3_mount(&lfs3, LFS3_M_RDWR, CFG) => 0;
@@ -2382,7 +2414,7 @@ code = '''
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == INIT_BLOCK_COUNT);
assert(fsinfo.block_count == FORMAT_BLOCK_COUNT);
assert(fsinfo.name_limit == LFS3_NAME_MAX);
assert(fsinfo.file_limit == LFS3_FILE_MAX);
}
@@ -2563,7 +2595,7 @@ code = '''
// try growing the filesystem
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_count >= INIT_BLOCK_COUNT);
assert(fsinfo.block_count >= FORMAT_BLOCK_COUNT);
assert(fsinfo.block_count <= BLOCK_COUNT);
lfs3_ssize_t used = lfs3_fs_usage(&lfs3);
assert(used >= 0);
@@ -2661,7 +2693,6 @@ code = '''
# wrong.
#
[cases.test_grow_incr_spam_fd_pl_fuzz]
defines.INIT_BLOCK_COUNT = 2
# note dirs x files grows O(n^2)
defines.N = [1, 2, 4, 8]
defines.M = 'N'
@@ -2686,8 +2717,11 @@ code = '''
if (err) {
// start with a small number of blocks
struct lfs3_cfg cfg = *CFG;
cfg.block_count = INIT_BLOCK_COUNT;
lfs3_format(&lfs3, LFS3_F_RDWR, &cfg) => 0;
cfg.block_count = FORMAT_BLOCK_COUNT;
lfs3_format(&lfs3,
LFS3_F_RDWR
| ((GBMAP) ? LFS3_IFDEF_GBMAP(LFS3_F_GBMAP, -1) : 0),
&cfg) => 0;
// mount with maximum block count
lfs3_mount(&lfs3, LFS3_M_RDWR, CFG) => 0;
@@ -2695,7 +2729,7 @@ code = '''
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_size == BLOCK_SIZE);
assert(fsinfo.block_count == INIT_BLOCK_COUNT);
assert(fsinfo.block_count == FORMAT_BLOCK_COUNT);
assert(fsinfo.name_limit == LFS3_NAME_MAX);
assert(fsinfo.file_limit == LFS3_FILE_MAX);
}
@@ -3003,7 +3037,7 @@ code = '''
// try growing the filesystem
struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.block_count >= INIT_BLOCK_COUNT);
assert(fsinfo.block_count >= FORMAT_BLOCK_COUNT);
assert(fsinfo.block_count <= BLOCK_COUNT);
lfs3_ssize_t used = lfs3_fs_usage(&lfs3);
assert(used >= 0);