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:
+53
-53
@@ -5456,7 +5456,7 @@ code = '''
|
||||
|
||||
// hack, don't use the internals like this
|
||||
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;
|
||||
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.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
|
||||
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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file.b.h.mdir.r.eoff & 0x7fffffff) <= 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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
|
||||
while ((file.b.h.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.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
|
||||
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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
|
||||
// uncompacted flag should have been cleared
|
||||
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
|
||||
@@ -5844,10 +5844,10 @@ code = '''
|
||||
assert(lfs3.mtree.weight == 0);
|
||||
// we need internals to check this
|
||||
lfs3_ssize_t estimate = lfs3_mdir_estimate__(&lfs3,
|
||||
&file1.b.o.mdir, -1, -1,
|
||||
&file1.b.h.mdir, -1, -1,
|
||||
NULL);
|
||||
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) {
|
||||
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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file1.b.h.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
|
||||
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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.h.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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
|
||||
while ((file1.b.h.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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
|
||||
while ((file2.b.h.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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
|
||||
while ((file3.b.h.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.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((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.h.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
|
||||
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.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((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file3.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
|
||||
// uncompacted flag should have been cleared
|
||||
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
|
||||
@@ -6276,10 +6276,10 @@ code = '''
|
||||
assert(lfs3.mtree.weight == orig);
|
||||
// we need internals to check this
|
||||
lfs3_ssize_t estimate = lfs3_mdir_estimate__(&lfs3,
|
||||
&file2.b.o.mdir, -1, -1,
|
||||
&file2.b.h.mdir, -1, -1,
|
||||
NULL);
|
||||
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) {
|
||||
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.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);
|
||||
assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file3.b.h.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
|
||||
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.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);
|
||||
assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file3.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file4.b.h.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.r.weight <= 3);
|
||||
assert(file2.b.o.mdir.r.weight <= 3);
|
||||
assert(file1.b.h.mdir.r.weight <= 3);
|
||||
assert(file2.b.h.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.r.weight <= 3);
|
||||
assert(file2.b.o.mdir.r.weight <= 3);
|
||||
assert(file1.b.h.mdir.r.weight <= 3);
|
||||
assert(file2.b.h.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.r.weight <= 3);
|
||||
assert(file2.b.o.mdir.r.weight <= 3);
|
||||
assert(file1.b.h.mdir.r.weight <= 3);
|
||||
assert(file2.b.h.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.r.weight <= 3);
|
||||
assert(file2.b.o.mdir.r.weight <= 3);
|
||||
assert(file1.b.h.mdir.r.weight <= 3);
|
||||
assert(file2.b.h.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.r.weight <= 3);
|
||||
assert(file2.b.o.mdir.r.weight <= 3);
|
||||
assert(file1.b.h.mdir.r.weight <= 3);
|
||||
assert(file2.b.h.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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
|
||||
while ((file1.b.h.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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
|
||||
while ((file2.b.h.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.r.weight <= 3);
|
||||
assert(file2.b.o.mdir.r.weight <= 3);
|
||||
assert(file1.b.h.mdir.r.weight <= 3);
|
||||
assert(file2.b.h.mdir.r.weight <= 3);
|
||||
|
||||
// mdirs should have been compacted
|
||||
assert((file1.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file1.b.h.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
|
||||
// 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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file1.b.h.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.h.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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
|
||||
while ((file1.b.h.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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH) {
|
||||
while ((file2.b.h.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.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file2.b.o.mdir.r.eoff & 0x7fffffff) <= GC_COMPACT_THRESH);
|
||||
assert((file1.b.h.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
|
||||
lfs3_fs_stat(&lfs3, &fsinfo) => 0;
|
||||
|
||||
Reference in New Issue
Block a user