--- zzzz-none-000/linux-3.10.107/fs/ubifs/compress.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/fs/ubifs/compress.c 2021-02-04 17:41:59.000000000 +0000 @@ -71,6 +71,24 @@ }; #endif +#ifdef CONFIG_UBIFS_FS_XZ +static DEFINE_MUTEX(xz_enc_mutex); +static DEFINE_MUTEX(xz_dec_mutex); + +static struct ubifs_compressor xz_compr = { + .compr_type = UBIFS_COMPR_XZ, + .comp_mutex = &xz_enc_mutex, + .decomp_mutex = &xz_dec_mutex, + .name = "xz", + .capi_name = "xz", +}; +#else +static struct ubifs_compressor xz_compr = { + .compr_type = UBIFS_COMPR_XZ, + .name = "xz", +}; +#endif + /* All UBIFS compressors */ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; @@ -92,8 +110,8 @@ * Note, if the input buffer was not compressed, it is copied to the output * buffer and %UBIFS_COMPR_NONE is returned in @compr_type. */ -void ubifs_compress(const void *in_buf, int in_len, void *out_buf, int *out_len, - int *compr_type) +void ubifs_compress(const struct ubifs_info *c, const void *in_buf, + int in_len, void *out_buf, int *out_len, int *compr_type) { int err; struct ubifs_compressor *compr = ubifs_compressors[*compr_type]; @@ -112,9 +130,9 @@ if (compr->comp_mutex) mutex_unlock(compr->comp_mutex); if (unlikely(err)) { - ubifs_warn("cannot compress %d bytes, compressor %s, error %d, leave data uncompressed", + ubifs_warn(c, "cannot compress %d bytes, compressor %s, error %d, leave data uncompressed", in_len, compr->name, err); - goto no_compr; + goto no_compr; } /* @@ -144,21 +162,21 @@ * The length of the uncompressed data is returned in @out_len. This functions * returns %0 on success or a negative error code on failure. */ -int ubifs_decompress(const void *in_buf, int in_len, void *out_buf, - int *out_len, int compr_type) +int ubifs_decompress(const struct ubifs_info *c, const void *in_buf, + int in_len, void *out_buf, int *out_len, int compr_type) { int err; struct ubifs_compressor *compr; if (unlikely(compr_type < 0 || compr_type >= UBIFS_COMPR_TYPES_CNT)) { - ubifs_err("invalid compression type %d", compr_type); + ubifs_err(c, "invalid compression type %d", compr_type); return -EINVAL; } compr = ubifs_compressors[compr_type]; if (unlikely(!compr->capi_name)) { - ubifs_err("%s compression is not compiled in", compr->name); + ubifs_err(c, "%s compression is not compiled in", compr->name); return -EINVAL; } @@ -175,7 +193,7 @@ if (compr->decomp_mutex) mutex_unlock(compr->decomp_mutex); if (err) - ubifs_err("cannot decompress %d bytes, compressor %s, error %d", + ubifs_err(c, "cannot decompress %d bytes, compressor %s, error %d", in_len, compr->name, err); return err; @@ -193,8 +211,8 @@ if (compr->capi_name) { compr->cc = crypto_alloc_comp(compr->capi_name, 0, 0); if (IS_ERR(compr->cc)) { - ubifs_err("cannot initialize compressor %s, error %ld", - compr->name, PTR_ERR(compr->cc)); + pr_err("UBIFS error (pid %d): cannot initialize compressor %s, error %ld", + current->pid, compr->name, PTR_ERR(compr->cc)); return PTR_ERR(compr->cc); } } @@ -232,9 +250,15 @@ if (err) goto out_lzo; + err = compr_init(&xz_compr); + if (err) + goto out_zlib; + ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr; return 0; +out_zlib: + compr_exit(&zlib_compr); out_lzo: compr_exit(&lzo_compr); return err; @@ -247,4 +271,5 @@ { compr_exit(&lzo_compr); compr_exit(&zlib_compr); + compr_exit(&xz_compr); }