mtd/fs/jffs3 erase.c,3.7,3.8 summary.c,3.7,3.8

havasi at infradead.org havasi at infradead.org
Mon Jan 31 09:45:28 EST 2005


Update of /home/cvs/mtd/fs/jffs3
In directory phoenix.infradead.org:/tmp/cvs-serv18301

Modified Files:
	erase.c summary.c 
Log Message:

Summary fixes:
- fix a small memory leak
- using USED_SPACE instead of WASTED_SPACE at writing summary node
  (it is important for GC)



Index: erase.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/erase.c,v
retrieving revision 3.7
retrieving revision 3.8
diff -u -r3.7 -r3.8
--- erase.c	5 Jan 2005 16:19:00 -0000	3.7
+++ erase.c	31 Jan 2005 14:45:25 -0000	3.8
@@ -419,6 +419,16 @@
 		jeb->wasted_size = 0;
 	}
 
+#ifdef CONFIG_JFFS3_SUMMARY
+	
+	if (jeb->sum_collected) {
+	
+		jffs2_sum_clean_collected(jeb);
+		jeb->sum_collected->sum_size = 0;
+		jeb->sum_collected->sum_padded = 0;
+	}
+#endif
+	
 	spin_lock(&c->erase_completion_lock);
 	c->erasing_size -= c->sector_size;
 	c->free_size += jeb->free_size;
@@ -434,4 +444,3 @@
 	spin_unlock(&c->erase_completion_lock);
 	wake_up(&c->erase_wait);
 }
-

Index: summary.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/summary.c,v
retrieving revision 3.7
retrieving revision 3.8
diff -u -r3.7 -r3.8
--- summary.c	21 Jan 2005 10:55:42 -0000	3.7
+++ summary.c	31 Jan 2005 14:45:25 -0000	3.8
@@ -551,10 +551,10 @@
 
 		USED_SPACE(sumsize);
 
-                jeb->wasted_size += jeb->free_size;
-                c->wasted_size += jeb->free_size;
-                c->free_size -= jeb->free_size;
-                jeb->free_size = 0;
+		jeb->wasted_size += jeb->free_size;
+		c->wasted_size += jeb->free_size;
+		c->free_size -= jeb->free_size;
+		jeb->free_size = 0;
 
 		/* somebody check this and all of space accounting in summary support */
 
@@ -586,6 +586,7 @@
 int jffs3_sum_write_sumnode(struct jffs3_sb_info *c)
 {
 	struct jffs3_summary_node isum;
+	struct jffs2_raw_node_ref *summary_ref;
 	union jffs3_sum_mem *temp;
 	jint32_t offset;
 	jint32_t *wpage;
@@ -640,7 +641,7 @@
 	isum.nodetype = cpu_to_je16(JFFS3_NODETYPE_SUMMARY);
 	isum.totlen = cpu_to_je32(infosize);
 	isum.hdr_crc = cpu_to_je32(crc32(0, &isum, sizeof(struct jffs3_unknown_node) - 4));
-        isum.padded = cpu_to_je32(jeb->sum_collected->sum_padded);
+	isum.padded = cpu_to_je32(jeb->sum_collected->sum_padded);
 
 	if (c->cleanmarker_size) {
 		isum.cln_mkr = cpu_to_je32(c->cleanmarker_size);
@@ -709,6 +710,7 @@
 	}
 
 	jeb->sum_collected->sum_size = 0;
+	jeb->sum_collected->sum_padded = 0;
 
 	tempptr = (uint8_t *) wpage;
 	tempptr += padsize;
@@ -742,12 +744,26 @@
 
 		return 0;
 	}
-
-	/*spin_unlock(&c->erase_completion_lock);
-	jffs3_flush_wbuf_pad(c); // summary filled the wbuf
-	spin_lock(&c->erase_completion_lock);*/
-
-	WASTED_SPACE(infosize);
-
+	
+	summary_ref = jffs2_alloc_raw_node_ref();
+	
+	if (!summary_ref) {
+		printk(KERN_NOTICE "Failed to allocate node ref for summary\n");
+		return -ENOMEM;
+	}
+		
+	summary_ref->next_in_ino = NULL;
+	summary_ref->next_phys = NULL;
+	summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL;
+	summary_ref->__totlen = infosize;
+		
+	if (!jeb->first_node)
+		jeb->first_node = summary_ref;
+	if (jeb->last_node)
+		jeb->last_node->next_phys = summary_ref;
+	jeb->last_node = summary_ref;
+	
+	USED_SPACE(infosize);
+	
 	return 0;
 }





More information about the linux-mtd-cvs mailing list