Skip to contentSkip to conversation

MLC NAND support

PATCH In review AYYANARPONNUSAMY GANGHEYAMOORTHY 5 participants 11 messages Sep 19, 2008 – Oct 3, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 MLC NAND support

Currently JFFS2 writes twice to the first page of the block, cleanmarker in OOB area and data in main area, which prevents JFFS2 from being used on MLC devices which have NOP count 1. This patch reserves the first page only for the cleanmarker.

Note : With robustness testing, one test board out six has given a BUG. We are looking into it.

---

fs/jffs2/build.c +13 -2
@@ -330,7 +330,11 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
 	int i;
 	int size;
 
-	c->free_size = c->flash_size;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		c->free_size = 0;
+	else
+		c->free_size = c->flash_size;
+
 	c->nr_blocks = c->flash_size / c->sector_size;
 	size = sizeof(struct jffs2_eraseblock) * c->nr_blocks;
 #ifndef __ECOS
@@ -346,7 +350,14 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
 	for (i=0; i<c->nr_blocks; i++) {
 		INIT_LIST_HEAD(&c->blocks[i].list);
 		c->blocks[i].offset = i * c->sector_size;
-		c->blocks[i].free_size = c->sector_size;
+		if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+			c->blocks[i].free_size =
+					c->sector_size - c->wbuf_pagesize;
+			c->blocks[i].used_size = c->wbuf_pagesize;
+			c->free_size +=  c->blocks[i].free_size;
+			c->used_size += c->blocks[i].used_size;
+		} else
+			c->blocks[i].free_size = c->sector_size;
 	}
 
 	INIT_LIST_HEAD(&c->clean_list);
fs/jffs2/debug.c +3 -0
@@ -307,6 +307,9 @@ __jffs2_dbg_acct_paranoia_check_nolock(s
 	uint32_t my_dirty_size = 0;
 	struct jffs2_raw_node_ref *ref2 = jeb->first_node;
 
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		my_used_size = c->wbuf_pagesize;
+
 	while (ref2) {
 		uint32_t totlen = ref_totlen(c, jeb, ref2);
 
fs/jffs2/erase.c +10 -2
@@ -454,13 +454,21 @@ static void jffs2_mark_erased_block(stru
 		}
 	}
 	/* Everything else got zeroed before the erase */
-	jeb->free_size = c->sector_size;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+		jeb->free_size = c->sector_size - c->wbuf_pagesize;
+		jeb->used_size = c->wbuf_pagesize;
+	} else
+		jeb->free_size = c->sector_size;
 
 	mutex_lock(&c->erase_free_sem);
 	spin_lock(&c->erase_completion_lock);
 
 	c->erasing_size -= c->sector_size;
-	c->free_size += c->sector_size;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+		c->free_size += c->sector_size - c->wbuf_pagesize;
+		c->used_size += c->wbuf_pagesize;
+	} else
+		c->free_size += c->sector_size;
 
 	/* Account for cleanmarker now, if it's in-band */
 	if (c->cleanmarker_size && !jffs2_cleanmarker_oob(c))
fs/jffs2/gc.c +39 -10

61 lines not on this page · raw message

fs/jffs2/nodelist.c +5 -1
@@ -634,7 +634,11 @@ struct jffs2_raw_node_ref *jffs2_link_no
 
 	if (!jeb->first_node) {
 		jeb->first_node = ref;
-		BUG_ON(ref_offset(ref) != jeb->offset);
+		if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+			BUG_ON(ref_offset(ref) !=
+						jeb->offset + c->wbuf_pagesize);
+		else
+			BUG_ON(ref_offset(ref) != jeb->offset);
 	} else if (unlikely(ref_offset(ref) != jeb->offset + c->sector_size - jeb->free_size)) {
 		uint32_t last_len = ref_totlen(c, jeb, jeb->last_node);
 
fs/jffs2/nodemgmt.c +13 -4
@@ -362,16 +362,25 @@ static int jffs2_do_reserve_space(struct
 	}
 
 	if (!jeb) {
-
 		ret = jffs2_find_nextblock(c);
 		if (ret)
 			return ret;
 
 		jeb = c->nextblock;
+		if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+			if (jeb->free_size != c->sector_size -
+				c->cleanmarker_size - c->wbuf_pagesize) {
+				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;
+			}
+		}
 
-		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;
+		else{
+			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;
+			}
 		}
 	}
 	/* OK, jeb (==c->nextblock) is now pointing at a block which definitely has
fs/jffs2/scan.c +8 -2
@@ -534,7 +534,10 @@ static int jffs2_scan_eraseblock (struct
 		}
 	}
 
-	buf_ofs = jeb->offset;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		buf_ofs = jeb->offset + c->wbuf_pagesize;
+	else
+		buf_ofs = jeb->offset;
 
 	if (!buf_size) {
 		/* This is the XIP case -- we're reading _directly_ from the flash chip */
@@ -582,7 +585,10 @@ static int jffs2_scan_eraseblock (struct
 	}
 
 	/* Now ofs is a complete physical flash offset as it always was... */
-	ofs += jeb->offset;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		ofs += jeb->offset + c->wbuf_pagesize;
+	else
+		ofs += jeb->offset;
 
 	noise = 10;
 
fs/jffs2/wbuf.c +7 -0
@@ -873,6 +873,13 @@ int jffs2_flash_writev(struct jffs2_sb_i
 			vlen -= wbuf_retlen;
 			outvec_to += wbuf_retlen;
 			c->wbuf_ofs = outvec_to;
+			if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+				/* adjust write buffer offset,
+				 * else we get a non contiguous write bug
+				 */
+				if (!(c->wbuf_ofs % c->sector_size))
+					c->wbuf_ofs = 0xffffffff;
+			}
 			donelen += wbuf_retlen;
 			v += wbuf_retlen;
 		}
include/mtd/mtd-abi.h +2 -0
@@ -28,12 +28,14 @@ struct mtd_oob_buf {
 #define MTD_BIT_WRITEABLE	0x800	/* Single bits can be flipped */
 #define MTD_NO_ERASE		0x1000	/* No erase necessary */
 #define MTD_POWERUP_LOCK	0x2000	/* Always locked after reset */
+#define MTD_WRITABLE_ONCE	0x4000
 
 // Some common devices / combinations of capabilities
 #define MTD_CAP_ROM		0
 #define MTD_CAP_RAM		(MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
 #define MTD_CAP_NORFLASH	(MTD_WRITEABLE | MTD_BIT_WRITEABLE)
 #define MTD_CAP_NANDFLASH	(MTD_WRITEABLE)
+#define MTD_CAP_MLCNANDFLASH	(MTD_WRITEABLE | MTD_WRITABLE_ONCE)
 
 /* ECC byte placement */
 #define MTD_NANDECC_OFF		0	// Switch off ECC (Not recommended)
#1 lore raw

Could you send out the panic log? How do you perform the robustness test. Currently, I found the jffs2 filesystem can't support MLC well. Not long time ago,
I use the patch JFFS2 doesn't use OOB at MLC NAND/OneNAND from Kyungmin Park <kyungmin.park at samsung.com> on Sumsung MLC nand flash K9LAG08U0M, but sometimes i will meet BUG() on the jffs2 file system. I suspect that that patch does not completely handle MLC nand flash well. How about this patch?

2008/9/19 AYYANARPONNUSAMY GANGHEYAMOORTHY <[email protected]>:

Quoted 259 lines

Currently JFFS2 writes twice to the first page of the block, cleanmarker in OOB area and data in main area, which prevents JFFS2 from being used on MLC devices which have NOP count 1. This patch reserves the first page only for the cleanmarker.

Note : With robustness testing, one test board out six has given a BUG. We are looking into it.

---

fs/jffs2/build.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/build.c 2008-08-24 04:48:32.000000000 +0530 +13 -2
@@ -330,7 +330,11 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
       int i;
       int size;
 
-       c->free_size = c->flash_size;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               c->free_size = 0;
+       else
+               c->free_size = c->flash_size;
+
       c->nr_blocks = c->flash_size / c->sector_size;
       size = sizeof(struct jffs2_eraseblock) * c->nr_blocks;
 #ifndef __ECOS
@@ -346,7 +350,14 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
       for (i=0; i<c->nr_blocks; i++) {
               INIT_LIST_HEAD(&c->blocks[i].list);
               c->blocks[i].offset = i * c->sector_size;
-               c->blocks[i].free_size = c->sector_size;
+               if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+                       c->blocks[i].free_size =
+                                       c->sector_size - c->wbuf_pagesize;
+                       c->blocks[i].used_size = c->wbuf_pagesize;
+                       c->free_size +=  c->blocks[i].free_size;
+                       c->used_size += c->blocks[i].used_size;
+               } else
+                       c->blocks[i].free_size = c->sector_size;
       }
 
       INIT_LIST_HEAD(&c->clean_list);
