mtd/fs/jffs3 TODO, 3.6, 3.7 debug.c, 1.8, 1.9 nodelist.h, 3.8, 3.9 nodemgmt.c, 3.7, 3.8 scan.c, 3.7, 3.8 scan.h, 1.1, 1.2

Artem Bityuckiy dedekind at infradead.org
Mon Dec 27 05:14:12 EST 2004


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

Modified Files:
	TODO debug.c nodelist.h nodemgmt.c scan.c scan.h 
Log Message:
Eliminating __totlen. Now works on NOR.
Still doesn't work with summaries enabled.


Index: TODO
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/TODO,v
retrieving revision 3.6
retrieving revision 3.7
diff -u -r3.6 -r3.7
--- TODO	24 Dec 2004 08:23:00 -0000	3.6
+++ TODO	27 Dec 2004 10:14:08 -0000	3.7
@@ -57,6 +57,14 @@
      characters. Currently it is hard to read JFFS3 sources 80xX
      terminals.
 
+   - __totlen elimination: when adding obsolete nodes, we just allocate
+     new node_ref and call add_physical_node_ref. That is sux. It
+     doesn't merge obsolete nodes. Fix it.
+     Wasted space accounting is broken. Pads are treated as dirty with
+     new changes. Either fix it or remove the notion of wasted space at
+     all - is it really needed? Why not to treat it just as dirty space?
+     Why do we need this?
+
    - Summaries:
      1. In get_inode_nodes - do not check nodes CRC if their block
 	contains summary node (when checking).
@@ -71,3 +79,4 @@
 	  this block was written, and we may trust this block - that
 	  means we may not check CRCs there.
 
+

