Skip to content

Commit cb3bee0

Browse files
geliangtangkees
authored andcommitted
pstore: Use crypto compress API
In the pstore compression part, we use zlib/lzo/lz4/lz4hc/842 compression algorithm API to implement pstore compression backends. But there are many repeat codes in these implementations. This patch uses crypto compress API to simplify these codes. 1) rewrite allocate_buf_for_compression, free_buf_for_compression, pstore_compress, pstore_decompress functions using crypto compress API. 2) drop compress, decompress, allocate, free functions in pstore_zbackend, and add zbufsize function to get each different compress buffer size. 3) use late_initcall to call ramoops_init later, to make sure the crypto subsystem has already initialized. 4) use 'unsigned int' type instead of 'size_t' in pstore_compress, pstore_decompress functions' length arguments. 5) rename 'zlib' to 'deflate' to follow the crypto API's name convention. Signed-off-by: Geliang Tang <geliangtang@gmail.com> [kees: tweaked error messages on allocation failures and Kconfig help] Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent f2531f1 commit cb3bee0

File tree

3 files changed

+84
-367
lines changed

3 files changed

+84
-367
lines changed

fs/pstore/Kconfig

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,47 @@ config PSTORE
1212
If you don't have a platform persistent store driver,
1313
say N.
1414

15-
config PSTORE_ZLIB_COMPRESS
16-
bool "ZLIB compression"
15+
config PSTORE_DEFLATE_COMPRESS
16+
bool "DEFLATE (ZLIB) compression"
1717
default y
1818
depends on PSTORE
19-
select ZLIB_DEFLATE
20-
select ZLIB_INFLATE
19+
select CRYPTO_DEFLATE
2120
help
22-
This option enables ZLIB compression algorithm support.
21+
This option enables DEFLATE (also known as ZLIB) compression
22+
algorithm support.
2323

2424
config PSTORE_LZO_COMPRESS
2525
bool "LZO compression"
2626
depends on PSTORE
27-
select LZO_COMPRESS
28-
select LZO_DECOMPRESS
27+
select CRYPTO_LZO
2928
help
3029
This option enables LZO compression algorithm support.
3130

3231
config PSTORE_LZ4_COMPRESS
3332
bool "LZ4 compression"
3433
depends on PSTORE
35-
select LZ4_COMPRESS
36-
select LZ4_DECOMPRESS
34+
select CRYPTO_LZ4
3735
help
3836
This option enables LZ4 compression algorithm support.
3937

4038
config PSTORE_LZ4HC_COMPRESS
4139
bool "LZ4HC compression"
4240
depends on PSTORE
43-
select LZ4HC_COMPRESS
44-
select LZ4_DECOMPRESS
41+
select CRYPTO_LZ4HC
4542
help
4643
This option enables LZ4HC (high compression) mode algorithm.
4744

4845
config PSTORE_842_COMPRESS
4946
bool "842 compression"
5047
depends on PSTORE
51-
select 842_COMPRESS
52-
select 842_DECOMPRESS
48+
select CRYPTO_842
5349
help
5450
This option enables 842 compression algorithm support.
5551

5652
config PSTORE_COMPRESS
5753
def_bool y
5854
depends on PSTORE
59-
depends on PSTORE_ZLIB_COMPRESS || PSTORE_LZO_COMPRESS || \
55+
depends on PSTORE_DEFLATE_COMPRESS || PSTORE_LZO_COMPRESS || \
6056
PSTORE_LZ4_COMPRESS || PSTORE_LZ4HC_COMPRESS || \
6157
PSTORE_842_COMPRESS
6258

@@ -69,12 +65,12 @@ choice
6965
the kernel command line.
7066

7167
Currently, pstore has support for 5 compression algorithms:
72-
zlib, lzo, lz4, lz4hc and 842.
68+
deflate, lzo, lz4, lz4hc and 842.
7369

74-
The default compression algorithm is zlib.
70+
The default compression algorithm is deflate.
7571

76-
config PSTORE_ZLIB_COMPRESS_DEFAULT
77-
bool "zlib" if PSTORE_ZLIB_COMPRESS=y
72+
config PSTORE_DEFLATE_COMPRESS_DEFAULT
73+
bool "deflate" if PSTORE_DEFLATE_COMPRESS=y
7874

7975
config PSTORE_LZO_COMPRESS_DEFAULT
8076
bool "lzo" if PSTORE_LZO_COMPRESS=y
@@ -93,7 +89,7 @@ endchoice
9389
config PSTORE_COMPRESS_DEFAULT
9490
string
9591
depends on PSTORE_COMPRESS
96-
default "zlib" if PSTORE_ZLIB_COMPRESS_DEFAULT
92+
default "deflate" if PSTORE_DEFLATE_COMPRESS_DEFAULT
9793
default "lzo" if PSTORE_LZO_COMPRESS_DEFAULT
9894
default "lz4" if PSTORE_LZ4_COMPRESS_DEFAULT
9995
default "lz4hc" if PSTORE_LZ4HC_COMPRESS_DEFAULT

0 commit comments

Comments
 (0)