fs/jffs2/debug.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/debug.c 2008-08-24 04:48:32.000000000 +0530 +3 -0
@@ -307,6 +307,9 @@ __jffs2_dbg_acct_paranoia_check_nolock(s
       uint32_t my_dirty_size = 0;
       struct jffs2_raw_node_ref *ref2 = jeb->first_node;
 
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               my_used_size = c->wbuf_pagesize;
+
       while (ref2) {
               uint32_t totlen = ref_totlen(c, jeb, ref2);
 
fs/jffs2/erase.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/erase.c 2008-08-24 04:48:32.000000000 +0530 +10 -2
@@ -454,13 +454,21 @@ static void jffs2_mark_erased_block(stru
               }
       }
       /* Everything else got zeroed before the erase */
-       jeb->free_size = c->sector_size;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               jeb->free_size = c->sector_size - c->wbuf_pagesize;
+               jeb->used_size = c->wbuf_pagesize;
+       } else
+               jeb->free_size = c->sector_size;
 
       mutex_lock(&c->erase_free_sem);
       spin_lock(&c->erase_completion_lock);
 
       c->erasing_size -= c->sector_size;
-       c->free_size += c->sector_size;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               c->free_size += c->sector_size - c->wbuf_pagesize;
+               c->used_size += c->wbuf_pagesize;
+       } else
+               c->free_size += c->sector_size;
 
       /* Account for cleanmarker now, if it's in-band */
       if (c->cleanmarker_size && !jffs2_cleanmarker_oob(c))
fs/jffs2/gc.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/gc.c 2008-08-24 04:48:32.000000000 +0530 +39 -10
@@ -237,9 +237,19 @@ int jffs2_garbage_collect_pass(struct jf
       D1(if (c->nextblock)
          printk(KERN_DEBUG "Nextblock at  %08x, used_size %08x, dirty_size %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size));
 
-       if (!jeb->used_size) {
-               mutex_unlock(&c->alloc_sem);
-               goto eraseit;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               if (jeb->used_size <= c->wbuf_pagesize) {
+                       mutex_unlock(&c->alloc_sem);
+                       goto eraseit;
+               }
+
+       }
+
+       else{
+               if (!jeb->used_size) {
+                       mutex_unlock(&c->alloc_sem);
+                       goto eraseit;
+               }
       }
 
       raw = jeb->gc_node;
@@ -429,13 +439,32 @@ int jffs2_garbage_collect_pass(struct jf
       spin_lock(&c->erase_completion_lock);
 
 eraseit:
-       if (c->gcblock && !c->gcblock->used_size) {
-               D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset));
-               /* We're GC'ing an empty block? */
-               list_add_tail(&c->gcblock->list, &c->erase_pending_list);
-               c->gcblock = NULL;
-               c->nr_erasing_blocks++;
-               jffs2_erase_pending_trigger(c);
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               if (c->gcblock && (c->gcblock->used_size <= c->wbuf_pagesize)) {
+                       D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+                               " obsoleted by GC. Moving to erase_pending_list\n"
+                               , c->gcblock->offset));
+                       /* We're GC'ing an empty block? */
+                       list_add_tail(&c->gcblock->list,
+                                       &c->erase_pending_list);
+                       c->gcblock = NULL;
+                       c->nr_erasing_blocks++;
+                       jffs2_erase_pending_trigger(c);
+               }
+       }
+
+       else{
+               if (c->gcblock && !c->gcblock->used_size) {
+                       D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+                               " obsoleted by GC. Moving to erase_pending_list\n"
+                               , c->gcblock->offset));
+                       /* We're GC'ing an empty block? */
+                       list_add_tail(&c->gcblock->list,
+                                       &c->erase_pending_list);
+                       c->gcblock = NULL;
+                       c->nr_erasing_blocks++;
+                       jffs2_erase_pending_trigger(c);
+               }
       }
       spin_unlock(&c->erase_completion_lock);
 
fs/jffs2/nodelist.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/nodelist.c 2008-08-24 04:48:32.000000000 +0530 +5 -1
@@ -634,7 +634,11 @@ struct jffs2_raw_node_ref *jffs2_link_no
 
       if (!jeb->first_node) {
               jeb->first_node = ref;
-               BUG_ON(ref_offset(ref) != jeb->offset);
+               if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+                       BUG_ON(ref_offset(ref) !=
+                                               jeb->offset + c->wbuf_pagesize);
+               else
+                       BUG_ON(ref_offset(ref) != jeb->offset);
       } else if (unlikely(ref_offset(ref) != jeb->offset + c->sector_size - jeb->free_size)) {
               uint32_t last_len = ref_totlen(c, jeb, jeb->last_node);
 
fs/jffs2/nodemgmt.c 2008-09-01 16:15:47.000000000 +0530 renamed from fs/jffs2/nodemgmt.c 2008-08-24 04:48:32.000000000 +0530 +13 -4
@@ -362,16 +362,25 @@ static int jffs2_do_reserve_space(struct
       }
 
       if (!jeb) {
-
               ret = jffs2_find_nextblock(c);
               if (ret)
                       return ret;
 
               jeb = c->nextblock;
+               if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+                       if (jeb->free_size != c->sector_size -
+                               c->cleanmarker_size - c->wbuf_pagesize) {
+                               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;
+                       }
+               }
 
-               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;
+               else{
+                       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;
+                       }
               }
       }
       /* OK, jeb (==c->nextblock) is now pointing at a block which definitely has
fs/jffs2/scan.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/scan.c 2008-08-24 04:48:32.000000000 +0530 +8 -2
@@ -534,7 +534,10 @@ static int jffs2_scan_eraseblock (struct
               }
       }
 
-       buf_ofs = jeb->offset;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               buf_ofs = jeb->offset + c->wbuf_pagesize;
+       else
+               buf_ofs = jeb->offset;
 
       if (!buf_size) {
               /* This is the XIP case -- we're reading _directly_ from the flash chip */
@@ -582,7 +585,10 @@ static int jffs2_scan_eraseblock (struct
       }
 
       /* Now ofs is a complete physical flash offset as it always was... */
-       ofs += jeb->offset;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               ofs += jeb->offset + c->wbuf_pagesize;
+       else
+               ofs += jeb->offset;
 
       noise = 10;
 
fs/jffs2/wbuf.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/wbuf.c 2008-08-24 04:48:32.000000000 +0530 +7 -0
@@ -873,6 +873,13 @@ int jffs2_flash_writev(struct jffs2_sb_i
                       vlen -= wbuf_retlen;
                       outvec_to += wbuf_retlen;
                       c->wbuf_ofs = outvec_to;
+                       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+                               /* adjust write buffer offset,
+                                * else we get a non contiguous write bug
+                                */
+                               if (!(c->wbuf_ofs % c->sector_size))
+                                       c->wbuf_ofs = 0xffffffff;
+                       }
                       donelen += wbuf_retlen;
                       v += wbuf_retlen;
               }
