diff options
author | Christopher Haster <chaster@utexas.edu> | 2019-04-10 02:56:53 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2019-04-10 19:27:53 +0300 |
commit | 48bd2bff821ae70e85c82d7f6c6c6bcf2ee23dae (patch) | |
tree | 29a8fd649d99bbc442bb5a70e46622cac35d5211 | |
parent | 651e14e79683be0cab30b91858018c19159968c1 (diff) |
Artificially limited number of file ids per metadata blockv2-alpha
This is an expirement to determine which field in the tag structure is
the most critical: tag id or tag size.
This came from looking at NAND storage and discussions around behaviour of
large prog_sizes. Initial exploration indicates that prog_sizes around
2KiB are not _that_ uncommon, and the 1KiB limitation is surprising.
It's possible to increase the lfs_tag size to 12-bits (4096), but at the
cost of only 8-bit ids (256).
[---- 32 ----]
a [1|-3-|-- 8 --|-- 10 --|-- 10 --]
b [1|-3-|-- 8 --|-- 8 --|-- 12 --]
This requires more investigation, but in order to allow us to change
the tag sizes with minimal impact I've artificially limited the number
of file ids to 0xfe (255) different file ids per metadata pair. If
12-bit lengths turn out to be a bad idea, we can remove the artificial
limit without backwards incompatible changes.
To avoid breaking users already on v2-alpha, this change will refuse
_creating_ file ids > 255, but should read file ids > 255 without
issues.
-rw-r--r-- | lfs.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1437,8 +1437,10 @@ static int lfs_dir_compact(lfs_t *lfs, // space is complicated, we need room for tail, crc, gstate, // cleanup delete, and we cap at half a block to give room // for metadata updates. - if (size <= lfs_min(lfs->cfg->block_size - 36, - lfs_alignup(lfs->cfg->block_size/2, lfs->cfg->prog_size))) { + if (end - begin < 0xff && + size <= lfs_min(lfs->cfg->block_size - 36, + lfs_alignup(lfs->cfg->block_size/2, + lfs->cfg->prog_size))) { break; } @@ -1711,7 +1713,7 @@ static int lfs_dir_commit(lfs_t *lfs, lfs_mdir_t *dir, } } - if (dir->erased) { + if (dir->erased || dir->count >= 0xff) { // try to commit struct lfs_commit commit = { .block = dir->pair[0], |