Folded rbyd.erased into rbyd.off=block_size, some rbyd cleanup

- The erased flag in lfsr_rbyd_t uses only a single bit, which is
  wasteful for a heavily used struct in littlefs. We can use
  rbyd.off=block_size to indicate the same state for free. Note that
  when rbyd.off=block_size, we must treat rbyd as unerased anyways.

- Improved state handling in rbyd_append/commit when an error occurs.
  I will be trying to make better use of cleanup gotos to make these
  functions less unpredictable when an error occurs. Hopefully the state
  of littlefs after an error can be well-defined in the future.

- Fixed sign-mismatch warnings in asserts when compiled outside of the
  test runner.
This commit is contained in:
Christopher Haster
2023-04-07 14:59:22 -05:00
parent 7eb0c4763a
commit ed8d8c0c24
3 changed files with 73 additions and 157 deletions
+3 -4
View File
@@ -332,13 +332,12 @@ typedef struct lfs_cache {
typedef struct lfsr_rbyd {
lfs_block_t block;
uint32_t rev;
// off=block_size => rbyd not erased/needs compaction
lfs_off_t off;
uint32_t crc;
lfs_off_t trunk;
lfs_size_t weight;
// TODO can we get rid of erased? use sign bit of off maybe?
bool erased;
uint32_t rev;
uint32_t crc;
} lfsr_rbyd_t;
//typedef struct lfsr_btree {