include/mtd/mtd-abi.h 2008-09-02 13:51:42.000000000 +0530 renamed from include/mtd/mtd-abi.h 2008-09-02 13:51:09.000000000 +0530 +2 -0
@@ -28,12 +28,14 @@ struct mtd_oob_buf {
 #define MTD_BIT_WRITEABLE      0x800   /* Single bits can be flipped */
 #define MTD_NO_ERASE           0x1000  /* No erase necessary */
 #define MTD_POWERUP_LOCK       0x2000  /* Always locked after reset */
+#define MTD_WRITABLE_ONCE      0x4000
 
 // Some common devices / combinations of capabilities
 #define MTD_CAP_ROM            0
 #define MTD_CAP_RAM            (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
 #define MTD_CAP_NORFLASH       (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
 #define MTD_CAP_NANDFLASH      (MTD_WRITEABLE)
+#define MTD_CAP_MLCNANDFLASH   (MTD_WRITEABLE | MTD_WRITABLE_ONCE)
 
 /* ECC byte placement */
 #define MTD_NANDECC_OFF                0       // Switch off ECC (Not recommended)

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#2 lore raw
In reply to AYYANARPONNUSAMY GANGHEYAMOORTHY

Hi,

Quoted 4 lines · AYYANARPONNUSAMY GANGHEYAMOORTHY

Currently JFFS2 writes twice to the first page of the block, cleanmarker in OOB area and data in main area, which prevents JFFS2 from being used on MLC devices which have NOP count 1. This patch reserves the first page only for the cleanmarker.

Is it reasonable to waste the first page at each blocks? It wastes 1/128 storages e.g., 512MiB/128 = 4MiB.
How about to unuse the oob cleanmarker at previous email sent by me?

I'm not sure why the oob cleanmaker makes a problem at runtime?

And small coding synmatic problem at patche. See below.

Thank you,
Kyungmin Park

Quoted 17 lines

---

fs/jffs2/gc.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/gc.c 2008-08-24 04:48:32.000000000 +0530 +4 -3
@@ -237,9 +237,19 @@ int jffs2_garbage_collect_pass(struct jf
       D1(if (c->nextblock)
          printk(KERN_DEBUG "Nextblock at  %08x, used_size %08x, dirty_size %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size));
 
-       if (!jeb->used_size) {
-               mutex_unlock(&c->alloc_sem);
-               goto eraseit;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               if (jeb->used_size <= c->wbuf_pagesize) {
+                       mutex_unlock(&c->alloc_sem);
+                       goto eraseit;

fs/jffs2/gc.c 2008-09-01 13:39:56.000000000 +0530 int jffs2_garbage_collect_pass(struct jf · line 253

Quoted 10 lines
fs/jffs2/gc.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/gc.c 2008-08-24 04:48:32.000000000 +0530 +9 -0
+               }
+
+       }
+
+       else{
+               if (!jeb->used_size) {
+                       mutex_unlock(&c->alloc_sem);
+                       goto eraseit;
+               }
       }

Please add 'else' after curly braces .

Quoted 31 lines
fs/jffs2/gc.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/gc.c 2008-08-24 04:48:32.000000000 +0530 +18 -7
       raw = jeb->gc_node;
@@ -429,13 +439,32 @@ int jffs2_garbage_collect_pass(struct jf
       spin_lock(&c->erase_completion_lock);
 
 eraseit:
-       if (c->gcblock && !c->gcblock->used_size) {
-               D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset));
-               /* We're GC'ing an empty block? */
-               list_add_tail(&c->gcblock->list, &c->erase_pending_list);
-               c->gcblock = NULL;
-               c->nr_erasing_blocks++;
-               jffs2_erase_pending_trigger(c);
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               if (c->gcblock && (c->gcblock->used_size <= c->wbuf_pagesize)) {
+                       D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+                               " obsoleted by GC. Moving to erase_pending_list\n"
+                               , c->gcblock->offset));
+                       /* We're GC'ing an empty block? */
+                       list_add_tail(&c->gcblock->list,
+                                       &c->erase_pending_list);
+                       c->gcblock = NULL;
+                       c->nr_erasing_blocks++;
+                       jffs2_erase_pending_trigger(c);
+               }
+       }
+
+       else{
+               if (c->gcblock && !c->gcblock->used_size) {
+                       D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+                               " obsoleted by GC. Moving to erase_pending_list\n"

fs/jffs2/gc.c 2008-09-01 13:39:56.000000000 +0530 int jffs2_garbage_collect_pass(struct jf · line 469

Quoted 10 lines
fs/jffs2/gc.c 2008-09-01 13:39:56.000000000 +0530 renamed from fs/jffs2/gc.c 2008-08-24 04:48:32.000000000 +0530 +8 -0
+                               , c->gcblock->offset));
+                       /* We're GC'ing an empty block? */
+                       list_add_tail(&c->gcblock->list,
+                                       &c->erase_pending_list);
+                       c->gcblock = NULL;
+                       c->nr_erasing_blocks++;
+                       jffs2_erase_pending_trigger(c);
+               }
       }
       spin_unlock(&c->erase_completion_lock);

Ditto.

Quoted 5 lines
include/mtd/mtd-abi.h 2008-09-02 13:51:42.000000000 +0530 renamed from include/mtd/mtd-abi.h 2008-09-02 13:51:09.000000000 +0530 +0 -0
@@ -28,12 +28,14 @@ struct mtd_oob_buf {
 #define MTD_BIT_WRITEABLE      0x800   /* Single bits can be flipped */
 #define MTD_NO_ERASE           0x1000  /* No erase necessary */

include/mtd/mtd-abi.h 2008-09-02 13:51:42.000000000 +0530 struct mtd_oob_buf { · line 39

Quoted 10 lines
include/mtd/mtd-abi.h 2008-09-02 13:51:42.000000000 +0530 renamed from include/mtd/mtd-abi.h 2008-09-02 13:51:09.000000000 +0530 +2 -0
 #define MTD_POWERUP_LOCK       0x2000  /* Always locked after reset */
+#define MTD_WRITABLE_ONCE      0x4000
 
 // Some common devices / combinations of capabilities
 #define MTD_CAP_ROM            0
 #define MTD_CAP_RAM            (MTD_WRITEABLE | MTD_BIT_WRITEABLE | MTD_NO_ERASE)
 #define MTD_CAP_NORFLASH       (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
 #define MTD_CAP_NANDFLASH      (MTD_WRITEABLE)
+#define MTD_CAP_MLCNANDFLASH   (MTD_WRITEABLE | MTD_WRITABLE_ONCE)
 

As previously, define MTD_OOB_WRITEABLE instead of WRITABLE_ONCE. SLC NAND has WRITEABLE | OOB_WRITEABLE, but MLC NAND has WRITEABLE only

author
#3 lore raw

Hi,

Quoted 8 lines · Kyungmin Park
Quoted 4 lines

Currently JFFS2 writes twice to the first page of the block, cleanmarker in OOB area and data in main area, which prevents JFFS2 from being used on MLC devices which have NOP count 1. This patch reserves the first page only for the cleanmarker.

Is it reasonable to waste the first page at each blocks? It wastes 1/128 storages e.g., 512MiB/128 = 4MiB.
How about to unuse the oob cleanmarker at previous email sent by me?

- I will look into this.

Quoted 1 line

And small coding synmatic problem at patche. See below.

- corrected those in the new patch

---

fs/jffs2/build.c +13 -2
@@ -330,7 +330,11 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
 	int i;
 	int size;
 
-	c->free_size = c->flash_size;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		c->free_size = 0;
+	else
+		c->free_size = c->flash_size;
+
 	c->nr_blocks = c->flash_size / c->sector_size;
 	size = sizeof(struct jffs2_eraseblock) * c->nr_blocks;
 #ifndef __ECOS
@@ -346,7 +350,14 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
 	for (i=0; i<c->nr_blocks; i++) {
 		INIT_LIST_HEAD(&c->blocks[i].list);
 		c->blocks[i].offset = i * c->sector_size;
-		c->blocks[i].free_size = c->sector_size;
+		if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+			c->blocks[i].free_size =
+					c->sector_size - c->wbuf_pagesize;
+			c->blocks[i].used_size = c->wbuf_pagesize;
+			c->free_size +=  c->blocks[i].free_size;
+			c->used_size += c->blocks[i].used_size;
+		} else
+			c->blocks[i].free_size = c->sector_size;
 	}
 
 	INIT_LIST_HEAD(&c->clean_list);
fs/jffs2/debug.c +3 -0
@@ -307,6 +307,9 @@ __jffs2_dbg_acct_paranoia_check_nolock(s
 	uint32_t my_dirty_size = 0;
 	struct jffs2_raw_node_ref *ref2 = jeb->first_node;
 
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		my_used_size = c->wbuf_pagesize;
+
 	while (ref2) {
 		uint32_t totlen = ref_totlen(c, jeb, ref2);
 
fs/jffs2/erase.c +10 -2
@@ -454,13 +454,21 @@ static void jffs2_mark_erased_block(stru
 		}
 	}
 	/* Everything else got zeroed before the erase */
-	jeb->free_size = c->sector_size;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+		jeb->free_size = c->sector_size - c->wbuf_pagesize;
+		jeb->used_size = c->wbuf_pagesize;
+	} else
+		jeb->free_size = c->sector_size;
 
 	mutex_lock(&c->erase_free_sem);
 	spin_lock(&c->erase_completion_lock);
 
 	c->erasing_size -= c->sector_size;
-	c->free_size += c->sector_size;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+		c->free_size += c->sector_size - c->wbuf_pagesize;
+		c->used_size += c->wbuf_pagesize;
+	} else
+		c->free_size += c->sector_size;
 
 	/* Account for cleanmarker now, if it's in-band */
 	if (c->cleanmarker_size && !jffs2_cleanmarker_oob(c))
fs/jffs2/gc.c +0 -0
@@ -237,9 +237,17 @@ int jffs2_garbage_collect_pass(struct jf
 	D1(if (c->nextblock)
 	   printk(KERN_DEBUG "Nextblock at  %08x, used_size %08x, dirty_size

%08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size));

- if (!jeb->used_size) {
- mutex_unlock(&c->alloc_sem);
- goto eraseit;
+ if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+ if (jeb->used_size <= c->wbuf_pagesize) {
+ mutex_unlock(&c->alloc_sem);
+ goto eraseit;
+ }
+
+ } else{
+ if (!jeb->used_size) {
+ mutex_unlock(&c->alloc_sem);
+ goto eraseit;
+ }
}

raw = jeb->gc_node;
@@ -429,13 +437,30 @@ int jffs2_garbage_collect_pass(struct jf
spin_lock(&c->erase_completion_lock);

eraseit:
- if (c->gcblock && !c->gcblock->used_size) {
- D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted
by GC. Moving to erase_pending_list\n", c->gcblock->offset));
- /* We're GC'ing an empty block? */
- list_add_tail(&c->gcblock->list, &c->erase_pending_list);
- c->gcblock = NULL;
- c->nr_erasing_blocks++;
- jffs2_erase_pending_trigger(c);
+ if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+ if (c->gcblock && (c->gcblock->used_size <=
c->wbuf_pagesize)) {
+ D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+ " obsoleted by GC. Moving to
erase_pending_list\n"
+ , c->gcblock->offset));
+ /* We're GC'ing an empty block? */
+ list_add_tail(&c->gcblock->list,
+ &c->erase_pending_list);
+ c->gcblock = NULL;
+ c->nr_erasing_blocks++;
+ jffs2_erase_pending_trigger(c);
+ }
+ } else{
+ if (c->gcblock && !c->gcblock->used_size) {
+ D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+ " obsoleted by GC. Moving to
erase_pending_list\n"
+ , c->gcblock->offset));
+ /* We're GC'ing an empty block? */
+ list_add_tail(&c->gcblock->list,
+ &c->erase_pending_list);
+ c->gcblock = NULL;
+ c->nr_erasing_blocks++;
+ jffs2_erase_pending_trigger(c);
+ }
}
spin_unlock(&c->erase_completion_lock);

