mtd/fs/jffs3 scan.h,1.2,1.3

Artem Bityuckiy dedekind at infradead.org
Mon Dec 27 05:43:15 EST 2004


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

Modified Files:
	scan.h 
Log Message:
Improve dirty_space function.


Index: scan.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/scan.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- scan.h	27 Dec 2004 10:14:08 -0000	1.2
+++ scan.h	27 Dec 2004 10:43:13 -0000	1.3
@@ -71,6 +71,27 @@
 		struct jffs3_raw_node_ref *ref;
 
 		size = PAD(size);
+
+		DBG_SCAN(2, "Add dirt of length %#x to the node_refs list\n", size);
+
+		/* 
+		 * If the previous node represents dirt too, dont
+		 * allocate new node_ref object.
+		 */
+		if (jeb->last_node && ref_obsolete(jeb->last_node)) {
+			DBG_SCAN(2, "Previous node at %#08x is obsolete too, "
+					"don't allocate new node_ref\n",
+					ref_offset(jeb->last_node));
+#ifdef TMP_TOTLEN
+			jeb->last_node->__totlen += size;
+#endif
+			c->free_size -= size;
+			jeb->free_size -= size;
+			jeb->dirty_size += size;
+			c->dirty_size += size;
+			return 0;
+		}
+
 		ref = jffs3_alloc_raw_node_ref();
 		if (!ref) {
 			WARNING_MSG("Can't allocate raw_node_ref object\n");
@@ -78,13 +99,22 @@
 		}
 
 		ref->flash_offset = (jeb->offset + (c->sector_size - jeb->free_size)) | REF_OBSOLETE;
+		ref->next_in_ino = ref->next_phys = NULL;
 #ifdef TMP_TOTLEN
 		ref->__totlen = size;
 #endif
-		ref->next_in_ino = NULL;
-		ref->next_phys = NULL;
-		DBG_SCAN(1, "Add dirt of length %#x to the node_refs list\n", size);
-		jffs3_add_physical_node_ref(c, ref, size);
+
+		if (!jeb->first_node)
+			jeb->first_node = ref;
+		if (jeb->last_node)
+			jeb->last_node->next_phys = ref;
+		jeb->last_node = ref;
+		
+		c->free_size -= size;
+		jeb->free_size -= size;
+		c->dirty_size += size;
+		jeb->dirty_size += size;
+		
 		return 0;
 }
 





More information about the linux-mtd-cvs mailing list