mtd/fs/jffs2 background.c,1.38,1.39 file.c,1.85,1.86 fs.c,1.24,1.25 nodemgmt.c,1.94,1.95 os-linux.h,1.26,1.27 scan.c,1.100,1.101 super-v24.c,1.65,1.66 super.c,1.79,1.80 wbuf.c,1.30,1.31

David Woodhouse dwmw2 at infradead.org
Mon Jun 30 06:59:00 EDT 2003


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

Modified Files:
	background.c file.c fs.c nodemgmt.c os-linux.h scan.c 
	super-v24.c super.c wbuf.c 
Log Message:
Slight NAND cleanup -- move setup/cleanup into wbuf.c, ifdef the 
NAND-only members of struct jffs2_sb_info; this makes 2.4-compat in the
no-nand case somewhat easier.


Index: background.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/background.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- background.c	26 May 2003 09:50:38 -0000	1.38
+++ background.c	30 Jun 2003 10:58:57 -0000	1.39
@@ -61,13 +61,14 @@
 
 void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c)
 {
-	if (c->mtd->type == MTD_NANDFLASH) {
+#ifdef CONFIG_JFFS2_FS_NAND
+	if (jffs2_cleanmarker_oob(c)) {
 		/* stop a eventually scheduled wbuf flush timer */
 		del_timer_sync(&c->wbuf_timer);
 		/* make sure, that a scheduled wbuf flush task is completed */
 		flush_scheduled_work();
 	}
-
+#endif
 	spin_lock(&c->erase_completion_lock);
 	if (c->gc_task) {
 		D1(printk(KERN_DEBUG "jffs2: Killing GC task %d\n", c->gc_task->pid));

Index: file.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/file.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- file.c	26 May 2003 09:50:38 -0000	1.85
+++ file.c	30 Jun 2003 10:58:57 -0000	1.86
@@ -30,7 +30,8 @@
 	struct inode *inode = dentry->d_inode;
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
 	struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
-	if (!c->wbuf || !c->wbuf_len)
+
+	if (!jffs2_wbuf_dirty(c))
 		return 0;
 
 	/* flush write buffer and update c->nextblock */

Index: fs.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/fs.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- fs.c	29 Apr 2003 09:52:58 -0000	1.24
+++ fs.c	30 Jun 2003 10:58:57 -0000	1.25
@@ -286,25 +286,10 @@
 	/* Joern -- 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;
-		c->wbuf_ofs = 0xFFFFFFFF;
-		c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
-		if (!c->wbuf)
-			return -ENOMEM;
-
-		/* Initialise process for timed wbuf flush */
-		INIT_WORK(&c->wbuf_task,(void*) jffs2_wbuf_process, (void *)c);
-
-		/* Initialise timer for timed wbuf flush */
-		init_timer(&c->wbuf_timer);
-		c->wbuf_timer.function = jffs2_wbuf_timeout;
-		c->wbuf_timer.data = (unsigned long) c;
+		/* NAND (or other bizarre) flash... do setup accordingly */
+		ret = jffs2_nand_flash_setup(c);
+		if (ret)
+			return ret;
 	}
 
 	c->inocache_list = kmalloc(INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *), GFP_KERNEL);
@@ -350,7 +335,7 @@
  out_inohash:
 	kfree(c->inocache_list);
  out_wbuf:
-	if (c->wbuf)
-		kfree(c->wbuf);
+	jffs2_nand_flash_cleanup(c);
+
 	return ret;
 }

Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodemgmt.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- nodemgmt.c	19 Feb 2003 17:50:26 -0000	1.94
+++ nodemgmt.c	30 Jun 2003 10:58:57 -0000	1.95
@@ -158,7 +158,7 @@
 	if (jeb && minsize > jeb->free_size) {
 		/* Skip the end of this block and file it as having some dirty space */
 		/* If there's a pending write to it, flush now */
-		if (c->wbuf_len) {
+		if (jffs2_wbuf_dirty(c)) {
 			spin_unlock(&c->erase_completion_lock);
 			D1(printk(KERN_DEBUG "jffs2_do_reserve_space: Flushing write buffer\n"));			    
 			jffs2_flush_wbuf(c, 1);
@@ -344,7 +344,7 @@
 		/* If it lives on the dirty_list, jffs2_reserve_space will put it there */
 		D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
 			  jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size));
-		if (c->wbuf_len) {
+		if (jffs2_wbuf_dirty(c)) {
 			/* Flush the last write in the block if it's outstanding */
 			spin_unlock(&c->erase_completion_lock);
 			jffs2_flush_wbuf(c, 1);
@@ -455,7 +455,7 @@
 			D1(printk(KERN_DEBUG "Eraseblock at 0x%08x completely dirtied. Removing from (dirty?) list...\n", jeb->offset));
 			list_del(&jeb->list);
 		}
-		if (c->wbuf_len) {
+		if (jffs2_wbuf_dirty(c)) {
 			D1(printk(KERN_DEBUG "...and adding to erasable_pending_wbuf_list\n"));
 			list_add_tail(&jeb->list, &c->erasable_pending_wbuf_list);
 #if 0 /* This check was added to allow us to find places where we added nodes to the lists

Index: os-linux.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/os-linux.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- os-linux.h	16 May 2003 18:45:25 -0000	1.26
+++ os-linux.h	30 Jun 2003 10:58:57 -0000	1.27
@@ -111,6 +111,9 @@
 #define jffs2_flush_wbuf(c, flag) do { ; } while(0)
 #define jffs2_nand_read_failcnt(c,jeb) do { ; } while(0)
 #define jffs2_write_nand_badblock(c,jeb) do { ; } while(0)
+#define jffs2_nand_flash_setup(c) (0)
+#define jffs2_nand_flash_cleanup(c) do {} while(0)
+#define jffs2_wbuf_dirty(c) (0)
 #define jffs2_flash_writev jffs2_flash_direct_writev
 #define jffs2_wbuf_timeout NULL
 #define jffs2_wbuf_process NULL
@@ -122,7 +125,7 @@
 
 #define jffs2_flash_write_oob(c, ofs, len, retlen, buf) ((c)->mtd->write_oob((c)->mtd, ofs, len, retlen, buf))
 #define jffs2_flash_read_oob(c, ofs, len, retlen, buf) ((c)->mtd->read_oob((c)->mtd, ofs, len, retlen, buf))
-
+#define jffs2_wbuf_dirty(c) (!!(c)->wbuf_len)
 struct statfs;
 
 /* wbuf.c */
@@ -135,6 +138,8 @@
 int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
 void jffs2_wbuf_timeout(unsigned long data);
 void jffs2_wbuf_process(void *data);
+int jffs2_nand_flash_setup(struct jffs2_sb_info *c);
+void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c);
 #endif /* NAND */
 
 /* background.c */

Index: scan.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/scan.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- scan.c	5 Jun 2003 14:42:24 -0000	1.100
+++ scan.c	30 Jun 2003 10:58:57 -0000	1.101
@@ -65,6 +65,16 @@
 #define BLK_STATE_ALLDIRTY	4
 #define BLK_STATE_BADBLOCK	5
 
+static inline int min_free(struct jffs2_sb_info *c)
+{
+	uint32_t min = 2 * sizeof(struct jffs2_raw_inode);
+#ifdef CONFIG_JFFS2_FS_NAND
+	if (!jffs2_can_mark_obsolete(c) && min < c->wbuf_pagesize)
+		return c->wbuf_pagesize;
+#endif
+	return min;
+
+}
 int jffs2_scan_medium(struct jffs2_sb_info *c)
 {
 	int i, ret;
@@ -151,8 +161,7 @@
                            Later when we do snapshots, this must be the most recent block,
                            not the one with most free space.
                         */
-                        if (jeb->free_size > 2*sizeof(struct jffs2_raw_inode) && 
-			    (jffs2_can_mark_obsolete(c) || jeb->free_size > c->wbuf_pagesize) &&
+                        if (jeb->free_size > min_free(c) && 
 			    (!c->nextblock || c->nextblock->free_size < jeb->free_size)) {
                                 /* Better candidate for the next writes to go to */
                                 if (c->nextblock) {
@@ -210,7 +219,7 @@
 		c->dirty_size -= c->nextblock->dirty_size;
 		c->nextblock->dirty_size = 0;
 	}
-
+#ifdef CONFIG_JFFS2_FS_NAND
 	if (!jffs2_can_mark_obsolete(c) && c->nextblock && (c->nextblock->free_size & (c->wbuf_pagesize-1))) {
 		/* If we're going to start writing into a block which already 
 		   contains data, and the end of the data isn't page-aligned,
@@ -226,6 +235,7 @@
 		c->nextblock->free_size -= skip;
 		c->free_size -= skip;
 	}
+#endif
 	if (c->nr_erasing_blocks) {
 		if ( !c->used_size && ((empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) {
 			printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n");

Index: super-v24.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/super-v24.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- super-v24.c	11 Mar 2003 19:18:36 -0000	1.65
+++ super-v24.c	30 Jun 2003 10:58:58 -0000	1.66
@@ -89,8 +89,7 @@
 	jffs2_free_ino_caches(c);
 	jffs2_free_raw_node_refs(c);
 	kfree(c->blocks);
-	if (c->wbuf)
-		kfree(c->wbuf);
+	jffs2_nand_flash_cleanup(c);
 	kfree(c->inocache_list);
 	if (c->mtd->sync)
 		c->mtd->sync(c->mtd);

Index: super.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/super.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- super.c	27 May 2003 22:35:42 -0000	1.79
+++ super.c	30 Jun 2003 10:58:58 -0000	1.80
@@ -265,8 +265,7 @@
 	jffs2_free_ino_caches(c);
 	jffs2_free_raw_node_refs(c);
 	kfree(c->blocks);
-	if (c->wbuf)
-		kfree(c->wbuf);
+	jffs2_nand_flash_cleanup(c);
 	kfree(c->inocache_list);
 	if (c->mtd->sync)
 		c->mtd->sync(c->mtd);

Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- wbuf.c	19 Feb 2003 17:48:49 -0000	1.30
+++ wbuf.c	30 Jun 2003 10:58:58 -0000	1.31
@@ -797,3 +797,31 @@
 	}
 	return 0;
 }
+
+int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
+{
+	/* Cleanmarker is out-of-band, so inline size zero */
+	c->cleanmarker_size = 0;
+
+	/* Initialise write buffer */
+	c->wbuf_pagesize = c->mtd->oobblock;
+	c->wbuf_ofs = 0xFFFFFFFF;
+	c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
+	if (!c->wbuf)
+		return -ENOMEM;
+
+	/* Initialise process for timed wbuf flush */
+	INIT_WORK(&c->wbuf_task,(void*) jffs2_wbuf_process, (void *)c);
+
+	/* Initialise timer for timed wbuf flush */
+	init_timer(&c->wbuf_timer);
+	c->wbuf_timer.function = jffs2_wbuf_timeout;
+	c->wbuf_timer.data = (unsigned long) c;
+
+	return 0;
+}
+
+void jffs2_nand_flash_cleanup(struct jffs2_sb_info *c)
+{
+	kfree(c->wbuf);
+}




More information about the linux-mtd-cvs mailing list