fs/jffs2/nodelist.c +3 -1
@@ -634,7 +634,11 @@ struct jffs2_raw_node_ref *jffs2_link_no
 
 	if (!jeb->first_node) {
 		jeb->first_node = ref;
-		BUG_ON(ref_offset(ref) != jeb->offset);
+		if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+			BUG_ON(ref_offset(ref) !=
+						jeb->offset +

c->wbuf_pagesize);
+ else
+ BUG_ON(ref_offset(ref) != jeb->offset);
} else if (unlikely(ref_offset(ref) != jeb->offset + c->sector_size
- jeb->free_size)) {
uint32_t last_len = ref_totlen(c, jeb, jeb->last_node);

fs/jffs2/nodemgmt.c +4 -1
@@ -362,16 +362,25 @@ static int jffs2_do_reserve_space(struct
 	}
 
 	if (!jeb) {
-
 		ret = jffs2_find_nextblock(c);
 		if (ret)
 			return ret;
 
 		jeb = c->nextblock;
+		if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+			if (jeb->free_size != c->sector_size -
+				c->cleanmarker_size - c->wbuf_pagesize) {
+				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;
+ }
+ }

- 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;
+ else{
+ 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;
+ }
}
}
/* OK, jeb (==c->nextblock) is now pointing at a block which
definitely has

fs/jffs2/scan.c +4 -1
@@ -534,7 +534,10 @@ static int jffs2_scan_eraseblock (struct
 		}
 	}
 
-	buf_ofs = jeb->offset;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		buf_ofs = jeb->offset + c->wbuf_pagesize;
+	else
+		buf_ofs = jeb->offset;
 
 	if (!buf_size) {
 		/* This is the XIP case -- we're reading _directly_ from the

flash chip */
@@ -582,7 +585,10 @@ static int jffs2_scan_eraseblock (struct
}

/* Now ofs is a complete physical flash offset as it always was...
*/
- ofs += jeb->offset;
+ if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+ ofs += jeb->offset + c->wbuf_pagesize;
+ else
+ ofs += jeb->offset;

noise = 10;

fs/jffs2/wbuf.c +7 -0
@@ -873,6 +873,13 @@ int jffs2_flash_writev(struct jffs2_sb_i
 			vlen -= wbuf_retlen;
 			outvec_to += wbuf_retlen;
 			c->wbuf_ofs = outvec_to;
+			if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+				/* adjust write buffer offset,
+				 * else we get a non contiguous write bug
+				 */
+				if (!(c->wbuf_ofs % c->sector_size))
+					c->wbuf_ofs = 0xffffffff;
+			}
 			donelen += wbuf_retlen;
 			v += wbuf_retlen;
 		}
include/mtd/mtd-abi.h +1 -0
@@ -28,12 +28,14 @@ struct mtd_oob_buf {
 #define MTD_BIT_WRITEABLE	0x800	/* Single bits can be flipped */
 #define MTD_NO_ERASE		0x1000	/* No erase necessary */
 #define MTD_POWERUP_LOCK	0x2000	/* Always locked after reset */
+#define MTD_OOB_WRITEABLE	0x4000
 
 // Some common devices / combinations of capabilities
 #define MTD_CAP_ROM		0
 #define MTD_CAP_RAM		(MTD_WRITEABLE | MTD_BIT_WRITEABLE |

MTD_NO_ERASE)
#define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
#define MTD_CAP_NANDFLASH (MTD_WRITEABLE)
+#define MTD_CAP_MLCNANDFLASH (MTD_WRITEABLE | MTD_OOB_WRITEABLE)

/* ECC byte placement */
#define MTD_NANDECC_OFF 0 // Switch off ECC (Not
recommended)

author
#4 lore raw
In reply to Kyungmin Park

Hi,

In the earlier patch there was a typo , have rectified it and posting it back.

---

fs/jffs2/build.c +5 -1
@@ -330,7 +330,11 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
 	int i;
 	int size;
 
-	c->free_size = c->flash_size;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		c->free_size = 0;
+	else
+		c->free_size = c->flash_size;
+
 	c->nr_blocks = c->flash_size / c->sector_size;
 	size = sizeof(struct jffs2_eraseblock) * c->nr_blocks;  #ifndef

__ECOS @@ -346,7 +350,14 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
for (i=0; i<c->nr_blocks; i++) {
INIT_LIST_HEAD(&c->blocks[i].list); c->blocks[i].offset = i * c->sector_size;
- c->blocks[i].free_size = c->sector_size;
+ if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+ c->blocks[i].free_size =
+ c->sector_size - c->wbuf_pagesize;
+ c->blocks[i].used_size = c->wbuf_pagesize;
+ c->free_size += c->blocks[i].free_size;
+ c->used_size += c->blocks[i].used_size;
+ } else
+ c->blocks[i].free_size = c->sector_size;
}

INIT_LIST_HEAD(&c->clean_list);

fs/jffs2/debug.c +3 -0
@@ -307,6 +307,9 @@ __jffs2_dbg_acct_paranoia_check_nolock(s
 	uint32_t my_dirty_size = 0;
 	struct jffs2_raw_node_ref *ref2 = jeb->first_node;
 
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		my_used_size = c->wbuf_pagesize;
+
 	while (ref2) {
 		uint32_t totlen = ref_totlen(c, jeb, ref2);
 
fs/jffs2/erase.c +10 -2
@@ -454,13 +454,21 @@ static void jffs2_mark_erased_block(stru
 		}
 	}
 	/* Everything else got zeroed before the erase */
-	jeb->free_size = c->sector_size;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+		jeb->free_size = c->sector_size - c->wbuf_pagesize;
+		jeb->used_size = c->wbuf_pagesize;
+	} else
+		jeb->free_size = c->sector_size;
 
 	mutex_lock(&c->erase_free_sem);
 	spin_lock(&c->erase_completion_lock);
 
 	c->erasing_size -= c->sector_size;
-	c->free_size += c->sector_size;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+		c->free_size += c->sector_size - c->wbuf_pagesize;
+		c->used_size += c->wbuf_pagesize;
+	} else
+		c->free_size += c->sector_size;
 
 	/* Account for cleanmarker now, if it's in-band */
 	if (c->cleanmarker_size && !jffs2_cleanmarker_oob(c))
