Skip to content

Commit 2f82ce1

Browse files
Andrew VictorThomas Gleixner
authored andcommitted
[JFFS2] Use a single config option for write buffer support
This patch replaces the current CONFIG_JFFS2_FS_NAND, CONFIG_JFFS2_FS_NOR_ECC and CONFIG_JFFS2_FS_DATAFLASH with a single configuration option - CONFIG_JFFS2_FS_WRITEBUFFER. The only functional change of this patch is that the slower div/mod calculations for SECTOR_ADDR(), PAGE_DIV() and PAGE_MOD() are now always used when CONFIG_JFFS2_FS_WRITEBUFFER is enabled. Signed-off-by: Andrew Victor <andrew@sanpeople.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 8f15fd5 commit 2f82ce1

9 files changed

Lines changed: 35 additions & 70 deletions

File tree

‎fs/Kconfig‎

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,33 +1063,18 @@ config JFFS2_FS_DEBUG
10631063
If reporting bugs, please try to have available a full dump of the
10641064
messages at debug level 1 while the misbehaviour was occurring.
10651065

1066-
config JFFS2_FS_NAND
1067-
bool "JFFS2 support for NAND flash"
1066+
config JFFS2_FS_WRITEBUFFER
1067+
bool "JFFS2 write-buffering support"
10681068
depends on JFFS2_FS
1069-
default n
1069+
default y
10701070
help
1071-
This enables the support for NAND flash in JFFS2. NAND is a newer
1072-
type of flash chip design than the traditional NOR flash, with
1073-
higher density but a handful of characteristics which make it more
1074-
interesting for the file system to use.
1071+
This enables the write-buffering support in JFFS2.
10751072

1076-
Say 'N' unless you have NAND flash.
1077-
1078-
config JFFS2_FS_NOR_ECC
1079-
bool "JFFS2 support for ECC'd NOR flash (EXPERIMENTAL)"
1080-
depends on JFFS2_FS && EXPERIMENTAL
1081-
default n
1082-
help
1083-
This enables the experimental support for NOR flash with transparent
1084-
ECC for JFFS2. This type of flash chip is not common, however it is
1085-
available from ST Microelectronics.
1086-
1087-
config JFFS2_FS_DATAFLASH
1088-
bool "JFFS2 support for DataFlash (EXPERIMENTAL)"
1089-
depends on JFFS2_FS && EXPERIMENTAL
1090-
default n
1091-
help
1092-
This enables the experimental support for JFFS2 on DataFlash devices.
1073+
This functionality is required to support JFFS2 on the following
1074+
types of flash devices:
1075+
- NAND flash
1076+
- NOR flash with transparent ECC
1077+
- DataFlash
10931078

10941079
config JFFS2_COMPRESSION_OPTIONS
10951080
bool "Advanced compression options for JFFS2"

‎fs/jffs2/Makefile‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Makefile for the Linux Journalling Flash File System v2 (JFFS2)
33
#
4-
# $Id: Makefile.common,v 1.8 2005/02/09 09:17:40 pavlov Exp $
4+
# $Id: Makefile.common,v 1.9 2005/02/09 09:23:53 pavlov Exp $
55
#
66

77
obj-$(CONFIG_JFFS2_FS) += jffs2.o
@@ -11,9 +11,7 @@ jffs2-y += read.o nodemgmt.o readinode.o write.o scan.o gc.o
1111
jffs2-y += symlink.o build.o erase.o background.o fs.o writev.o
1212
jffs2-y += super.o
1313

14-
jffs2-$(CONFIG_JFFS2_FS_NAND) += wbuf.o
15-
jffs2-$(CONFIG_JFFS2_FS_NOR_ECC) += wbuf.o
16-
jffs2-$(CONFIG_JFFS2_FS_DATAFLASH) += wbuf.o
14+
jffs2-$(CONFIG_JFFS2_FS_WRITEBUFFER) += wbuf.o
1715
jffs2-$(CONFIG_JFFS2_RUBIN) += compr_rubin.o
1816
jffs2-$(CONFIG_JFFS2_RTIME) += compr_rtime.o
1917
jffs2-$(CONFIG_JFFS2_ZLIB) += compr_zlib.o

