mtd/fs/jffs2 fs.c,1.19,1.20

gleixner at infradead.org gleixner at infradead.org
Sun Nov 24 16:10:00 EST 2002


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

Modified Files:
	fs.c 
Log Message:
force virtual blocks of 2/4/8 physical blocks, if c->blocks memory would exceed 128KiB

Index: fs.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/fs.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- fs.c	12 Nov 2002 09:53:40 -0000	1.19
+++ fs.c	24 Nov 2002 21:09:56 -0000	1.20
@@ -258,27 +258,32 @@
 	struct jffs2_sb_info *c;
 	struct inode *root_i;
 	int ret;
+	size_t blocks;
 
 	c = JFFS2_SB_INFO(sb);
 
-	c->sector_size = c->mtd->erasesize;
 	c->flash_size = c->mtd->size;
 
-#if 0
-	if (c->sector_size < 0x10000) {
-		printk(KERN_INFO "jffs2: Erase block size too small (%dKiB). Using 64KiB instead\n",
-		       c->sector_size / 1024);
-		c->sector_size = 0x10000;
-	}
-#endif
+	/* 
+	 * Check, if we have to concatenate physical blocks to larger virtual blocks
+	 * to reduce the memorysize for c->blocks. (kmalloc allows max. 128K allocation)
+	 */
+	blocks = c->flash_size / c->mtd->erasesize;
+	while ((blocks * sizeof (struct jffs2_eraseblock)) > (128 * 1024))
+		blocks >>= 1;
+	
+	c->sector_size = c->flash_size / blocks;
+	if (c->sector_size != c->mtd->erasesize)
+		printk(KERN_INFO "jffs2: Erase block size too small (%dKiB). Using virtual blocks size (%dKiB) instead\n", 
+			c->mtd->erasesize / 1024, c->sector_size / 1024);
+
 	if (c->flash_size < 5*c->sector_size) {
-		printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n",
-		       c->flash_size / c->sector_size);
+		printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n", c->flash_size / c->sector_size);
 		return -EINVAL;
 	}
 
 	c->cleanmarker_size = sizeof(struct jffs2_unknown_node);
-	/* Jörn -- stick alignment for weird 8-byte-page flash here */
+	/* Joern -- stick alignment for weird 8-byte-page flash here */
 
 	if (jffs2_cleanmarker_oob(c)) {
 		/* Cleanmarker is out-of-band, so inline size zero */





More information about the linux-mtd-cvs mailing list