EBH Changes in Jffs2 broke Sibley Nor flash support in CVS

nishanth menon menon.nishanth at gmail.com
Wed Dec 7 21:09:37 EST 2005


Hi All,
Looks like my mail client seems to have some issues.. :(

After plodding through a bit of code for sometime, the culprit seems
to be the ebh changes done to CVS sometime in Nov 4th (Ref:
http://lists.infradead.org/pipermail/linux-mtd/2005-November/014232.html)
Here is a dirty little patch for the same. I am not very happy with
the kmalloc/kfree method I have done, but something on the lines is
worth it. I suspect it breaking NOR ECC/Dataflash too.. since I don't
see any dependency on c->cleanmarker_size or c->ebh_size anymore!!

Regards,
Nishanth Menon

--- mtd-latest-20051206/fs/jffs2/erase.c	2005-12-06 17:01:33.000000000 -0600
+++ 2.6_kernel/fs/jffs2/erase.c	2005-12-07 12:09:29.000000000 -0600
@@ -360,6 +360,7 @@
 static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct
jffs2_eraseblock *jeb)  {
 	struct jffs2_raw_node_ref *ebh_ref = NULL;
+	unsigned char * cln_mrker=NULL;
 	size_t retlen;
 	int ret;
 	uint32_t bad_offset;
@@ -391,7 +392,7 @@
 		struct jffs2_raw_ebh ebh = {
 			.magic =        cpu_to_je16(JFFS2_MAGIC_BITMASK),
 			.nodetype =     cpu_to_je16(JFFS2_NODETYPE_ERASEBLOCK_HEADER),
-			.totlen =       cpu_to_je32(sizeof(struct jffs2_raw_ebh)),
+			.totlen =       cpu_to_je32(c->ebh_size),
 			.reserved =     0,
 			.compat_fset =  JFFS2_EBH_COMPAT_FSET,
 			.incompat_fset = JFFS2_EBH_INCOMPAT_FSET, @@ -408,11 +409,20 @@
 		ebh.node_crc = cpu_to_je32(crc32(0, (unsigned char *)&ebh +
sizeof(struct jffs2_unknown_node) + 4,
 					 sizeof(struct jffs2_raw_ebh) - sizeof(struct jffs2_unknown_node) - 4));

-		vecs[0].iov_base = (unsigned char *) &ebh;
-		vecs[0].iov_len = sizeof(ebh);
+		cln_mrker=kmalloc(c->ebh_size,GFP_KERNEL);
+		if (!cln_mrker) {
+			printk(KERN_WARNING "Failed to allocate clean marker\n");
+			goto refile;
+		}
+		memset(cln_mrker,0xde,c->ebh_size);
+		memcpy(cln_mrker,&ebh,sizeof(ebh));
+
+		vecs[0].iov_base = cln_mrker;
+		vecs[0].iov_len = c->ebh_size;
 		ret = jffs2_flash_direct_writev(c, vecs, 1, jeb->offset, &retlen);
+		kfree(cln_mrker);

-		if (ret || retlen != sizeof(ebh)) {
+		if (ret || retlen != c->ebh_size ) {
 			if (ret)
 				printk(KERN_WARNING "Write eraseblock header to block at 0x%08x
failed: %d\n",
 				       jeb->offset, ret);




More information about the linux-mtd mailing list