Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

repeat lfs_file_seek and lfs_file_write may make lfs no space #656

Open
quqw opened this issue Mar 11, 2022 · 1 comment
Open

repeat lfs_file_seek and lfs_file_write may make lfs no space #656

quqw opened this issue Mar 11, 2022 · 1 comment

Comments

@quqw
Copy link

quqw commented Mar 11, 2022

issue:

  1. repeat lfs_file_seek and lfs_file_write may make lfs say "..\lfs.c:561:error: No more free space"
  2. according to the data size be written at first, every "lfs_file_seek " may erase 500-1000 blocks

recurrence:

```
.read_size = 256,
.prog_size = 256,
.block_size = 4096,
.block_count = 2048,
.cache_size = 512,
.lookahead_size = 256,
.block_cycles = 500,
```
  1. write 3M~4MB data
  2. lfs_file_seek(&lfs,&file,0, LFS_SEEK_SET);
  3. lfs_file_write(&lfs, &file, dat, len);
  4. goto 2
@geky
Copy link
Member

geky commented Mar 24, 2022

Hi @quqw, thanks for raising an issue.

I believe this is a symptom of #27. A big limitation of littlefs right now is that file updates require rewriting all trailing data. In your case, this appears to be the entire ~4MiB file.

Operations in littlefs are also copy-on-write, which means littlefs needs to hold both the original copy and new copy of the file in storage until the metadata is written to disk. This means littlefs needs 2x4MiB = 8MiB of storage to complete this operation. Unfortunately you have exactly 2048*4096 = 8MiB, which, because of an extra couple blocks for metadata won't be enough to complete the operation.

So I think the error is correct, due to other issues in littlefs.


This shouldn't happen when #27 is fixed. If the file data-structure allowed random updates of single blocks, then we would only need to hold copies of those blocks while updating metadata, not the whole file.

Unfortunately this is how things are at the moment.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants