mtd/fs/jffs2 scan.c,1.71,1.72

David Woodhouse dwmw2 at infradead.org
Wed Mar 27 04:53:15 EST 2002


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

Modified Files:
	scan.c 
Log Message:
Skip to page-alignment in nextblock on mount.
Don't attempt to use a block for nextblock if it has less than
wbuf_pagesize free and we're on NAND flash.


Index: scan.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/scan.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- scan.c	15 Mar 2002 16:53:19 -0000	1.71
+++ scan.c	27 Mar 2002 09:53:12 -0000	1.72
@@ -140,13 +140,14 @@
                            not the one with most free space.
                         */
                         if (jeb->free_size > 2*sizeof(struct jffs2_raw_inode) && 
-                                (!c->nextblock || c->nextblock->free_size < jeb->free_size)) {
+			    (jffs2_can_mark_obsolete(c) || jeb->free_size > c->wbuf_pagesize) &&
+			    (!c->nextblock || c->nextblock->free_size < jeb->free_size)) {
                                 /* Better candidate for the next writes to go to */
                                 if (c->nextblock) 
 					list_add(&c->nextblock->list, &c->dirty_list);
                                 c->nextblock = jeb;
                         } else {
-                                list_add(&jeb->list, &c->dirty_list);
+				list_add(&jeb->list, &c->dirty_list);
                         }
 			break;
 
@@ -166,11 +167,26 @@
 			bad_blocks++;
 			break;
 		default:
-			printk("jffs2_scan_medium(): unknown block state\n");
+			printk(KERN_WARNING "jffs2_scan_medium(): unknown block state\n");
 			BUG();	
 		}
 	}
 
+	if (!jffs2_can_mark_obsolete(c) && c->nextblock && (c->nextblock->free_size & (c->wbuf_pagesize-1))) {
+		/* If we're going to start writing into a block which already 
+		   contains data, and the end of the data isn't page-aligned,
+		   skip a little and align it. */
+
+		uint32_t skip = c->nextblock->free_size & (c->wbuf_pagesize-1);
+
+		D1(printk(KERN_DEBUG "jffs2_scan_medium(): Skipping %d bytes in nextblock to ensure page alignment\n",
+			  skip));
+		c->nextblock->dirty_size += skip;
+		c->dirty_size += skip;
+
+		c->nextblock->free_size -= skip;
+		c->free_size -= skip;
+	}
 	if (c->nr_erasing_blocks) {
 		if ( !c->used_size && ((empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) {
 			printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n");





More information about the linux-mtd-cvs mailing list