Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ubifs: Add support for zstd compression.

zstd shows a good compression rate and is faster than lzo,
also on slow ARM cores.

Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Michele Dionisio <michele.dionisio@gmail.com>
[rw: rewrote commit message]
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Michele Dionisio and committed by
Richard Weinberger
eeabb986 817aa094

+40 -1
+10
fs/ubifs/Kconfig
··· 6 6 select CRYPTO if UBIFS_FS_ADVANCED_COMPR 7 7 select CRYPTO if UBIFS_FS_LZO 8 8 select CRYPTO if UBIFS_FS_ZLIB 9 + select CRYPTO if UBIFS_FS_ZSTD 9 10 select CRYPTO_LZO if UBIFS_FS_LZO 10 11 select CRYPTO_DEFLATE if UBIFS_FS_ZLIB 12 + select CRYPTO_ZSTD if UBIFS_FS_ZSTD 11 13 select CRYPTO_HASH_INFO 12 14 select UBIFS_FS_XATTR if FS_ENCRYPTION 13 15 depends on MTD_UBI ··· 39 37 default y 40 38 help 41 39 Zlib compresses better than LZO but it is slower. Say 'Y' if unsure. 40 + 41 + config UBIFS_FS_ZSTD 42 + bool "ZSTD compression support" if UBIFS_FS_ADVANCED_COMPR 43 + depends on UBIFS_FS 44 + default y 45 + help 46 + ZSTD compresses is a big win in speed over Zlib and 47 + in compression ratio over LZO. Say 'Y' if unsure. 42 48 43 49 config UBIFS_ATIME_SUPPORT 44 50 bool "Access time support"
+26 -1
fs/ubifs/compress.c
··· 59 59 }; 60 60 #endif 61 61 62 + #ifdef CONFIG_UBIFS_FS_ZSTD 63 + static DEFINE_MUTEX(zstd_enc_mutex); 64 + static DEFINE_MUTEX(zstd_dec_mutex); 65 + 66 + static struct ubifs_compressor zstd_compr = { 67 + .compr_type = UBIFS_COMPR_ZSTD, 68 + .comp_mutex = &zstd_enc_mutex, 69 + .decomp_mutex = &zstd_dec_mutex, 70 + .name = "zstd", 71 + .capi_name = "zstd", 72 + }; 73 + #else 74 + static struct ubifs_compressor zstd_compr = { 75 + .compr_type = UBIFS_COMPR_ZSTD, 76 + .name = "zstd", 77 + }; 78 + #endif 79 + 62 80 /* All UBIFS compressors */ 63 81 struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; 64 82 ··· 234 216 if (err) 235 217 return err; 236 218 237 - err = compr_init(&zlib_compr); 219 + err = compr_init(&zstd_compr); 238 220 if (err) 239 221 goto out_lzo; 222 + 223 + err = compr_init(&zlib_compr); 224 + if (err) 225 + goto out_zstd; 240 226 241 227 ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr; 242 228 return 0; 243 229 230 + out_zstd: 231 + compr_exit(&zstd_compr); 244 232 out_lzo: 245 233 compr_exit(&lzo_compr); 246 234 return err; ··· 259 235 { 260 236 compr_exit(&lzo_compr); 261 237 compr_exit(&zlib_compr); 238 + compr_exit(&zstd_compr); 262 239 }
+2
fs/ubifs/super.c
··· 1045 1045 c->mount_opts.compr_type = UBIFS_COMPR_LZO; 1046 1046 else if (!strcmp(name, "zlib")) 1047 1047 c->mount_opts.compr_type = UBIFS_COMPR_ZLIB; 1048 + else if (!strcmp(name, "zstd")) 1049 + c->mount_opts.compr_type = UBIFS_COMPR_ZSTD; 1048 1050 else { 1049 1051 ubifs_err(c, "unknown compressor \"%s\"", name); //FIXME: is c ready? 1050 1052 kfree(name);
+2
fs/ubifs/ubifs-media.h
··· 340 340 * UBIFS_COMPR_NONE: no compression 341 341 * UBIFS_COMPR_LZO: LZO compression 342 342 * UBIFS_COMPR_ZLIB: ZLIB compression 343 + * UBIFS_COMPR_ZSTD: ZSTD compression 343 344 * UBIFS_COMPR_TYPES_CNT: count of supported compression types 344 345 */ 345 346 enum { 346 347 UBIFS_COMPR_NONE, 347 348 UBIFS_COMPR_LZO, 348 349 UBIFS_COMPR_ZLIB, 350 + UBIFS_COMPR_ZSTD, 349 351 UBIFS_COMPR_TYPES_CNT, 350 352 }; 351 353