[JFFS2] Introduce jffs2_scan_dirty_space() function.

To eliminate the __totlen field from struct jffs2_raw_node_ref, we need
to allocate nodes for dirty space instead of just tweaking the accounting
data. Introduce jffs2_scan_dirty_space() in preparation for that.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index 9ced3aa..11ea54c 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -380,6 +380,7 @@
 	struct jffs2_full_dirent *fd;
 	void *sp;
 	int i, ino;
+	int err;
 
 	sp = summary->sum;
 
@@ -494,7 +495,8 @@
 					jffs2_free_raw_node_ref(raw);
 					if (PTR_ERR(xd) == -EEXIST) {
 						/* a newer version of xd exists */
-						DIRTY_SPACE(je32_to_cpu(spx->totlen));
+						if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(spx->totlen))))
+							return err;
 						sp += JFFS2_SUMMARY_XATTR_SIZE;
 						break;
 					}
@@ -585,6 +587,7 @@
 	struct jffs2_raw_node_ref *cache_ref;
 	int ret, ofs;
 	uint32_t crc;
+	int err;
 
 	ofs = jeb->offset + c->sector_size - sumsize;
 
@@ -629,11 +632,13 @@
 		if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) {
 			dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n",
 				je32_to_cpu(summary->cln_mkr), c->cleanmarker_size);
-			DIRTY_SPACE(PAD(je32_to_cpu(summary->cln_mkr)));
+			if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
+				return err;
 		} else if (jeb->first_node) {
 			dbg_summary("CLEANMARKER node not first node in block "
 					"(0x%08x)\n", jeb->offset);
-			DIRTY_SPACE(PAD(je32_to_cpu(summary->cln_mkr)));
+			if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
+				return err;
 		} else {
 			struct jffs2_raw_node_ref *marker_ref = jffs2_alloc_raw_node_ref();
 
@@ -650,7 +655,8 @@
 	}
 
 	if (je32_to_cpu(summary->padded)) {
-		DIRTY_SPACE(je32_to_cpu(summary->padded));
+		if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(summary->padded))))
+			return err;
 	}
 
 	ret = jffs2_sum_process_sum_data(c, jeb, summary, pseudo_random);
@@ -823,7 +829,7 @@
 			infosize, jeb->offset + c->sector_size - jeb->free_size, ret, retlen);
 
 		c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
-		DIRTY_SPACE(infosize);
+		jffs2_scan_dirty_space(c, jeb, infosize);
 
 		return 1;
 	}