From 5339d49e3391f533dfd88e9e6b4bec5835e51315 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 18 Dec 2023 00:42:05 -0600 Subject: [PATCH] Fixed becksums picking up stale bd cache data This is more a cludge than a real fix, we should probably be handled in the bd-wrapper layer, but that's all a mess right now and slated for future work. The problem is that our "rewinding" of block-level progs for alignment leaves our bd caches with stale data. This is normally fine, but then we go read the stale data to calculate our becksum. Dropping our caches before calculating the becksums fixes this, at least temporarily. --- lfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lfs.c b/lfs.c index 1ec2c064..b94b7b00 100644 --- a/lfs.c +++ b/lfs.c @@ -10172,6 +10172,12 @@ static int lfsr_ftree_flush(lfs_t *lfs, return err; } + // TODO this is a cludge, but right now our bd layer is a mess, + // we need caches to be clean so becksum calculation does not pick + // up out-of-date pcaches/rcaches + lfs_cache_drop(lfs, &lfs->pcache); + lfs_cache_drop(lfs, &lfs->rcache); + // prepare our block pointer LFS_ASSERT(bptr.cksize > 0); LFS_ASSERT(bptr.cksize <= lfs->cfg->block_size);