mirror of
https://gitee.com/openharmony/third_party_littlefs
synced 2024-12-03 12:40:43 +00:00
6db5202bdc
The valid bit present in tags is a requirement to properly detect the end of commits in metadata logs. The way it works is that the CRC entry is allowed to specify what is needed from the next tag's valid bit. If it's incorrect, we've reached the end of the commit. We then set the valid bit to indicate when we tried to program a new commit. If we lose power, this commit will still be thrown out by a bad checksum. However, the valid bit is unused outside of the CRC entry. Here we turn on the valid bit for all tags, which means we have a decent chance of exiting early if we hit a half-written commit. We still need to guarantee detection of the valid bit on commits following the CRC entry, so we allow the CRC entry to flip the expected valid bit. The only tricky part is what valid bit we expect by default, since this is used on the first commit on a metadata log. Here we default to a 1, which gives us the fastest exit on blocks that erase to 0. This is because blocks that erase to 1s will implicitly flip the valid bit of the next tag, allowing us to exit on the next tag. If we defaulted to 0, we could exit faster on disks that erase to 1, but would need to scan the entire block on disks that erase to 0 before we realize a CRC commit is never coming. |
||
---|---|---|
.. | ||
corrupt.py | ||
debug.py | ||
stats.py | ||
template.fmt | ||
test_alloc.sh | ||
test_attrs.sh | ||
test_corrupt.sh | ||
test_dirs.sh | ||
test_entries.sh | ||
test_files.sh | ||
test_format.sh | ||
test_interspersed.sh | ||
test_move.sh | ||
test_orphan.sh | ||
test_paths.sh | ||
test_seek.sh | ||
test_truncate.sh | ||
test.py |