data loss on jffs2 filesystem on dataflash

Peter Menzebach pm-mtd at mw-itcon.de
Thu Sep 22 13:09:40 EDT 2005


Peter Menzebach wrote:
forget the last patch, I made up my mind. If I do not find a good sector 
size, I should resize the size of flash for jffs2. See below.

The question is, if the call for jffs2_flash_setup should be moved 
before the size checks in jffs2_do_fill_super?

Best regards
Peter


--- /arm/src/mtd/fs/jffs2/wbuf.c	2005-09-22 13:33:42.000000000 +0200
+++ wbuf.c	2005-09-22 18:52:17.000000000 +0200
@@ -1200,18 +1193,37 @@
  }

  int jffs2_dataflash_setup(struct jffs2_sb_info *c) {
+	int min_sector_size;
  	c->cleanmarker_size = 0;		/* No cleanmarkers needed */
  	
  	/* Initialize write buffer */
  	init_rwsem(&c->wbuf_sem);
-	c->wbuf_pagesize = c->sector_size;
+	c->wbuf_pagesize = c->mtd->erasesize;
+
+	min_sector_size = ((JFFS2_MIN_SECTOR_SIZE + c->mtd->erasesize - 1) / 
c->mtd->erasesize) * c->mtd->erasesize;
+
+	c->sector_size = min_sector_size;
+
+	c->flash_size = c->mtd->size;
+	
+	while ((c->sector_size < (2 * min_sector_size)) && (c->flash_size % 
c->sector_size != 0)) {
+		c->sector_size+=c->mtd->erasesize;
+	}
+
+	if ((c->flash_size % c->sector_size) != 0) {
+		c->sector_size = min_sector_size;
+		c->flash_size = (c->flash_size / min_sector_size) * min_sector_size;
+		printk(KERN_INFO "JFFS2 flash size and erase size adjusted size %dKiB 
erasesize %dB\n", c->flash_size/1024, c->sector_size);
+	};
+	
+	
  	c->wbuf_ofs = 0xFFFFFFFF;

  	c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
  	if (!c->wbuf)
  		return -ENOMEM;

-	printk(KERN_INFO "JFFS2 write-buffering enabled (%i)\n", 
c->wbuf_pagesize);
+	printk(KERN_INFO "JFFS2 write-buffering enabled (%i) erasesize 
(%i)\n", c->wbuf_pagesize, c->sector_size);

  	return 0;
  }

-- 
Peter Menzebach
Menzebach und Wolff IT-Consulting GbR
Phone +49 751 355 387 1




More information about the linux-mtd mailing list