Adopted more single-char field names

Limited to nested struct fields where the names don't really matter:

- bptr.data -> bptr.d
- mdir.rbyd -> mdir.r

Ok it actually just ended up those two.

This is on the tail end of some optimization work that ended up
abandoned because of maintainability concerns. But it did highlight that
struct nesting gets a bit out-of-control when trying to both optimize
stack allocations and respect C99's strict aliasing.

Consider further fragmenting lfs3_rbyd_t for fine-grain stack
allocations:

  typedef struct lfs3_rbyd {
      struct lfs3_rtrunkcksum {
          struct lfs3_rtrunk {
              lfs3_rid_t weight;
              struct lfs3_rtrunktrunk {
                  lfs3_block_t blocks[2];
                  lfs3_size_t trunk;
              } rtrunktrunk;
          } rtrunk;
          uint32_t cksum;
      } rtrunkcksum;
      lfs3_size_t eoff;
  } lfs3_rbyd_t;

Accessing fields just starts to get silly:

  rbyd.rtrunkcksum.rtrunk.trunktrunk.trunk

At least single-char field names keeps a little bit of readability:

  rbyd.ck.t.t.trunk

Or for some real examples:

- file->b.o.mdir.rbyd.weight -> file->b.o.mdir.r.weight
- bptr->data.u.disk.block -> bptr->d.u.disk.block
This commit is contained in:
Christopher Haster
2025-07-14 15:12:51 -05:00
parent 29e1701964
commit 0bed3867d8
9 changed files with 788 additions and 788 deletions
+215 -215
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -655,7 +655,7 @@ typedef struct lfs3_bptr {
// sign2(size)=0b00 => in-RAM buffer
// sign2(size)=0b10 => on-disk data
// sign2(size)=0b11 => block pointer
lfs3_data_t data;
lfs3_data_t d;
#if !defined(LFS3_2BONLY) && !defined(LFS3_CKDATACKSUMREADS)
// sign(cksize)=0 => block not erased
// sign(cksize)=1 => block erased
@@ -687,7 +687,7 @@ typedef lfs3_rbyd_t lfs3_btree_t;
// littlefs's atomic metadata log type
typedef struct lfs3_mdir {
lfs3_smid_t mid;
lfs3_rbyd_t rbyd;
lfs3_rbyd_t r;
uint32_t gcksumdelta;
} lfs3_mdir_t;
+26 -26
View File
@@ -198,18 +198,18 @@ code = '''
}
if (tag == LFS3_TAG_MDIR) {
lfs3_mdir_t *mdir = (lfs3_mdir_t*)bptr.data.u.buffer;
lfs3_mdir_t *mdir = (lfs3_mdir_t*)bptr.d.u.buffer;
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tag,
mdir->rbyd.blocks[0],
mdir->rbyd.blocks[1]);
mdir->r.blocks[0],
mdir->r.blocks[1]);
// keep track of seen blocks
seen[mdir->rbyd.blocks[1] / 8] |= 1 << (mdir->rbyd.blocks[1] % 8);
seen[mdir->rbyd.blocks[0] / 8] |= 1 << (mdir->rbyd.blocks[0] % 8);
seen[mdir->r.blocks[1] / 8] |= 1 << (mdir->r.blocks[1] % 8);
seen[mdir->r.blocks[0] / 8] |= 1 << (mdir->r.blocks[0] % 8);
} else if (tag == LFS3_TAG_BRANCH) {
lfs3_rbyd_t *rbyd = (lfs3_rbyd_t*)bptr.data.u.buffer;
lfs3_rbyd_t *rbyd = (lfs3_rbyd_t*)bptr.d.u.buffer;
printf("traversal: 0x%x btree 0x%x.%x\n",
tag,
rbyd->blocks[0], rbyd->trunk);
@@ -369,18 +369,18 @@ code = '''
}
if (tag == LFS3_TAG_MDIR) {
lfs3_mdir_t *mdir = (lfs3_mdir_t*)bptr.data.u.buffer;
lfs3_mdir_t *mdir = (lfs3_mdir_t*)bptr.d.u.buffer;
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tag,
mdir->rbyd.blocks[0],
mdir->rbyd.blocks[1]);
mdir->r.blocks[0],
mdir->r.blocks[1]);
// keep track of seen blocks
seen[mdir->rbyd.blocks[1] / 8] |= 1 << (mdir->rbyd.blocks[1] % 8);
seen[mdir->rbyd.blocks[0] / 8] |= 1 << (mdir->rbyd.blocks[0] % 8);
seen[mdir->r.blocks[1] / 8] |= 1 << (mdir->r.blocks[1] % 8);
seen[mdir->r.blocks[0] / 8] |= 1 << (mdir->r.blocks[0] % 8);
} else if (tag == LFS3_TAG_BRANCH) {
lfs3_rbyd_t *rbyd = (lfs3_rbyd_t*)bptr.data.u.buffer;
lfs3_rbyd_t *rbyd = (lfs3_rbyd_t*)bptr.d.u.buffer;
printf("traversal: 0x%x btree 0x%x.%x\n",
tag,
rbyd->blocks[0], rbyd->trunk);
@@ -391,11 +391,11 @@ code = '''
} else if (tag == LFS3_TAG_BLOCK) {
printf("traversal: 0x%x block 0x%x\n",
tag,
bptr.data.u.disk.block);
bptr.d.u.disk.block);
// keep track of seen blocks
seen[bptr.data.u.disk.block / 8]
|= 1 << (bptr.data.u.disk.block % 8);
seen[bptr.d.u.disk.block / 8]
|= 1 << (bptr.d.u.disk.block % 8);
} else {
// this shouldn't happen
@@ -526,20 +526,20 @@ code = '''
}
if (tag == LFS3_TAG_MDIR) {
lfs3_mdir_t *mdir = (lfs3_mdir_t*)bptr.data.u.buffer;
lfs3_mdir_t *mdir = (lfs3_mdir_t*)bptr.d.u.buffer;
printf("traversal: 0x%x mdir 0x{%x,%x}\n",
tag,
mdir->rbyd.blocks[0],
mdir->rbyd.blocks[1]);
mdir->r.blocks[0],
mdir->r.blocks[1]);
// keep track of seen blocks
seen[mdir->rbyd.blocks[1] / 8]
|= 1 << (mdir->rbyd.blocks[1] % 8);
seen[mdir->rbyd.blocks[0] / 8]
|= 1 << (mdir->rbyd.blocks[0] % 8);
seen[mdir->r.blocks[1] / 8]
|= 1 << (mdir->r.blocks[1] % 8);
seen[mdir->r.blocks[0] / 8]
|= 1 << (mdir->r.blocks[0] % 8);
} else if (tag == LFS3_TAG_BRANCH) {
lfs3_rbyd_t *rbyd = (lfs3_rbyd_t*)bptr.data.u.buffer;
lfs3_rbyd_t *rbyd = (lfs3_rbyd_t*)bptr.d.u.buffer;
printf("traversal: 0x%x btree 0x%x.%x\n",
tag,
rbyd->blocks[0], rbyd->trunk);
@@ -551,11 +551,11 @@ code = '''
} else if (tag == LFS3_TAG_BLOCK) {
printf("traversal: 0x%x block 0x%x\n",
tag,
bptr.data.u.disk.block);
bptr.d.u.disk.block);
// keep track of seen blocks
seen[bptr.data.u.disk.block / 8]
|= 1 << (bptr.data.u.disk.block % 8);
seen[bptr.d.u.disk.block / 8]
|= 1 << (bptr.d.u.disk.block % 8);
} else {
// this shouldn't happen
+30 -30
View File
@@ -226,9 +226,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// we disabled block crystallization so this shouldn't
// happen
@@ -375,9 +375,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// keep track of how many data blocks we've seen
blocks += 1;
@@ -640,9 +640,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// we disabled block crystallization so this shouldn't
// happen
@@ -804,9 +804,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// keep track of how many data blocks we've seen
blocks += 1;
@@ -2131,9 +2131,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// all blocks should have been fragmented
assert(false);
@@ -2283,9 +2283,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// all blocks should have been fragmented
assert(false);
@@ -2582,9 +2582,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// we disabled block crystallization so this shouldn't
// happen
@@ -2750,9 +2750,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// keep track of how many data blocks we've seen
blocks += 1;
@@ -3042,9 +3042,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// we disabled block crystallization so this shouldn't
// happen
@@ -3214,9 +3214,9 @@ code = '''
bid,
tag,
weight,
bptr.data.u.disk.block,
bptr.data.u.disk.off,
lfs3_data_size(bptr.data));
lfs3_bptr_block(&bptr),
lfs3_bptr_off(&bptr),
lfs3_bptr_size(&bptr));
// keep track of how many data blocks we've seen
blocks += 1;
+3 -3
View File
@@ -184,7 +184,7 @@ code = '''
// hack, don't use the internals like this
uint8_t wbuf[SIZE];
while ((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -213,7 +213,7 @@ code = '''
}
// mdir should have been compacted
assert((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// check we can still read the file
for (int remount = 0; remount < 2; remount++) {
@@ -273,7 +273,7 @@ code = '''
// hack, don't use the internals like this
uint8_t wbuf[SIZE];
while ((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
+2 -2
View File
@@ -203,7 +203,7 @@ code = '''
// hack, don't use the internals like this
uint8_t wbuf[SIZE];
while ((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -245,7 +245,7 @@ code = '''
// mdir should have been compacted
lfs3_file_open(&lfs3, &file, "jellyfish", LFS3_O_RDONLY) => 0;
assert((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// check we can still read the file
uint8_t rbuf[SIZE];
+422 -422
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -8021,7 +8021,7 @@ code = '''
<= ((1+lfs3_popc(BOOKENDS)) << lfs3.mbits));
lfs3_mdir_t mdir;
lfs3_mtree_lookup(&lfs3, 0, &mdir) => 0;
assert(mdir.rbyd.weight <= 1+lfs3_popc(BOOKENDS));
assert(mdir.r.weight <= 1+lfs3_popc(BOOKENDS));
// check that other files are unaffected
for (int remount = 0; remount < 2; remount++) {
@@ -8160,7 +8160,7 @@ code = '''
<= ((1+lfs3_popc(BOOKENDS)) << lfs3.mbits));
lfs3_mdir_t mdir;
lfs3_mtree_lookup(&lfs3, 0, &mdir) => 0;
assert(mdir.rbyd.weight <= 1+lfs3_popc(BOOKENDS));
assert(mdir.r.weight <= 1+lfs3_popc(BOOKENDS));
// check that other files are unaffected
for (int remount = 0; remount < 2; remount++) {
@@ -8313,7 +8313,7 @@ code = '''
<= ((1+lfs3_popc(BOOKENDS)) << lfs3.mbits));
lfs3_mdir_t mdir;
lfs3_mtree_lookup(&lfs3, 0, &mdir) => 0;
assert(mdir.rbyd.weight <= 1+lfs3_popc(BOOKENDS));
assert(mdir.r.weight <= 1+lfs3_popc(BOOKENDS));
// check that other files are unaffected
for (int remount = 0; remount < 2; remount++) {
@@ -8472,7 +8472,7 @@ code = '''
<= ((1+lfs3_popc(BOOKENDS)) << lfs3.mbits));
lfs3_mdir_t mdir;
lfs3_mtree_lookup(&lfs3, 0, &mdir) => 0;
assert(mdir.rbyd.weight <= 1+lfs3_popc(BOOKENDS));
assert(mdir.r.weight <= 1+lfs3_popc(BOOKENDS));
// check that other files are unaffected
if (BOOKENDS & 0x1) {
+84 -84
View File
@@ -3793,8 +3793,8 @@ code = '''
assert(tinfo.block == 0 || tinfo.block == 1);
// rewrite enough files for mroot to extend
while (lfs3.mroot.rbyd.blocks[0] == 0
|| lfs3.mroot.rbyd.blocks[0] == 1) {
while (lfs3.mroot.r.blocks[0] == 0
|| lfs3.mroot.r.blocks[0] == 1) {
lfs3_file_open(&lfs3, &file, "uloborus",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -3899,8 +3899,8 @@ code = '''
assert(tinfo.btype == LFS3_BTYPE_DATA);
// rewrite enough files for mroot to extend
while (lfs3.mroot.rbyd.blocks[0] == 0
|| lfs3.mroot.rbyd.blocks[0] == 1) {
while (lfs3.mroot.r.blocks[0] == 0
|| lfs3.mroot.r.blocks[0] == 1) {
lfs3_file_open(&lfs3, &file, "uloborus",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -3978,8 +3978,8 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0;
// rewrite enough files for mroot to extend
while (lfs3.mroot.rbyd.blocks[0] == 0
|| lfs3.mroot.rbyd.blocks[0] == 1) {
while (lfs3.mroot.r.blocks[0] == 0
|| lfs3.mroot.r.blocks[0] == 1) {
lfs3_file_open(&lfs3, &file, "uloborus",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -4001,9 +4001,9 @@ code = '''
assert(tinfo.block == 0 || tinfo.block == 1);
// rewrite enough files for mroot to relocate
lfs3_block_t orig = lfs3.mroot.rbyd.blocks[0];
while (lfs3.mroot.rbyd.blocks[0] == orig
|| lfs3.mroot.rbyd.blocks[0] == orig) {
lfs3_block_t orig = lfs3.mroot.r.blocks[0];
while (lfs3.mroot.r.blocks[0] == orig
|| lfs3.mroot.r.blocks[0] == orig) {
lfs3_file_open(&lfs3, &file, "uloborus",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -4092,8 +4092,8 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0;
// rewrite enough files for mroot to extend
while (lfs3.mroot.rbyd.blocks[0] == 0
|| lfs3.mroot.rbyd.blocks[0] == 1) {
while (lfs3.mroot.r.blocks[0] == 0
|| lfs3.mroot.r.blocks[0] == 1) {
lfs3_file_open(&lfs3, &file, "uloborus",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -4125,9 +4125,9 @@ code = '''
assert(tinfo.btype == LFS3_BTYPE_DATA);
// rewrite enough files for mroot to relocate
lfs3_block_t orig = lfs3.mroot.rbyd.blocks[0];
while (lfs3.mroot.rbyd.blocks[0] == orig
|| lfs3.mroot.rbyd.blocks[0] == orig) {
lfs3_block_t orig = lfs3.mroot.r.blocks[0];
while (lfs3.mroot.r.blocks[0] == orig
|| lfs3.mroot.r.blocks[0] == orig) {
lfs3_file_open(&lfs3, &file, "uloborus",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -4799,8 +4799,8 @@ code = '''
assert(tinfo.block == 0 || tinfo.block == 1);
// rewrite enough files for mroot to extend
while (lfs3.mroot.rbyd.blocks[0] == 0
|| lfs3.mroot.rbyd.blocks[0] == 1) {
while (lfs3.mroot.r.blocks[0] == 0
|| lfs3.mroot.r.blocks[0] == 1) {
lfs3_file_open(&lfs3, &file, "vulsor",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -4997,8 +4997,8 @@ code = '''
assert(tinfo.btype == LFS3_BTYPE_DATA);
// rewrite enough files for mroot to extend
while (lfs3.mroot.rbyd.blocks[0] == 0
|| lfs3.mroot.rbyd.blocks[0] == 1) {
while (lfs3.mroot.r.blocks[0] == 0
|| lfs3.mroot.r.blocks[0] == 1) {
lfs3_file_open(&lfs3, &file, "vulsor",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -5114,8 +5114,8 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0;
// rewrite enough files for mroot to extend
while (lfs3.mroot.rbyd.blocks[0] == 0
|| lfs3.mroot.rbyd.blocks[0] == 1) {
while (lfs3.mroot.r.blocks[0] == 0
|| lfs3.mroot.r.blocks[0] == 1) {
lfs3_file_open(&lfs3, &file, "vulsor",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -5159,9 +5159,9 @@ code = '''
assert(tinfo.block == 0 || tinfo.block == 1);
// rewrite enough files for mroot to relocate
orig = lfs3.mroot.rbyd.blocks[0];
while (lfs3.mroot.rbyd.blocks[0] == orig
|| lfs3.mroot.rbyd.blocks[0] == orig) {
orig = lfs3.mroot.r.blocks[0];
while (lfs3.mroot.r.blocks[0] == orig
|| lfs3.mroot.r.blocks[0] == orig) {
lfs3_file_open(&lfs3, &file, "vulsor",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -5294,8 +5294,8 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0;
// rewrite enough files for mroot to extend
while (lfs3.mroot.rbyd.blocks[0] == 0
|| lfs3.mroot.rbyd.blocks[0] == 1) {
while (lfs3.mroot.r.blocks[0] == 0
|| lfs3.mroot.r.blocks[0] == 1) {
lfs3_file_open(&lfs3, &file, "vulsor",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -5367,9 +5367,9 @@ code = '''
assert(tinfo.btype == LFS3_BTYPE_DATA);
// rewrite enough files for mroot to relocate
orig = lfs3.mroot.rbyd.blocks[0];
while (lfs3.mroot.rbyd.blocks[0] == orig
|| lfs3.mroot.rbyd.blocks[0] == orig) {
orig = lfs3.mroot.r.blocks[0];
while (lfs3.mroot.r.blocks[0] == orig
|| lfs3.mroot.r.blocks[0] == orig) {
lfs3_file_open(&lfs3, &file, "vulsor",
LFS3_O_WRONLY | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
lfs3_file_close(&lfs3, &file) => 0;
@@ -5456,7 +5456,7 @@ code = '''
// hack, don't use the internals like this
uint8_t wbuf[SIZE];
while ((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -5493,7 +5493,7 @@ code = '''
lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT;
// mdir should have been compacted
assert((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5515,7 +5515,7 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0;
// mdir should have been compacted
assert((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5568,8 +5568,8 @@ code = '''
LFS3_O_RDWR | LFS3_O_CREAT | LFS3_O_EXCL) => 0;
uint8_t wbuf[SIZE];
while (lfs3.mroot.rbyd.blocks[0] == 0
|| lfs3.mroot.rbyd.blocks[0] == 1) {
while (lfs3.mroot.r.blocks[0] == 0
|| lfs3.mroot.r.blocks[0] == 1) {
lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -5584,7 +5584,7 @@ code = '''
lfs3_mdir_t mrootanchor;
lfs3_mdir_fetch(&lfs3, &mrootanchor,
-1, LFS3_MPTR_MROOTANCHOR()) => 0;
if (lfs3_rbyd_eoff(&mrootanchor.rbyd) > GC_COMPACT_THRESH) {
if (lfs3_rbyd_eoff(&mrootanchor.r) > GC_COMPACT_THRESH) {
break;
}
@@ -5632,7 +5632,7 @@ code = '''
lfs3_mdir_t mrootanchor;
lfs3_mdir_fetch(&lfs3, &mrootanchor,
-1, LFS3_MPTR_MROOTANCHOR()) => 0;
assert(lfs3_rbyd_eoff(&mrootanchor.rbyd) <= GC_COMPACT_THRESH);
assert(lfs3_rbyd_eoff(&mrootanchor.r) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5656,7 +5656,7 @@ code = '''
// mrootanchor should have been compacted
lfs3_mdir_fetch(&lfs3, &mrootanchor,
-1, LFS3_MPTR_MROOTANCHOR()) => 0;
assert(lfs3_rbyd_eoff(&mrootanchor.rbyd) <= GC_COMPACT_THRESH);
assert(lfs3_rbyd_eoff(&mrootanchor.r) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5710,7 +5710,7 @@ code = '''
// hack, don't use the internals like this
uint8_t wbuf[SIZE];
while ((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -5749,7 +5749,7 @@ code = '''
lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT;
// mdir should have been compacted
assert((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5771,7 +5771,7 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0;
// mdir should have been compacted
assert((file.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5847,7 +5847,7 @@ code = '''
&file1.b.o.mdir, -1, -1,
NULL);
assert(estimate >= 0);
if ((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) > GC_COMPACT_THRESH
if ((file1.b.o.mdir.r.eoff & 0x7fffffff) > GC_COMPACT_THRESH
&& estimate > BLOCK_SIZE/2) {
break;
}
@@ -5902,8 +5902,8 @@ code = '''
lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT;
// mdirs should have been compacted
assert((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5925,8 +5925,8 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0;
// mdirs should have been compacted
assert((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6036,7 +6036,7 @@ code = '''
// write to each file until mdir >gc_compact_thresh full
if (COMPACTSET & 0x1) {
// hack, don't use the internals like this
while ((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file1) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf1[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -6048,7 +6048,7 @@ code = '''
if (COMPACTSET & 0x2) {
// hack, don't use the internals like this
while ((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file2) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf2[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -6060,7 +6060,7 @@ code = '''
if (COMPACTSET & 0x4) {
// hack, don't use the internals like this
while ((file3.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file3) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf3[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -6117,9 +6117,9 @@ code = '''
if (COMPACTSET) {
// mdirs should have been compacted
assert((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6142,9 +6142,9 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0;
// mdirs should have been compacted
assert((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6279,7 +6279,7 @@ code = '''
&file2.b.o.mdir, -1, -1,
NULL);
assert(estimate >= 0);
if ((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) > GC_COMPACT_THRESH
if ((file2.b.o.mdir.r.eoff & 0x7fffffff) > GC_COMPACT_THRESH
&& estimate > BLOCK_SIZE/2) {
break;
}
@@ -6344,10 +6344,10 @@ code = '''
lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT;
// mdirs should have been compacted
assert((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file4.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file4.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6369,10 +6369,10 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0;
// mdirs should have been compacted
assert((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file4.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file4.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6536,8 +6536,8 @@ code = '''
// which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.rbyd.weight <= 3);
assert(file2.b.o.mdir.rbyd.weight <= 3);
assert(file1.b.o.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3);
// and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6845,8 +6845,8 @@ code = '''
// which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.rbyd.weight <= 3);
assert(file2.b.o.mdir.rbyd.weight <= 3);
assert(file1.b.o.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3);
// and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7009,8 +7009,8 @@ code = '''
// which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.rbyd.weight <= 3);
assert(file2.b.o.mdir.rbyd.weight <= 3);
assert(file1.b.o.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3);
// and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7182,8 +7182,8 @@ code = '''
// which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.rbyd.weight <= 3);
assert(file2.b.o.mdir.rbyd.weight <= 3);
assert(file1.b.o.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3);
// and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7355,8 +7355,8 @@ code = '''
// which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.rbyd.weight <= 3);
assert(file2.b.o.mdir.rbyd.weight <= 3);
assert(file1.b.o.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3);
// and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7456,7 +7456,7 @@ code = '''
// write to our mdirs until >gc_compact_thresh full
//
// hack, don't use the internals like this
while ((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file1) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf1[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -7465,7 +7465,7 @@ code = '''
lfs3_file_sync(&lfs3, &file1) => 0;
}
while ((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file2) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf2[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -7524,12 +7524,12 @@ code = '''
// which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.rbyd.weight <= 3);
assert(file2.b.o.mdir.rbyd.weight <= 3);
assert(file1.b.o.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3);
// mdirs should have been compacted
assert((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// we should be marked as consistent, but because we mutated, we're
// still marked as uncompacted
@@ -7552,8 +7552,8 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0;
// mdirs should have been compacted
assert((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7631,7 +7631,7 @@ code = '''
// write to our mdirs until >gc_compact_thresh full
//
// hack, don't use the internals like this
while ((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file1) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf1[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -7640,7 +7640,7 @@ code = '''
lfs3_file_sync(&lfs3, &file1) => 0;
}
while ((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
while ((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file2) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf2[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -7723,8 +7723,8 @@ code = '''
}
// mdirs should have been compacted
assert((file1.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.rbyd.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// if we introduced actual orphans, we _must_ be marked as inconsistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0;