jffs2: implement mount option parsing and compression overriding
PATCH v2 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.
v2: kill some printks, and implement show_options as suggested by Artem Bityutskiy.
--- 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 | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 112 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 +97 -0
132 lines not on this page · raw message
Signature · 1 line
1.7.2.5
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 5 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.
Pushed both to l2-mtd-2.6.git, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy