littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
5.23k stars 801 forks source link

Error LFS_ERR_NOSPC after successfull lfs_remove() #1007

Closed pedromarinho94 closed 1 month ago

pedromarinho94 commented 4 months ago

Hello. I am having some issues with my littlefs (v2.9.0) implementation using a W25Q128 (16MB) via QSPI.

When we write entries until we get LFS_ERR_NOSPC we free space in our Filesystem with lfs_remove(). After successfully removing all the files created with lfs_remove() we start trying to write again but it still returns LFS_ERR_NOSPC. How is this possible? Shouldn't it clear the space?

Also, with block_count being 128 and block_size being 4096 I would expect to be able to write close to 128*4096 bytes until LFS_ERR_NOSPC error is thrown by littlefs. This is not very deterministic behavior.

Should we call garbage collection after all the files are removed? What is missing?

LFS is telling me there are 115 free blocks but there is no space left to write?

pedromarinho94 commented 1 month ago

We had a bug in our SPI driver in which we were always deleting block 0. It's fixed now.