mtd/fs/jffs2 wbuf.c,1.67,1.68

David Woodhouse dwmw2 at infradead.org
Tue Jul 6 06:32:35 EDT 2004


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

Modified Files:
	wbuf.c 
Log Message:
Always adjust free_size of the affected block when padding to flush.


Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- wbuf.c	30 Jun 2004 17:26:15 -0000	1.67
+++ wbuf.c	6 Jul 2004 10:32:33 -0000	1.68
@@ -391,7 +391,7 @@
    0: Do not pad. Probably pointless - we only ever use this when we can't pad anyway.
    1: Pad, do not adjust nextblock free_size
    2: Pad, adjust nextblock free_size
-*/
+/
 static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad)
 {
 	int ret;
@@ -461,31 +461,34 @@
 		return ret; 
 	}
 
-	/* Adjusting free size of next block only, if it's called from fsync ! */
-	if (pad == 2) {
-		D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of c->nextblock\n"));
-		spin_lock(&c->erase_completion_lock);
-		if (!c->nextblock)
-			BUG();
+	spin_lock(&c->erase_completion_lock);
+
+	/* Adjust free size of the block if we padded. */
+	if (pad) {
+		struct jffs2_eraseblock *jeb;
+
+		jeb = &c->blocks[c->wbuf_ofs / c->sector_size];
+
+		D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n",
+			  (jeb==nextblock)?"next":"", jeb->offset));
+
 		/* wbuf_pagesize - wbuf_len is the amount of space that's to be 
 		   padded. If there is less free space in the block than that,
 		   something screwed up */
-		if (c->nextblock->free_size < (c->wbuf_pagesize - c->wbuf_len)) {
+		if (jeb->free_size < (c->wbuf_pagesize - c->wbuf_len)) {
 			printk(KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n",
 			       c->wbuf_ofs, c->wbuf_len, c->wbuf_pagesize-c->wbuf_len);
 			printk(KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n",
-			       c->nextblock->offset, c->nextblock->free_size);
+			       jeb->offset, jeb->free_size);
 			BUG();
 		}
-		c->nextblock->free_size -= (c->wbuf_pagesize - c->wbuf_len);
+		jeb->free_size -= (c->wbuf_pagesize - c->wbuf_len);
 		c->free_size -= (c->wbuf_pagesize - c->wbuf_len);
-		c->nextblock->wasted_size += (c->wbuf_pagesize - c->wbuf_len);
+		jeb->wasted_size += (c->wbuf_pagesize - c->wbuf_len);
 		c->wasted_size += (c->wbuf_pagesize - c->wbuf_len);
-		spin_unlock(&c->erase_completion_lock);
 	}
 
 	/* Stick any now-obsoleted blocks on the erase_pending_list */
-	spin_lock(&c->erase_completion_lock);
 	jffs2_refile_wbuf_blocks(c);
 	jffs2_clear_wbuf_ino_list(c);
 	spin_unlock(&c->erase_completion_lock);





More information about the linux-mtd-cvs mailing list