From a2b4a95b892a307eaa4e0c39dd04724a52893993 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 13 May 2024 23:29:59 -0500 Subject: [PATCH] Fixed multiple open shrubs duplicating during mdir compact An easy mistake to make, we were incorrectly checking the non-staging shrub to see if our shrub had been copied over. Copying over the shrub updates the staging shrub, so this wasn't actually doing anything useful, resulting in a bunch of duplicate shrubs. The fix is to use the staging shrub. This was found thanks to test_fsync_wwrr, but only after bumping our fragment_size up from cache_size (16 bytes) -> block_size/8 (512 bytes). I'm guessing because this allowed our shrubs to be more overcommitted. --- lfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lfs.c b/lfs.c index 42a7a6bd..1d087a83 100644 --- a/lfs.c +++ b/lfs.c @@ -6102,7 +6102,7 @@ static int lfsr_mdir_commit__(lfs_t *lfs, lfsr_mdir_t *mdir, &file->m.mdir, &file->bshrub) // only compact once, first compact should stage // the new block - && file->bshrub.u.bshrub.blocks[0] + && file->bshrub_.u.bshrub.blocks[0] != rbyd_.blocks[0]) { int err = lfsr_shrub_compact(lfs, &rbyd_, &file->bshrub_.u.bshrub, @@ -6487,7 +6487,7 @@ static int lfsr_mdir_compact__(lfs_t *lfs, lfsr_mdir_t *mdir_, // inlined shrub? } else if (lfsr_bshrub_isbshrub(&file->m.mdir, &file->bshrub) // only compact once, first compact should stage the new block - && file->bshrub.u.bshrub.blocks[0] + && file->bshrub_.u.bshrub.blocks[0] != mdir_->rbyd.blocks[0]) { err = lfsr_shrub_compact(lfs, &mdir_->rbyd, &file->bshrub_.u.bshrub, &file->bshrub.u.bshrub);