mtd/fs/jffs2 write.c, 1.88, 1.89 wbuf.c, 1.83, 1.84 nodemgmt.c, 1.116, 1.117

hammache at infradead.org hammache at infradead.org
Tue Jan 25 15:11:14 EST 2005


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

Modified Files:
	write.c wbuf.c nodemgmt.c 
Log Message:
Code beautification and block filing correction for optimization.


Index: write.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/write.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- write.c	24 Jan 2005 21:13:39 -0000	1.88
+++ write.c	25 Jan 2005 20:11:11 -0000	1.89
@@ -138,17 +138,12 @@
 
 	if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version))
 	{
-		if (! retried)
-		{
-			BUG();
-		}
-		else
-		{
-			D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d,  highest version %d -> updating dnode\n", 
-					     je32_to_cpu(ri->version), f->highest_version));
-			ri->version = cpu_to_je32(++f->highest_version);
-			ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
-		}
+		BUG_ON(!retried);
+		D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, "
+				"highest version %d -> updating dnode\n", 
+				je32_to_cpu(ri->version), f->highest_version));
+		ri->version = cpu_to_je32(++f->highest_version);
+		ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
 	}
 
 	ret = jffs2_flash_writev(c, vecs, cnt, flash_ofs, &retlen,
@@ -297,18 +292,13 @@
 
 	if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version))
 	{
-		if (! retried)
-		{
-			BUG();
-		}
-		else
-		{
-			D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d,  highest version %d -> updating dirent\n", 
-					     je32_to_cpu(rd->version), f->highest_version));
-			rd->version = cpu_to_je32(++f->highest_version);
-			fd->version = je32_to_cpu(rd->version);
-			rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
-		}
+		BUG_ON(!retried);
+		D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, "
+				     "highest version %d -> updating dirent\n",
+				     je32_to_cpu(rd->version), f->highest_version));
+		rd->version = cpu_to_je32(++f->highest_version);
+		fd->version = je32_to_cpu(rd->version);
+		rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 	}
 
 	ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen,

Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- wbuf.c	24 Jan 2005 21:24:15 -0000	1.83
+++ wbuf.c	25 Jan 2005 20:11:11 -0000	1.84
@@ -147,8 +147,7 @@
 		D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset));
 		list_add(&jeb->list, &c->bad_used_list);
 	} else {
-		if (allow_empty == REFILE_NOTEMPTY)
-			BUG();
+		BUG_ON(allow_empty == REFILE_NOTEMPTY);
 		/* It has to have had some nodes or we couldn't be here */
 		D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset));
 		list_add(&jeb->list, &c->erase_pending_list);
@@ -268,16 +267,15 @@
 	ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len);
 	if (ret) {
 		printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n");
-		if (buf)
-			kfree(buf);
+		kfree(buf);
 		return;
 	}
 	if (end-start >= c->wbuf_pagesize) {
 		/* Need to do another write immediately, but it's possible
-		that this is just because the wbuf itself is completely
-		full, and there's nothing earlier read back from the 
-		flash. Hence 'buf' isn't necessarily what we're writing 
-		from. */
+		   that this is just because the wbuf itself is completely
+		   full, and there's nothing earlier read back from the 
+		   flash. Hence 'buf' isn't necessarily what we're writing 
+		   from. */
 		unsigned char *rewrite_buf = buf?:c->wbuf;
 		uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize);
 
@@ -303,8 +301,7 @@
 		if (ret || retlen != towrite) {
 			/* Argh. We tried. Really we did. */
 			printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n");
-			if (buf)
-				kfree(buf);
+			kfree(buf);
 
 			if (retlen) {
 				struct jffs2_raw_node_ref *raw2;
@@ -555,9 +552,7 @@
 		/* retry flushing wbuf in case jffs2_wbuf_recover
 		   left some data in the wbuf */
 		if (ret)
-		{
 			ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING);
-		}
 		up_write(&c->wbuf_sem);
 	} else while (old_wbuf_len &&
 		      old_wbuf_ofs == c->wbuf_ofs) {
@@ -575,9 +570,7 @@
 			/* retry flushing wbuf in case jffs2_wbuf_recover
 			   left some data in the wbuf */
 			if (ret)
-			{
 				ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING);
-			}
 			up_write(&c->wbuf_sem);
 			break;
 		}

Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodemgmt.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -r1.116 -r1.117
--- nodemgmt.c	24 Jan 2005 21:30:22 -0000	1.116
+++ nodemgmt.c	25 Jan 2005 20:11:11 -0000	1.117
@@ -310,8 +310,8 @@
 #if 1
 	/* we could get some obsolete nodes after nextblock was refiled
 	   in wbuf.c */
-	if (  (c->nextblock || !ref_obsolete(new))
-	    &&(jeb != c->nextblock || (ref_offset(new)) != jeb->offset + (c->sector_size - jeb->free_size))) {
+	if ((c->nextblock || !ref_obsolete(new))
+	    &&(jeb != c->nextblock || ref_offset(new) != jeb->offset + (c->sector_size - jeb->free_size))) {
 		printk(KERN_WARNING "argh. node added in wrong place\n");
 		jffs2_free_raw_node_ref(new);
 		return -EINVAL;
@@ -335,7 +335,7 @@
 		c->used_size += len;
 	}
 
-	if (!jeb->free_size && !jeb->dirty_size && !jeb->wasted_size) {
+	if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) {
 		/* 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));





More information about the linux-mtd-cvs mailing list