Removed removal of root bookmark in test_mtree

It turns out permanent root bookmark creates some rather interesting
constraints on our mtree:

1. We can never delete all mids, since at least one mid needs to exist
   to represent the root's bookmark.

2. We can never revert to an inlined mdir after uninlining, since our
   root bookmark always exists to stop this. This is an unfortunate
   downside as it would be nice to be able to reinline mdirs, but not
   the end of the world.

This restricts what operations are possible, and transitively, what we
can test.

This commit drops the removal of root bookmarks in test_mtree, which was
a workaround to keep tests from early implementation running. This was
preventing some minor optimizations. This required dropping some tests,
but these tests tested operations that aren't really possible in
practice.

Dropping the removal of root bookmarks allowed for a minor optimization
in lfsr_mdir_drop, and may lead to more in the future (or maybe just
stricter asserts):

            code          stack
  before:  31280           2648
  after:   31208 (-0.2%)   2648 (+0.0%)
This commit is contained in:
Christopher Haster
2023-11-29 01:38:25 -06:00
parent 74c4bb0792
commit a9772d785a
2 changed files with 222 additions and 704 deletions
+8 -22
View File
@@ -6278,30 +6278,16 @@ static int lfsr_mdir_drop(lfs_t *lfs, const lfsr_mdir_t *mdir) {
return err;
}
// TODO apply this
// // we should never drop a direct mdir, because we always have our
// // root bookmark
// LFS_ASSERT(!lfsr_mtree_ismptr(lfs));
// direct mdir?
if (lfsr_mtree_ismptr(lfs)) {
err = lfsr_mroot_commit(lfs, -1, 0, NULL, LFSR_ATTRS(
LFSR_ATTR(-1,
RM(WIDE(STRUCT)), 0, NULL())));
if (err) {
return err;
}
lfs->mtree = LFSR_MTREE_NULL();
// we should never drop a direct mdir, because we always have our
// root bookmark
LFS_ASSERT(!lfsr_mtree_ismptr(lfs));
// update our mtree
} else {
err = lfsr_mtree_commit(lfs, LFSR_ATTRS(
LFSR_ATTR(lfsr_mdir_bid(lfs, mdir),
RM, -lfsr_mweight(lfs), NULL())));
if (err) {
return err;
}
err = lfsr_mtree_commit(lfs, LFSR_ATTRS(
LFSR_ATTR(lfsr_mdir_bid(lfs, mdir),
RM, -lfsr_mweight(lfs), NULL())));
if (err) {
return err;
}
// success? update in-device state, we must not error at this point
+214 -682
View File
File diff suppressed because it is too large Load Diff