fs/jffs2/gc.c +0 -0
@@ -237,9 +237,17 @@ int jffs2_garbage_collect_pass(struct jf
 	D1(if (c->nextblock)
 	   printk(KERN_DEBUG "Nextblock at  %08x, used_size %08x, dirty_size

%08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size));

- if (!jeb->used_size) {
- mutex_unlock(&c->alloc_sem);
- goto eraseit;
+ if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+ if (jeb->used_size <= c->wbuf_pagesize) {
+ mutex_unlock(&c->alloc_sem);
+ goto eraseit;
+ }
+
+ } else{
+ if (!jeb->used_size) {
+ mutex_unlock(&c->alloc_sem);
+ goto eraseit;
+ }
}

raw = jeb->gc_node;
@@ -429,13 +437,30 @@ int jffs2_garbage_collect_pass(struct jf
spin_lock(&c->erase_completion_lock);

eraseit:
- if (c->gcblock && !c->gcblock->used_size) {
- D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted
by GC. Moving to erase_pending_list\n", c->gcblock->offset));
- /* We're GC'ing an empty block? */
- list_add_tail(&c->gcblock->list, &c->erase_pending_list);
- c->gcblock = NULL;
- c->nr_erasing_blocks++;
- jffs2_erase_pending_trigger(c);
+ if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+ if (c->gcblock && (c->gcblock->used_size <=
c->wbuf_pagesize)) {
+ D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+ " obsoleted by GC. Moving to
erase_pending_list\n"
+ , c->gcblock->offset));
+ /* We're GC'ing an empty block? */
+ list_add_tail(&c->gcblock->list,
+ &c->erase_pending_list);
+ c->gcblock = NULL;
+ c->nr_erasing_blocks++;
+ jffs2_erase_pending_trigger(c);
+ }
+ } else{
+ if (c->gcblock && !c->gcblock->used_size) {
+ D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+ " obsoleted by GC. Moving to
erase_pending_list\n"
+ , c->gcblock->offset));
+ /* We're GC'ing an empty block? */
+ list_add_tail(&c->gcblock->list,
+ &c->erase_pending_list);
+ c->gcblock = NULL;
+ c->nr_erasing_blocks++;
+ jffs2_erase_pending_trigger(c);
+ }
}
spin_unlock(&c->erase_completion_lock);

fs/jffs2/nodelist.c +3 -1
@@ -634,7 +634,11 @@ struct jffs2_raw_node_ref *jffs2_link_no
 
 	if (!jeb->first_node) {
 		jeb->first_node = ref;
-		BUG_ON(ref_offset(ref) != jeb->offset);
+		if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+			BUG_ON(ref_offset(ref) !=
+						jeb->offset +

c->wbuf_pagesize);
+ else
+ BUG_ON(ref_offset(ref) != jeb->offset);
} else if (unlikely(ref_offset(ref) != jeb->offset + c->sector_size
- jeb->free_size)) {
uint32_t last_len = ref_totlen(c, jeb, jeb->last_node);

fs/jffs2/nodemgmt.c +4 -1
@@ -362,16 +362,25 @@ static int jffs2_do_reserve_space(struct
 	}
 
 	if (!jeb) {
-
 		ret = jffs2_find_nextblock(c);
 		if (ret)
 			return ret;
 
 		jeb = c->nextblock;
+		if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+			if (jeb->free_size != c->sector_size -
+				c->cleanmarker_size - c->wbuf_pagesize) {
+				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;
+ }
+ }

- 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;
+ else{
+ 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;
+ }
}
}
/* OK, jeb (==c->nextblock) is now pointing at a block which
definitely has

fs/jffs2/scan.c +4 -1
@@ -534,7 +534,10 @@ static int jffs2_scan_eraseblock (struct
 		}
 	}
 
-	buf_ofs = jeb->offset;
+	if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+		buf_ofs = jeb->offset + c->wbuf_pagesize;
+	else
+		buf_ofs = jeb->offset;
 
 	if (!buf_size) {
 		/* This is the XIP case -- we're reading _directly_ from the

flash chip */ @@ -582,7 +585,10 @@ static int jffs2_scan_eraseblock (struct
}

/* Now ofs is a complete physical flash offset as it always was...
*/
- ofs += jeb->offset;
+ if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+ ofs += jeb->offset + c->wbuf_pagesize;
+ else
+ ofs += jeb->offset;

noise = 10;

fs/jffs2/wbuf.c +7 -0
@@ -873,6 +873,13 @@ int jffs2_flash_writev(struct jffs2_sb_i
 			vlen -= wbuf_retlen;
 			outvec_to += wbuf_retlen;
 			c->wbuf_ofs = outvec_to;
+			if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+				/* adjust write buffer offset,
+				 * else we get a non contiguous write bug
+				 */
+				if (!(c->wbuf_ofs % c->sector_size))
+					c->wbuf_ofs = 0xffffffff;
+			}
 			donelen += wbuf_retlen;
 			v += wbuf_retlen;
 		}
include/mtd/mtd-abi.h +1 -0
@@ -28,12 +28,14 @@ struct mtd_oob_buf {
 #define MTD_BIT_WRITEABLE	0x800	/* Single bits can be flipped */
 #define MTD_NO_ERASE		0x1000	/* No erase necessary */
 #define MTD_POWERUP_LOCK	0x2000	/* Always locked after reset */
+#define MTD_OOB_WRITEABLE	0x4000
 
 // Some common devices / combinations of capabilities
 #define MTD_CAP_ROM		0
 #define MTD_CAP_RAM		(MTD_WRITEABLE | MTD_BIT_WRITEABLE |

MTD_NO_ERASE)
#define MTD_CAP_NORFLASH (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
#define MTD_CAP_NANDFLASH (MTD_WRITEABLE | MTD_OOB_WRITEABLE)
+#define MTD_CAP_MLCNANDFLASH (MTD_WRITEABLE)

/* ECC byte placement */
#define MTD_NANDECC_OFF 0 // Switch off ECC (Not
recommended)

#5 lore raw

Hi,
I have looked into the log file. I notice the oops in the log
file is the same i often meet with MLC nand after apply the patch JFFS2 doesn't use OOB at MLC NAND/OneNAND from Kyungmin Park, it seems that jffs2 file system may have serious issues. I have strong feeling that jffs2 files system is far from production level at least for MLC nand flash. David, do you have any comments?

2008/9/29 apgmoorthy <[email protected]>:

Quoted 266 lines

Hi,

In the earlier patch there was a typo , have rectified it and posting it back.

---

fs/jffs2/build.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/build.c 2008-09-16 20:48:12.000000000 +0530 +5 -1
@@ -330,7 +330,11 @@ int jffs2_do_mount_fs(struct jffs2_sb_in
       int i;
       int size;
 
-       c->free_size = c->flash_size;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               c->free_size = 0;
+       else
+               c->free_size = c->flash_size;
+
       c->nr_blocks = c->flash_size / c->sector_size;
       size = sizeof(struct jffs2_eraseblock) * c->nr_blocks;  #ifndef

__ECOS @@ -346,7 +350,14 @@ int jffs2_do_mount_fs(struct jffs2_sb_in

       for (i=0; i<c->nr_blocks; i++) {
               INIT_LIST_HEAD(&c->blocks[i].list);
               c->blocks[i].offset = i * c->sector_size;
fs/jffs2/build.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/build.c 2008-09-16 20:48:12.000000000 +0530 +8 -1
-               c->blocks[i].free_size = c->sector_size;
+               if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+                       c->blocks[i].free_size =
+                                       c->sector_size - c->wbuf_pagesize;
+                       c->blocks[i].used_size = c->wbuf_pagesize;
+                       c->free_size +=  c->blocks[i].free_size;
+                       c->used_size += c->blocks[i].used_size;
+               } else
+                       c->blocks[i].free_size = c->sector_size;
       }
 
       INIT_LIST_HEAD(&c->clean_list);
fs/jffs2/debug.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/debug.c 2008-09-16 20:48:12.000000000 +0530 +3 -0
@@ -307,6 +307,9 @@ __jffs2_dbg_acct_paranoia_check_nolock(s
       uint32_t my_dirty_size = 0;
       struct jffs2_raw_node_ref *ref2 = jeb->first_node;
 
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               my_used_size = c->wbuf_pagesize;
+
       while (ref2) {
               uint32_t totlen = ref_totlen(c, jeb, ref2);
 
fs/jffs2/erase.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/erase.c 2008-09-16 20:48:12.000000000 +0530 +10 -2
@@ -454,13 +454,21 @@ static void jffs2_mark_erased_block(stru
               }
       }
       /* Everything else got zeroed before the erase */
-       jeb->free_size = c->sector_size;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               jeb->free_size = c->sector_size - c->wbuf_pagesize;
+               jeb->used_size = c->wbuf_pagesize;
+       } else
+               jeb->free_size = c->sector_size;
 
       mutex_lock(&c->erase_free_sem);
       spin_lock(&c->erase_completion_lock);
 
       c->erasing_size -= c->sector_size;
-       c->free_size += c->sector_size;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               c->free_size += c->sector_size - c->wbuf_pagesize;
+               c->used_size += c->wbuf_pagesize;
+       } else
+               c->free_size += c->sector_size;
 
       /* Account for cleanmarker now, if it's in-band */
       if (c->cleanmarker_size && !jffs2_cleanmarker_oob(c))
