jffs2: implement mount option parsing and compression overriding
PATCH 1/2 jffs2: implement mount option parsing and compression overriding
Currently jffs2 has compile-time constants (and .config options) controlling whether or not the various compression/decompression drivers are built in and enabled. This is fine for embedded systems, but it clashes with distribution kernels. Distro kernels tend to turn on everything; this causes OpenFirmware to fall over, as it understands ZLIB-compressed inodes. Booting a kernel that has LZO compression enabled, writing to the boot partition, and then rebooting causes OFW to fail to read the kernel from the filesystem. This is because LZO compression has priority when writing new data to jffs2, if LZO is enabled.
This patch adds mount option parsing, and a single supported option ("compr=none"). This adds the flexibility of being able to specify which compressor overrides on a per-superblock basis. For now, we can simply disable compression; additional flexibility coming soon.
--- fs/jffs2/compr.c | 9 ++++- fs/jffs2/fs.c | 2 +- fs/jffs2/jffs2_fs_sb.h | 6 ++++ fs/jffs2/os-linux.h | 2 +- fs/jffs2/super.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 4 deletions(-)
fs/jffs2/compr.c +7 -2
@@ -76,13 +76,18 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t *datalen, uint32_t *cdatalen) { int ret = JFFS2_COMPR_NONE; -int compr_ret; +int mode, compr_ret;struct jffs2_compressor *this, *best=NULL ;unsigned char *output_buf =NULL , *tmp_buf;uint32_t orig_slen, orig_dlen;uint32_t best_slen=0 , best_dlen=0 ; -switch (jffs2_compression_mode) { +if (c->mount_opts.override_compr) + mode = c->mount_opts.compr; +else + mode = jffs2_compression_mode; + +switch (mode) {case JFFS2_COMPR_MODE_NONE :break ;case JFFS2_COMPR_MODE_PRIORITY :
fs/jffs2/fs.c +1 -1
@@ -379,7 +379,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags)jffs2_do_setattr (inode, &iattr); } -int jffs2_remount_fs (struct super_block *sb,int *flags,char *data) +int jffs2_do_remount_fs (struct super_block *sb,int *flags,char *data) {struct jffs2_sb_info *c =JFFS2_SB_INFO (sb);
fs/jffs2/jffs2_fs_sb.h +6 -0
@@ -29,6 +29,11 @@struct jffs2_inodirty ; +struct jffs2_mount_opts { +bool override_compr; +unsigned int compr; +}; +/* A struct for the overall file system control. Pointers to jffs2_sb_info structs are named `c' in the source code. Nee jffs_control
@@ -126,6 +131,7 @@ struct jffs2_sb_info {#endif struct jffs2_summary *summary;/* Summary information */ +struct jffs2_mount_opts mount_opts;#ifdef CONFIG_JFFS2_FS_XATTR #define XATTRINDEX_HASHSIZE (57)
fs/jffs2/os-linux.h +1 -1
@@ -176,7 +176,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags);struct inode *jffs2_new_inode (struct inode *dir_i,umode_t mode,struct jffs2_raw_inode *ri);int jffs2_statfs (struct dentry *,struct kstatfs *); -int jffs2_remount_fs (struct super_block *,int *,char *); +int jffs2_do_remount_fs (struct super_block *,int *,char *);int jffs2_do_fill_super (struct super_block *sb,void *data,int silent);void jffs2_gc_release_inode (struct jffs2_sb_info *c,struct jffs2_inode_info *f);
fs/jffs2/super.c +75 -0
93 lines not on this page · raw message
Signature · 1 line
1.7.2.5
Hi,
please, cc the fs-devel mailing list when you sumbit v2.
Quoted 11 lines · Andres Salomon
Currently jffs2 has compile-time constants (and .config options) controlling whether or not the various compression/decompression drivers are built in and enabled. This is fine for embedded systems, but it clashes with distribution kernels. Distro kernels tend to turn on everything; this causes OpenFirmware to fall over, as it understands ZLIB-compressed inodes. Booting a kernel that has LZO compression enabled, writing to the boot partition, and then rebooting causes OFW to fail to read the kernel from the filesystem. This is because LZO compression has priority when writing new data to jffs2, if LZO is enabled.
Quoted 7 lines
This patch adds mount option parsing, and a single supported option ("compr=none"). This adds the flexibility of being able to specify which compressor overrides on a per-superblock basis. For now, we can simply disable compression; additional flexibility coming soon.
Signed-off-by Andres Salomon <[email protected]>
You forgot to implement .show_options method of
'struct super_operations' - it is needed to make sure 'compr=none' is shown when you do 'cat /proc/mounts'.
fs/jffs2/super.c static const struct export_operations jffs2_export_ops = { · line 197
Quoted 3 lines
fs/jffs2/super.c +3
-0+ err =jffs2_parse_options (c, data); +if (err) { +printk (KERN_ERR "JFFS2 error: invalid or unknown mount option\n" );
'jffs2_parse_options()' prints the error message, do not duplicate it please.
Quoted 10 lines
fs/jffs2/super.c +6
-0+return -EINVAL ; + } + +return jffs2_do_remount_fs (sb, flags, data); +} +static const struct super_operations jffs2_super_operations = { .alloc_inode = jffs2_alloc_inode,
fs/jffs2/super.c static int jffs2_fill_super(struct super_block *sb, void *data, int silent) · line 239
Quoted 6 lines
fs/jffs2/super.c +3
-0@@ -166,6 +234,13 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) c->os_priv = sb; sb->s_fs_info = c; + ret =jffs2_parse_options (c, data); +if (ret) { +printk (KERN_ERR "JFFS2 error: invalid or unknown mount option\n" );
Ditto - kill this printk please.
Signature · 7 lines
Best Regards, Artem Bityutskiy ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 3 lines · On Sun, 16 Oct 2011 17:03:00 +0300 Artem Bityutskiy <[email protected]> wrote:
Hi,
please, cc the fs-devel mailing list when you sumbit v2.
Thanks for the review, I've sent updated patches. BTW, I didn't see fs-devel in MAINTAINERS anywhere; is there a patch pending for that?