Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Free space of overwritten files in LittleFS #7434

Merged
merged 3 commits into from
Jul 8, 2020

Conversation

earlephilhower
Copy link
Collaborator

Fixes #7426

LittleFS doesn't update the on-flash data structures when a file is
reopened as O_TRUNC until the file is closed. This means the space of
the original, inaccessible file cannot be used, causing OOS errors in
cases when a large file is being overwritten.

Explicitly call the file sync operation to update the on-flash metadata
as soon as a file is opened. For normal files it's a no-op, but for
O_TRUNC modes it will free the space, allowing full overwrite of large
files.

Fixes esp8266#7426

LittleFS doesn't update the on-flash data structures when a file is
reopened as O_TRUNC until the file is closed.  This means the space of
the original, inaccessible file cannot be used, causing OOS errors in
cases when a large file is being overwritten.

Explicitly call the file sync operation to update the on-flash metadata
as soon as a file is opened.  For normal files it's a no-op, but for
O_TRUNC modes it will free the space, allowing full overwrite of large
files.
@earlephilhower earlephilhower merged commit c663c55 into esp8266:master Jul 8, 2020
@earlephilhower earlephilhower deleted the syncopated branch July 8, 2020 00:14
d-a-v added a commit that referenced this pull request Jul 18, 2020
lorol added a commit to lorol/LITTLEFS that referenced this pull request Nov 15, 2020
Following:
Sync file upon opening to free storage when overwriting a file
joltwallet/esp_littlefs#22

Fixes out-of-storage issues when overwriting a file by syncing-on-open. Not that this effectively immediately deletes the file being overwritten.

Based on:
esp8266/Arduino#7434
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LittleFS unexpected behaviour
1 participant