Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2019-07-29 05:35:48 +0300
committerGitHub <noreply@github.com>2019-07-29 05:35:48 +0300
commit74fe46de3de98cecdff8681ccd53c481c31352e6 (patch)
tree6836f06dda74127ba6a544058b2c5fefd3865c15
parent582b596ed1818aab60a65dd931815fa8e688796c (diff)
parente8c023aab055a8892b8abc262d82f78a11108dc5 (diff)
Merge pull request #233 from ARMmbed/discourage-no-wear-leveling
Change block_cycles disable from 0 to -1
-rw-r--r--.travis.yml4
-rw-r--r--lfs.c12
-rw-r--r--lfs.h10
3 files changed, 18 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml
index 04f8720..c7a9bfb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -123,7 +123,7 @@ jobs:
if: branch !~ -prefix$
install:
- sudo apt-get install libfuse-dev
- - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha
+ - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2
- fusermount -V
- gcc --version
before_script:
@@ -158,7 +158,7 @@ jobs:
if: branch !~ -prefix$
install:
- sudo apt-get install libfuse-dev
- - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha v2
+ - git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2 v2
- git clone --depth 1 https://github.com/geky/littlefs-fuse -b v1 v1
- fusermount -V
- gcc --version
diff --git a/lfs.c b/lfs.c
index 8fecafa..3de95e1 100644
--- a/lfs.c
+++ b/lfs.c
@@ -1468,7 +1468,7 @@ static int lfs_dir_compact(lfs_t *lfs,
// increment revision count
dir->rev += 1;
- if (lfs->cfg->block_cycles &&
+ if (lfs->cfg->block_cycles > 0 &&
(dir->rev % (lfs->cfg->block_cycles+1) == 0)) {
if (lfs_pair_cmp(dir->pair, (const lfs_block_t[2]){0, 1}) == 0) {
// oh no! we're writing too much to the superblock,
@@ -3226,8 +3226,14 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
LFS_ASSERT(4*lfs_npw2(0xffffffff / (lfs->cfg->block_size-2*4))
<= lfs->cfg->block_size);
- // we don't support some corner cases
- LFS_ASSERT(lfs->cfg->block_cycles < 0xffffffff);
+ // block_cycles = 0 is no longer supported.
+ //
+ // block_cycles is the number of erase cycles before littlefs evicts
+ // metadata logs as a part of wear leveling. Suggested values are in the
+ // range of 100-1000, or set block_cycles to -1 to disable block-level
+ // wear-leveling.
+ LFS_ASSERT(lfs->cfg->block_cycles != 0);
+
// setup read cache
if (lfs->cfg->read_buffer) {
diff --git a/lfs.h b/lfs.h
index 3f80016..64d4f0a 100644
--- a/lfs.h
+++ b/lfs.h
@@ -191,9 +191,13 @@ struct lfs_config {
// Number of erasable blocks on the device.
lfs_size_t block_count;
- // Number of erase cycles before we should move data to another block.
- // May be zero, in which case no block-level wear-leveling is performed.
- uint32_t block_cycles;
+ // Number of erase cycles before littlefs evicts metadata logs and moves
+ // the metadata to another block. Suggested values are in the
+ // range 100-1000, with large values having better performance at the cost
+ // of less consistent wear distribution.
+ //
+ // Set to -1 to disable block-level wear-leveling.
+ int32_t block_cycles;
// Size of block caches. Each cache buffers a portion of a block in RAM.
// The littlefs needs a read cache, a program cache, and one additional