Fixed incorrect assumption that weights imply bshrub roots
rbyd.weight == btree.weight does not imply rbyd is a bshrub root!
This was introduced during a btrv rework, and, unfortunately, works
_most_ of the time. It's extra deceptive because we eagerly collapse
these degenerate roots in lfs3_btree_commit_, but we can't collapse
bshrub roots!
Well, not easily anyways (I guess we could convert to a btree...), but
what's important is that single-entry btree nodes are possible, and
relying on the weight for shrubbed roots is a weak condition.
Instead, we now just check the shrub bit for shrubbed roots. We have a
whole bit for this, so might as well actually use it.
This isn't even the first reliance of the shrub bit in this function!
---
Code changes minimal:
code stack ctx
before: 35148 2136 660
after: 35152 (+0.0%) 2136 (+0.0%) 660 (+0.0%)
code stack ctx
gbmap before: 38388 2144 776
gbmap after: 38388 (+0.0%) 2144 (+0.0%) 776 (+0.0%)
code stack ctx
preerase before: 38928 2168 796
preerase after: 38928 (+0.0%) 2168 (+0.0%) 796 (+0.0%)
This commit is contained in:
@@ -6332,9 +6332,9 @@ static lfs3_stag_t lfs3_btree_traverse(lfs3_t *lfs3,
|
|||||||
// restart from the root?
|
// restart from the root?
|
||||||
if (btrv->bid == -1
|
if (btrv->bid == -1
|
||||||
|| btrv->rid >= (lfs3_srid_t)btrv->rbyd.weight
|
|| btrv->rid >= (lfs3_srid_t)btrv->rbyd.weight
|
||||||
// we do this unconditionally when rbyd == root to avoid
|
// we do this unconditionally when rbyd is a shrub to avoid
|
||||||
// bshrubs falling out-of-sync
|
// bshrub root traversals falling out-of-sync under mutation
|
||||||
|| btrv->rbyd.weight == btree->r.weight) {
|
|| lfs3_rbyd_isshrub(&btrv->rbyd)) {
|
||||||
// end of traversal?
|
// end of traversal?
|
||||||
if (btrv->bid >= (lfs3_sbid_t)btree->r.weight) {
|
if (btrv->bid >= (lfs3_sbid_t)btree->r.weight) {
|
||||||
return LFS3_ERR_NOENT;
|
return LFS3_ERR_NOENT;
|
||||||
|
|||||||
Reference in New Issue
Block a user