mtd/fs/jffs2 nodelist.h,1.103,1.104 write.c,1.74,1.75

David Woodhouse dwmw2 at infradead.org
Wed Oct 8 07:45:14 EDT 2003


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

Modified Files:
	nodelist.h write.c 
Log Message:
Retry at a higher level in jffs2_write_inode_range(), so we make more 
optimal use of space.


Index: nodelist.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodelist.h,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -r1.103 -r1.104
--- nodelist.h	6 Oct 2003 12:50:45 -0000	1.103
+++ nodelist.h	8 Oct 2003 11:45:11 -0000	1.104
@@ -271,6 +271,7 @@
 #define ALLOC_NORMAL	0	/* Normal allocation */
 #define ALLOC_DELETION	1	/* Deletion node. Best to allow it */
 #define ALLOC_GC	2	/* Space requested for GC. Give it or die */
+#define ALLOC_NORETRY	3	/* For jffs2_write_dnode: On failure, return -EAGAIN instead of retrying */
 
 /* How much dirty space before it goes on the very_dirty_list */
 #define VERYDIRTY(c, size) ((size) >= ((c)->sector_size / 2))

Index: write.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/write.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- write.c	4 Oct 2003 08:33:07 -0000	1.74
+++ write.c	8 Oct 2003 11:45:11 -0000	1.75
@@ -160,7 +160,7 @@
 			printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset);
 			jffs2_free_raw_node_ref(raw);
 		}
-		if (!retried && (raw = jffs2_alloc_raw_node_ref())) {
+		if (!retried && alloc_mode != ALLOC_NORETRY && (raw = jffs2_alloc_raw_node_ref())) {
 			/* Try to reallocate space and retry */
 			uint32_t dummy;
 			struct jffs2_eraseblock *jeb = &c->blocks[flash_ofs / c->sector_size];
@@ -362,7 +362,9 @@
 		unsigned char comprtype = JFFS2_COMPR_NONE;
 		uint32_t phys_ofs, alloclen;
 		uint32_t datalen, cdatalen;
+		int retried = 0;
 
+	retry:
 		D2(printk(KERN_DEBUG "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", writelen, offset));
 
 		ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, &phys_ofs, &alloclen, ALLOC_NORMAL);
@@ -405,7 +407,7 @@
 		ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
 		ri->data_crc = cpu_to_je32(crc32(0, comprbuf, cdatalen));
 
-		fn = jffs2_write_dnode(c, f, ri, comprbuf, cdatalen, phys_ofs, ALLOC_NORMAL);
+		fn = jffs2_write_dnode(c, f, ri, comprbuf, cdatalen, phys_ofs, ALLOC_NORETRY);
 
 		if (comprtype != JFFS2_COMPR_NONE)
 			kfree(comprbuf);
@@ -414,6 +416,12 @@
 			ret = PTR_ERR(fn);
 			up(&f->sem);
 			jffs2_complete_reservation(c);
+			if (!retried) {
+				/* Write error to be retried */
+				retried = 1;
+				D1(printk(KERN_DEBUG "Retrying node write in jffs2_write_inode_range()\n"));
+				goto retry;
+			}
 			break;
 		}
 		ret = jffs2_add_full_dnode_to_inode(c, f, fn);




More information about the linux-mtd-cvs mailing list