mtd/fs/jffs2 erase.c,1.37,1.38 fs.c,1.12,1.13 nodemgmt.c,1.69,1.70 scan.c,1.77,1.78

David Woodhouse dwmw2 at infradead.org
Tue Jul 2 18:48:26 EDT 2002


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

Modified Files:
	erase.c fs.c nodemgmt.c scan.c 
Log Message:
Abstract out the cleanmarker size for weird flash chips.


Index: erase.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/erase.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- erase.c	19 Jun 2002 12:04:51 -0000	1.37
+++ erase.c	2 Jul 2002 22:48:24 -0000	1.38
@@ -262,20 +262,12 @@
 
 void jffs2_mark_erased_blocks(struct jffs2_sb_info *c)
 {
-	static struct jffs2_unknown_node marker = {
-		magic:		JFFS2_MAGIC_BITMASK,
-		nodetype:	JFFS2_NODETYPE_CLEANMARKER,
-		totlen:		sizeof(struct jffs2_unknown_node)
-	};
 	struct jffs2_eraseblock *jeb;
 	struct jffs2_raw_node_ref *marker_ref = NULL;
 	unsigned char *ebuf;
 	size_t retlen;
 	int ret;
 
-	if (unlikely(!marker.hdr_crc))
-		marker.hdr_crc = crc32(0, &marker, sizeof(struct jffs2_unknown_node)-4);
-
 	spin_lock_bh(&c->erase_completion_lock);
 	while (!list_empty(&c->erase_complete_list)) {
 		jeb = list_entry(c->erase_complete_list.next, struct jffs2_eraseblock, list);
@@ -353,22 +345,30 @@
 			jeb->used_size = 0;
 			jeb->dirty_size = 0;
 		} else {
-			ret = jffs2_flash_write(c, jeb->offset, sizeof(marker), &retlen, (char *)&marker);
+			struct jffs2_unknown_node marker = {
+				magic:		JFFS2_MAGIC_BITMASK,
+				nodetype:	JFFS2_NODETYPE_CLEANMARKER,
+				totlen:		c->cleanmarker_size
+			};
+
+			marker.hdr_crc = crc32(0, &marker, marker.totlen - 4);
+
+			ret = jffs2_flash_write(c, jeb->offset, marker.totlen, &retlen, (char *)&marker);
 			if (ret) {
 				printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n",
 				       jeb->offset, ret);
 				goto bad2;
 			}
-			if (retlen != sizeof(marker)) {
+			if (retlen != marker.totlen) {
 				printk(KERN_WARNING "Short write to newly-erased block at 0x%08x: Wanted %d, got %d\n",
-				       jeb->offset, sizeof(marker), retlen);
+				       jeb->offset, marker.totlen, retlen);
 				goto bad2;
 			}
 			
 			marker_ref->next_in_ino = NULL;
 			marker_ref->next_phys = NULL;
 			marker_ref->flash_offset = jeb->offset;
-			marker_ref->totlen = PAD(sizeof(marker));
+			marker_ref->totlen = PAD(marker.totlen);
 			
 			jeb->first_node = jeb->last_node = marker_ref;
 			

Index: fs.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/fs.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- fs.c	26 Jun 2002 01:20:43 -0000	1.12
+++ fs.c	2 Jul 2002 22:48:24 -0000	1.13
@@ -285,7 +285,15 @@
 		       c->flash_size / c->sector_size);
 		return -EINVAL;
 	}
-	
+
+	c->cleanmarker_size = sizeof(struct jffs2_unknown_node);
+	/* Jörn -- stick alignment for weird 8-byte-page flash here */
+
+	if (jffs2_cleanmarker_oob(c)) {
+		/* Cleanmarker is out-of-band, so inline size zero */
+		c->cleanmarker_size = 0;
+	}
+
 	if (c->mtd->type == MTD_NANDFLASH) {
 		/* Initialise write buffer */
 		c->wbuf_pagesize = c->mtd->oobblock;

Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodemgmt.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- nodemgmt.c	20 May 2002 14:56:38 -0000	1.69
+++ nodemgmt.c	2 Jul 2002 22:48:24 -0000	1.70
@@ -215,10 +215,7 @@
 		c->nextblock = jeb = list_entry(next, struct jffs2_eraseblock, list);
 		c->nr_free_blocks--;
 
-		/* On NAND free_size == sector_size, cleanmarker is in spare area !*/
-		if (jeb->free_size != c->sector_size - 
-			(jffs2_cleanmarker_oob(c)) ? 0 : sizeof(struct jffs2_unknown_node)) {
-
+		if (jeb->free_size != c->sector_size - c->cleanmarker_size) {
 			printk(KERN_WARNING "Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n", jeb->offset, jeb->free_size);
 			goto restart;
 		}

Index: scan.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/scan.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- scan.c	2 Jul 2002 13:59:27 -0000	1.77
+++ scan.c	2 Jul 2002 22:48:24 -0000	1.78
@@ -342,9 +342,9 @@
 			break;
 
 		case JFFS2_NODETYPE_CLEANMARKER:
-			if (node.totlen != sizeof(struct jffs2_unknown_node)) {
+			if (node.totlen != c->cleanmarker_size) {
 				printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", 
-				       ofs, node.totlen, sizeof(struct jffs2_unknown_node));
+				       ofs, node.totlen, c->cleanmarker_size);
 				DIRTY_SPACE(PAD(sizeof(struct jffs2_unknown_node)));
 			} else if (jeb->first_node) {
 				printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x, not first node in block (0x%08x)\n", ofs, jeb->offset);





More information about the linux-mtd-cvs mailing list