Index: debug.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/debug.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- debug.c	25 Dec 2004 11:11:21 -0000	1.8
+++ debug.c	27 Dec 2004 10:14:08 -0000	1.9
@@ -489,7 +489,11 @@
 
 	printk(KERN_DEBUG);
 	for (ref = jeb->first_node; ; ref = ref->next_phys) {
+#ifdef TMP_TOTLEN
+		printk("%#08x(%#x)", ref_offset(ref), ref->__totlen);
+#else
 		printk("%#08x(%#x)", ref_offset(ref), ref_totlen(c, jeb, ref));
+#endif
 		if (ref->next_phys)
 			printk("->");
 		else

Index: nodelist.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/nodelist.h,v
retrieving revision 3.8
retrieving revision 3.9
diff -u -r3.8 -r3.9
--- nodelist.h	25 Dec 2004 11:11:21 -0000	3.8
+++ nodelist.h	27 Dec 2004 10:14:08 -0000	3.9
@@ -82,7 +82,9 @@
 		word so you know when you've got there :) */
 	struct jffs3_raw_node_ref *next_phys;
 	uint32_t flash_offset;
+#ifdef TMP_TOTLEN
 	uint32_t __totlen; /* This may die; use ref_totlen(c, jeb, ) below */
+#endif
 };
 
         /* flash_offset & 3 always has to be zero, because nodes are
@@ -239,7 +241,9 @@
 	}
 
 #ifdef TMP_TOTLEN
-	if (ref_end - ref_offs != ref->__totlen) {
+	if (ref_end - ref_offs != ref->__totlen
+		/* Last obsolete node may have wrong length */
+		&& ref != jeb->last_node) {
 		ERROR_MSG("Ref (%p) totlen %#x (%#08x-%#08x) miscalculated as "
 			"%#x (%#08x-%#08x) instead of %#x\n",
 			ref, ref->__totlen, ref_offs, ref_offs + ref->__totlen,

Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/nodemgmt.c,v
retrieving revision 3.7
retrieving revision 3.8
diff -u -r3.7 -r3.8
--- nodemgmt.c	25 Dec 2004 11:11:21 -0000	3.7
+++ nodemgmt.c	27 Dec 2004 10:14:08 -0000	3.8
@@ -236,6 +236,8 @@
 	} else {
 #endif
 		if (jeb && minsize > jeb->free_size) {
+			struct jffs3_raw_node_ref *ref;
+			
 			/* 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 (jffs3_wbuf_dirty(c)) {
@@ -246,10 +248,20 @@
 				jeb = c->nextblock;
 				goto restart;
 			}
-			c->wasted_size += jeb->free_size;
-			c->free_size -= jeb->free_size;
-			jeb->wasted_size += jeb->free_size;
-			jeb->free_size = 0;
+			
+			if ((ref = jffs3_alloc_raw_node_ref()) == NULL)
+				return - ENOMEM;
+			ref->flash_offset = PAD(jeb->offset + (c->sector_size - jeb->free_size)) | REF_OBSOLETE;
+#ifdef TMP_TOTLEN
+			ref->__totlen = c->wbuf_pagesize - c->wbuf_len;
+#endif
+			ref->next_in_ino = NULL;
+			ref->next_phys = NULL;
+			DBG_BL(1, "Too few space at the block %#x (%#x bytes), waste it\n",
+					jeb->offset, c->sector_size - jeb->free_size);
+			jffs3_add_physical_node_ref(c, ref, c->sector_size - jeb->free_size);
+			if (SANITY)
+				BUG_ON(jeb->free_size != 0);
 
 			/* Check, if we have a dirty block now, or if it was dirty already */
 			if (ISDIRTY (jeb->wasted_size + jeb->dirty_size)) {
@@ -467,7 +479,7 @@
 	int ret, addedsize;
 	size_t retlen;
 
-	if(!ref) {
+	if(SANITY && !ref) {
 		ERROR_MSG("called with NULL node\n");
 		BUG();
 	}
@@ -478,12 +490,13 @@
 	}
 
 	blocknr = ref->flash_offset / c->sector_size;
-	if (blocknr >= c->nr_blocks) {
+	if (SANITY && blocknr >= c->nr_blocks) {
 		ERROR_MSG("raw node at 0x%08x is off the end of device!\n", ref->flash_offset);
 		BUG();
 	}
 	jeb = &c->blocks[blocknr];
 
+/* TODO: remove */ jffs3_dbg_dump_node_refs(c, jeb);
 	if (jffs3_can_mark_obsolete(c) && !jffs3_is_readonly(c) &&
 	    !(c->flags & JFFS3_SB_FLAG_MOUNTING)) {
 		/* Hm. This may confuse static lock analysis. If any of the above
@@ -690,13 +703,19 @@
 		spin_unlock(&c->erase_completion_lock);
 	}
 
-
 	/* Merge with the next node in the physical list, if there is one
 	   and if it's also obsolete and if it doesn't belong to any inode */
-	if (ref->next_phys && ref_obsolete(ref->next_phys) &&
-	    !ref->next_phys->next_in_ino) {
+	if (ref->next_phys && ref_obsolete(ref->next_phys)) {
 		struct jffs3_raw_node_ref *n = ref->next_phys;
 
+		if (SANITY)
+			BUG_ON(ref->next_phys->next_in_ino != NULL);
+
+		DBG_NR(2, "Merging ref (ofs %#08x len %#08x) with next ref "
+			"(ofs %#08x len %#08x)\n", ref_offset(ref),
+			ref_totlen(c, jeb, ref), ref_offset(n),
+			ref_totlen(c, jeb, n));
+
 		spin_lock(&c->erase_completion_lock);
 
 #ifdef TMP_TOTLEN
@@ -723,7 +742,17 @@
 		while (p->next_phys != ref)
 			p = p->next_phys;
 
-		if (ref_obsolete(p) && !ref->next_in_ino) {
+		if (ref_obsolete(p)) {
+			if (SANITY)
+				/* In case of NOR per - inode list can
+				 * not contain obsoleted nodes */
+				BUG_ON(ref->next_in_ino);
+		
+			DBG_NR(2, "Merging ref (ofs %#08x len %#08x) with previous ref "
+				"(ofs %#08x len %#08x)\n", ref_offset(ref),
+				ref_totlen(c, jeb, ref), ref_offset(p),
+				ref_totlen(c, jeb, p));
+
 #ifdef TMP_TOTLEN
 			p->__totlen += ref->__totlen;
 #endif

Index: scan.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/scan.c,v
retrieving revision 3.7
retrieving revision 3.8
diff -u -r3.7 -r3.8
--- scan.c	25 Dec 2004 11:11:22 -0000	3.7
+++ scan.c	27 Dec 2004 10:14:08 -0000	3.8
@@ -211,7 +211,7 @@
 	}
 #endif
 	if (c->nr_erasing_blocks) {
-		if ( !c->used_size && ((c->nr_free_blocks + empty_blocks+bad_blocks)
+		if (!c->used_size && ((c->nr_free_blocks + empty_blocks+bad_blocks)
 					!= c->nr_blocks || bad_blocks == c->nr_blocks) ) {
 			NOTICE_MSG("Cowardly refusing to erase blocks on filesystem with "
 					"no valid JFFS3 nodes\n");
@@ -596,11 +596,26 @@
 					return -ENOMEM;
 				ofs += PAD(sizeof(struct jffs3_unknown_node));
 			} else {
-				if (jeb->first_node)
+				struct jffs3_raw_node_ref *marker_ref;
+
+				if (jeb->first_node) {
 					WARNING_MSG("CLEANMARKER node found at %#08x, not first node in "
 						"block (%#08x)\n", ofs, jeb->offset);
-				if (dirty_space(c, jeb, c->cleanmarker_size) != 0)
-					return - ENOMEM;
+					if (dirty_space(c, jeb, c->cleanmarker_size) != 0)
+						return - ENOMEM;
+					ofs += PAD(c->cleanmarker_size);
+				}
+
+				if ((marker_ref = jffs3_alloc_raw_node_ref()) == NULL) {
+					ERROR_MSG("Failed to allocate node ref for clean marker\n");
+					return -ENOMEM;
+				}
+				marker_ref->next_in_ino = NULL;
+				marker_ref->next_phys = NULL;
+				marker_ref->flash_offset = ofs | REF_NORMAL;
+				marker_ref->__totlen = c->cleanmarker_size;
+				jeb->first_node = jeb->last_node = marker_ref;
+				USED_SPACE(PAD(c->cleanmarker_size));
 				ofs += PAD(c->cleanmarker_size);
 			}
 			break;

Index: scan.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/scan.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- scan.h	25 Dec 2004 11:07:35 -0000	1.1
+++ scan.h	27 Dec 2004 10:14:08 -0000	1.2
@@ -61,7 +61,9 @@
  * Mark space dirty. Each chunk of dirty space in JFFS3 should be
  * represented by the correspondent obsolete node (in order to be
  * able to calculate nodes length in the ref_totlen() function).
- * TODO: support merging here
+ * 
+ * If the last node is obsolete, do not allocate ne node_ref object,
+ * just merge it with our dirt.
  */
 static inline int
 dirty_space(struct jffs3_sb_info *c, struct jffs3_eraseblock *jeb, uint32_t size)





More information about the linux-mtd-cvs mailing list