Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * JFFS2 -- Journalling Flash File System, Version 2. |
| 3 | * |
David Woodhouse | c00c310 | 2007-04-25 14:16:47 +0100 | [diff] [blame] | 4 | * Copyright © 2001-2007 Red Hat, Inc. |
David Woodhouse | 6088c05 | 2010-08-08 14:15:22 +0100 | [diff] [blame] | 5 | * Copyright © 2004-2010 David Woodhouse <dwmw2@infradead.org> |
David Woodhouse | c00c310 | 2007-04-25 14:16:47 +0100 | [diff] [blame] | 6 | * Copyright © 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>, |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 7 | * University of Szeged, Hungary |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
David Woodhouse | 6088c05 | 2010-08-08 14:15:22 +0100 | [diff] [blame] | 9 | * Created by Arjan van de Ven <arjan@infradead.org> |
| 10 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * For licensing information, see the file 'LICENCE' in this directory. |
| 12 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include "compr.h" |
| 16 | |
| 17 | static DEFINE_SPINLOCK(jffs2_compressor_list_lock); |
| 18 | |
| 19 | /* Available compressors are on this list */ |
| 20 | static LIST_HEAD(jffs2_compressor_list); |
| 21 | |
| 22 | /* Actual compression mode */ |
| 23 | static int jffs2_compression_mode = JFFS2_COMPR_MODE_PRIORITY; |
| 24 | |
| 25 | /* Statistics for blocks stored without compression */ |
| 26 | static uint32_t none_stat_compr_blocks=0,none_stat_decompr_blocks=0,none_stat_compr_size=0; |
| 27 | |
Richard Purdie | 3b23c1f | 2007-07-10 10:28:42 +0100 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | * Return 1 to use this compression |
| 31 | */ |
| 32 | static int jffs2_is_best_compression(struct jffs2_compressor *this, |
| 33 | struct jffs2_compressor *best, uint32_t size, uint32_t bestsize) |
| 34 | { |
| 35 | switch (jffs2_compression_mode) { |
| 36 | case JFFS2_COMPR_MODE_SIZE: |
| 37 | if (bestsize > size) |
| 38 | return 1; |
| 39 | return 0; |
| 40 | case JFFS2_COMPR_MODE_FAVOURLZO: |
| 41 | if ((this->compr == JFFS2_COMPR_LZO) && (bestsize > size)) |
| 42 | return 1; |
| 43 | if ((best->compr != JFFS2_COMPR_LZO) && (bestsize > size)) |
| 44 | return 1; |
| 45 | if ((this->compr == JFFS2_COMPR_LZO) && (bestsize > (size * FAVOUR_LZO_PERCENT / 100))) |
| 46 | return 1; |
| 47 | if ((bestsize * FAVOUR_LZO_PERCENT / 100) > size) |
| 48 | return 1; |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | /* Shouldn't happen */ |
| 53 | return 0; |
| 54 | } |
| 55 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | /* jffs2_compress: |
Geert Uytterhoeven | faa5c2a | 2008-10-17 16:19:45 +0200 | [diff] [blame] | 57 | * @data_in: Pointer to uncompressed data |
| 58 | * @cpage_out: Pointer to returned pointer to buffer for compressed data |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | * @datalen: On entry, holds the amount of data available for compression. |
| 60 | * On exit, expected to hold the amount of data actually compressed. |
| 61 | * @cdatalen: On entry, holds the amount of space available for compressed |
| 62 | * data. On exit, expected to hold the actual size of the compressed |
| 63 | * data. |
| 64 | * |
| 65 | * Returns: Lower byte to be stored with data indicating compression type used. |
Thomas Gleixner | 182ec4e | 2005-11-07 11:16:07 +0000 | [diff] [blame] | 66 | * Zero is used to show that the data could not be compressed - the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | * compressed version was actually larger than the original. |
| 68 | * Upper byte will be used later. (soon) |
| 69 | * |
| 70 | * If the cdata buffer isn't large enough to hold all the uncompressed data, |
Thomas Gleixner | 182ec4e | 2005-11-07 11:16:07 +0000 | [diff] [blame] | 71 | * jffs2_compress should compress as much as will fit, and should set |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | * *datalen accordingly to show the amount of data which were compressed. |
| 73 | */ |
| 74 | uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 75 | unsigned char *data_in, unsigned char **cpage_out, |
| 76 | uint32_t *datalen, uint32_t *cdatalen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | { |
| 78 | int ret = JFFS2_COMPR_NONE; |
Andres Salomon | 92abc47 | 2011-10-16 18:15:16 -0700 | [diff] [blame^] | 79 | int mode, compr_ret; |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 80 | struct jffs2_compressor *this, *best=NULL; |
| 81 | unsigned char *output_buf = NULL, *tmp_buf; |
| 82 | uint32_t orig_slen, orig_dlen; |
| 83 | uint32_t best_slen=0, best_dlen=0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Andres Salomon | 92abc47 | 2011-10-16 18:15:16 -0700 | [diff] [blame^] | 85 | if (c->mount_opts.override_compr) |
| 86 | mode = c->mount_opts.compr; |
| 87 | else |
| 88 | mode = jffs2_compression_mode; |
| 89 | |
| 90 | switch (mode) { |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 91 | case JFFS2_COMPR_MODE_NONE: |
| 92 | break; |
| 93 | case JFFS2_COMPR_MODE_PRIORITY: |
| 94 | output_buf = kmalloc(*cdatalen,GFP_KERNEL); |
| 95 | if (!output_buf) { |
| 96 | printk(KERN_WARNING "JFFS2: No memory for compressor allocation. Compression failed.\n"); |
| 97 | goto out; |
| 98 | } |
| 99 | orig_slen = *datalen; |
| 100 | orig_dlen = *cdatalen; |
| 101 | spin_lock(&jffs2_compressor_list_lock); |
| 102 | list_for_each_entry(this, &jffs2_compressor_list, list) { |
| 103 | /* Skip decompress-only backwards-compatibility and disabled modules */ |
| 104 | if ((!this->compress)||(this->disabled)) |
| 105 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 107 | this->usecount++; |
| 108 | spin_unlock(&jffs2_compressor_list_lock); |
| 109 | *datalen = orig_slen; |
| 110 | *cdatalen = orig_dlen; |
Mike Frysinger | 088bd45 | 2010-09-22 22:52:33 -0400 | [diff] [blame] | 111 | compr_ret = this->compress(data_in, output_buf, datalen, cdatalen); |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 112 | spin_lock(&jffs2_compressor_list_lock); |
| 113 | this->usecount--; |
| 114 | if (!compr_ret) { |
| 115 | ret = this->compr; |
| 116 | this->stat_compr_blocks++; |
| 117 | this->stat_compr_orig_size += *datalen; |
| 118 | this->stat_compr_new_size += *cdatalen; |
| 119 | break; |
| 120 | } |
| 121 | } |
| 122 | spin_unlock(&jffs2_compressor_list_lock); |
| 123 | if (ret == JFFS2_COMPR_NONE) |
| 124 | kfree(output_buf); |
| 125 | break; |
| 126 | case JFFS2_COMPR_MODE_SIZE: |
Richard Purdie | 3b23c1f | 2007-07-10 10:28:42 +0100 | [diff] [blame] | 127 | case JFFS2_COMPR_MODE_FAVOURLZO: |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 128 | orig_slen = *datalen; |
| 129 | orig_dlen = *cdatalen; |
| 130 | spin_lock(&jffs2_compressor_list_lock); |
| 131 | list_for_each_entry(this, &jffs2_compressor_list, list) { |
| 132 | /* Skip decompress-only backwards-compatibility and disabled modules */ |
| 133 | if ((!this->compress)||(this->disabled)) |
| 134 | continue; |
| 135 | /* Allocating memory for output buffer if necessary */ |
Richard Purdie | 3b23c1f | 2007-07-10 10:28:42 +0100 | [diff] [blame] | 136 | if ((this->compr_buf_size < orig_slen) && (this->compr_buf)) { |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 137 | spin_unlock(&jffs2_compressor_list_lock); |
| 138 | kfree(this->compr_buf); |
| 139 | spin_lock(&jffs2_compressor_list_lock); |
| 140 | this->compr_buf_size=0; |
| 141 | this->compr_buf=NULL; |
| 142 | } |
| 143 | if (!this->compr_buf) { |
| 144 | spin_unlock(&jffs2_compressor_list_lock); |
Richard Purdie | 3b23c1f | 2007-07-10 10:28:42 +0100 | [diff] [blame] | 145 | tmp_buf = kmalloc(orig_slen, GFP_KERNEL); |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 146 | spin_lock(&jffs2_compressor_list_lock); |
| 147 | if (!tmp_buf) { |
Richard Purdie | 3b23c1f | 2007-07-10 10:28:42 +0100 | [diff] [blame] | 148 | printk(KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n", orig_slen); |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 149 | continue; |
| 150 | } |
| 151 | else { |
| 152 | this->compr_buf = tmp_buf; |
Richard Purdie | 3b23c1f | 2007-07-10 10:28:42 +0100 | [diff] [blame] | 153 | this->compr_buf_size = orig_slen; |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 154 | } |
| 155 | } |
| 156 | this->usecount++; |
| 157 | spin_unlock(&jffs2_compressor_list_lock); |
| 158 | *datalen = orig_slen; |
| 159 | *cdatalen = orig_dlen; |
Mike Frysinger | 088bd45 | 2010-09-22 22:52:33 -0400 | [diff] [blame] | 160 | compr_ret = this->compress(data_in, this->compr_buf, datalen, cdatalen); |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 161 | spin_lock(&jffs2_compressor_list_lock); |
| 162 | this->usecount--; |
| 163 | if (!compr_ret) { |
Richard Purdie | 3b23c1f | 2007-07-10 10:28:42 +0100 | [diff] [blame] | 164 | if (((!best_dlen) || jffs2_is_best_compression(this, best, *cdatalen, best_dlen)) |
| 165 | && (*cdatalen < *datalen)) { |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 166 | best_dlen = *cdatalen; |
| 167 | best_slen = *datalen; |
| 168 | best = this; |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | if (best_dlen) { |
| 173 | *cdatalen = best_dlen; |
| 174 | *datalen = best_slen; |
| 175 | output_buf = best->compr_buf; |
| 176 | best->compr_buf = NULL; |
| 177 | best->compr_buf_size = 0; |
| 178 | best->stat_compr_blocks++; |
| 179 | best->stat_compr_orig_size += best_slen; |
| 180 | best->stat_compr_new_size += best_dlen; |
| 181 | ret = best->compr; |
| 182 | } |
| 183 | spin_unlock(&jffs2_compressor_list_lock); |
| 184 | break; |
| 185 | default: |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 186 | printk(KERN_ERR "JFFS2: unknown compression mode.\n"); |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 187 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | out: |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 189 | if (ret == JFFS2_COMPR_NONE) { |
| 190 | *cpage_out = data_in; |
| 191 | *datalen = *cdatalen; |
| 192 | none_stat_compr_blocks++; |
| 193 | none_stat_compr_size += *datalen; |
| 194 | } |
| 195 | else { |
| 196 | *cpage_out = output_buf; |
| 197 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | return ret; |
| 199 | } |
| 200 | |
| 201 | int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
Thomas Gleixner | 182ec4e | 2005-11-07 11:16:07 +0000 | [diff] [blame] | 202 | uint16_t comprtype, unsigned char *cdata_in, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | unsigned char *data_out, uint32_t cdatalen, uint32_t datalen) |
| 204 | { |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 205 | struct jffs2_compressor *this; |
| 206 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | |
| 208 | /* Older code had a bug where it would write non-zero 'usercompr' |
| 209 | fields. Deal with it. */ |
| 210 | if ((comprtype & 0xff) <= JFFS2_COMPR_ZLIB) |
| 211 | comprtype &= 0xff; |
| 212 | |
| 213 | switch (comprtype & 0xff) { |
| 214 | case JFFS2_COMPR_NONE: |
| 215 | /* This should be special-cased elsewhere, but we might as well deal with it */ |
| 216 | memcpy(data_out, cdata_in, datalen); |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 217 | none_stat_decompr_blocks++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | break; |
| 219 | case JFFS2_COMPR_ZERO: |
| 220 | memset(data_out, 0, datalen); |
| 221 | break; |
| 222 | default: |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 223 | spin_lock(&jffs2_compressor_list_lock); |
| 224 | list_for_each_entry(this, &jffs2_compressor_list, list) { |
| 225 | if (comprtype == this->compr) { |
| 226 | this->usecount++; |
| 227 | spin_unlock(&jffs2_compressor_list_lock); |
Mike Frysinger | 088bd45 | 2010-09-22 22:52:33 -0400 | [diff] [blame] | 228 | ret = this->decompress(cdata_in, data_out, cdatalen, datalen); |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 229 | spin_lock(&jffs2_compressor_list_lock); |
| 230 | if (ret) { |
| 231 | printk(KERN_WARNING "Decompressor \"%s\" returned %d\n", this->name, ret); |
| 232 | } |
| 233 | else { |
| 234 | this->stat_decompr_blocks++; |
| 235 | } |
| 236 | this->usecount--; |
| 237 | spin_unlock(&jffs2_compressor_list_lock); |
| 238 | return ret; |
| 239 | } |
| 240 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | printk(KERN_WARNING "JFFS2 compression type 0x%02x not available.\n", comprtype); |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 242 | spin_unlock(&jffs2_compressor_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | return -EIO; |
| 244 | } |
| 245 | return 0; |
| 246 | } |
| 247 | |
| 248 | int jffs2_register_compressor(struct jffs2_compressor *comp) |
| 249 | { |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 250 | struct jffs2_compressor *this; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 252 | if (!comp->name) { |
| 253 | printk(KERN_WARNING "NULL compressor name at registering JFFS2 compressor. Failed.\n"); |
| 254 | return -1; |
| 255 | } |
| 256 | comp->compr_buf_size=0; |
| 257 | comp->compr_buf=NULL; |
| 258 | comp->usecount=0; |
| 259 | comp->stat_compr_orig_size=0; |
| 260 | comp->stat_compr_new_size=0; |
| 261 | comp->stat_compr_blocks=0; |
| 262 | comp->stat_decompr_blocks=0; |
| 263 | D1(printk(KERN_DEBUG "Registering JFFS2 compressor \"%s\"\n", comp->name)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 265 | spin_lock(&jffs2_compressor_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 267 | list_for_each_entry(this, &jffs2_compressor_list, list) { |
| 268 | if (this->priority < comp->priority) { |
| 269 | list_add(&comp->list, this->list.prev); |
| 270 | goto out; |
| 271 | } |
| 272 | } |
| 273 | list_add_tail(&comp->list, &jffs2_compressor_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | out: |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 275 | D2(list_for_each_entry(this, &jffs2_compressor_list, list) { |
| 276 | printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority); |
| 277 | }) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 279 | spin_unlock(&jffs2_compressor_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 281 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | int jffs2_unregister_compressor(struct jffs2_compressor *comp) |
| 285 | { |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 286 | D2(struct jffs2_compressor *this;) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 288 | D1(printk(KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n", comp->name)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 290 | spin_lock(&jffs2_compressor_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 292 | if (comp->usecount) { |
| 293 | spin_unlock(&jffs2_compressor_list_lock); |
| 294 | printk(KERN_WARNING "JFFS2: Compressor modul is in use. Unregister failed.\n"); |
| 295 | return -1; |
| 296 | } |
| 297 | list_del(&comp->list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 299 | D2(list_for_each_entry(this, &jffs2_compressor_list, list) { |
| 300 | printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority); |
| 301 | }) |
| 302 | spin_unlock(&jffs2_compressor_list_lock); |
| 303 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig) |
| 307 | { |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 308 | if (orig != comprbuf) |
| 309 | kfree(comprbuf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | } |
| 311 | |
David Brownell | 7d2beb1 | 2006-05-16 16:08:10 +0100 | [diff] [blame] | 312 | int __init jffs2_compressors_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | { |
| 314 | /* Registering compressors */ |
| 315 | #ifdef CONFIG_JFFS2_ZLIB |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 316 | jffs2_zlib_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | #endif |
| 318 | #ifdef CONFIG_JFFS2_RTIME |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 319 | jffs2_rtime_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | #endif |
| 321 | #ifdef CONFIG_JFFS2_RUBIN |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 322 | jffs2_rubinmips_init(); |
| 323 | jffs2_dynrubin_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | #endif |
Richard Purdie | c799aca | 2007-07-10 10:28:36 +0100 | [diff] [blame] | 325 | #ifdef CONFIG_JFFS2_LZO |
| 326 | jffs2_lzo_init(); |
| 327 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | /* Setting default compression mode */ |
| 329 | #ifdef CONFIG_JFFS2_CMODE_NONE |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 330 | jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; |
| 331 | D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | #else |
| 333 | #ifdef CONFIG_JFFS2_CMODE_SIZE |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 334 | jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; |
| 335 | D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | #else |
Richard Purdie | 3b23c1f | 2007-07-10 10:28:42 +0100 | [diff] [blame] | 337 | #ifdef CONFIG_JFFS2_CMODE_FAVOURLZO |
| 338 | jffs2_compression_mode = JFFS2_COMPR_MODE_FAVOURLZO; |
| 339 | D1(printk(KERN_INFO "JFFS2: default compression mode: favourlzo\n");) |
| 340 | #else |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 341 | D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | #endif |
| 343 | #endif |
Richard Purdie | 3b23c1f | 2007-07-10 10:28:42 +0100 | [diff] [blame] | 344 | #endif |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 345 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | } |
| 347 | |
David Woodhouse | 3bcc86f | 2006-06-03 00:25:50 +0100 | [diff] [blame] | 348 | int jffs2_compressors_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | { |
| 350 | /* Unregistering compressors */ |
Richard Purdie | c799aca | 2007-07-10 10:28:36 +0100 | [diff] [blame] | 351 | #ifdef CONFIG_JFFS2_LZO |
| 352 | jffs2_lzo_exit(); |
| 353 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | #ifdef CONFIG_JFFS2_RUBIN |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 355 | jffs2_dynrubin_exit(); |
| 356 | jffs2_rubinmips_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | #endif |
| 358 | #ifdef CONFIG_JFFS2_RTIME |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 359 | jffs2_rtime_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | #endif |
| 361 | #ifdef CONFIG_JFFS2_ZLIB |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 362 | jffs2_zlib_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | #endif |
David Woodhouse | ef53cb0 | 2007-07-10 10:01:22 +0100 | [diff] [blame] | 364 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | } |