Replaced lfs->seed with lfs->gcksum for pseudorandom noise
lfs->seed was already just the rough xor of all mdir cksums, so
replacing it with our gcksum doesn't really do anything but make its
definition more rigorous.
That and save both code and ctx:
code stack ctx
before: 38560 2624 644
after: 38492 (-0.2%) 2624 (+0.0%) 640 (-0.6%)
This commit is contained in:
@@ -7044,7 +7044,7 @@ static inline uint32_t lfsr_rev_init(lfs_t *lfs, uint32_t rev) {
|
|||||||
// increment revision
|
// increment revision
|
||||||
rev += 1 << 28;
|
rev += 1 << 28;
|
||||||
// xor in a pseudorandom nonce
|
// xor in a pseudorandom nonce
|
||||||
rev ^= ((1 << (28-lfs_smax(lfs->recycle_bits, 0)))-1) & lfs->seed;
|
rev ^= ((1 << (28-lfs_smax(lfs->recycle_bits, 0)))-1) & lfs->gcksum;
|
||||||
return rev;
|
return rev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7062,7 +7062,7 @@ static inline uint32_t lfsr_rev_inc(lfs_t *lfs, uint32_t rev) {
|
|||||||
// increment recycle counter/revision
|
// increment recycle counter/revision
|
||||||
rev += 1 << (28-lfs_smax(lfs->recycle_bits, 0));
|
rev += 1 << (28-lfs_smax(lfs->recycle_bits, 0));
|
||||||
// xor in a pseudorandom nonce
|
// xor in a pseudorandom nonce
|
||||||
rev ^= ((1 << (28-lfs_smax(lfs->recycle_bits, 0)))-1) & lfs->seed;
|
rev ^= ((1 << (28-lfs_smax(lfs->recycle_bits, 0)))-1) & lfs->gcksum;
|
||||||
return rev;
|
return rev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8751,14 +8751,6 @@ static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir,
|
|||||||
// success? update in-device state, we must not error at this point! //
|
// success? update in-device state, we must not error at this point! //
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// toss our cksum into the filesystem seed for pseudorandom numbers
|
|
||||||
if (mdelta >= 0) {
|
|
||||||
lfs->seed ^= mdir_[0].rbyd.cksum;
|
|
||||||
}
|
|
||||||
if (mdelta > 0) {
|
|
||||||
lfs->seed ^= mdir_[1].rbyd.cksum;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we may have touched any number of mdirs, so assume uncompacted
|
// we may have touched any number of mdirs, so assume uncompacted
|
||||||
// until lfsr_gc can prove otherwise
|
// until lfsr_gc can prove otherwise
|
||||||
lfs->flags |= LFS_I_COMPACT;
|
lfs->flags |= LFS_I_COMPACT;
|
||||||
@@ -13384,7 +13376,6 @@ static int lfs_init(lfs_t *lfs, uint32_t flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setup default state
|
// setup default state
|
||||||
lfs->seed = 0;
|
|
||||||
|
|
||||||
// lfs->root[0] = LFS_BLOCK_NULL;
|
// lfs->root[0] = LFS_BLOCK_NULL;
|
||||||
// lfs->root[1] = LFS_BLOCK_NULL;
|
// lfs->root[1] = LFS_BLOCK_NULL;
|
||||||
@@ -13959,10 +13950,6 @@ static int lfsr_mountinited(lfs_t *lfs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// toss our cksum into the filesystem seed for pseudorandom
|
|
||||||
// numbers
|
|
||||||
lfs->seed ^= mdir->rbyd.cksum;
|
|
||||||
|
|
||||||
// build gcksum out of mdir cksums
|
// build gcksum out of mdir cksums
|
||||||
lfs->gcksum ^= mdir->rbyd.cksum;
|
lfs->gcksum ^= mdir->rbyd.cksum;
|
||||||
|
|
||||||
@@ -14027,7 +14014,7 @@ static int lfsr_mountinited(lfs_t *lfs) {
|
|||||||
// the purpose of this is to avoid bad wear patterns such as always
|
// the purpose of this is to avoid bad wear patterns such as always
|
||||||
// allocating blocks near the beginning of disk after a power-loss
|
// allocating blocks near the beginning of disk after a power-loss
|
||||||
//
|
//
|
||||||
lfs->lookahead.window = lfs->seed % lfs->block_count;
|
lfs->lookahead.window = lfs->gcksum % lfs->block_count;
|
||||||
|
|
||||||
// TODO should the consumegdelta above take gstate/gdelta as a parameter?
|
// TODO should the consumegdelta above take gstate/gdelta as a parameter?
|
||||||
// keep track of the current gstate on disk
|
// keep track of the current gstate on disk
|
||||||
|
|||||||
Reference in New Issue
Block a user