From 09faac593c6668706f1aea9979c25214313c79fe Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 24 May 2024 01:47:00 -0500 Subject: [PATCH] Fixed prng xors during mdir splits/drops We were unconditionally xoring our prng seed with mdir_[0]'s cksum, but we should really use mdelta to xor in the relevant cksums. This is a little bit more complicated, so adds a little bit of code: code stack before: 33442 2640 after: 33470 (+0.1%) 2640 (+0.0%) --- lfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lfs.c b/lfs.c index 5938691c..d06200ee 100644 --- a/lfs.c +++ b/lfs.c @@ -7051,7 +7051,12 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, // success? update in-device state, we must not error at this point // toss our cksum into the filesystem seed for pseudorandom numbers - lfs->seed ^= mdir_[0].rbyd.cksum; + if (mdelta >= 0) { + lfs->seed ^= mdir_[0].rbyd.cksum; + } + if (mdelta > 0) { + lfs->seed ^= mdir_[1].rbyd.cksum; + } // update any gstate changes lfsr_fs_commitgdelta(lfs);