Ported over most rbyd+btree tests to new attr-list format

Found a bug, and maybe a fundamental issue:

- The lfs_btree_lookupnext_ in lfsr_btree_commit_ no longer needs the
  min32, since we never commit with bid pointing past the end of the
  btree anymore.

  This was mixing the unsigned min32 with our now-signed bid type,
  causing the wrong btree leaf to be fetched when inserting at bid=-1 in
  a non-empty btree.

  Easy fix.

- lfsr_btree_commit_ with bid!=-1, rid=-1 (inserting at the beginning of
  not-the-first rbyd) now actually appends to the leaf to the left of
  the rbyd instead of inserting into the expected rbyd because of how
  lfs_btree_lookup_ works.

  Initially, this doesn't seem like it would be an issue, these should
  be more-or-less equivalent, but this doesn't match
  lfsr_btree_namelookup! This is a big problem!

  This wasn't noticed because it's rare for the high-level tests to
  trigger that many btree splits with names. Named btrees are only used
  for the mtree, and we need mdirs to split before the mtree even splits
  once.

  Not an easy fix.

On the upside, these low-level tests continue to prove themselves
valuable, if tedious to maintain...
This commit is contained in:
Christopher Haster
2024-01-26 13:16:36 -06:00
parent f323ea1bda
commit 7868ec7122
3 changed files with 1260 additions and 1963 deletions
+1 -2
View File
@@ -3998,8 +3998,7 @@ static int lfsr_btree_commit_(lfs_t *lfs, lfsr_btree_t *btree,
lfsr_srid_t rid = bid;
if (btree->weight > 0) {
lfsr_srid_t rid_;
int err = lfsr_btree_lookupnext_(lfs, btree,
lfs_min32(bid, btree->weight-1),
int err = lfsr_btree_lookupnext_(lfs, btree, bid,
&bid, &rbyd, &rid_, NULL, NULL, NULL);
if (err) {
LFS_ASSERT(err != LFS_ERR_NOENT);