Re: data loss on jffs2 filesystem on dataflash

Peter Menzebach
2005-09-22T16:14:51Z

Andrew Victor wrote:

> This magic minimum block size could always be calculated in JFFS2 (in
> jffs2_dataflash_setup). It is a JFFS2-specific value.
> Just calculate an 'N' where:
> (N * mtd->erasesize) >= jffs2_minimum_block_size
> and
> (mtd->size % (N * mtd->erasesize)) == 0

How about this in jffs2_dataflash_setup:

--- /arm/src/mtd/fs/jffs2/wbuf.c 2005-09-22 13:33:42.000000000 +0200
+++ wbuf.c 2005-09-22 17:52:17.000000000 +0200
@@ -1204,14 +1197,28 @@

/* Initialize write buffer */
init_rwsem(&c->wbuf_sem);
- c->wbuf_pagesize = c->sector_size;
+ c->wbuf_pagesize = c->mtd->erasesize;
+
+ c->sector_size = ((JFFS2_MIN_SECTOR_SIZE + c->mtd->erasesize - 1) /
+ c->mtd->erasesize) * c->mtd->erasesize;
+
+ while ((5*c->sector_size < c->mtd->size) &&
+ ((c->mtd->size % c->sector_size) != 0))
+ {
+ c->sector_size+=c->mtd->erasesize;
+ }
+ if ((c->mtd->size % c->sector_size) != 0) {
+ printk(KERN_WARNING "JFFS2 no suitable sector size found\n");
+ return (1);
+ };
+
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