Moved erase into lfs_alloc, mostly

This doesn't really help us all that much right now, but will be useful
for the future-planned block map and being able to cache pre-erased
blocks.

Though the lack of erasing when allocating new mdirs raises some
questions... Oh well, future problems.

Code changes:

           code          stack
  before: 33856           2880
  after:  33864 (+0.0%)   2880 (+0.0%)
This commit is contained in:
Christopher Haster
2024-02-25 11:10:11 -06:00
parent 788a9d0129
commit 5005db2b4e
2 changed files with 17 additions and 20 deletions
+5 -3
View File
@@ -17,6 +17,7 @@ after = ['test_mtree', 'test_dirs', 'test_files']
# test that we can alloc
[cases.test_alloc_alloc]
in = 'lfs.c'
defines.ERASE = [false, true]
code = '''
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
@@ -27,7 +28,7 @@ code = '''
lfs_size_t alloced = 0;
while (true) {
lfs_block_t block;
int err = lfs_alloc(&lfs, &block);
int err = lfs_alloc(&lfs, &block, ERASE);
assert(!err || err == LFS_ERR_NOSPC);
if (err == LFS_ERR_NOSPC) {
@@ -50,6 +51,7 @@ code = '''
# test that we can realloc after an ack
[cases.test_alloc_reuse]
in = 'lfs.c'
defines.ERASE = [false, true]
code = '''
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
@@ -60,7 +62,7 @@ code = '''
lfs_size_t alloced = 0;
while (true) {
lfs_block_t block;
int err = lfs_alloc(&lfs, &block);
int err = lfs_alloc(&lfs, &block, ERASE);
assert(!err || err == LFS_ERR_NOSPC);
if (err == LFS_ERR_NOSPC) {
@@ -82,7 +84,7 @@ code = '''
alloced = 0;
while (true) {
lfs_block_t block;
int err = lfs_alloc(&lfs, &block);
int err = lfs_alloc(&lfs, &block, ERASE);
assert(!err || err == LFS_ERR_NOSPC);
if (err == LFS_ERR_NOSPC) {