fs/jffs2/gc.c 2008-09-23 21:36:56.000000000 +0530 renamed from fs/jffs2/gc.c 2008-09-16 20:48:12.000000000 +0530 +11 -3
@@ -237,9 +237,17 @@ int jffs2_garbage_collect_pass(struct jf
       D1(if (c->nextblock)
          printk(KERN_DEBUG "Nextblock at  %08x, used_size %08x, dirty_size
 %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset,
 c->nextblock->used_size, c->nextblock->dirty_size,
 c->nextblock->wasted_size, c->nextblock->free_size));
 
-       if (!jeb->used_size) {
-               mutex_unlock(&c->alloc_sem);
-               goto eraseit;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               if (jeb->used_size <= c->wbuf_pagesize) {
+                       mutex_unlock(&c->alloc_sem);
+                       goto eraseit;
+               }
+
+       } else{
+               if (!jeb->used_size) {
+                       mutex_unlock(&c->alloc_sem);
+                       goto eraseit;
+               }
       }

       raw = jeb->gc_node;
fs/jffs2/gc.c 2008-09-23 21:36:56.000000000 +0530 renamed from fs/jffs2/gc.c 2008-09-16 20:48:12.000000000 +0530 +4 -7
@@ -429,13 +437,30 @@ int jffs2_garbage_collect_pass(struct jf
       spin_lock(&c->erase_completion_lock);
 
 eraseit:
-       if (c->gcblock && !c->gcblock->used_size) {
-               D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted
 by GC. Moving to erase_pending_list\n", c->gcblock->offset));
-               /* We're GC'ing an empty block? */
-               list_add_tail(&c->gcblock->list, &c->erase_pending_list);
-               c->gcblock = NULL;
-               c->nr_erasing_blocks++;
-               jffs2_erase_pending_trigger(c);
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               if (c->gcblock && (c->gcblock->used_size <=
 c->wbuf_pagesize)) {
+                       D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+                               " obsoleted by GC. Moving to

erase_pending_list\n"

fs/jffs2/gc.c 2008-09-23 21:36:56.000000000 +0530 renamed from fs/jffs2/gc.c 2008-09-16 20:48:12.000000000 +0530 +12 -0
+                               , c->gcblock->offset));
+                       /* We're GC'ing an empty block? */
+                       list_add_tail(&c->gcblock->list,
+                                       &c->erase_pending_list);
+                       c->gcblock = NULL;
+                       c->nr_erasing_blocks++;
+                       jffs2_erase_pending_trigger(c);
+               }
+       } else{
+               if (c->gcblock && !c->gcblock->used_size) {
+                       D1(printk(KERN_DEBUG "Block at 0x%08x completely"
+                               " obsoleted by GC. Moving to

erase_pending_list\n"

fs/jffs2/gc.c 2008-09-23 21:36:56.000000000 +0530 renamed from fs/jffs2/gc.c 2008-09-16 20:48:12.000000000 +0530 +8 -0
+                               , c->gcblock->offset));
+                       /* We're GC'ing an empty block? */
+                       list_add_tail(&c->gcblock->list,
+                                       &c->erase_pending_list);
+                       c->gcblock = NULL;
+                       c->nr_erasing_blocks++;
+                       jffs2_erase_pending_trigger(c);
+               }
       }
       spin_unlock(&c->erase_completion_lock);
fs/jffs2/nodelist.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/nodelist.c 2008-09-16 20:48:12.000000000 +0530 +5 -2
@@ -634,7 +634,11 @@ struct jffs2_raw_node_ref *jffs2_link_no
 
       if (!jeb->first_node) {
               jeb->first_node = ref;
-               BUG_ON(ref_offset(ref) != jeb->offset);
+               if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+                       BUG_ON(ref_offset(ref) !=
+                                               jeb->offset +
 c->wbuf_pagesize);
+               else
+                       BUG_ON(ref_offset(ref) != jeb->offset);
       } else if (unlikely(ref_offset(ref) != jeb->offset + c->sector_size
- jeb->free_size)) {
               uint32_t last_len = ref_totlen(c, jeb, jeb->last_node);
fs/jffs2/nodemgmt.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/nodemgmt.c 2008-09-16 20:48:12.000000000 +0530 +11 -4
@@ -362,16 +362,25 @@ static int jffs2_do_reserve_space(struct
       }
 
       if (!jeb) {
-
               ret = jffs2_find_nextblock(c);
               if (ret)
                       return ret;
 
               jeb = c->nextblock;
+               if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+                       if (jeb->free_size != c->sector_size -
+                               c->cleanmarker_size - c->wbuf_pagesize) {
+                               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;
+                       }
+               }
 
-               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;
+               else{
+                       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);

fs/jffs2/nodemgmt.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/nodemgmt.c 2008-09-16 20:48:12.000000000 +0530 +2 -0
+                               goto restart;
+                       }
               }
       }
       /* OK, jeb (==c->nextblock) is now pointing at a block which

definitely has

fs/jffs2/scan.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/scan.c 2008-09-16 20:48:12.000000000 +0530 +4 -1
@@ -534,7 +534,10 @@ static int jffs2_scan_eraseblock (struct
               }
       }
 
-       buf_ofs = jeb->offset;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               buf_ofs = jeb->offset + c->wbuf_pagesize;
+       else
+               buf_ofs = jeb->offset;
 
       if (!buf_size) {
               /* This is the XIP case -- we're reading _directly_ from the

flash chip */ @@ -582,7 +585,10 @@ static int jffs2_scan_eraseblock (struct

       }

       /* Now ofs is a complete physical flash offset as it always was...

*/

fs/jffs2/scan.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/scan.c 2008-09-16 20:48:12.000000000 +0530 +4 -1
-       ofs += jeb->offset;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               ofs += jeb->offset + c->wbuf_pagesize;
+       else
+               ofs += jeb->offset;
 
       noise = 10;
fs/jffs2/wbuf.c 2008-09-19 17:07:48.000000000 +0530 renamed from fs/jffs2/wbuf.c 2008-09-16 20:48:12.000000000 +0530 +7 -0
@@ -873,6 +873,13 @@ int jffs2_flash_writev(struct jffs2_sb_i
                       vlen -= wbuf_retlen;
                       outvec_to += wbuf_retlen;
                       c->wbuf_ofs = outvec_to;
+                       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+                               /* adjust write buffer offset,
+                                * else we get a non contiguous write bug
+                                */
+                               if (!(c->wbuf_ofs % c->sector_size))
+                                       c->wbuf_ofs = 0xffffffff;
+                       }
                       donelen += wbuf_retlen;
                       v += wbuf_retlen;
               }
include/mtd/mtd-abi.h 2008-09-23 22:09:18.000000000 +0530 renamed from include/mtd/mtd-abi.h 2008-09-16 20:48:12.000000000 +0530 +2 -0
@@ -28,12 +28,14 @@ struct mtd_oob_buf {
 #define MTD_BIT_WRITEABLE      0x800   /* Single bits can be flipped */
 #define MTD_NO_ERASE           0x1000  /* No erase necessary */
 #define MTD_POWERUP_LOCK       0x2000  /* Always locked after reset */
+#define MTD_OOB_WRITEABLE      0x4000
 
 // Some common devices / combinations of capabilities
 #define MTD_CAP_ROM            0
 #define MTD_CAP_RAM            (MTD_WRITEABLE | MTD_BIT_WRITEABLE |
 MTD_NO_ERASE)
 #define MTD_CAP_NORFLASH       (MTD_WRITEABLE | MTD_BIT_WRITEABLE)
 #define MTD_CAP_NANDFLASH      (MTD_WRITEABLE | MTD_OOB_WRITEABLE)
+#define MTD_CAP_MLCNANDFLASH   (MTD_WRITEABLE)
 
 /* ECC byte placement */

#define MTD_NANDECC_OFF 0 // Switch off ECC (Not
recommended)

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#6 lore raw

We are also facing many difficulty in robustness and reliability test with Jffs2 not only this we have tested our MLC patches on kernel 2.6.22 their Jffs2 stability was little bit higher as compare to 2.6.27 , not only this LTP file tests and rw test fails with Jffs2 and same driver works fine with yaffs2 but yaffs2 also has issue with Symlink operation we are working for that.

