Mention that shrinking is unlikely to work
This commit is contained in:
@@ -374,6 +374,22 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
CFLAGS="$CFLAGS -DLFS_NO_INTRINSICS" make test
|
CFLAGS="$CFLAGS -DLFS_NO_INTRINSICS" make test
|
||||||
|
|
||||||
|
test-shrink:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: install
|
||||||
|
run: |
|
||||||
|
# need a few things
|
||||||
|
sudo apt-get update -qq
|
||||||
|
sudo apt-get install -qq gcc python3 python3-pip
|
||||||
|
pip3 install toml
|
||||||
|
gcc --version
|
||||||
|
python3 --version
|
||||||
|
- name: test-no-intrinsics
|
||||||
|
run: |
|
||||||
|
CFLAGS="$CFLAGS -DLFS_SHRINKIFCHEAP" make test
|
||||||
|
|
||||||
# run with all trace options enabled to at least make sure these
|
# run with all trace options enabled to at least make sure these
|
||||||
# all compile
|
# all compile
|
||||||
test-yes-trace:
|
test-yes-trace:
|
||||||
|
|||||||
@@ -766,11 +766,11 @@ int lfs_fs_gc(lfs_t *lfs);
|
|||||||
// Grows the filesystem to a new size, updating the superblock with the new
|
// Grows the filesystem to a new size, updating the superblock with the new
|
||||||
// block count.
|
// block count.
|
||||||
//
|
//
|
||||||
// if LFS_SHRINKIFCHEAP is defined, this function will also accept
|
// If LFS_SHRINKIFCHEAP is defined, this function will also accept
|
||||||
// block_counts smaller than the current configuration, after checking
|
// block_counts smaller than the current configuration, after checking
|
||||||
// that none of the blocks that are being removed are in use.
|
// that none of the blocks that are being removed are in use.
|
||||||
//
|
// Note that littlefs's pseudorandom block allocation means that
|
||||||
// Note: This is irreversible.
|
// this is very unlikely to work in the general case.
|
||||||
//
|
//
|
||||||
// Returns a negative error code on failure.
|
// Returns a negative error code on failure.
|
||||||
int lfs_fs_grow(lfs_t *lfs, lfs_size_t block_count);
|
int lfs_fs_grow(lfs_t *lfs, lfs_size_t block_count);
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
[cases.test_shrink_simple]
|
[cases.test_shrink_simple]
|
||||||
defines.BLOCK_COUNT = [10, 15, 20]
|
defines.BLOCK_COUNT = [10, 15, 20]
|
||||||
defines.AFTER_BLOCK_COUNT = [5, 10, 15, 19]
|
defines.AFTER_BLOCK_COUNT = [5, 10, 15, 19]
|
||||||
|
|
||||||
if = "AFTER_BLOCK_COUNT <= BLOCK_COUNT"
|
if = "AFTER_BLOCK_COUNT <= BLOCK_COUNT"
|
||||||
code = '''
|
code = '''
|
||||||
|
#ifdef LFS_SHRINKIFCHEAP
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
lfs_format(&lfs, cfg) => 0;
|
||||||
lfs_mount(&lfs, cfg) => 0;
|
lfs_mount(&lfs, cfg) => 0;
|
||||||
@@ -18,6 +20,7 @@ code = '''
|
|||||||
lfs2.cfg = &cfg2;
|
lfs2.cfg = &cfg2;
|
||||||
lfs_mount(&lfs2, &cfg2) => 0;
|
lfs_mount(&lfs2, &cfg2) => 0;
|
||||||
lfs_unmount(&lfs2) => 0;
|
lfs_unmount(&lfs2) => 0;
|
||||||
|
#endif
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# shrinking full
|
# shrinking full
|
||||||
@@ -27,6 +30,7 @@ defines.AFTER_BLOCK_COUNT = [5, 7, 10, 12, 15, 17, 20]
|
|||||||
defines.FILES_COUNT = [7, 8, 9, 10]
|
defines.FILES_COUNT = [7, 8, 9, 10]
|
||||||
if = "AFTER_BLOCK_COUNT <= BLOCK_COUNT && FILES_COUNT + 2 < BLOCK_COUNT"
|
if = "AFTER_BLOCK_COUNT <= BLOCK_COUNT && FILES_COUNT + 2 < BLOCK_COUNT"
|
||||||
code = '''
|
code = '''
|
||||||
|
#ifdef LFS_SHRINKIFCHEAP
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
lfs_format(&lfs, cfg) => 0;
|
||||||
// create FILES_COUNT files of BLOCK_SIZE - 50 bytes (to avoid inlining)
|
// create FILES_COUNT files of BLOCK_SIZE - 50 bytes (to avoid inlining)
|
||||||
@@ -101,4 +105,5 @@ code = '''
|
|||||||
}
|
}
|
||||||
lfs_unmount(&lfs2);
|
lfs_unmount(&lfs2);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -531,6 +531,7 @@ defines.BLOCK_COUNT = 'ERASE_COUNT'
|
|||||||
defines.BLOCK_COUNT_2 = ['ERASE_COUNT/2', 'ERASE_COUNT/4', '2']
|
defines.BLOCK_COUNT_2 = ['ERASE_COUNT/2', 'ERASE_COUNT/4', '2']
|
||||||
defines.KNOWN_BLOCK_COUNT = [true, false]
|
defines.KNOWN_BLOCK_COUNT = [true, false]
|
||||||
code = '''
|
code = '''
|
||||||
|
#ifdef LFS_SHRINKIFCHEAP
|
||||||
lfs_t lfs;
|
lfs_t lfs;
|
||||||
lfs_format(&lfs, cfg) => 0;
|
lfs_format(&lfs, cfg) => 0;
|
||||||
|
|
||||||
@@ -628,6 +629,7 @@ code = '''
|
|||||||
lfs_file_close(&lfs, &file) => 0;
|
lfs_file_close(&lfs, &file) => 0;
|
||||||
assert(memcmp(buffer, "hello!", 6) == 0);
|
assert(memcmp(buffer, "hello!", 6) == 0);
|
||||||
lfs_unmount(&lfs) => 0;
|
lfs_unmount(&lfs) => 0;
|
||||||
|
#endif
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# test that metadata_max does not cause problems for superblock compaction
|
# test that metadata_max does not cause problems for superblock compaction
|
||||||
|
|||||||
Reference in New Issue
Block a user