Skip to contentSkip to conversation

use MTD_OOB_AUTO

PATCH In review Artem Bityutskiy 2 participants 5 messages Feb 2, 2007 – Feb 5, 2007

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

PATCH 1/1 use MTD_OOB_AUTO

From: Artem Bityutskiy <[email protected]>
Date: Wed, 31 Jan 2007 11:38:53 +0200
Subject: [PATCH] [JFFS2] use MTD_OOB_AUTO

Nowadays MTD supports an MTD_OOB_AUTO option which allows users to access free bytes in NAND's OOB as a contiguous buffer, although it may be highly discontinuous.

This patch teaches JFFS2 to use this nice feature instead of the old MTD_OOB_PLACE option. This for example caused problems with OneNAND. Now JFFS2 does not care how are the free bytes situated.

This may change position of the clean marker on some flashes, but this is not a problem. JFFS2 will just re-erase the empty eraseblocks and write the new (correct) clean marker (this was tested).

---
 fs/jffs2/jffs2_fs_sb.h |   12 +--
 fs/jffs2/scan.c        |   10 ++-
 fs/jffs2/wbuf.c        |  206 +++++++++++++++++-------------------------------
 3 files changed, 84 insertions(+), 144 deletions(-)
fs/jffs2/jffs2_fs_sb.h +3 -9
Index: dedekind-mtd-2.6.git/fs/jffs2/jffs2_fs_sb.h
===================================================================
@@ -98,20 +98,14 @@ struct jffs2_sb_info {
 	uint32_t wbuf_pagesize; /* 0 for NOR and other flashes with no wbuf */
 
 #ifdef CONFIG_JFFS2_FS_WRITEBUFFER
-	/* Write-behind buffer for NAND flash */
-	unsigned char *wbuf;
-	unsigned char *oobbuf;
+	unsigned char *wbuf; /* Write-behind buffer for NAND flash */
 	uint32_t wbuf_ofs;
 	uint32_t wbuf_len;
 	struct jffs2_inodirty *wbuf_inodes;
-
 	struct rw_semaphore wbuf_sem;	/* Protects the write buffer */
 
-	/* Information about out-of-band area usage... */
-	struct nand_ecclayout *ecclayout;
-	uint32_t badblock_pos;
-	uint32_t fsdata_pos;
-	uint32_t fsdata_len;
+	unsigned char *oobbuf;
+	int oobavail; /* How many bytes are available for JFFS2 in OOB */
 #endif
 
 	struct jffs2_summary *summary;		/* Summary information */
fs/jffs2/scan.c +7 -3
Index: dedekind-mtd-2.6.git/fs/jffs2/scan.c
===================================================================
@@ -450,16 +450,20 @@ static int jffs2_scan_eraseblock (struct
 
 #ifdef CONFIG_JFFS2_FS_WRITEBUFFER
 	if (jffs2_cleanmarker_oob(c)) {
-		int ret = jffs2_check_nand_cleanmarker(c, jeb);
+		int ret;
+
+		if (c->mtd->block_isbad(c->mtd, jeb->offset))
+			return BLK_STATE_BADBLOCK;
+
+		ret = jffs2_check_nand_cleanmarker(c, jeb);
 		D2(printk(KERN_NOTICE "jffs_check_nand_cleanmarker returned %d\n",ret));
+
 		/* Even if it's not found, we still scan to see
 		   if the block is empty. We use this information
 		   to decide whether to erase it or not. */
 		switch (ret) {
 		case 0:		cleanmarkerfound = 1; break;
 		case 1: 	break;
-		case 2: 	return BLK_STATE_BADBLOCK;
-		case 3:		return BLK_STATE_ALLDIRTY; /* Block has failed to erase min. once */
 		default: 	return ret;
 		}
 	}
fs/jffs2/wbuf.c +67 -136

284 lines not on this page · raw message

#1 lore raw

Hi,

To David Woodhouse

Before commit this patch, please first merge the OneNAND tree. Since current mtd tree don't have MTD_OOB_AUTO support in OneNAND. I think It's right merge sequence.

Quoted 1 line

May you please try it on NAND and confirm it is OK?

Sorry, I don't have NAND chip.

fs/jffs2/wbuf.c exit: · line 970

Quoted 11 lines
(quoted diff) +2 -0
+
+/* For historical reasons we use only 12 bytes for OOB clean 

marker */

fs/jffs2/wbuf.c +7 -0
+#define OOB_CM_SIZE 12
+
+const static struct jffs2_unknown_node oob_cleanmarker = {
+	.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
+	.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
+	.totlen = cpu_to_je32(8)
+};

const static => static const

Thank you,
Kyungmin Park

#2 lore raw
Quoted 1 line · Kyungmin Park

const static => static const

You keep me busy :-)

const is "type qualifier", static is "storage class specifier" (C99, 6.7). The order may be arbitrary.

:-)

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

const static => static const

You keep me busy :-)

const is "type qualifier", static is "storage class specifier" (C99, 6.7). The order may be arbitrary.

Yes, I know it. In fact. it's minor issue.
I just saw the some works convert from "const static" to "static const" in LKML.

Ah, there are some "const static"s :)

$ grep "const static" -R *
arch/powerpc/kernel/rtas.c:     const static int *row_width;
arch/sh/kernel/cpu/sh2a/clock-sh7206.c:const static int pll1rate[]={1,2,3,4,
6,8};
arch/sh/kernel/cpu/sh2a/clock-sh7206.c:const static int pfc_divisors[]={1,2,
3,4,6,8,12};
arch/sh/kernel/cpu/sh2/clock-sh7619.c:const static int pll1rate[]={1,2};
arch/sh/kernel/cpu/sh2/clock-sh7619.c:const static int
pfc_divisors[]={1,2,0,4};
drivers/input/serio/libps2.c:   const static char keyboard_ids[] = {
drivers/ieee1394/ohci1394.c:const static size_t hdr_sizes[] = {
drivers/media/video/pvrusb2/pvrusb2-video-v4l.c:const static struct
pvr2_i2c_handler_functions hfuncs = {
drivers/media/video/pvrusb2/pvrusb2-wm8775.c:const static struct
pvr2_i2c_handler_functions hfuncs = {
drivers/media/video/pvrusb2/pvrusb2-tuner.c:const static struct
pvr2_i2c_handler_functions tuner_funcs = {
drivers/media/video/pvrusb2/pvrusb2-audio.c:const static struct
pvr2_i2c_handler_functions msp3400_funcs = {
drivers/media/video/pvrusb2/pvrusb2-std.c:const static struct std_name
std_groups[] = {
drivers/media/video/pvrusb2/pvrusb2-std.c:const static struct std_name
std_items[] = {
drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c:const static struct
pvr2_i2c_handler_functions hfuncs = {
fs/cifs/cifssmb.c:const static struct cifs_sid sid_everyone =
fs/cifs/cifssmb.c:const static struct cifs_sid sid_user =

Thank you,
Kyungmin Park

#4 lore raw
Quoted 5 lines · Kyungmin Park
Quoted 5 lines
Quoted 2 lines

const static => static const

You keep me busy :-)

Quoted 7 lines
Quoted 3 lines

const is "type qualifier", static is "storage class specifier" (C99, 6.7). The order may be arbitrary.

Yes, I know it. In fact. it's minor issue.
I just saw the some works convert from "const static" to "static const" in LKML.

Kyungmin,

if you kindly pointed me the LKML posts, I would be grateful!

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