‎fs/jffs2/fs.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* For licensing information, see the file 'LICENCE' in this directory.
99
*
10-
* $Id: fs.c,v 1.52 2005/02/09 09:17:40 pavlov Exp $
10+
* $Id: fs.c,v 1.53 2005/02/09 09:23:53 pavlov Exp $
1111
*
1212
*/
1313

@@ -450,13 +450,11 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
450450

451451
c = JFFS2_SB_INFO(sb);
452452

453-
#ifndef CONFIG_JFFS2_FS_NAND
453+
#ifndef CONFIG_JFFS2_FS_WRITEBUFFER
454454
if (c->mtd->type == MTD_NANDFLASH) {
455455
printk(KERN_ERR "jffs2: Cannot operate on NAND flash unless jffs2 NAND support is compiled in.\n");
456456
return -EINVAL;
457457
}
458-
#endif
459-
#ifndef CONFIG_JFFS2_FS_DATAFLASH
460458
if (c->mtd->type == MTD_DATAFLASH) {
461459
printk(KERN_ERR "jffs2: Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in.\n");
462460
return -EINVAL;

‎fs/jffs2/nodelist.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* For licensing information, see the file 'LICENCE' in this directory.
99
*
10-
* $Id: nodelist.h,v 1.126 2004/11/19 15:06:29 dedekind Exp $
10+
* $Id: nodelist.h,v 1.127 2005/02/09 09:23:53 pavlov Exp $
1111
*
1212
*/
1313

@@ -462,7 +462,7 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c);
462462
/* erase.c */
463463
void jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count);
464464

465-
#ifdef CONFIG_JFFS2_FS_NAND
465+
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
466466
/* wbuf.c */
467467
int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino);
468468
int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c);

‎fs/jffs2/os-linux.h‎

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* For licensing information, see the file 'LICENCE' in this directory.
99
*
10-
* $Id: os-linux.h,v 1.53 2005/02/09 09:17:41 pavlov Exp $
10+
* $Id: os-linux.h,v 1.54 2005/02/09 09:23:53 pavlov Exp $
1111
*
1212
*/
1313

@@ -97,16 +97,12 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
9797
#endif
9898
}
9999

100-
#ifdef CONFIG_JFFS2_FS_DATAFLASH
101-
#define SECTOR_ADDR(x) ( ((unsigned long)(x) / (unsigned long)(c->sector_size)) * c->sector_size )
102-
#else
103-
#define SECTOR_ADDR(x) ( ((unsigned long)(x) & ~(c->sector_size-1)) )
104-
#endif
105100

106101
#define jffs2_is_readonly(c) (OFNI_BS_2SFFJ(c)->s_flags & MS_RDONLY)
107102
#define jffs2_is_writebuffered(c) (c->wbuf != NULL)
108103

109-
#if (!defined CONFIG_JFFS2_FS_NAND && !defined CONFIG_JFFS2_FS_NOR_ECC && !defined CONFIG_JFFS2_FS_DATAFLASH)
104+
#ifndef CONFIG_JFFS2_FS_WRITEBUFFER
105+
#define SECTOR_ADDR(x) ( ((unsigned long)(x) & ~(c->sector_size-1)) )
110106
#define jffs2_can_mark_obsolete(c) (1)
111107
#define jffs2_cleanmarker_oob(c) (0)
112108
#define jffs2_write_nand_cleanmarker(c,jeb) (-EIO)
@@ -129,6 +125,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
129125

130126
#else /* NAND and/or ECC'd NOR support present */
131127

128+
#define SECTOR_ADDR(x) ( ((unsigned long)(x) / (unsigned long)(c->sector_size)) * c->sector_size )
132129
#define jffs2_can_mark_obsolete(c) ((c->mtd->type == MTD_NORFLASH && !(c->mtd->flags & MTD_ECC)) || c->mtd->type == MTD_RAM)
133130
#define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH)
134131

