Commit ea27234e authored by David Woodhouse's avatar David Woodhouse

JFFS2: Allow NAND driver to disable virtual eraseblocks.

In order to keep the RAM usage down with large devices and smaller
erase block sizes, we were using blocks in JFFS2 larger than the 
physical erase size. This means that bad blocks lose a lot more space
though; allow it to be disabled.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent aea68803
...@@ -7,13 +7,15 @@ ...@@ -7,13 +7,15 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: build.c,v 1.66 2004/11/20 19:18:07 dwmw2 Exp $ * $Id: build.c,v 1.68 2004/11/27 13:38:10 gleixner Exp $
* *
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mtd/mtd.h>
#include "nodelist.h" #include "nodelist.h"
static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, struct jffs2_inode_cache *, struct jffs2_full_dirent **); static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, struct jffs2_inode_cache *, struct jffs2_full_dirent **);
...@@ -312,7 +314,10 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c) ...@@ -312,7 +314,10 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
c->free_size = c->flash_size; c->free_size = c->flash_size;
c->nr_blocks = c->flash_size / c->sector_size; c->nr_blocks = c->flash_size / c->sector_size;
c->blocks = kmalloc(sizeof(struct jffs2_eraseblock) * c->nr_blocks, GFP_KERNEL); if (c->mtd->flags & MTD_NO_VIRTBLOCKS)
c->blocks = vmalloc(sizeof(struct jffs2_eraseblock) * c->nr_blocks);
else
c->blocks = kmalloc(sizeof(struct jffs2_eraseblock) * c->nr_blocks, GFP_KERNEL);
if (!c->blocks) if (!c->blocks)
return -ENOMEM; return -ENOMEM;
for (i=0; i<c->nr_blocks; i++) { for (i=0; i<c->nr_blocks; i++) {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: fs.c,v 1.49 2004/11/16 20:36:11 dwmw2 Exp $ * $Id: fs.c,v 1.50 2004/11/23 15:37:31 gleixner Exp $
* *
*/ */
...@@ -463,11 +463,13 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) ...@@ -463,11 +463,13 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
*/ */
c->sector_size = c->mtd->erasesize; c->sector_size = c->mtd->erasesize;
blocks = c->flash_size / c->sector_size; blocks = c->flash_size / c->sector_size;
while ((blocks * sizeof (struct jffs2_eraseblock)) > (128 * 1024)) { if (!(c->mtd->flags & MTD_NO_VIRTBLOCKS)) {
blocks >>= 1; while ((blocks * sizeof (struct jffs2_eraseblock)) > (128 * 1024)) {
c->sector_size <<= 1; blocks >>= 1;
} c->sector_size <<= 1;
}
}
/* /*
* Size alignment check * Size alignment check
*/ */
...@@ -533,7 +535,10 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) ...@@ -533,7 +535,10 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
out_nodes: out_nodes:
jffs2_free_ino_caches(c); jffs2_free_ino_caches(c);
jffs2_free_raw_node_refs(c); jffs2_free_raw_node_refs(c);
kfree(c->blocks); if (c->mtd->flags & MTD_NO_VIRTBLOCKS)
vfree(c->blocks);
else
kfree(c->blocks);
out_inohash: out_inohash:
kfree(c->inocache_list); kfree(c->inocache_list);
out_wbuf: out_wbuf:
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
* $Id: super.c,v 1.103 2004/11/16 20:36:12 dwmw2 Exp $ * $Id: super.c,v 1.104 2004/11/23 15:37:31 gleixner Exp $
* *
*/ */
...@@ -277,7 +277,10 @@ static void jffs2_put_super (struct super_block *sb) ...@@ -277,7 +277,10 @@ static void jffs2_put_super (struct super_block *sb)
up(&c->alloc_sem); up(&c->alloc_sem);
jffs2_free_ino_caches(c); jffs2_free_ino_caches(c);
jffs2_free_raw_node_refs(c); jffs2_free_raw_node_refs(c);
kfree(c->blocks); if (c->mtd->flags & MTD_NO_VIRTBLOCKS)
vfree(c->blocks);
else
kfree(c->blocks);
jffs2_flash_cleanup(c); jffs2_flash_cleanup(c);
kfree(c->inocache_list); kfree(c->inocache_list);
if (c->mtd->sync) if (c->mtd->sync)
......
/* /*
* $Id: mtd-abi.h,v 1.6 2004/08/09 13:38:30 dwmw2 Exp $ * $Id: mtd-abi.h,v 1.7 2004/11/23 15:37:32 gleixner Exp $
* *
* Portions of MTD ABI definition which are shared by kernel and user space * Portions of MTD ABI definition which are shared by kernel and user space
*/ */
...@@ -40,6 +40,7 @@ struct mtd_oob_buf { ...@@ -40,6 +40,7 @@ struct mtd_oob_buf {
#define MTD_XIP 32 // eXecute-In-Place possible #define MTD_XIP 32 // eXecute-In-Place possible
#define MTD_OOB 64 // Out-of-band data (NAND flash) #define MTD_OOB 64 // Out-of-band data (NAND flash)
#define MTD_ECC 128 // Device capable of automatic ECC #define MTD_ECC 128 // Device capable of automatic ECC
#define MTD_NO_VIRTBLOCKS 256 // Virtual blocks not allowed
// Some common devices / combinations of capabilities // Some common devices / combinations of capabilities
#define MTD_CAP_ROM 0 #define MTD_CAP_ROM 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment