diff -rup linux-2.6.15/fs/jffs2/compr.c linux-2.6.15-jffs2-mountoptions/fs/jffs2/compr.c --- linux-2.6.15/fs/jffs2/compr.c 2006-01-04 07:12:40.000000000 +0100 +++ linux-2.6.15-jffs2-mountoptions/fs/jffs2/compr.c 2006-05-01 16:52:51.000000000 +0200 @@ -9,7 +9,7 @@ * * For licensing information, see the file 'LICENCE' in this directory. * - * $Id: compr.c,v 1.46 2005/11/07 11:14:38 gleixner Exp $ + * $Id: compr.c,v 1.1.2.1 2006/05/01 14:52:51 rln Exp $ * */ @@ -20,9 +20,6 @@ static DEFINE_SPINLOCK(jffs2_compressor_ /* Available compressors are on this list */ static LIST_HEAD(jffs2_compressor_list); -/* Actual compression mode */ -static int jffs2_compression_mode = JFFS2_COMPR_MODE_PRIORITY; - /* Statistics for blocks stored without compression */ static uint32_t none_stat_compr_blocks=0,none_stat_decompr_blocks=0,none_stat_compr_size=0; @@ -55,7 +52,7 @@ uint16_t jffs2_compress(struct jffs2_sb_ uint32_t orig_slen, orig_dlen; uint32_t best_slen=0, best_dlen=0; - switch (jffs2_compression_mode) { + switch (c->compression_mode) { case JFFS2_COMPR_MODE_NONE: break; case JFFS2_COMPR_MODE_PRIORITY: @@ -268,7 +265,6 @@ int jffs2_unregister_compressor(struct j return 0; } -#ifdef CONFIG_JFFS2_PROC #define JFFS2_STAT_BUF_SIZE 16000 @@ -317,9 +313,9 @@ char *jffs2_stats(void) return buf; } -char *jffs2_get_compression_mode_name(void) +char *jffs2_get_compression_mode_name(const struct jffs2_sb_info *c) { - switch (jffs2_compression_mode) { + switch (c->compression_mode) { case JFFS2_COMPR_MODE_NONE: return "none"; case JFFS2_COMPR_MODE_PRIORITY: @@ -330,18 +326,37 @@ char *jffs2_get_compression_mode_name(vo return "unkown"; } -int jffs2_set_compression_mode_name(const char *name) + +int jffs2_get_dflt_compression_mode(void) +{ +/* Setting default compression mode */ +#ifdef CONFIG_JFFS2_CMODE_NONE + D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");) + return JFFS2_COMPR_MODE_NONE; +#else +#ifdef CONFIG_JFFS2_CMODE_SIZE + D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");) + return JFFS2_COMPR_MODE_SIZE; +#else + D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");) + return JFFS2_COMPR_MODE_PRIORITY; +#endif +#endif +} + + +int jffs2_set_compression_mode_name(struct jffs2_sb_info *c, const char *name) { if (!strcmp("none",name)) { - jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; + c->compression_mode = JFFS2_COMPR_MODE_NONE; return 0; } if (!strcmp("priority",name)) { - jffs2_compression_mode = JFFS2_COMPR_MODE_PRIORITY; + c->compression_mode = JFFS2_COMPR_MODE_PRIORITY; return 0; } if (!strcmp("size",name)) { - jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; + c->compression_mode = JFFS2_COMPR_MODE_SIZE; return 0; } return 1; @@ -404,7 +419,6 @@ reinsert: return 0; } -#endif void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig) { @@ -425,18 +439,6 @@ int jffs2_compressors_init(void) jffs2_rubinmips_init(); jffs2_dynrubin_init(); #endif -/* Setting default compression mode */ -#ifdef CONFIG_JFFS2_CMODE_NONE - jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; - D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");) -#else -#ifdef CONFIG_JFFS2_CMODE_SIZE - jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; - D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");) -#else - D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");) -#endif -#endif return 0; } diff -rup linux-2.6.15/fs/jffs2/compr.h linux-2.6.15-jffs2-mountoptions/fs/jffs2/compr.h --- linux-2.6.15/fs/jffs2/compr.h 2006-01-03 07:33:54.000000000 +0100 +++ linux-2.6.15-jffs2-mountoptions/fs/jffs2/compr.h 2006-05-01 16:52:51.000000000 +0200 @@ -7,7 +7,7 @@ * For licensing information, see the file 'LICENCE' in the * jffs2 directory. * - * $Id: compr.h,v 1.9 2005/11/07 11:14:38 gleixner Exp $ + * $Id: compr.h,v 1.1.2.1 2006/05/01 14:52:51 rln Exp $ * */ @@ -37,6 +37,7 @@ #define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */ #define JFFS2_DYNRUBIN_DISABLED /* for decompression */ +#define JFFS2_COMPR_MODE_UNKNOWN (-1) #define JFFS2_COMPR_MODE_NONE 0 #define JFFS2_COMPR_MODE_PRIORITY 1 #define JFFS2_COMPR_MODE_SIZE 2 @@ -76,15 +77,14 @@ int jffs2_decompress(struct jffs2_sb_inf void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig); -#ifdef CONFIG_JFFS2_PROC int jffs2_enable_compressor_name(const char *name); int jffs2_disable_compressor_name(const char *name); -int jffs2_set_compression_mode_name(const char *mode_name); -char *jffs2_get_compression_mode_name(void); +int jffs2_set_compression_mode_name(struct jffs2_sb_info *c, const char *mode_name); +char *jffs2_get_compression_mode_name(const struct jffs2_sb_info *c); +int jffs2_get_dflt_compression_mode(void); int jffs2_set_compressor_priority(const char *mode_name, int priority); char *jffs2_list_compressors(void); char *jffs2_stats(void); -#endif /* Compressor modules */ /* These functions will be called by jffs2_compressors_init/exit */ diff -rup linux-2.6.15/fs/jffs2/fs.c linux-2.6.15-jffs2-mountoptions/fs/jffs2/fs.c --- linux-2.6.15/fs/jffs2/fs.c 2006-01-03 07:33:54.000000000 +0100 +++ linux-2.6.15-jffs2-mountoptions/fs/jffs2/fs.c 2006-05-01 16:52:51.000000000 +0200 @@ -7,7 +7,7 @@ * * For licensing information, see the file 'LICENCE' in this directory. * - * $Id: fs.c,v 1.66 2005/09/27 13:17:29 dedekind Exp $ + * $Id: fs.c,v 1.1.2.1 2006/05/01 14:52:51 rln Exp $ * */ @@ -22,7 +22,9 @@ #include #include #include +#include #include "nodelist.h" +#include "compr.h" static int jffs2_flash_setup(struct jffs2_sb_info *c); @@ -339,6 +341,49 @@ void jffs2_dirty_inode(struct inode *ino jffs2_do_setattr(inode, &iattr); } + +enum { + OPT_COMPRESSOR, + OPT_ERR +}; + +static match_table_t tokens = { + { OPT_COMPRESSOR, "compressor=%s" }, + { OPT_ERR, NULL } +}; + + +static int parse_options(struct jffs2_sb_info *c, char *data) { + substring_t args[MAX_OPT_ARGS]; + int needCompr = (c->compression_mode == JFFS2_COMPR_MODE_UNKNOWN); /* Set default only once. */ + int token; + char *p, *arg; + + while (data && strlen(data) && (p = strsep(&data, ","))) { + if (!*p) continue; + + token = match_token(p, tokens, args); + switch (token) { + case OPT_COMPRESSOR: + arg = match_strdup(&args[0]); + needCompr = jffs2_set_compression_mode_name(c, arg); + kfree(arg); + break; + + default: + break; + } + } + + /* Was a valid compressor set by user? + * Otherwise set default. */ + if(needCompr) c->compression_mode = jffs2_get_dflt_compression_mode(); + D1(printk(KERN_DEBUG "jffs2 parse_options() compressor=%d\n", c->compression_mode)); + + return 0; +} + + int jffs2_remount_fs (struct super_block *sb, int *flags, char *data) { struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); @@ -361,6 +406,7 @@ int jffs2_remount_fs (struct super_block jffs2_start_garbage_collect_thread(c); *flags |= MS_NOATIME; + parse_options(c, data); return 0; } @@ -491,6 +537,10 @@ int jffs2_do_fill_super(struct super_blo } memset(c->inocache_list, 0, INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *)); + /* Parse mount options */ + c->compression_mode = JFFS2_COMPR_MODE_UNKNOWN; + parse_options(c, data); + if ((ret = jffs2_do_mount_fs(c))) goto out_inohash; diff -rup linux-2.6.15/include/linux/jffs2_fs_sb.h linux-2.6.15-jffs2-mountoptions/include/linux/jffs2_fs_sb.h --- linux-2.6.15/include/linux/jffs2_fs_sb.h 2006-01-04 07:13:46.000000000 +0100 +++ linux-2.6.15-jffs2-mountoptions/include/linux/jffs2_fs_sb.h 2006-05-01 16:52:51.000000000 +0200 @@ -1,4 +1,4 @@ -/* $Id: jffs2_fs_sb.h,v 1.54 2005/09/21 13:37:34 dedekind Exp $ */ +/* $Id: jffs2_fs_sb.h,v 1.1.2.1 2006/05/01 14:52:51 rln Exp $ */ #ifndef _JFFS2_FS_SB #define _JFFS2_FS_SB @@ -14,8 +14,8 @@ #include #define JFFS2_SB_FLAG_RO 1 -#define JFFS2_SB_FLAG_SCANNING 2 /* Flash scanning is in progress */ -#define JFFS2_SB_FLAG_BUILDING 4 /* File system building is in progress */ +#define JFFS2_SB_FLAG_SCANNING 2 /* Flash scanning is in progress */ +#define JFFS2_SB_FLAG_BUILDING 4 /* File system building is in progress */ struct jffs2_inodirty; @@ -30,6 +30,7 @@ struct jffs2_sb_info { uint32_t checked_ino; unsigned int flags; + int compression_mode; struct task_struct *gc_task; /* GC task struct */ struct completion gc_thread_start; /* GC thread start completion */