From af9db26a2299dc67c364d9f65d8c3758560a7ff0 Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Wed, 28 Apr 2010 12:57:45 +1200 Subject: [PATCH 1/1] yaffs: Don't do checkpoint for small partitions. On very small partitions a checkpoint is pointless and wastes space. For less than 60 blocks we don't try making a checkpoint. Signed-off-by: Charles Manning --- yaffs_guts.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/yaffs_guts.c b/yaffs_guts.c index ff5c963..d067d1d 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -36,6 +36,14 @@ #define YAFFS_SMALL_HOLE_THRESHOLD 3 +/* + * Checkpoints are really no benefit on very small partitions. + * + * To save space on small partitions don't bother with checkpoints unless + * the partition is at least this big. + */ +#define YAFFS_CHECKPOINT_MIN_BLOCKS 60 + #include "yaffs_ecc.h" @@ -2953,10 +2961,17 @@ static int yaffs_FindBlockForAllocation(yaffs_Device *dev) +static int yaffs_CheckpointRequired(yaffs_Device *dev) +{ + int nblocks = dev->internalEndBlock - dev->internalStartBlock + 1 ; + return dev->param.isYaffs2 && + !dev->param.skipCheckpointWrite && + (nblocks >= YAFFS_CHECKPOINT_MIN_BLOCKS); +} static int yaffs_CalcCheckpointBlocksRequired(yaffs_Device *dev) { if (!dev->nCheckpointBlocksRequired && - dev->param.isYaffs2) { + yaffs_CheckpointRequired(dev)){ /* Not a valid value so recalculate */ int nBytes = 0; int nBlocks; @@ -4877,7 +4892,7 @@ static int yaffs_WriteCheckpointData(yaffs_Device *dev) { int ok = 1; - if (dev->param.skipCheckpointWrite || !dev->param.isYaffs2) { + if (!yaffs_CheckpointRequired(dev)) { T(YAFFS_TRACE_CHECKPOINT, (TSTR("skipping checkpoint write" TENDSTR))); ok = 0; } -- 2.30.2