Fixed test_traversal_compact_mroot_split NOSPC error

This is a pretty suspicious looking test failure, considering the recent
changes to the mroot/mtree and related splitting logic, but it just
turned out to be a bug in the test logic.

Sort of. This loop is trying to create an mroot that will both compact
and split, but it doesn't check if the mdir was split prematurely, so it
just keeps adding files until we hit a true LFS_ERR_NOSPC condition:

  if ((file1.o.o.mdir.rbyd.eoff & 0x7fffffff) > GC_COMPACT_THRESH
          && estimate > BLOCK_SIZE/2) {
      break;
  }

The solution is to make the filename size a bit smaller so we don't
split too early.

I also added some asserts to catch premature splits in case this happens
again. These tests are a bit delicate.
This commit is contained in:
Christopher Haster
2025-01-31 03:31:01 -06:00
parent e580db20dd
commit 62e3d2109d
+7 -2
View File
@@ -5778,6 +5778,8 @@ code = '''
// create enough files to both compact and split
lfs_size_t i = 0;
while (true) {
// we should not have split yet
assert(lfs.mtree.weight == 0);
// we need internals to check this
lfs_ssize_t estimate = lfsr_mdir_estimate__(&lfs,
&file1.o.o.mdir, -1, -1,
@@ -5789,7 +5791,7 @@ code = '''
}
char name[256];
sprintf(name, "medusaaaaaaaaaaaaaaaaaaaaaaaaaaaa%03x", i);
sprintf(name, "medusaaaaaaaaaaaaaaaa%03x", i);
lfsr_file_t file;
lfsr_file_open(&lfs, &file, name,
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;
@@ -6204,7 +6206,10 @@ code = '''
// create enough files to both compact and split
i = 0;
orig = lfs.mtree.weight;
while (true) {
// we should not have split yet
assert(lfs.mtree.weight == orig);
// we need internals to check this
lfs_ssize_t estimate = lfsr_mdir_estimate__(&lfs,
&file2.o.o.mdir, -1, -1,
@@ -6216,7 +6221,7 @@ code = '''
}
char name[256];
sprintf(name, "medusaaaaaaaaaaaaaaaaaaaaaaaaaaaa%03x", i);
sprintf(name, "medusaaaaaaaaaaaaaaaa%03x", i);
lfsr_file_t file;
lfsr_file_open(&lfs, &file, name,
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL) => 0;