Rgs
Amit
----- Original Message -----
From: "Jason Liu" <[email protected]>
To: "apgmoorthy" <[email protected]>
Cc: <[email protected]>; "Kyungmin Park" <[email protected]>; <[email protected]>
Sent: Tuesday, September 30, 2008 5:37 PM
Subject: Re: [PATCH 1/2] [MTD] [JFFS2] MLC NAND support

Quoted 373 lines

Hi,
I have looked into the log file. I notice the oops in
the log
file is the same i often meet with MLC nand after apply the patch
JFFS2 doesn't use OOB at MLC NAND/OneNAND from Kyungmin Park, it seems
that jffs2 file system may have serious issues. I have strong feeling
that jffs2 files system is far from production level at least for MLC
nand flash. David, do you have any comments?

2008/9/29 apgmoorthy <[email protected]>:

Quoted 351 lines

Hi,

In the earlier patch there was a typo , have rectified it and posting it
back.

Signed-off-by: Rajshekar H Payagond <[email protected]>
---
--- a/fs/jffs2/build.c 2008-09-16 20:48:12.000000000 +0530
+++ b/fs/jffs2/build.c 2008-09-19 17:07:48.000000000 +0530

(quoted diff) +0 -0
@@ -330,7 +330,11 @@ int jffs2_do_mount_fs(struct 

jffs2_sb_in

       int i;
       int size;
fs/jffs2/build.c +5 -1
-       c->free_size = c->flash_size;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               c->free_size = 0;
+       else
+               c->free_size = c->flash_size;
+
       c->nr_blocks = c->flash_size / c->sector_size;
       size = sizeof(struct jffs2_eraseblock) * 

c->nr_blocks; #ifndef
__ECOS @@ -346,7 +350,14 @@ int jffs2_do_mount_fs(struct jffs2_sb_in

       for (i=0; i<c->nr_blocks; i++) {
               INIT_LIST_HEAD(&c->blocks[i].list);
               c->blocks[i].offset = i * c->sector_size;
(quoted diff) +1 -1
-               c->blocks[i].free_size = c->sector_size;
+               if (c->mtd->flags == 

MTD_CAP_MLCNANDFLASH) {

(quoted diff) +2 -0
+                       c->blocks[i].free_size =
+                                       c->sector_size - 

c->wbuf_pagesize;
+ c->blocks[i].used_size =
c->wbuf_pagesize;
+ c->free_size +=
c->blocks[i].free_size;
+ c->used_size +=
c->blocks[i].used_size;

(quoted diff) +2 -0
+               } else
+                       c->blocks[i].free_size = 
c->sector_size;
       }

       INIT_LIST_HEAD(&c->clean_list);

--- a/fs/jffs2/debug.c 2008-09-16 20:48:12.000000000 +0530
+++ b/fs/jffs2/debug.c 2008-09-19 17:07:48.000000000 +0530

(quoted diff) +0 -0
@@ -307,6 +307,9 @@ 

__jffs2_dbg_acct_paranoia_check_nolock(s

       uint32_t my_dirty_size = 0;
       struct jffs2_raw_node_ref *ref2 = jeb->first_node;
fs/jffs2/debug.c +3 -0
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               my_used_size = c->wbuf_pagesize;
+
       while (ref2) {
               uint32_t totlen = ref_totlen(c, jeb, 

ref2);

--- a/fs/jffs2/erase.c 2008-09-16 20:48:12.000000000 +0530
+++ b/fs/jffs2/erase.c 2008-09-19 17:07:48.000000000 +0530

(quoted diff) +0 -0
@@ -454,13 +454,21 @@ static void 

jffs2_mark_erased_block(stru

               }
       }
       /* Everything else got zeroed before the erase */
fs/jffs2/erase.c +2 -1
-       jeb->free_size = c->sector_size;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               jeb->free_size = c->sector_size - 

c->wbuf_pagesize;

fs/jffs2/erase.c +5 -1
+               jeb->used_size = c->wbuf_pagesize;
+       } else
+               jeb->free_size = c->sector_size;
 
       mutex_lock(&c->erase_free_sem);
       spin_lock(&c->erase_completion_lock);
 
       c->erasing_size -= c->sector_size;
-       c->free_size += c->sector_size;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               c->free_size += c->sector_size - 

c->wbuf_pagesize;

fs/jffs2/erase.c +3 -0
+               c->used_size += c->wbuf_pagesize;
+       } else
+               c->free_size += c->sector_size;
 
       /* Account for cleanmarker now, if it's in-band */
       if (c->cleanmarker_size && 

!jffs2_cleanmarker_oob(c))
--- a/fs/jffs2/gc.c 2008-09-16 20:48:12.000000000
+0530
+++ b/fs/jffs2/gc.c 2008-09-23 21:36:56.000000000
+0530

(quoted diff) +0 -0
@@ -237,9 +237,17 @@ int 

jffs2_garbage_collect_pass(struct jf
D1(if (c->nextblock)
printk(KERN_DEBUG "Nextblock at %08x,
used_size %08x, dirty_size
%08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size));

(quoted diff) +11 -3
-       if (!jeb->used_size) {
-               mutex_unlock(&c->alloc_sem);
-               goto eraseit;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               if (jeb->used_size <= c->wbuf_pagesize) {
+                       mutex_unlock(&c->alloc_sem);
+                       goto eraseit;
+               }
+
+       } else{
+               if (!jeb->used_size) {
+                       mutex_unlock(&c->alloc_sem);
+                       goto eraseit;
+               }
       }
 
       raw = jeb->gc_node;
@@ -429,13 +437,30 @@ int 

jffs2_garbage_collect_pass(struct jf

       spin_lock(&c->erase_completion_lock);

eraseit:

(quoted diff) +0 -2
-       if (c->gcblock && !c->gcblock->used_size) {
-               D1(printk(KERN_DEBUG "Block at 0x%08x 

completely obsoleted
by GC. Moving to erase_pending_list\n",
c->gcblock->offset));

(quoted diff) +0 -2
-               /* We're GC'ing an empty block? */
-               list_add_tail(&c->gcblock->list, 

&c->erase_pending_list);

(quoted diff) +2 -3
-               c->gcblock = NULL;
-               c->nr_erasing_blocks++;
-               jffs2_erase_pending_trigger(c);
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH) {
+               if (c->gcblock && (c->gcblock->used_size 

<=
c->wbuf_pagesize)) {
+ D1(printk(KERN_DEBUG "Block at
0x%08x completely"
+ " obsoleted by GC. Moving
to
erase_pending_list\n"

(quoted diff) +2 -0
+                               , c->gcblock->offset));
+                       /* We're GC'ing an empty block? 

*/
+ list_add_tail(&c->gcblock->list,
+
&c->erase_pending_list);

(quoted diff) +6 -0
+                       c->gcblock = NULL;
+                       c->nr_erasing_blocks++;
+                       jffs2_erase_pending_trigger(c);
+               }
+       } else{
+               if (c->gcblock && !c->gcblock->used_size) 

{
+ D1(printk(KERN_DEBUG "Block at
0x%08x completely"
+ " obsoleted by GC. Moving
to
erase_pending_list\n"

(quoted diff) +2 -0
+                               , c->gcblock->offset));
+                       /* We're GC'ing an empty block? 

*/
+ list_add_tail(&c->gcblock->list,
+
&c->erase_pending_list);

(quoted diff) +4 -1
+                       c->gcblock = NULL;
+                       c->nr_erasing_blocks++;
+                       jffs2_erase_pending_trigger(c);
+               }
       }
       spin_unlock(&c->erase_completion_lock);
 
--- a/fs/jffs2/nodelist.c       2008-09-16 

20:48:12.000000000 +0530
+++ b/fs/jffs2/nodelist.c 2008-09-19
17:07:48.000000000 +0530

fs/jffs2/nodelist.c +3 -1
@@ -634,7 +634,11 @@ struct jffs2_raw_node_ref 
 *jffs2_link_no
 
       if (!jeb->first_node) {
               jeb->first_node = ref;
-               BUG_ON(ref_offset(ref) != jeb->offset);
+               if (c->mtd->flags == 
 MTD_CAP_MLCNANDFLASH)
+                       BUG_ON(ref_offset(ref) !=
+ 

jeb->offset +
c->wbuf_pagesize);

(quoted diff) +2 -0
+               else
+                       BUG_ON(ref_offset(ref) != 
jeb->offset);
       } else if (unlikely(ref_offset(ref) != jeb->offset 

+ c->sector_size
- jeb->free_size)) {
uint32_t last_len = ref_totlen(c, jeb,
jeb->last_node);

--- a/fs/jffs2/nodemgmt.c 2008-09-16
20:48:12.000000000 +0530
+++ b/fs/jffs2/nodemgmt.c 2008-09-19
17:07:48.000000000 +0530

(quoted diff) +0 -0
@@ -362,16 +362,25 @@ static int 

jffs2_do_reserve_space(struct

       }

       if (!jeb) {
fs/jffs2/nodemgmt.c +1 -1
-
               ret = jffs2_find_nextblock(c);
               if (ret)
                       return ret;
 
               jeb = c->nextblock;
+               if (c->mtd->flags == 

MTD_CAP_MLCNANDFLASH) {
+ if (jeb->free_size !=
c->sector_size -
+ c->cleanmarker_size -
c->wbuf_pagesize) {
+ printk(KERN_WARNING "Eep.
Block 0x%08x taken
from free_list had free_size of 0x%08x!!\n", jeb->offset, jeb->free_size);

(quoted diff) +3 -1
+                               goto restart;
+                       }
+               }
 
-               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);

(quoted diff) +2 -1
-                       goto restart;
+               else{
+                       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);

(quoted diff) +2 -0
+                               goto restart;
+                       }
               }
       }
       /* OK, jeb (==c->nextblock) is now pointing at a 

block which
definitely has
--- a/fs/jffs2/scan.c 2008-09-16 20:48:12.000000000
+0530
+++ b/fs/jffs2/scan.c 2008-09-19 17:07:48.000000000
+0530

(quoted diff) +0 -0
@@ -534,7 +534,10 @@ static int jffs2_scan_eraseblock 

(struct

               }
       }
fs/jffs2/scan.c +4 -1
-       buf_ofs = jeb->offset;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               buf_ofs = jeb->offset + c->wbuf_pagesize;
+       else
+               buf_ofs = jeb->offset;
 
       if (!buf_size) {
               /* This is the XIP case -- we're reading 

_directly_ from the
flash chip */ @@ -582,7 +585,10 @@ static int
jffs2_scan_eraseblock (struct

       }

       /* Now ofs is a complete physical flash offset as 

it always was...
*/

(quoted diff) +7 -2
-       ofs += jeb->offset;
+       if (c->mtd->flags == MTD_CAP_MLCNANDFLASH)
+               ofs += jeb->offset + c->wbuf_pagesize;
+       else
+               ofs += jeb->offset;
 
       noise = 10;
 
--- a/fs/jffs2/wbuf.c   2008-09-16 20:48:12.000000000 
+0530
+++ b/fs/jffs2/wbuf.c   2008-09-19 17:07:48.000000000 
+0530
@@ -873,6 +873,13 @@ int jffs2_flash_writev(struct 

jffs2_sb_i

                       vlen -= wbuf_retlen;
                       outvec_to += wbuf_retlen;
                       c->wbuf_ofs = outvec_to;

+ if (c->mtd->flags ==
MTD_CAP_MLCNANDFLASH) {
+ /* adjust write buffer
offset,
+ * else we get a non
contiguous write bug

(quoted diff) +2 -0
+                                */
+                               if (!(c->wbuf_ofs % 

c->sector_size))
+ c->wbuf_ofs =
0xffffffff;
+ }

                       donelen += wbuf_retlen;
                       v += wbuf_retlen;
               }

--- a/include/mtd/mtd-abi.h 2008-09-16
20:48:12.000000000 +0530
+++ b/include/mtd/mtd-abi.h 2008-09-23
22:09:18.000000000 +0530

(quoted diff) +0 -0
@@ -28,12 +28,14 @@ struct mtd_oob_buf {
 #define MTD_BIT_WRITEABLE      0x800   /* Single bits 

can be flipped */
#define MTD_NO_ERASE 0x1000 /* No erase
necessary */
#define MTD_POWERUP_LOCK 0x2000 /* Always locked
after reset */
+#define MTD_OOB_WRITEABLE 0x4000

// Some common devices / combinations of capabilities
#define MTD_CAP_ROM 0
#define MTD_CAP_RAM (MTD_WRITEABLE |
MTD_BIT_WRITEABLE |
MTD_NO_ERASE)
#define MTD_CAP_NORFLASH (MTD_WRITEABLE |
MTD_BIT_WRITEABLE)
#define MTD_CAP_NANDFLASH (MTD_WRITEABLE |
MTD_OOB_WRITEABLE)
+#define MTD_CAP_MLCNANDFLASH (MTD_WRITEABLE)

