From 88d783f4bbbfcf832a706af41903a04b24f1fdb2 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 13 May 2024 22:06:48 -0500 Subject: [PATCH] Relaxed fragment_size limit from block_size/8 -> block_size/4 The concern with block_size/4 is that it limits fragments to a single fragment per-block. But while this may be inefficient, it's technically not wrong, and may still work with other metadata (bptrs, file names, uattrs, etc) taking up the remaining space. This deserves benchmarking, but even if this ends up being a terrible configuration, we should just discourage this via good defaults and documentation. --- lfs.c | 4 ++-- lfs.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lfs.c b/lfs.c index 5fcfb04f..42a7a6bd 100644 --- a/lfs.c +++ b/lfs.c @@ -15231,8 +15231,8 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) { LFS_ASSERT(lfs->cfg->inline_size <= lfs->cfg->block_size/4); // shrub_size must be <= block_size/4 LFS_ASSERT(lfs->cfg->shrub_size <= lfs->cfg->block_size/4); - // fragment_size must be <= block_size/8 - LFS_ASSERT(lfs->cfg->fragment_size <= lfs->cfg->block_size/8); + // fragment_size must be <= block_size/4 + LFS_ASSERT(lfs->cfg->fragment_size <= lfs->cfg->block_size/4); // setup read cache lfs->rcache.block = 0; diff --git a/lfs.h b/lfs.h index 6d51b3e6..4a4b2cca 100644 --- a/lfs.h +++ b/lfs.h @@ -286,7 +286,7 @@ struct lfs_config { // Maximum size of a non-block B-tree leaf in bytes. Smaller values may // make small random-writes cheaper, but increase metadata overhead. Must - // be <= block_size/8. + // be <= block_size/4. lfs_size_t fragment_size; // Threshold for compacting multiple fragments into a block. Smaller