Skip to content

Commit a1138a4

Browse files
committed
Fixed dirty rcache during directory commit
An interesting side-effect of adding internal checks to the littlefs for block errors, is that the littlefs starts to cover up its own flaws. Probably out of embarrassment. In this case, the relocation logic for directories left the littlefs rcache dirty with invalid data. The littlefs detected the error, treated it as a corrupted write, and just moved the "corrupted" block to a new block, which as a side-effect flushes the rcache. Since committing a dir will end up flushing the rcache to check for errors anyways, we can just drop the rcache in lfs_bd_sync.
1 parent 1166416 commit a1138a4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lfs.c

+2
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ static int lfs_bd_erase(lfs_t *lfs, lfs_block_t block) {
237237
}
238238

239239
static int lfs_bd_sync(lfs_t *lfs) {
240+
lfs->rcache.block = 0xffffffff;
241+
240242
int err = lfs_cache_flush(lfs, &lfs->pcache, NULL);
241243
if (err) {
242244
return err;

0 commit comments

Comments
 (0)