diff options
author | Sven Schmidt <4sschmid@informatik.uni-hamburg.de> | 2017-02-24 18:01:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-24 20:46:57 -0500 |
commit | d21b5ff12df45a65bb220c7e8103a5f0f5609377 (patch) | |
tree | 965462c0aa0797c11e5411313d0dc48db91e5b79 | |
parent | 73a15ac6d5413caaee95979e318df58d4ee6d9a3 (diff) |
fs/pstore: fs/squashfs: change usage of LZ4 to work with new LZ4 version
Update fs/pstore and fs/squashfs to use the updated functions from the
new LZ4 module.
Link: http://lkml.kernel.org/r/1486321748-19085-5-git-send-email-4sschmid@informatik.uni-hamburg.de
Signed-off-by: Sven Schmidt <4sschmid@informatik.uni-hamburg.de>
Cc: Bongkyu Kim <bongkyu.kim@lge.com>
Cc: Rui Salvaterra <rsalvaterra@gmail.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David S. Miller <davem@davemloft.net>
Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Colin Cross <ccross@android.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/pstore/platform.c | 22 | ||||
-rw-r--r-- | fs/squashfs/lz4_wrapper.c | 12 |
2 files changed, 19 insertions, 15 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 729677e18e36..efab7b64925b 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c | |||
@@ -342,31 +342,35 @@ static int compress_lz4(const void *in, void *out, size_t inlen, size_t outlen) | |||
342 | { | 342 | { |
343 | int ret; | 343 | int ret; |
344 | 344 | ||
345 | ret = lz4_compress(in, inlen, out, &outlen, workspace); | 345 | ret = LZ4_compress_default(in, out, inlen, outlen, workspace); |
346 | if (ret) { | 346 | if (!ret) { |
347 | pr_err("lz4_compress error, ret = %d!\n", ret); | 347 | pr_err("LZ4_compress_default error; compression failed!\n"); |
348 | return -EIO; | 348 | return -EIO; |
349 | } | 349 | } |
350 | 350 | ||
351 | return outlen; | 351 | return ret; |
352 | } | 352 | } |
353 | 353 | ||
354 | static int decompress_lz4(void *in, void *out, size_t inlen, size_t outlen) | 354 | static int decompress_lz4(void *in, void *out, size_t inlen, size_t outlen) |
355 | { | 355 | { |
356 | int ret; | 356 | int ret; |
357 | 357 | ||
358 | ret = lz4_decompress_unknownoutputsize(in, inlen, out, &outlen); | 358 | ret = LZ4_decompress_safe(in, out, inlen, outlen); |
359 | if (ret) { | 359 | if (ret < 0) { |
360 | pr_err("lz4_decompress error, ret = %d!\n", ret); | 360 | /* |
361 | * LZ4_decompress_safe will return an error code | ||
362 | * (< 0) if decompression failed | ||
363 | */ | ||
364 | pr_err("LZ4_decompress_safe error, ret = %d!\n", ret); | ||
361 | return -EIO; | 365 | return -EIO; |
362 | } | 366 | } |
363 | 367 | ||
364 | return outlen; | 368 | return ret; |
365 | } | 369 | } |
366 | 370 | ||
367 | static void allocate_lz4(void) | 371 | static void allocate_lz4(void) |
368 | { | 372 | { |
369 | big_oops_buf_sz = lz4_compressbound(psinfo->bufsize); | 373 | big_oops_buf_sz = LZ4_compressBound(psinfo->bufsize); |
370 | big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL); | 374 | big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL); |
371 | if (big_oops_buf) { | 375 | if (big_oops_buf) { |
372 | workspace = kmalloc(LZ4_MEM_COMPRESS, GFP_KERNEL); | 376 | workspace = kmalloc(LZ4_MEM_COMPRESS, GFP_KERNEL); |
diff --git a/fs/squashfs/lz4_wrapper.c b/fs/squashfs/lz4_wrapper.c index ff4468bd18b0..95da65366548 100644 --- a/fs/squashfs/lz4_wrapper.c +++ b/fs/squashfs/lz4_wrapper.c | |||
@@ -97,7 +97,6 @@ static int lz4_uncompress(struct squashfs_sb_info *msblk, void *strm, | |||
97 | struct squashfs_lz4 *stream = strm; | 97 | struct squashfs_lz4 *stream = strm; |
98 | void *buff = stream->input, *data; | 98 | void *buff = stream->input, *data; |
99 | int avail, i, bytes = length, res; | 99 | int avail, i, bytes = length, res; |
100 | size_t dest_len = output->length; | ||
101 | 100 | ||
102 | for (i = 0; i < b; i++) { | 101 | for (i = 0; i < b; i++) { |
103 | avail = min(bytes, msblk->devblksize - offset); | 102 | avail = min(bytes, msblk->devblksize - offset); |
@@ -108,12 +107,13 @@ static int lz4_uncompress(struct squashfs_sb_info *msblk, void *strm, | |||
108 | put_bh(bh[i]); | 107 | put_bh(bh[i]); |
109 | } | 108 | } |
110 | 109 | ||
111 | res = lz4_decompress_unknownoutputsize(stream->input, length, | 110 | res = LZ4_decompress_safe(stream->input, stream->output, |
112 | stream->output, &dest_len); | 111 | length, output->length); |
113 | if (res) | 112 | |
113 | if (res < 0) | ||
114 | return -EIO; | 114 | return -EIO; |
115 | 115 | ||
116 | bytes = dest_len; | 116 | bytes = res; |
117 | data = squashfs_first_page(output); | 117 | data = squashfs_first_page(output); |
118 | buff = stream->output; | 118 | buff = stream->output; |
119 | while (data) { | 119 | while (data) { |
@@ -128,7 +128,7 @@ static int lz4_uncompress(struct squashfs_sb_info *msblk, void *strm, | |||
128 | } | 128 | } |
129 | squashfs_finish_page(output); | 129 | squashfs_finish_page(output); |
130 | 130 | ||
131 | return dest_len; | 131 | return res; |
132 | } | 132 | } |
133 | 133 | ||
134 | const struct squashfs_decompressor squashfs_lz4_comp_ops = { | 134 | const struct squashfs_decompressor squashfs_lz4_comp_ops = { |