/* ECC byte placement */
#define MTD_NANDECC_OFF 0 // Switch
off ECC (Not
recommended)

Quoted 4 lines

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#7 lore raw

Hi,

Quoted 7 lines · Amit Kumar Sharma

We are also facing many difficulty in robustness and reliability test with Jffs2 not only this we have tested our MLC patches on kernel 2.6.22 their Jffs2 stability was little bit higher as compare to 2.6.27 , not only this LTP file tests and rw test fails with Jffs2 and same driver works fine with yaffs2 but yaffs2 also has issue with Symlink operation we are working for that.

Have you tries UBIFS?

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#8 lore raw

no we have started working for UBIFS , very soon we will start working for UBIFS , let u know results. ----- Original Message -----
From: "Artem Bityutskiy" <[email protected]>
To: "Amit Kumar Sharma" <[email protected]>
Cc: "Jason Liu" <[email protected]>; "apgmoorthy" <[email protected]>; "Kyungmin Park" <[email protected]>; <[email protected]>; <[email protected]>
Sent: Wednesday, October 01, 2008 11:22 AM
Subject: Re: [PATCH 1/2] [MTD] [JFFS2] MLC NAND support

Quoted 25 lines

Hi,

Quoted 9 lines · Amit Kumar Sharma

We are also facing many difficulty in robustness and reliability test with Jffs2 not only this we have tested our
MLC patches on kernel 2.6.22 their Jffs2 stability was little bit higher as compare to 2.6.27 , not only this LTP
file tests and rw test fails with Jffs2 and same driver works fine with yaffs2 but yaffs2 also has issue with Symlink operation we are working for that.

Have you tries UBIFS?

Signature · 7 lines
Best regards,
Artem Bityutskiy (???????? ?????)


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#9 lore raw
Quoted 2 lines · Amit Kumar Sharma

no we have started working for UBIFS , very soon we will start working for UBIFS , let u know results.

Note, JFFS2 is not really suitable for MLC because it has random wear-leveling algorithm, and it may erase one eraseblock thousands of times, while erasing the other eraseblock only hundreds of times.

In UBI you may set the WL threshold to control this. Also, JFFS2 does not really help with read-disturb problem, but this is fixable.

UBI refreshes data when it meets a bit-flip.

However, UBIFS is not really ready to handle this paired page problem. I mean, in MLC, if you interrupt power during write operation, this may result in corruptions in one of the previous NAND page. The only simple way to fix this is to make UBIFS assume that min. I/O unit size is not one NAND page, but several pages, so that both paired NAND pages were in one min. I/O unit.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#10 lore raw

Thanks Artem for pre information , your information I hope will be useful for us and we will consider your points during UBIFS with OneNAND-FlexOneNAND.
----- Original Message -----
From: "Artem Bityutskiy" <[email protected]>
To: "Amit Kumar Sharma" <[email protected]>
Cc: "Jason Liu" <[email protected]>; "apgmoorthy" <[email protected]>; "Kyungmin Park" <[email protected]>; <[email protected]>; <[email protected]>
Sent: Wednesday, October 01, 2008 3:22 PM
Subject: Re: [PATCH 1/2] [MTD] [JFFS2] MLC NAND support

Quoted 41 lines
Quoted 2 lines · Amit Kumar Sharma

no we have started working for UBIFS , very soon we will start working for UBIFS , let u know results.

Note, JFFS2 is not really suitable for MLC because it has random wear-leveling algorithm, and it may erase one eraseblock
thousands of times, while erasing the other eraseblock only hundreds of
times.

In UBI you may set the WL threshold to control this. Also, JFFS2
does not really help with read-disturb problem, but this is fixable.

UBI refreshes data when it meets a bit-flip.

However, UBIFS is not really ready to handle this paired page problem.
I mean, in MLC, if you interrupt power during write operation, this
may result in corruptions in one of the previous NAND page. The only
simple way to fix this is to make UBIFS assume that min. I/O unit size
is not one NAND page, but several pages, so that both paired NAND pages
were in one min. I/O unit.

Signature · 7 lines
Best regards,
Artem Bityutskiy (???????? ?????)


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/