Skip to content

Commit

Permalink
Fixed dirty rcache during directory commit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
geky committed Jun 29, 2017
1 parent 1166416 commit a1138a4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ static int lfs_bd_erase(lfs_t *lfs, lfs_block_t block) {
}

static int lfs_bd_sync(lfs_t *lfs) {
lfs->rcache.block = 0xffffffff;

int err = lfs_cache_flush(lfs, &lfs->pcache, NULL);
if (err) {
return err;
Expand Down

0 comments on commit a1138a4

Please sign in to comment.