Files
littlefs/tests
Christopher Haster 34be5055b4 Fixed mdir drop during compaction breaking fixorphan loop
The core problem is that we weren't updating dropped mdirs with weight=0
if the mdir was compacted at the same time. This is hard to notice,
because most operations that can drop don't care about the mdir
afterwards, but in lfsr_fs_fixorphans this caused the fixorphan loop to
think it might still have orphans it could remove.

The implementation is very subtle here:

- In lfsr_mdir_commit_, if an error occurs during lfsr_mdir_compact__,
  we need to revert to the original mdir state to allow fallback to mdir
  split.

- In lfsr_mdir_commit_, if an error occurs during lfsr_mdir_commit__
  (even after a compact), we need to update the mdir in case a drop
  reduced the mdir weight to zero.

  We also need to update the mdir for things like erased state, but this
  doesn't come into play in the compaction route.

Fixed the bug by updating the mdir copy before lfsr_mdir_commit__.

Also added asserts to all insert/delete operations in test_mtree.toml.
We already had drop-during-compaction tests, but these didn't check that
the mdir was updated correctly. The new asserts catch this bug and
should prevent a regression.
2024-03-03 13:25:46 -06:00
..