Skip to content

Commit 8348d7d

Browse files
authored
Fixed incorrect modulus in lfs_alloc_reset
Modulus of the offset by block_size was clearly a typo, and should be block_count. Interesting to note that later moduluses during alloc calculations prevents this from breaking anything, but as gtaska notes it could skew the wear-leveling distribution. Found by guiserle and gtaska
1 parent 4c9146e commit 8348d7d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ static void lfs_alloc_ack(lfs_t *lfs) {
459459
// Invalidate the lookahead buffer. This is done during mounting and
460460
// failed traversals
461461
static void lfs_alloc_reset(lfs_t *lfs) {
462-
lfs->free.off = lfs->seed % lfs->cfg->block_size;
462+
lfs->free.off = lfs->seed % lfs->cfg->block_count;
463463
lfs->free.size = 0;
464464
lfs->free.i = 0;
465465
lfs_alloc_ack(lfs);

0 commit comments

Comments
 (0)