yaffs: Fix free space tracking of summary during gc.
authorCharles Manning <cdhmanning@gmail.com>
Thu, 31 Mar 2011 04:04:09 +0000 (17:04 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Thu, 31 Mar 2011 04:04:09 +0000 (17:04 +1300)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs_summary.c

index 31d443a872710fec5ff406892579ad4bc2608dc5..2768f166a1aa9f93a470c45e1e7a74dee4e015f1 100644 (file)
  * published by the Free Software Foundation.
  */
 
-/* Summaries write all the tags for the chunks in a block into packed tags
- * (just the tags part - no ECC) in the last n chunks of the block.
+/* Summaries write the useful part of the tags for the chunks in a block into an
+ * an array which is written to the last n chunks of the block.
  * Reading the summaries gives all the tags for the block in one read. Much
  * faster.
  *
  * Chunks holding summaries are marked with tags making it look like
  * they are part of a fake file.
  *
- * The chunks that hold the summary are removed from free space and are marked
- * as being in use.
+ * The summary could also be used during gc.
  *
- * THa above might need to be revisited.
  */
 
 #include "yaffs_summary.h"
@@ -245,6 +243,12 @@ void yaffs_summary_gc(struct yaffs_dev *dev, int blk)
        if (!bi->has_summary)
                return;
 
-       for (i = dev->chunks_per_summary; i < dev->param.chunks_per_block; i++)
-               yaffs_clear_chunk_bit(dev, blk, i);
+       for (i = dev->chunks_per_summary; i < dev->param.chunks_per_block; i++) {
+               if( yaffs_check_chunk_bit(dev, blk, i)) {
+                       yaffs_clear_chunk_bit(dev, blk, i);
+                       bi->pages_in_use--;
+                       dev->n_free_chunks++;
+               }
+       }
+
 }