Open andriyndev opened 7 months ago
Hi @andriyndev, thanks for creating an issue.
Ah yes... These variables...
They sort of evolved during development, and during several attempts to reduce the number of copies, so the names aren't the greatest.
They become important during commits, when we need to keep track of what gstate will be before and after.
Roughly:
gstate
=> State of gstate we wantgdisk
=> State of gstate on diskgdelta
=> gstate that needs to be writtenDuring a commit, gdelta
starts off as gstate xor gdisk
, but if littlefs drops or relocates any mdirs, gdelta
is "steals" the gdelta that was on that mdir.
For drops this is necessary, since we are removing the mdir and our gstate would become corrupted otherwise, for relocations it's an attempt to move gdelta upwards to try to clean up the amount of gdeltas on the system.
The whole gstate system is rather fragile, and I haven't found a way to avoid all three copies.
From what I understand, they're related to the "global state" but the documentation mentions only one field responsible for global state while the
lfs
structure contains three. What is each of these fields responsible for?