yaffs: Don't do checkpoint for small partitions.
authorCharles Manning <cdhmanning@gmail.com>
Wed, 28 Apr 2010 00:57:45 +0000 (12:57 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Wed, 28 Apr 2010 00:57:45 +0000 (12:57 +1200)
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>
yaffs_guts.c

index ff5c963b4dc9ea86eaa0e81929c6abccba6abd6f..d067d1d03d53552efbff6d9bd16e84f83a86f71d 100644 (file)
 
 #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;
        }