@@ -150,25 +147,16 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino);
150147
int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c);
151148
int jffs2_nand_flash_setup(struct jffs2_sb_info *c);
152149
void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c);
153-
#ifdef CONFIG_JFFS2_FS_NOR_ECC
150+
154151
#define jffs2_nor_ecc(c) (c->mtd->type == MTD_NORFLASH && (c->mtd->flags & MTD_ECC))
155152
int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c);
156153
void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c);
157-
#else
158-
#define jffs2_nor_ecc(c) (0)
159-
#define jffs2_nor_ecc_flash_setup(c) (0)
160-
#define jffs2_nor_ecc_flash_cleanup(c) do {} while (0)
161-
#endif /* NOR ECC */
162-
#ifdef CONFIG_JFFS2_FS_DATAFLASH
154+
163155
#define jffs2_dataflash(c) (c->mtd->type == MTD_DATAFLASH)
164156
int jffs2_dataflash_setup(struct jffs2_sb_info *c);
165157
void jffs2_dataflash_cleanup(struct jffs2_sb_info *c);
166-
#else
167-
#define jffs2_dataflash(c) (0)
168-
#define jffs2_dataflash_setup(c) (0)
169-
#define jffs2_dataflash_cleanup(c) do {} while (0)
170-
#endif /* DATAFLASH */
171-
#endif /* NAND */
158+
159+
#endif /* WRITEBUFFER */
172160

173161
/* erase.c */
174162
static inline void jffs2_erase_pending_trigger(struct jffs2_sb_info *c)

‎fs/jffs2/scan.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* For licensing information, see the file 'LICENCE' in this directory.
99
*
10-
* $Id: scan.c,v 1.117 2005/02/09 09:17:41 pavlov Exp $
10+
* $Id: scan.c,v 1.118 2005/02/09 09:23:53 pavlov Exp $
1111
*
1212
*/
1313
#include <linux/kernel.h>
@@ -68,7 +68,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
6868
static inline int min_free(struct jffs2_sb_info *c)
6969
{
7070
uint32_t min = 2 * sizeof(struct jffs2_raw_inode);
71-
#if defined CONFIG_JFFS2_FS_NAND || defined CONFIG_JFFS2_FS_NOR_ECC || defined CONFIG_JFFS2_FS_DATAFLASH
71+
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
7272
if (!jffs2_can_mark_obsolete(c) && min < c->wbuf_pagesize)
7373
return c->wbuf_pagesize;
7474
#endif
@@ -228,7 +228,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
228228
c->dirty_size -= c->nextblock->dirty_size;
229229
c->nextblock->dirty_size = 0;
230230
}
231-
#if defined CONFIG_JFFS2_FS_NAND || defined CONFIG_JFFS2_FS_NOR_ECC || defined CONFIG_JFFS2_FS_DATAFLASH
231+
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
232232
if (!jffs2_can_mark_obsolete(c) && c->nextblock && (c->nextblock->free_size & (c->wbuf_pagesize-1))) {
233233
/* If we're going to start writing into a block which already
234234
contains data, and the end of the data isn't page-aligned,
@@ -294,7 +294,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
294294
uint32_t hdr_crc, buf_ofs, buf_len;
295295
int err;
296296
int noise = 0;
297-
#ifdef CONFIG_JFFS2_FS_NAND
297+
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
298298
int cleanmarkerfound = 0;
299299
#endif
300300

@@ -303,7 +303,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
303303

304304
D1(printk(KERN_DEBUG "jffs2_scan_eraseblock(): Scanning block at 0x%x\n", ofs));
305305

306-
#ifdef CONFIG_JFFS2_FS_NAND
306+
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
307307
if (jffs2_cleanmarker_oob(c)) {
308308
int ret = jffs2_check_nand_cleanmarker(c, jeb);
309309
D2(printk(KERN_NOTICE "jffs_check_nand_cleanmarker returned %d\n",ret));
@@ -338,7 +338,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
338338
ofs += 4;
339339

340340
if (ofs == EMPTY_SCAN_SIZE(c->sector_size)) {
341-
#ifdef CONFIG_JFFS2_FS_NAND
341+
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
342342
if (jffs2_cleanmarker_oob(c)) {
343343
/* scan oob, take care of cleanmarker */
344344
int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound);

‎fs/jffs2/super.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* For licensing information, see the file 'LICENCE' in this directory.
99
*
10-
* $Id: super.c,v 1.104 2004/11/23 15:37:31 gleixner Exp $
10+
* $Id: super.c,v 1.105 2005/02/09 09:23:54 pavlov Exp $
1111
*
1212
*/
1313

@@ -309,7 +309,7 @@ static int __init init_jffs2_fs(void)
309309
int ret;
310310

311311
printk(KERN_INFO "JFFS2 version 2.2."
312-
#ifdef CONFIG_JFFS2_FS_NAND
312+
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
313313
" (NAND)"
314314
#endif
315315
" (C) 2001-2003 Red Hat, Inc.\n");

‎fs/jffs2/wbuf.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* For licensing information, see the file 'LICENCE' in this directory.
1111
*
12-
* $Id: wbuf.c,v 1.88 2005/02/09 09:17:41 pavlov Exp $
12+
* $Id: wbuf.c,v 1.89 2005/02/09 09:23:54 pavlov Exp $
1313
*
1414
*/
1515

@@ -604,7 +604,7 @@ int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c)
604604
return ret;
605605
}
606606

607-
#ifdef CONFIG_JFFS2_FS_DATAFLASH
607+
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
608608
#define PAGE_DIV(x) ( ((unsigned long)(x) / (unsigned long)(c->wbuf_pagesize)) * (unsigned long)(c->wbuf_pagesize) )
609609
#define PAGE_MOD(x) ( (unsigned long)(x) % (unsigned long)(c->wbuf_pagesize) )
610610
#else
@@ -1198,7 +1198,6 @@ void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c)
11981198
kfree(c->wbuf);
11991199
}
12001200

1201-
#ifdef CONFIG_JFFS2_FS_DATAFLASH
12021201
int jffs2_dataflash_setup(struct jffs2_sb_info *c) {
12031202
c->cleanmarker_size = 0; /* No cleanmarkers needed */
12041203

@@ -1219,9 +1218,7 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) {
12191218
void jffs2_dataflash_cleanup(struct jffs2_sb_info *c) {
12201219
kfree(c->wbuf);
12211220
}
1222-
#endif
12231221

1224-
#ifdef CONFIG_JFFS2_FS_NOR_ECC
12251222
int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c) {
12261223
/* Cleanmarker is actually larger on the flashes */
12271224
c->cleanmarker_size = 16;
@@ -1241,4 +1238,3 @@ int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c) {
12411238
void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) {
12421239
kfree(c->wbuf);
12431240
}
1244-
#endif

‎include/linux/jffs2_fs_sb.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: jffs2_fs_sb.h,v 1.49 2005/02/09 09:17:41 pavlov Exp $ */
1+
/* $Id: jffs2_fs_sb.h,v 1.50 2005/02/09 09:23:55 pavlov Exp $ */
22

33
#ifndef _JFFS2_FS_SB
44
#define _JFFS2_FS_SB
@@ -94,7 +94,7 @@ struct jffs2_sb_info {
9494
to an obsoleted node. I don't like this. Alternatives welcomed. */
9595
struct semaphore erase_free_sem;
9696

97-
#if defined CONFIG_JFFS2_FS_NAND || defined CONFIG_JFFS2_FS_NOR_ECC || defined CONFIG_JFFS2_FS_DATAFLASH
97+
#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
9898
/* Write-behind buffer for NAND flash */
9999
unsigned char *wbuf;
100100
uint32_t wbuf_ofs;

0 commit comments

Comments
 (0)