jffs2: Add a "favourlzo" compression mode to jffs2
Subsystems (4)
PATCH 3/5 jffs2: Add a "favourlzo" compression mode to jffs2
Add a "favourlzo" compression mode to jffs2 which tries to optimise by size but gives lzo an advantage when comparing sizes. This means the faster lzo algorithm can be preferred when there isn't much difference in compressed size (the exact threshold can be changed).
--- fs/Kconfig | 7 +++++++ fs/jffs2/compr.c | 45 ++++++++++++++++++++++++++++++++++++++++----- fs/jffs2/compr.h | 3 +++ 3 files changed, 50 insertions(+), 5 deletions(-)
fs/Kconfig +7 -0
@@ -1359,6 +1359,13 @@ config JFFS2_CMODE_SIZE Tries all compressors and chooses the one which has the smallest result. +config JFFS2_CMODE_FAVOURLZO + bool "Favour LZO" + help + Tries all compressors and chooses the one which has the smallest + result but gives some preference to LZO (which has faster + decompression) at the expense of size. + endchoice config CRAMFS
fs/jffs2/compr.c +40 -5
90 lines not on this page · raw message
fs/jffs2/compr.h +3 -0
@@ -38,6 +38,9 @@#define JFFS2_COMPR_MODE_NONE 0#define JFFS2_COMPR_MODE_PRIORITY 1#define JFFS2_COMPR_MODE_SIZE 2 +#define JFFS2_COMPR_MODE_FAVOURLZO 3 + +#define FAVOUR_LZO_PERCENT 80struct jffs2_compressor {struct list_head list;
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 18 lines · On Tue, 01 May 2007 15:47:12 +0100 Richard Purdie wrote:
Add a "favourlzo" compression mode to jffs2 which tries to optimise by size but gives lzo an advantage when comparing sizes. This means the faster lzo algorithm can be preferred when there isn't much difference in compressed size (the exact threshold can be changed).
Signed-off-by Richard Purdie <[email protected]>--- fs/Kconfig | 7 +++++++ fs/jffs2/compr.c | 45 ++++++++++++++++++++++++++++++++++++++++----- fs/jffs2/compr.h | 3 +++ 3 files changed, 50 insertions(+), 5 deletions(-)fs/Kconfig +0
-0
fs/Kconfig config JFFS2_CMODE_SIZE · line 1367
Quoted 9 lines
fs/Kconfig +6
-0@@ -1359,6 +1359,13 @@ config JFFS2_CMODE_SIZE Tries all compressors and chooses the one which has the smallest result. +config JFFS2_CMODE_FAVOURLZO + bool "Favour LZO" + help + Tries all compressors and chooses the one which has the smallest + result but gives some preference to LZO (which has faster + decompression) at the expense of size.
Use tabs instead of spaces on "bool" and "help".
Use <tab><space><space> on help text lines.
Quoted 9 lines
fs/Kconfig +0
-0endchoice config CRAMFSfs/jffs2/compr.c +0
-0@@ -24,6 +24,34 @@ static int jffs2_compression_mode = JFFS2_COMPR_MODE_PRIORITY;/* Statistics for blocks stored without compression */
fs/jffs2/compr.c static int jffs2_compression_mode = JFFS2_COMPR_MODE_PRIORITY; · line 34
Quoted 10 lines
fs/jffs2/compr.c +8
-0static uint32_t none_stat_compr_blocks=0 ,none_stat_decompr_blocks=0 ,none_stat_compr_size=0 ; + +/* +* Return 1 to use this compression +*/ +static int jffs2_is_best_compression (struct jffs2_compressor *this, +struct jffs2_compressor *best,uint32_t size,uint32_t bestsize) +{ +switch (jffs2_compression_mode) {
Place case statements at same indent level as 'switch'.
fs/jffs2/compr.c static int jffs2_compression_mode = JFFS2_COMPR_MODE_PRIORITY; · line 44
Quoted 10 lines
fs/jffs2/compr.c +10
-0+case JFFS2_COMPR_MODE_SIZE : +if (bestsize > size) +return 1 ; +return 0 ; +case JFFS2_COMPR_MODE_FAVOURLZO : +if ((this->compr ==JFFS2_COMPR_LZO ) && (bestsize > size)) +return 1 ; +if ((best->compr !=JFFS2_COMPR_LZO ) && (bestsize > size)) +return 1 ; +if ((this->compr ==JFFS2_COMPR_LZO ) && (bestsize > (size *FAVOUR_LZO_PERCENT /100 )))
line too long.
Quoted 14 lines
fs/jffs2/compr.c +10
-0+return 1 ; +if ((bestsize *FAVOUR_LZO_PERCENT /100 ) > size) +return 1 ; + +return 0 ; + } +/* Shouldn't happen */ +return 0 ; +} +/* jffs2_compress: * @data: Pointer to uncompressed data * @cdata: Pointer to returned pointer to buffer for compressed data
fs/jffs2/compr.c uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, · line 138
Quoted 5 lines
fs/jffs2/compr.c +1
-1@@ -106,15 +135,15 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, }if (!this->compr_buf) {spin_unlock (&jffs2_compressor_list_lock); - tmp_buf =kmalloc (orig_dlen,GFP_KERNEL ); + tmp_buf =kmalloc (orig_slen,GFP_KERNEL );
space after comma
fs/jffs2/compr.c uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, · line 141
Quoted 4 lines
fs/jffs2/compr.c +1
-1spin_lock (&jffs2_compressor_list_lock);if (!tmp_buf) { -printk (KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n" ,orig_dlen); +printk (KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n" ,orig_slen);
space after comma. Line too long (except for David :).
Quoted 10 lines
fs/jffs2/compr.c +1
-1continue ; }else { this->compr_buf = tmp_buf; - this->compr_buf_size = orig_dlen; + this->compr_buf_size = orig_slen; } } this->usecount++;
fs/jffs2/compr.c uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, · line 157
Quoted 5 lines
fs/jffs2/compr.c +1
-1@@ -125,7 +154,8 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,spin_lock (&jffs2_compressor_list_lock); this->usecount--;if (!compr_ret) { -if ((!best_dlen)||(best_dlen>*cdatalen)) { + if (((!best_dlen) || jffs2_is_best_compression(this, best, *cdatalen, best_dlen))
line too long
fs/jffs2/compr.c uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, · line 161
Quoted 4 lines
fs/jffs2/compr.c +1
-0+ && (*cdatalen < *datalen)) { best_dlen = *cdatalen; best_slen = *datalen; best = this;
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***