Shifted block_recycles so 0 => pure copy-on-write

This makes a bit more sense with the new block_recycles name.
block_recycles=0 (previously block_recycles=1) requires 1 erase, but it
doesn't really "recycle" the block. With this change, block_recycles=1
"recycles" the block once (2 erases in total) before relocating, which I
think is a bit more intuitive.

Note, this sort of messes with our power-of-2 rounding, as the
block_recycles is technically rounded down to the nearest power-of-2
after adding 1:

- block_recycles=1022 -> 512 erases
- block_recycles=1023 -> 1024 erases
- block_recycles=1024 -> 1024 erases
- block_recycles=1025 -> 1024 erases

But I'm going to keep the block_recycles description more-or-less as is
for now, as I think this extra detail is more confusing than useful,
powers-of-2 stay powers-of-2, and the <=block_recycles contraint is not
violated.
This commit is contained in:
Christopher Haster
2024-05-22 17:53:15 -05:00
parent 4d76551d6b
commit e4fe2b5234
4 changed files with 31 additions and 31 deletions
+4 -2
View File
@@ -209,9 +209,11 @@ struct lfs_config {
// Number of erase cycles before metadata blocks are relocated for
// wear-leveling. Suggested values are in the range 16-1024. Larger values
// relocate less frequently, improving average performance, at the cost
// of worse wear distribution. Note this is rounded down to a power-of-2.
// of worse wear distribution. Note this ends up rounded down to a
// power-of-2.
//
// Set to -1 to disable block-level wear-leveling.
// 0 results in pure copy-on-write, which may be counter-productive. Set
// to -1 to disable block-level wear-leveling.
int32_t block_recycles;
// Size of the read cache in bytes. Larger buffers can improve