diff yaffs_guts.c @ 415:755b89191133

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 <cdhmanning@gmail.com>
author Charles Manning <cdhmanning@gmail.com>
date Wed, 28 Apr 2010 12:57:45 +1200
parents d94b1449bddc
children 4cda507d908e
line wrap: on
line diff
--- 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(
 
 
 
+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(yaf
 {
 	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;
 	}