Some minor tweaks to internal ptr types

- Renamed mpair -> mptr, may have >2 blocks in the future.

- Renamed branch -> bptr for consistency.

- Renamed other_block -> redund_rbyd.

- Changed comparison functions to use -1, 0, +1, even for unordered
  types.

- Added lfs_cmp function for unioning comparisons with signed errors.
This commit is contained in:
Christopher Haster
2023-06-27 13:15:15 -05:00
parent cf588ac3fa
commit 91d90b7eef
3 changed files with 237 additions and 246 deletions
+46 -46
View File
@@ -1557,7 +1557,7 @@ code = '''
LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mdir, &mdir));
assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -1584,7 +1584,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated
assert(!lfsr_mdir_eq(&old_mdir, &mdir));
assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -1648,7 +1648,7 @@ code = '''
LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mdir, &mdir));
assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0);
// assert that our entries are still in the mtree
lfsr_mtree_lookup(&lfs, 0, &mdir) => 0;
@@ -1675,7 +1675,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated
assert(!lfsr_mdir_eq(&old_mdir, &mdir));
assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0);
// assert that our entries are still in the mtree
lfsr_mtree_lookup(&lfs, 0, &mdir) => 0;
@@ -1739,7 +1739,7 @@ code = '''
LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mdir, &mdir));
assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0);
// assert that our entries are still in the mtree
lfsr_mtree_lookup(&lfs, 0, &mdir) => 0;
@@ -1766,7 +1766,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated
assert(!lfsr_mdir_eq(&old_mdir, &mdir));
assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0);
// assert that our entries are still in the mtree
lfsr_mtree_lookup(&lfs, 0, &mdir) => 0;
@@ -1813,7 +1813,7 @@ code = '''
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -1827,7 +1827,7 @@ code = '''
lfsr_mount(&lfs, cfg) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -1871,7 +1871,7 @@ code = '''
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -1885,7 +1885,7 @@ code = '''
lfsr_mount(&lfs, cfg) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -1922,7 +1922,7 @@ code = '''
lfsr_mdir_commit(&lfs, &lfs.mroot, &(lfs_ssize_t){-1}, NULL, 0) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// force mroot to compact twice again, this should relocate the mroot
old_mroot = lfs.mroot;
@@ -1935,7 +1935,7 @@ code = '''
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -1949,7 +1949,7 @@ code = '''
lfsr_mount(&lfs, cfg) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -2011,10 +2011,10 @@ code = '''
LFSR_ATTR(0, INLINED, 0, buffer, SIZE))) => 0;
// assert we relocated our mdir
assert(!lfsr_mdir_eq(&old_mdir, &mdir));
assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -2041,10 +2041,10 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated our mdir
assert(!lfsr_mdir_eq(&old_mdir, &mdir));
assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -2117,7 +2117,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -2149,7 +2149,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -2222,7 +2222,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -2241,7 +2241,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -2290,7 +2290,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -2318,7 +2318,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -2374,7 +2374,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our entries are still in the mtree
lfsr_mdir_t mdir;
@@ -2402,7 +2402,7 @@ code = '''
assert(lfs.mroot.rbyd.weight == 0);
// assert we relocated our mroot
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our entries are still in the mtree
lfsr_mtree_lookup(&lfs, 0, &mdir) => 0;
@@ -2966,7 +2966,7 @@ code = '''
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -3045,7 +3045,7 @@ code = '''
LFSR_ATTR(1, INLINED, 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mdir, &mdir));
assert(lfsr_mdir_cmp(&old_mdir, &mdir) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -3133,11 +3133,11 @@ code = '''
printf("traversal: %d 0x%x mdir 0x{%x,%x}\n",
mid_,
tag_,
mdir->rbyd.block, mdir->other_block);
mdir->rbyd.block, mdir->redund_block);
// keep track of seen blocks
seen[mdir->rbyd.block / 8] |= 1 << (mdir->rbyd.block % 8);
seen[mdir->other_block / 8] |= 1 << (mdir->other_block % 8);
seen[mdir->redund_block / 8] |= 1 << (mdir->redund_block % 8);
} else {
// this shouldn't happen
printf("traversal: %d 0x%x %d\n",
@@ -3251,11 +3251,11 @@ code = '''
printf("traversal: %d 0x%x mdir 0x{%x,%x}\n",
mid_,
tag_,
mdir->rbyd.block, mdir->other_block);
mdir->rbyd.block, mdir->redund_block);
// keep track of seen blocks
seen[mdir->rbyd.block / 8] |= 1 << (mdir->rbyd.block % 8);
seen[mdir->other_block / 8] |= 1 << (mdir->other_block % 8);
seen[mdir->redund_block / 8] |= 1 << (mdir->redund_block % 8);
} else {
// this shouldn't happen
printf("traversal: %d 0x%x %d\n",
@@ -3380,11 +3380,11 @@ code = '''
printf("traversal: %d 0x%x mdir 0x{%x,%x}\n",
mid_,
tag_,
mdir->rbyd.block, mdir->other_block);
mdir->rbyd.block, mdir->redund_block);
// keep track of seen blocks
seen[mdir->rbyd.block / 8] |= 1 << (mdir->rbyd.block % 8);
seen[mdir->other_block / 8] |= 1 << (mdir->other_block % 8);
seen[mdir->redund_block / 8] |= 1 << (mdir->redund_block % 8);
} else {
// this shouldn't happen
printf("traversal: %d 0x%x %d\n",
@@ -3459,7 +3459,7 @@ code = '''
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -3501,11 +3501,11 @@ code = '''
printf("traversal: %d 0x%x mdir 0x{%x,%x}\n",
mid_,
tag_,
mdir->rbyd.block, mdir->other_block);
mdir->rbyd.block, mdir->redund_block);
// keep track of seen blocks
seen[mdir->rbyd.block / 8] |= 1 << (mdir->rbyd.block % 8);
seen[mdir->other_block / 8] |= 1 << (mdir->other_block % 8);
seen[mdir->redund_block / 8] |= 1 << (mdir->redund_block % 8);
} else {
// this shouldn't happen
printf("traversal: %d 0x%x %d\n",
@@ -3530,7 +3530,7 @@ code = '''
// and the tree should still work
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -3629,11 +3629,11 @@ code = '''
printf("traversal: %d 0x%x mdir 0x{%x,%x}\n",
mid_,
tag_,
mdir->rbyd.block, mdir->other_block);
mdir->rbyd.block, mdir->redund_block);
// keep track of seen blocks
seen[mdir->rbyd.block / 8] |= 1 << (mdir->rbyd.block % 8);
seen[mdir->other_block / 8] |= 1 << (mdir->other_block % 8);
seen[mdir->redund_block / 8] |= 1 << (mdir->redund_block % 8);
} else {
// this shouldn't happen
printf("traversal: %d 0x%x %d\n",
@@ -3795,11 +3795,11 @@ code = '''
printf("traversal: %d 0x%x mdir 0x{%x,%x}\n",
mid_,
tag_,
mdir->rbyd.block, mdir->other_block);
mdir->rbyd.block, mdir->redund_block);
// keep track of seen blocks
seen[mdir->rbyd.block / 8] |= 1 << (mdir->rbyd.block % 8);
seen[mdir->other_block / 8] |= 1 << (mdir->other_block % 8);
seen[mdir->redund_block / 8] |= 1 << (mdir->redund_block % 8);
} else {
// this shouldn't happen
printf("traversal: %d 0x%x %d\n",
@@ -3861,8 +3861,8 @@ code = '''
lfsr_format(&lfs, cfg) => 0;
lfsr_mount(&lfs, cfg) => 0;
uint8_t buffer[LFSR_MPAIR_DSIZE];
lfs_ssize_t d = lfsr_mpair_todisk(&lfs, LFSR_MPAIR(0, 1), buffer);
uint8_t buffer[LFSR_MPTR_DSIZE];
lfs_ssize_t d = lfsr_mptr_todisk(&lfs, LFSR_MPTR_MROOTANCHOR, buffer);
assert(d >= 0);
lfsr_mdir_commit(&lfs, &lfs.mroot, &(lfs_ssize_t){-1}, LFSR_ATTRS(
LFSR_ATTR(-1, MROOT, 0, buffer, d))) => 0;
@@ -3896,7 +3896,7 @@ code = '''
printf("traversal: %d 0x%x mdir 0x{%x,%x}\n",
mid_,
tag_,
mdir->rbyd.block, mdir->other_block);
mdir->rbyd.block, mdir->redund_block);
} else {
// this shouldn't happen
printf("traversal: %d 0x%x %d\n",
@@ -3962,7 +3962,7 @@ code = '''
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),
@@ -4018,7 +4018,7 @@ code = '''
LFSR_ATTR(-1, UATTR(1), 0, buffer, SIZE))) => 0;
// assert we relocated
assert(!lfsr_mdir_eq(&old_mroot, &lfs.mroot));
assert(lfsr_mdir_cmp(&old_mroot, &lfs.mroot) != 0);
// assert that our attr is still in the mroot
lfsr_mdir_get(&lfs, &lfs.mroot, -1, LFSR_TAG_UATTR(1),