Renamed omdir -> handle

- lfs3_omdir_t -> lfs3_handle_t
- lfs3.omdirs -> lfs3.handles
- o -> h
- lfs3_omdir_* -> lfs3_handle_*
- lfs3_omdir_ismidopen -> lfs3_mid_isopen

From conversations with users, the term "handle" or "file handle" seems
to be the most common/easily understood term for the lfs3_file_t struct
itself. It makes sense to adopt this in our codebase.

I usually dislike inventing new names for things when prefixes can imply
a relationship (size -> ssize, cache -> rcache, shrub -> bshrub, etc),
but lfs3_omdirs_t was probably a bit much.
This commit is contained in:
Christopher Haster
2025-07-18 15:22:22 -05:00
parent ee3be04a93
commit 4cea5af96f
8 changed files with 650 additions and 644 deletions
+501 -498
View File
File diff suppressed because it is too large Load Diff
+10 -7
View File
@@ -691,11 +691,14 @@ typedef struct lfs3_mdir {
uint32_t gcksumdelta; uint32_t gcksumdelta;
} lfs3_mdir_t; } lfs3_mdir_t;
typedef struct lfs3_omdir { // a handle to an opened mdir for tracking purposes
struct lfs3_omdir *next; typedef struct lfs3_handle {
// an invasive linked-list is used to keep things in-sync
struct lfs3_handle *next;
// flags includes the type and type-specific flags
uint32_t flags; uint32_t flags;
lfs3_mdir_t mdir; lfs3_mdir_t mdir;
} lfs3_omdir_t; } lfs3_handle_t;
// a shrub is a secondary trunk in an mdir // a shrub is a secondary trunk in an mdir
typedef lfs3_rbyd_t lfs3_shrub_t; typedef lfs3_rbyd_t lfs3_shrub_t;
@@ -703,7 +706,7 @@ typedef lfs3_rbyd_t lfs3_shrub_t;
// a bshrub is like a btree but with a shrub as a root // a bshrub is like a btree but with a shrub as a root
typedef struct lfs3_bshrub { typedef struct lfs3_bshrub {
// bshrubs need to be tracked for commits to work // bshrubs need to be tracked for commits to work
lfs3_omdir_t o; lfs3_handle_t h;
// files contain both an active bshrub and staging bshrub, to allow // files contain both an active bshrub and staging bshrub, to allow
// staging during mdir compacts // staging during mdir compacts
// trunk=0 => no bshrub/btree // trunk=0 => no bshrub/btree
@@ -749,7 +752,7 @@ typedef struct lfs3_file {
// littlefs directory type // littlefs directory type
typedef struct lfs3_dir { typedef struct lfs3_dir {
lfs3_omdir_t o; lfs3_handle_t h;
lfs3_did_t did; lfs3_did_t did;
lfs3_off_t pos; lfs3_off_t pos;
} lfs3_dir_t; } lfs3_dir_t;
@@ -767,7 +770,7 @@ typedef struct lfs3_traversal {
// state machine // state machine
lfs3_bshrub_t b; lfs3_bshrub_t b;
// opened file state // opened file state
lfs3_omdir_t *ot; lfs3_handle_t *ht;
union { union {
// cycle detection state, only valid when traversing the mroot chain // cycle detection state, only valid when traversing the mroot chain
struct { struct {
@@ -817,7 +820,7 @@ typedef struct lfs3 {
#endif #endif
// linked-list of opened mdirs // linked-list of opened mdirs
lfs3_omdir_t *omdirs; lfs3_handle_t *handles;
lfs3_mdir_t mroot; lfs3_mdir_t mroot;
#ifndef LFS3_2BONLY #ifndef LFS3_2BONLY
+5 -5
View File
@@ -977,7 +977,7 @@ code = '''
lfs3_file_sync(&lfs3, &file) => 0; lfs3_file_sync(&lfs3, &file) => 0;
// delete any bshrub/btree // delete any bshrub/btree
lfs3_mdir_commit(&lfs3, &file.b.o.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &file.b.h.mdir, LFS3_RATTRS(
LFS3_RATTR( LFS3_RATTR(
LFS3_TAG_RM | LFS3_TAG_MASK8 | LFS3_TAG_STRUCT, 0))) => 0; LFS3_TAG_RM | LFS3_TAG_MASK8 | LFS3_TAG_STRUCT, 0))) => 0;
@@ -1093,7 +1093,7 @@ code = '''
lfs3_file_sync(&lfs3, &file) => 0; lfs3_file_sync(&lfs3, &file) => 0;
// create an empty bshrub // create an empty bshrub
lfs3_mdir_commit(&lfs3, &file.b.o.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &file.b.h.mdir, LFS3_RATTRS(
LFS3_RATTR_SHRUBCOMMIT( LFS3_RATTR_SHRUBCOMMIT(
(&(lfs3_shrubcommit_t){ (&(lfs3_shrubcommit_t){
.bshrub=&file.b, .bshrub=&file.b,
@@ -1101,7 +1101,7 @@ code = '''
.rattrs=((lfs3_rattr_t[]){ .rattrs=((lfs3_rattr_t[]){
LFS3_RATTR_BUF(LFS3_TAG_DATA, +1, "?", 1)}), LFS3_RATTR_BUF(LFS3_TAG_DATA, +1, "?", 1)}),
.rattr_count=1})))) => 0; .rattr_count=1})))) => 0;
lfs3_mdir_commit(&lfs3, &file.b.o.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &file.b.h.mdir, LFS3_RATTRS(
LFS3_RATTR_SHRUBCOMMIT( LFS3_RATTR_SHRUBCOMMIT(
(&(lfs3_shrubcommit_t){ (&(lfs3_shrubcommit_t){
.bshrub=&file.b, .bshrub=&file.b,
@@ -1109,7 +1109,7 @@ code = '''
.rattrs=((lfs3_rattr_t[]){ .rattrs=((lfs3_rattr_t[]){
LFS3_RATTR(LFS3_TAG_RM, -1)}), LFS3_RATTR(LFS3_TAG_RM, -1)}),
.rattr_count=1})))) => 0; .rattr_count=1})))) => 0;
lfs3_mdir_commit(&lfs3, &file.b.o.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &file.b.h.mdir, LFS3_RATTRS(
LFS3_RATTR_SHRUB( LFS3_RATTR_SHRUB(
LFS3_TAG_MASK8 | LFS3_TAG_BSHRUB, 0, LFS3_TAG_MASK8 | LFS3_TAG_BSHRUB, 0,
&file.b.shrub_))) => 0; &file.b.shrub_))) => 0;
@@ -1232,7 +1232,7 @@ code = '''
LFS3_RATTR_BUF(LFS3_TAG_DATA, +1, "?", 1))) => 0; LFS3_RATTR_BUF(LFS3_TAG_DATA, +1, "?", 1))) => 0;
lfs3_rbyd_commit(&lfs3, &file.b.shrub, 0, LFS3_RATTRS( lfs3_rbyd_commit(&lfs3, &file.b.shrub, 0, LFS3_RATTRS(
LFS3_RATTR(LFS3_TAG_RM, -1))) => 0; LFS3_RATTR(LFS3_TAG_RM, -1))) => 0;
lfs3_mdir_commit(&lfs3, &file.b.o.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &file.b.h.mdir, LFS3_RATTRS(
LFS3_RATTR_BTREE( LFS3_RATTR_BTREE(
LFS3_TAG_MASK8 | LFS3_TAG_BTREE, 0, LFS3_TAG_MASK8 | LFS3_TAG_BTREE, 0,
&file.b.shrub))) => 0; &file.b.shrub))) => 0;
+2 -2
View File
@@ -5006,7 +5006,7 @@ code = '''
pos = pos - (weight/2) + 1; pos = pos - (weight/2) + 1;
} }
file.b.o.flags |= LFS3_o_UNSYNC; file.b.h.flags |= LFS3_o_UNSYNC;
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
for (int remount = 0; remount < 2; remount++) { for (int remount = 0; remount < 2; remount++) {
@@ -5116,7 +5116,7 @@ code = '''
pos = pos - (weight/2) + 1; pos = pos - (weight/2) + 1;
} }
file.b.o.flags |= LFS3_o_UNSYNC; file.b.h.flags |= LFS3_o_UNSYNC;
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
for (int remount = 0; remount < 2; remount++) { for (int remount = 0; remount < 2; remount++) {
+17 -17
View File
@@ -45,7 +45,7 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_LOOKAHEAD); assert(fsinfo.flags & LFS3_I_LOOKAHEAD);
assert(lfs3.omdirs != &lfs3.gc.t.b.o); assert(lfs3.handles != &lfs3.gc.t.b.h);
// run GC until we make progress // run GC until we make progress
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
@@ -112,11 +112,11 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_LOOKAHEAD); assert(fsinfo.flags & LFS3_I_LOOKAHEAD);
assert(lfs3.omdirs != &lfs3.gc.t.b.o); assert(lfs3.handles != &lfs3.gc.t.b.h);
// run GC one step // run GC one step
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
assert(lfs3.omdirs == &lfs3.gc.t.b.o); assert(lfs3.handles == &lfs3.gc.t.b.h);
// mutate the filesystem // mutate the filesystem
lfs3_file_open(&lfs3, &file, "spider", lfs3_file_open(&lfs3, &file, "spider",
@@ -128,7 +128,7 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
// run GC until our traversal is done // run GC until our traversal is done
while (lfs3.omdirs == &lfs3.gc.t.b.o) { while (lfs3.handles == &lfs3.gc.t.b.h) {
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
} }
@@ -184,7 +184,7 @@ code = '''
// hack, don't use the internals like this // hack, don't use the internals like this
uint8_t wbuf[SIZE]; uint8_t wbuf[SIZE];
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0; lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -197,7 +197,7 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_COMPACT); assert(fsinfo.flags & LFS3_I_COMPACT);
assert(lfs3.omdirs != &lfs3.gc.t.b.o); assert(lfs3.handles != &lfs3.gc.t.b.h);
// run GC until we make progress // run GC until we make progress
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
@@ -213,7 +213,7 @@ code = '''
} }
// mdir should have been compacted // mdir should have been compacted
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// check we can still read the file // check we can still read the file
for (int remount = 0; remount < 2; remount++) { for (int remount = 0; remount < 2; remount++) {
@@ -273,7 +273,7 @@ code = '''
// hack, don't use the internals like this // hack, don't use the internals like this
uint8_t wbuf[SIZE]; uint8_t wbuf[SIZE];
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0; lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -286,19 +286,19 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_COMPACT); assert(fsinfo.flags & LFS3_I_COMPACT);
assert(lfs3.omdirs != &lfs3.gc.t.b.o); assert(lfs3.handles != &lfs3.gc.t.b.h);
// run GC one traversal + one step // run GC one traversal + one step
while (true) { while (true) {
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
// internal traversal done? // internal traversal done?
if (lfs3.omdirs != &lfs3.gc.t.b.o) { if (lfs3.handles != &lfs3.gc.t.b.h) {
break; break;
} }
} }
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
assert(lfs3.omdirs == &lfs3.gc.t.b.o); assert(lfs3.handles == &lfs3.gc.t.b.h);
// mutate the filesystem // mutate the filesystem
lfs3_file_rewind(&lfs3, &file) => 0; lfs3_file_rewind(&lfs3, &file) => 0;
@@ -309,7 +309,7 @@ code = '''
lfs3_file_sync(&lfs3, &file) => 0; lfs3_file_sync(&lfs3, &file) => 0;
// run GC until our traversal is done (twice for compact) // run GC until our traversal is done (twice for compact)
while (lfs3.omdirs == &lfs3.gc.t.b.o) { while (lfs3.handles == &lfs3.gc.t.b.h) {
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
} }
@@ -410,7 +410,7 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_MKCONSISTENT); assert(fsinfo.flags & LFS3_I_MKCONSISTENT);
assert(lfs3.omdirs != &lfs3.gc.t.b.o); assert(lfs3.handles != &lfs3.gc.t.b.h);
// run GC until we make progress // run GC until we make progress
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
@@ -513,7 +513,7 @@ code = '''
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_MKCONSISTENT); assert(fsinfo.flags & LFS3_I_MKCONSISTENT);
#ifdef LFS3_GC #ifdef LFS3_GC
assert(lfs3.omdirs != &lfs3.gc.t.b.o); assert(lfs3.handles != &lfs3.gc.t.b.h);
#endif #endif
// call lfs3_fs_mkconsistent // call lfs3_fs_mkconsistent
@@ -614,9 +614,9 @@ code = '''
} }
// run GC one step // run GC one step
assert(lfs3.omdirs != &lfs3.gc.t.b.o); assert(lfs3.handles != &lfs3.gc.t.b.h);
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
assert(lfs3.omdirs == &lfs3.gc.t.b.o); assert(lfs3.handles == &lfs3.gc.t.b.h);
// create the rest of the orphans after GC has started // create the rest of the orphans after GC has started
for (lfs3_size_t i = 0; i < ORPHANS; i++) { for (lfs3_size_t i = 0; i < ORPHANS; i++) {
@@ -638,7 +638,7 @@ code = '''
assert(fsinfo.flags & LFS3_I_MKCONSISTENT); assert(fsinfo.flags & LFS3_I_MKCONSISTENT);
// run GC until our traversal is done // run GC until our traversal is done
while (lfs3.omdirs == &lfs3.gc.t.b.o) { while (lfs3.handles == &lfs3.gc.t.b.h) {
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
} }
+2 -2
View File
@@ -203,7 +203,7 @@ code = '''
// hack, don't use the internals like this // hack, don't use the internals like this
uint8_t wbuf[SIZE]; uint8_t wbuf[SIZE];
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0; lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -245,7 +245,7 @@ code = '''
// mdir should have been compacted // mdir should have been compacted
lfs3_file_open(&lfs3, &file, "jellyfish", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "jellyfish", LFS3_O_RDONLY) => 0;
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// check we can still read the file // check we can still read the file
uint8_t rbuf[SIZE]; uint8_t rbuf[SIZE];
+60 -60
View File
@@ -2860,21 +2860,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "c", 1, lfs3_mtree_namelookup(&lfs3, 0, "c", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "c", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "c", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// insert a new entry, this should update our neighbors // insert a new entry, this should update our neighbors
lfs3_mdir_t mdir; lfs3_mdir_t mdir;
@@ -2906,8 +2906,8 @@ code = '''
assert(right.mdir.r.trunk == mdir.r.trunk); assert(right.mdir.r.trunk == mdir.r.trunk);
assert(right.mdir.r.cksum == mdir.r.cksum); assert(right.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
@@ -2920,21 +2920,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "b", 1, lfs3_mtree_namelookup(&lfs3, 0, "b", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "b", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "b", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// try removing left neighbor // try removing left neighbor
lfs3_mdir_t mdir; lfs3_mdir_t mdir;
@@ -2956,8 +2956,8 @@ code = '''
assert(right.mdir.r.trunk == mdir.r.trunk); assert(right.mdir.r.trunk == mdir.r.trunk);
assert(right.mdir.r.cksum == mdir.r.cksum); assert(right.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
@@ -2970,21 +2970,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "b", 1, lfs3_mtree_namelookup(&lfs3, 0, "b", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "b", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "b", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// try removing right neighbor // try removing right neighbor
lfs3_mdir_t mdir; lfs3_mdir_t mdir;
@@ -3006,8 +3006,8 @@ code = '''
assert(left.mdir.r.trunk == mdir.r.trunk); assert(left.mdir.r.trunk == mdir.r.trunk);
assert(left.mdir.r.cksum == mdir.r.cksum); assert(left.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
@@ -3022,21 +3022,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "d", 1, lfs3_mtree_namelookup(&lfs3, 0, "d", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "d", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "d", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// create 2 large entries that needs to be uninlined and split // create 2 large entries that needs to be uninlined and split
uint8_t buffer[SIZE]; uint8_t buffer[SIZE];
@@ -3083,8 +3083,8 @@ code = '''
assert(right.mdir.r.trunk == mdir.r.trunk); assert(right.mdir.r.trunk == mdir.r.trunk);
assert(right.mdir.r.cksum == mdir.r.cksum); assert(right.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
@@ -3099,21 +3099,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "e", 1, lfs3_mtree_namelookup(&lfs3, 0, "e", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "e", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "e", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// create 2 large entries that needs to be uninlined and split // create 2 large entries that needs to be uninlined and split
uint8_t buffer[SIZE]; uint8_t buffer[SIZE];
@@ -3174,8 +3174,8 @@ code = '''
assert(right.mdir.r.trunk == mdir.r.trunk); assert(right.mdir.r.trunk == mdir.r.trunk);
assert(right.mdir.r.cksum == mdir.r.cksum); assert(right.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
@@ -3190,21 +3190,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "b", 1, lfs3_mtree_namelookup(&lfs3, 0, "b", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "b", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "b", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// force mroot to compact twice, this should extend the mroot // force mroot to compact twice, this should extend the mroot
lfs3_mdir_t old_mroot = lfs3.mroot; lfs3_mdir_t old_mroot = lfs3.mroot;
@@ -3230,8 +3230,8 @@ code = '''
assert(right.mdir.r.trunk == mdir.r.trunk); assert(right.mdir.r.trunk == mdir.r.trunk);
assert(right.mdir.r.cksum == mdir.r.cksum); assert(right.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
@@ -3248,21 +3248,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "d", 1, lfs3_mtree_namelookup(&lfs3, 0, "d", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "d", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "d", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// create 2 large entries that needs to be uninlined and split // create 2 large entries that needs to be uninlined and split
uint8_t buffer[SIZE]; uint8_t buffer[SIZE];
@@ -3327,8 +3327,8 @@ code = '''
assert(right.mdir.r.trunk == mdir.r.trunk); assert(right.mdir.r.trunk == mdir.r.trunk);
assert(right.mdir.r.cksum == mdir.r.cksum); assert(right.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
@@ -3345,21 +3345,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "d", 1, lfs3_mtree_namelookup(&lfs3, 0, "d", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "d", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "d", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// create 2 large entries that needs to be uninlined and split // create 2 large entries that needs to be uninlined and split
uint8_t buffer[SIZE]; uint8_t buffer[SIZE];
@@ -3424,8 +3424,8 @@ code = '''
assert(right.mdir.r.trunk == mdir.r.trunk); assert(right.mdir.r.trunk == mdir.r.trunk);
assert(right.mdir.r.cksum == mdir.r.cksum); assert(right.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
@@ -3440,21 +3440,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "f", 1, lfs3_mtree_namelookup(&lfs3, 0, "f", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "f", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "f", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// create 2 large entries that needs to be uninlined and split // create 2 large entries that needs to be uninlined and split
uint8_t buffer[SIZE]; uint8_t buffer[SIZE];
@@ -3534,8 +3534,8 @@ code = '''
assert(right.mdir.r.trunk == mdir.r.trunk); assert(right.mdir.r.trunk == mdir.r.trunk);
assert(right.mdir.r.cksum == mdir.r.cksum); assert(right.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
@@ -3550,21 +3550,21 @@ code = '''
lfs3_alloc_ckpoint(&lfs3); lfs3_alloc_ckpoint(&lfs3);
// setup our neighbors // setup our neighbors
lfs3_omdir_t left = {.flags=0}; lfs3_handle_t left = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "a", 1, lfs3_mtree_namelookup(&lfs3, 0, "a", 1,
&left.mdir, NULL) => LFS3_ERR_NOENT; &left.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &left.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "a", 1))) => 0;
assert(left.mdir.r.weight == 2); assert(left.mdir.r.weight == 2);
lfs3_omdir_open(&lfs3, &left); lfs3_handle_open(&lfs3, &left);
lfs3_omdir_t right = {.flags=0}; lfs3_handle_t right = {.flags=0};
lfs3_mtree_namelookup(&lfs3, 0, "e", 1, lfs3_mtree_namelookup(&lfs3, 0, "e", 1,
&right.mdir, NULL) => LFS3_ERR_NOENT; &right.mdir, NULL) => LFS3_ERR_NOENT;
lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS( lfs3_mdir_commit(&lfs3, &right.mdir, LFS3_RATTRS(
LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "e", 1))) => 0; LFS3_RATTR_NAME(LFS3_TAG_REG, +1, 0, "e", 1))) => 0;
assert(right.mdir.r.weight == 3); assert(right.mdir.r.weight == 3);
lfs3_omdir_open(&lfs3, &right); lfs3_handle_open(&lfs3, &right);
// create 2 large entries that needs to be uninlined and split // create 2 large entries that needs to be uninlined and split
uint8_t buffer[SIZE]; uint8_t buffer[SIZE];
@@ -3635,8 +3635,8 @@ code = '''
assert(right.mdir.r.trunk == mdir.r.trunk); assert(right.mdir.r.trunk == mdir.r.trunk);
assert(right.mdir.r.cksum == mdir.r.cksum); assert(right.mdir.r.cksum == mdir.r.cksum);
lfs3_omdir_close(&lfs3, &left); lfs3_handle_close(&lfs3, &left);
lfs3_omdir_close(&lfs3, &right); lfs3_handle_close(&lfs3, &right);
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
''' '''
+53 -53
View File
@@ -5456,7 +5456,7 @@ code = '''
// hack, don't use the internals like this // hack, don't use the internals like this
uint8_t wbuf[SIZE]; uint8_t wbuf[SIZE];
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0; lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -5493,7 +5493,7 @@ code = '''
lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT; lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT;
// mdir should have been compacted // mdir should have been compacted
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted // but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5515,7 +5515,7 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_traversal_close(&lfs3, &t) => 0;
// mdir should have been compacted // mdir should have been compacted
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared // uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5710,7 +5710,7 @@ code = '''
// hack, don't use the internals like this // hack, don't use the internals like this
uint8_t wbuf[SIZE]; uint8_t wbuf[SIZE];
while ((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file) => 0; lfs3_file_rewind(&lfs3, &file) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -5749,7 +5749,7 @@ code = '''
lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT; lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT;
// mdir should have been compacted // mdir should have been compacted
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted // but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5771,7 +5771,7 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_traversal_close(&lfs3, &t) => 0;
// mdir should have been compacted // mdir should have been compacted
assert((file.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared // uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5844,10 +5844,10 @@ code = '''
assert(lfs3.mtree.weight == 0); assert(lfs3.mtree.weight == 0);
// we need internals to check this // we need internals to check this
lfs3_ssize_t estimate = lfs3_mdir_estimate__(&lfs3, lfs3_ssize_t estimate = lfs3_mdir_estimate__(&lfs3,
&file1.b.o.mdir, -1, -1, &file1.b.h.mdir, -1, -1,
NULL); NULL);
assert(estimate >= 0); assert(estimate >= 0);
if ((file1.b.o.mdir.r.eoff & 0x7fffffff) > GC_COMPACT_THRESH if ((file1.b.h.mdir.r.eoff & 0x7fffffff) > GC_COMPACT_THRESH
&& estimate > BLOCK_SIZE/2) { && estimate > BLOCK_SIZE/2) {
break; break;
} }
@@ -5902,8 +5902,8 @@ code = '''
lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT; lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT;
// mdirs should have been compacted // mdirs should have been compacted
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted // but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -5925,8 +5925,8 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_traversal_close(&lfs3, &t) => 0;
// mdirs should have been compacted // mdirs should have been compacted
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared // uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6036,7 +6036,7 @@ code = '''
// write to each file until mdir >gc_compact_thresh full // write to each file until mdir >gc_compact_thresh full
if (COMPACTSET & 0x1) { if (COMPACTSET & 0x1) {
// hack, don't use the internals like this // hack, don't use the internals like this
while ((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file1) => 0; lfs3_file_rewind(&lfs3, &file1) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf1[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf1[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -6048,7 +6048,7 @@ code = '''
if (COMPACTSET & 0x2) { if (COMPACTSET & 0x2) {
// hack, don't use the internals like this // hack, don't use the internals like this
while ((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file2) => 0; lfs3_file_rewind(&lfs3, &file2) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf2[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf2[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -6060,7 +6060,7 @@ code = '''
if (COMPACTSET & 0x4) { if (COMPACTSET & 0x4) {
// hack, don't use the internals like this // hack, don't use the internals like this
while ((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file3.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file3) => 0; lfs3_file_rewind(&lfs3, &file3) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf3[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf3[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -6117,9 +6117,9 @@ code = '''
if (COMPACTSET) { if (COMPACTSET) {
// mdirs should have been compacted // mdirs should have been compacted
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file3.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted // but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6142,9 +6142,9 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_traversal_close(&lfs3, &t) => 0;
// mdirs should have been compacted // mdirs should have been compacted
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file3.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared // uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6276,10 +6276,10 @@ code = '''
assert(lfs3.mtree.weight == orig); assert(lfs3.mtree.weight == orig);
// we need internals to check this // we need internals to check this
lfs3_ssize_t estimate = lfs3_mdir_estimate__(&lfs3, lfs3_ssize_t estimate = lfs3_mdir_estimate__(&lfs3,
&file2.b.o.mdir, -1, -1, &file2.b.h.mdir, -1, -1,
NULL); NULL);
assert(estimate >= 0); assert(estimate >= 0);
if ((file2.b.o.mdir.r.eoff & 0x7fffffff) > GC_COMPACT_THRESH if ((file2.b.h.mdir.r.eoff & 0x7fffffff) > GC_COMPACT_THRESH
&& estimate > BLOCK_SIZE/2) { && estimate > BLOCK_SIZE/2) {
break; break;
} }
@@ -6344,10 +6344,10 @@ code = '''
lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT; lfs3_traversal_read(&lfs3, &t, &tinfo) => LFS3_ERR_NOENT;
// mdirs should have been compacted // mdirs should have been compacted
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file3.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file4.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file4.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// but because we mutated, we're still marked as uncompacted // but because we mutated, we're still marked as uncompacted
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6369,10 +6369,10 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_traversal_close(&lfs3, &t) => 0;
// mdirs should have been compacted // mdirs should have been compacted
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file3.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file3.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file4.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file4.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared // uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6536,8 +6536,8 @@ code = '''
// which means there shouldn't be that many files left // which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits)); assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.r.weight <= 3); assert(file1.b.h.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3); assert(file2.b.h.mdir.r.weight <= 3);
// and we should be marked as consistent // and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -6845,8 +6845,8 @@ code = '''
// which means there shouldn't be that many files left // which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits)); assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.r.weight <= 3); assert(file1.b.h.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3); assert(file2.b.h.mdir.r.weight <= 3);
// and we should be marked as consistent // and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7009,8 +7009,8 @@ code = '''
// which means there shouldn't be that many files left // which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits)); assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.r.weight <= 3); assert(file1.b.h.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3); assert(file2.b.h.mdir.r.weight <= 3);
// and we should be marked as consistent // and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7182,8 +7182,8 @@ code = '''
// which means there shouldn't be that many files left // which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits)); assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.r.weight <= 3); assert(file1.b.h.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3); assert(file2.b.h.mdir.r.weight <= 3);
// and we should be marked as consistent // and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7355,8 +7355,8 @@ code = '''
// which means there shouldn't be that many files left // which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits)); assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.r.weight <= 3); assert(file1.b.h.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3); assert(file2.b.h.mdir.r.weight <= 3);
// and we should be marked as consistent // and we should be marked as consistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7456,7 +7456,7 @@ code = '''
// write to our mdirs until >gc_compact_thresh full // write to our mdirs until >gc_compact_thresh full
// //
// hack, don't use the internals like this // hack, don't use the internals like this
while ((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file1) => 0; lfs3_file_rewind(&lfs3, &file1) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf1[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf1[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -7465,7 +7465,7 @@ code = '''
lfs3_file_sync(&lfs3, &file1) => 0; lfs3_file_sync(&lfs3, &file1) => 0;
} }
while ((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file2) => 0; lfs3_file_rewind(&lfs3, &file2) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf2[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf2[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -7524,12 +7524,12 @@ code = '''
// which means there shouldn't be that many files left // which means there shouldn't be that many files left
assert(lfs3.mtree.weight <= (2 << lfs3.mbits)); assert(lfs3.mtree.weight <= (2 << lfs3.mbits));
assert(file1.b.o.mdir.r.weight <= 3); assert(file1.b.h.mdir.r.weight <= 3);
assert(file2.b.o.mdir.r.weight <= 3); assert(file2.b.h.mdir.r.weight <= 3);
// mdirs should have been compacted // mdirs should have been compacted
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// we should be marked as consistent, but because we mutated, we're // we should be marked as consistent, but because we mutated, we're
// still marked as uncompacted // still marked as uncompacted
@@ -7552,8 +7552,8 @@ code = '''
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_traversal_close(&lfs3, &t) => 0;
// mdirs should have been compacted // mdirs should have been compacted
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// uncompacted flag should have been cleared // uncompacted flag should have been cleared
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
@@ -7631,7 +7631,7 @@ code = '''
// write to our mdirs until >gc_compact_thresh full // write to our mdirs until >gc_compact_thresh full
// //
// hack, don't use the internals like this // hack, don't use the internals like this
while ((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file1) => 0; lfs3_file_rewind(&lfs3, &file1) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf1[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf1[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -7640,7 +7640,7 @@ code = '''
lfs3_file_sync(&lfs3, &file1) => 0; lfs3_file_sync(&lfs3, &file1) => 0;
} }
while ((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) { while ((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
lfs3_file_rewind(&lfs3, &file2) => 0; lfs3_file_rewind(&lfs3, &file2) => 0;
for (lfs3_size_t j = 0; j < SIZE; j++) { for (lfs3_size_t j = 0; j < SIZE; j++) {
wbuf2[j] = 'a' + (TEST_PRNG(&prng) % 26); wbuf2[j] = 'a' + (TEST_PRNG(&prng) % 26);
@@ -7723,8 +7723,8 @@ code = '''
} }
// mdirs should have been compacted // mdirs should have been compacted
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH); assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
// if we introduced actual orphans, we _must_ be marked as inconsistent // if we introduced actual orphans, we _must_ be marked as inconsistent
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;