From ec5814c9a71c18cebc4c9527a92269279e3d3553 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Tue, 24 Oct 2023 22:02:55 +0800 Subject: [PATCH] EX-8311 csdc: allow specify 'fast'/'best' compression type Use lctl set_param osc.*.compress_type_{fast|best}=: to specify the compression_type:level for LL_COMPR_TYPE_FAST/ LL_COMPR_TYPE_BEST. lctl get_param osc.*.compress_type_{fast|best} will list these values. Signed-off-by: Bobi Jam Change-Id: Ifeff7f25e30fc0884f0c770a3b6d0798937b3c35 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52814 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/include/lustre/lustreapi.h | 90 ----------------- lustre/include/lustre_compr.h | 10 +- lustre/include/obd.h | 4 + lustre/include/uapi/linux/lustre/lustre_user.h | 130 ++++++++++++++++++++++++- lustre/ldlm/ldlm_lib.c | 5 + lustre/obdclass/lustre_compr.c | 73 ++++++++++++-- lustre/ofd/ofd_compress.c | 2 +- lustre/osc/lproc_osc.c | 103 ++++++++++++++++++++ lustre/osc/osc_compress.c | 7 +- lustre/osc/osc_compress.h | 2 +- lustre/osc/osc_request.c | 2 +- lustre/utils/liblustreapi.c | 37 ------- 12 files changed, 319 insertions(+), 146 deletions(-) diff --git a/lustre/include/lustre/lustreapi.h b/lustre/include/lustre/lustreapi.h index 8935250..3963a8a 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -1169,96 +1169,6 @@ static const struct comp_flag_name { { LCME_FL_NOCOMPR, "nocompr" }, }; - -/* map compression algorithm compress level to 4bits value */ -#ifndef LZ4_ACCELERATION_DEFAULT -#define LZ4_ACCELERATION_DEFAULT 1 -#endif - -#ifndef LZ4HC_DEFAULT_CLEVEL -#define LZ4HC_DEFAULT_CLEVEL 9 - -/* Level as stored in the Lustre file layout is limited to 4 bits, i.e. - * between 0 and 15. - * So we map the provided level to the lz4hc compression level - * simply by adding 1. - */ -static inline __u8 to_lz4hc_level(__u8 level) -{ - return level + 1; -} - -#endif - -#ifndef LZ4HC_MIN_CLEVEL -#define LZ4HC_MIN_CLEVEL 3 -#endif - -/* if user does not set level (-1), it would be set to the default level */ -static inline __u8 from_lz4hc_level(int level) -{ - if (level == -1) - return LZ4_ACCELERATION_DEFAULT - 1; - if ((level - 1) > 0xf) - return 0xf; - return level - 1; -} - -/* Level as stored in the Lustre file layout is limited to 4 bits, i.e. - * between 0 and 15. But for lz4fast, acceleration factor can be fine tuned - * with each successive value providing roughly +~3% to speed. - * So we map the provided level to the lz4 acceleration factor by keeping 1-9 - * as-is, and then going by steps of 3 so 12 15 18 21 24 27. - * And to mock lz4 command line utility behavior, the user provided factor is - * actually applied internally as 'value + 1'. - */ -static inline __u8 to_lz4fast_lvl(__u8 level) -{ - if (level < 10) - return level - 1; - return (level - 9) * 3 + 9 - 1; -} - -static inline __u8 from_lz4fast_lvl(int level) -{ - if (level <= 0) - return LZ4_ACCELERATION_DEFAULT + 1; - if (level < 10) - return level + 1; - if ((level - 9) / 3 + 9 + 1 > 0xf) - return 0xf; - return (level - 9) / 3 + 9 + 1; -} - -static inline __u8 from_gzip_level(int level) -{ - if (level == -1) - return 6; - if (level == 0) - return 1; - if (level > 9) - return 9; - return level; -} - -typedef __u8 (*from_compress_level)(int level); -typedef __u8 (*to_compress_level)(__u8 level); - -static const struct compr_type_name { - enum ll_compr_type ctn_compr_type; - const char *ctn_name; - from_compress_level ctn_from_compr_level; - to_compress_level ctn_to_compr_level; -} compr_type_table[] = { - { LL_COMPR_TYPE_NONE, "none", NULL, NULL }, - { LL_COMPR_TYPE_FAST, "fast", NULL, NULL }, - { LL_COMPR_TYPE_BEST, "best", NULL, NULL }, - { LL_COMPR_TYPE_GZIP, "gzip", from_gzip_level, NULL }, - { LL_COMPR_TYPE_LZ4FAST, "lz4fast", from_lz4fast_lvl, to_lz4fast_lvl }, - { LL_COMPR_TYPE_LZ4HC, "lz4", from_lz4hc_level, to_lz4hc_level }, - { LL_COMPR_TYPE_LZO, "lzo", NULL, NULL }, -}; - /* HSM component flags table */ static const struct hsm_flag_name { enum hsm_states hfn_flag; diff --git a/lustre/include/lustre_compr.h b/lustre/include/lustre_compr.h index 9a3b31e..c877a72 100644 --- a/lustre/include/lustre_compr.h +++ b/lustre/include/lustre_compr.h @@ -29,9 +29,10 @@ #include #define LL_COMPR_GAP 4096 -int alloc_compr(const char *obd_name, enum ll_compr_type *type, - unsigned int *lvl, struct crypto_comp **cc, bool decompress); - +int alloc_compr(struct client_obd *cli, enum ll_compr_type *type, + unsigned int *lvl, struct crypto_comp **cc); +int alloc_decompr(const char *obd_name, enum ll_compr_type *type, + unsigned int *lvl, struct crypto_comp **cc); int compress_chunk(const char *obd_name, struct crypto_comp *cc, const unsigned char *in, unsigned int in_len, unsigned char *out, unsigned int *out_len, @@ -53,4 +54,7 @@ int decompress_chunk(const char *obd_name, struct crypto_comp *cc, unsigned char *out, unsigned int *out_len, enum ll_compr_type type, unsigned int lvl); +int compress_str2type(char *s_type, enum ll_compr_type *type, + char *s_level, int *level); + #endif /* _LUSTRE_COMPR_H_ */ diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 2dbcb3f..d0b4a27 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -378,6 +378,10 @@ struct client_obd { __u64 cl_quota_last_xid; /* Links to the global list of registered changelog devices */ struct list_head cl_chg_dev_linkage; + enum ll_compr_type cl_compr_type_fast; + unsigned int cl_compr_fast_level; + enum ll_compr_type cl_compr_type_best; + unsigned int cl_compr_best_level; }; #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 98de08d..958b9c0 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -1474,7 +1474,7 @@ struct sepol_downcall_data { #define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES) #endif -#endif /* !__KERNEL__ */ +#endif /* NEED_QUOTA_DEFS */ /* lustre volatile file support * file name header: ".^L^S^T^R:volatile" @@ -2994,6 +2994,134 @@ enum ll_compr_type { #define COMPR_CHUNK_MAX_BITS 26 /* == PTLRPC_MAX_BRW_BITS */ #define COMPR_LEVEL_MAX 31 #define COMPR_MIN_PAGES (1UL << (COMPR_CHUNK_MIN_BITS - PAGE_SHIFT)) + +/* map compression algorithm compress level to 4bits value */ +#ifndef LZ4_ACCELERATION_DEFAULT +#define LZ4_ACCELERATION_DEFAULT 1 +#endif + +#ifndef LZ4HC_DEFAULT_CLEVEL +#define LZ4HC_DEFAULT_CLEVEL 9 + +/* Level as stored in the Lustre file layout is limited to 4 bits, i.e. + * between 0 and 15. + * So we map the provided level to the lz4hc compression level + * simply by adding 1. + */ +static inline __u8 to_lz4hc_lvl(__u8 level) +{ + return level + 1; +} + +#endif + +#ifndef LZ4HC_MIN_CLEVEL +#define LZ4HC_MIN_CLEVEL 3 +#endif + +/* if user does not set level (-1), it would be set to the default level */ +static inline __u8 from_lz4hc_lvl(int level) +{ + if (level == -1) + return LZ4_ACCELERATION_DEFAULT - 1; + if ((level - 1) > 0xf) + return 0xf; + return level - 1; +} + +/* Level as stored in the Lustre file layout is limited to 4 bits, i.e. + * between 0 and 15. But for lz4fast, acceleration factor can be fine tuned + * with each successive value providing roughly +~3% to speed. + * So we map the provided level to the lz4 acceleration factor by keeping 1-9 + * as-is, and then going by steps of 3 so 12 15 18 21 24 27. + * And to mock lz4 command line utility behavior, the user provided factor is + * actually applied internally as 'value + 1'. + */ +static inline __u8 to_lz4fast_lvl(__u8 level) +{ + if (level < 10) + return level - 1; + return (level - 9) * 3 + 9 - 1; +} + +static inline __u8 from_lz4fast_lvl(int level) +{ + if (level <= 0) + return LZ4_ACCELERATION_DEFAULT + 1; + if (level < 10) + return level + 1; + if ((level - 9) / 3 + 9 + 1 > 0xf) + return 0xf; + return (level - 9) / 3 + 9 + 1; +} + +static inline __u8 from_gzip_lvl(int level) +{ + if (level == -1) + return 6; + if (level == 0) + return 1; + if (level > 9) + return 9; + return level; +} + +typedef __u8 (*from_compress_level)(int level); +typedef __u8 (*to_compress_level)(__u8 level); + +static const struct compr_type_name { + enum ll_compr_type ctn_compr_type; + const char *ctn_name; + from_compress_level ctn_from_compr_level; + to_compress_level ctn_to_compr_level; +} compr_type_table[] = { + { LL_COMPR_TYPE_NONE, "none", NULL, NULL }, + { LL_COMPR_TYPE_FAST, "fast", NULL, NULL }, + { LL_COMPR_TYPE_BEST, "best", NULL, NULL }, + { LL_COMPR_TYPE_GZIP, "gzip", from_gzip_lvl, NULL }, + { LL_COMPR_TYPE_LZ4FAST, "lz4fast", from_lz4fast_lvl, to_lz4fast_lvl }, + { LL_COMPR_TYPE_LZ4HC, "lz4", from_lz4hc_lvl, to_lz4hc_lvl }, + { LL_COMPR_TYPE_LZO, "lzo", NULL, NULL }, + { LL_COMPR_TYPE_MAX, NULL, NULL, NULL}, +}; + +static inline const char *compress_type_2str(__u8 compr_type) +{ + bool found = false; + int i = 0; + + for (i = 0; compr_type_table[i].ctn_name != NULL; i++) { + if (compr_type == compr_type_table[i].ctn_compr_type) { + found = true; + break; + } + } + if (found) + return compr_type_table[i].ctn_name; + + return("unknown"); +} + +static inline int mapback_compress_level(enum ll_compr_type type, __u8 level) +{ + int i; + bool known_type = false; + + for (i = 0; compr_type_table[i].ctn_name != NULL; i++) { + if (compr_type_table[i].ctn_compr_type == type) { + known_type = true; + if (compr_type_table[i].ctn_to_compr_level != NULL) + return compr_type_table[i].ctn_to_compr_level( + level); + } + } + + if (!known_type) + return 0; + + return level; +} + #if defined(__cplusplus) } #endif diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 713f1f7..b89b5c1 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -519,6 +519,11 @@ int client_obd_setup(struct obd_device *obd, struct lustre_cfg *lcfg) INIT_LIST_HEAD(&cli->cl_chg_dev_linkage); + cli->cl_compr_type_fast = LL_COMPR_TYPE_LZ4FAST; + cli->cl_compr_fast_level = 0; + cli->cl_compr_type_best = LL_COMPR_TYPE_GZIP; + cli->cl_compr_best_level = 9; + if (connect_op == MDS_CONNECT) { cli->cl_max_mod_rpcs_in_flight = cli->cl_max_rpcs_in_flight - 1; OBD_ALLOC(cli->cl_mod_tag_bitmap, diff --git a/lustre/obdclass/lustre_compr.c b/lustre/obdclass/lustre_compr.c index e5268013..5f090e5 100644 --- a/lustre/obdclass/lustre_compr.c +++ b/lustre/obdclass/lustre_compr.c @@ -170,12 +170,15 @@ void load_crypto_module(enum ll_compr_type type) } } -#define compr_type_fast LL_COMPR_TYPE_LZ4FAST -#define compr_type_best LL_COMPR_TYPE_GZIP - -int alloc_compr(const char *obd_name, enum ll_compr_type *type, - unsigned int *lvl, struct crypto_comp **cc, bool decompress) +static int __alloc_compr(struct client_obd *cli, const char *obdname, + enum ll_compr_type *type, unsigned int *lvl, + struct crypto_comp **cc, bool decompress) { + const char *obd_name; + enum ll_compr_type compr_type_best = LL_COMPR_TYPE_GZIP; + unsigned int compr_best_lvl = 9; + enum ll_compr_type compr_type_fast = LL_COMPR_TYPE_LZ4FAST; + unsigned int compr_fast_lvl = LL_LZ4FAST_MAX_LEVEL; int ret = 0; ENTRY; @@ -190,10 +193,19 @@ int alloc_compr(const char *obd_name, enum ll_compr_type *type, LASSERT(ergo(decompress, *type != LL_COMPR_TYPE_BEST && *type != LL_COMPR_TYPE_FAST)); + if (cli) { + obd_name = cli->cl_import->imp_obd->obd_name; + compr_type_best = cli->cl_compr_type_best; + compr_best_lvl = cli->cl_compr_best_level; + compr_type_fast = cli->cl_compr_type_fast; + compr_fast_lvl = cli->cl_compr_fast_level; + } else { + obd_name = obdname; + } + if (*type == LL_COMPR_TYPE_BEST) { *type = compr_type_best; - /* all compression types support a level 9 */ - *lvl = 9; + *lvl = compr_best_lvl; } else if (*type == LL_COMPR_TYPE_FAST) { *type = compr_type_fast; /* lz4fast - our usual 'fast' interprets level as an @@ -202,8 +214,7 @@ int alloc_compr(const char *obd_name, enum ll_compr_type *type, if (*type == LL_COMPR_TYPE_LZ4FAST) *lvl = LL_LZ4FAST_MAX_LEVEL; else - /* all compression types support a level 0 */ - *lvl = 0; + *lvl = compr_fast_lvl; } load_crypto_module(*type); @@ -251,10 +262,22 @@ out: } RETURN(ret); +} +int alloc_compr(struct client_obd *cli, enum ll_compr_type *type, + unsigned int *lvl, struct crypto_comp **cc) +{ + return __alloc_compr(cli, NULL, type, lvl, cc, false); } EXPORT_SYMBOL(alloc_compr); +int alloc_decompr(const char *obd_name, enum ll_compr_type *type, + unsigned int *lvl, struct crypto_comp **cc) +{ + return __alloc_compr(NULL, obd_name, type, lvl, cc, true); +} +EXPORT_SYMBOL(alloc_decompr); + /* * The minimum delta between compressed and plain data to * use the compressed one. @@ -462,3 +485,35 @@ void unmerge_chunk(struct brw_page **pga, struct niobuf_local *lnb, int first, } } EXPORT_SYMBOL(unmerge_chunk); + +int compress_str2type(char *s_type, enum ll_compr_type *type, + char *s_level, int *level) +{ + bool found = false; + int i; + int rc = 0; + + for (i = 0; compr_type_table[i].ctn_name != NULL; i++) { + if (strcmp(s_type, compr_type_table[i].ctn_name) == 0) { + *type = compr_type_table[i].ctn_compr_type; + + if (s_level && level) { + rc = kstrtoint(s_level, 0, level); + if (rc) + return rc; + + if (compr_type_table[i].ctn_from_compr_level) + *level = compr_type_table[i]. + ctn_from_compr_level(*level); + } + found = true; + break; + } + } + + if (!found) + return -EINVAL; + + return rc; +} +EXPORT_SYMBOL(compress_str2type); diff --git a/lustre/ofd/ofd_compress.c b/lustre/ofd/ofd_compress.c index 9778693..32d16ed 100644 --- a/lustre/ofd/ofd_compress.c +++ b/lustre/ofd/ofd_compress.c @@ -83,7 +83,7 @@ static int decompress_chunk_in_lnb(const char *obd_name, type = llch->llch_compr_type; lvl = llch->llch_compr_level; hdr_size = llch->llch_header_size; - rc = alloc_compr(obd_name, &type, &lvl, &cc, true); + rc = alloc_decompr(obd_name, &type, &lvl, &cc); if (rc) { CERROR("%s: Setup for decompression failed, type %i, lvl %d, rc = %d\n", obd_name, type, lvl, rc); diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index a61300e..a912b30 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "osc_internal.h" @@ -667,6 +668,104 @@ static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr, } LUSTRE_RW_ATTR(grant_shrink); +static int osc_compress_type_fast_seq_show(struct seq_file *m, void *data) +{ + struct obd_device *obd = m->private; + struct client_obd *cli = &obd->u.cli; + + seq_printf(m, "%s:%d\n", compress_type_2str(cli->cl_compr_type_fast), + mapback_compress_level(cli->cl_compr_type_fast, + cli->cl_compr_fast_level)); + + return 0; +} +static ssize_t osc_compress_type_fast_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) +{ + struct seq_file *seq = file->private_data; + struct obd_device *obd = seq->private; + struct client_obd *cli = &obd->u.cli; + char *kbuf; + char *end; + int rc = 0; + + OBD_ALLOC(kbuf, count + 1); + if (kbuf == NULL) + return -ENOMEM; + + if (copy_from_user(kbuf, buffer, count)) + GOTO(out, rc = -EFAULT); + kbuf[count] = 0; + + end = memchr(kbuf, ':', count); + if (end != NULL) { + *end = 0; + end++; + } + + if (strcmp(kbuf, "none") == 0 || strcmp(kbuf, "fast") == 0 || + strcmp(kbuf, "best") == 0) + GOTO(out, rc = -EINVAL); + + rc = compress_str2type(kbuf, &cli->cl_compr_type_fast, + end, &cli->cl_compr_fast_level); + +out: + OBD_FREE(kbuf, count + 1); + return rc < 0 ? rc: count; +} +LPROC_SEQ_FOPS(osc_compress_type_fast); + +static int osc_compress_type_best_seq_show(struct seq_file *m, void *data) +{ + struct obd_device *obd = m->private; + struct client_obd *cli = &obd->u.cli; + + seq_printf(m, "%s:%d\n", compress_type_2str(cli->cl_compr_type_best), + mapback_compress_level(cli->cl_compr_type_best, + cli->cl_compr_best_level)); + + return 0; +} +static ssize_t osc_compress_type_best_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) +{ + struct seq_file *seq = file->private_data; + struct obd_device *obd = seq->private; + struct client_obd *cli = &obd->u.cli; + char *kbuf; + char *end; + int rc = 0; + + OBD_ALLOC(kbuf, count + 1); + if (kbuf == NULL) + return -ENOMEM; + + if (copy_from_user(kbuf, buffer, count)) + GOTO(out, rc = -EFAULT); + kbuf[count] = 0; + + end = memchr(kbuf, ':', count); + if (end != NULL) { + *end = 0; + end++; + } + + if (strcmp(kbuf, "none") == 0 || strcmp(kbuf, "fast") == 0 || + strcmp(kbuf, "best") == 0) + GOTO(out, rc = -EINVAL); + + rc = compress_str2type(kbuf, &cli->cl_compr_type_best, + end, &cli->cl_compr_best_level); + +out: + OBD_FREE(kbuf, count + 1); + return rc < 0 ? rc: count; +} +LPROC_SEQ_FOPS(osc_compress_type_best); + LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts); @@ -698,6 +797,10 @@ struct lprocfs_vars lprocfs_osc_obd_vars[] = { .fops = &osc_pinger_recov_fops }, { .name = "unstable_stats", .fops = &osc_unstable_stats_fops }, + { .name = "compress_type_fast", + .fops = &osc_compress_type_fast_fops }, + { .name = "compress_type_best", + .fops = &osc_compress_type_best_fops }, { NULL } }; diff --git a/lustre/osc/osc_compress.c b/lustre/osc/osc_compress.c index f6a6f28..b581d51 100644 --- a/lustre/osc/osc_compress.c +++ b/lustre/osc/osc_compress.c @@ -106,10 +106,11 @@ int fill_cpga(struct brw_page **cpga, struct brw_page **pga, } /* returns 0 on success, non-zero on failure to compress */ -int compress_request(const char *obd_name, struct obdo *oa, +int compress_request(struct client_obd *cli, struct obdo *oa, struct brw_page **pga, struct brw_page ***cpga, u32 *page_count, __u64 kms) { + const char *obd_name = cli->cl_import->imp_obd->obd_name; struct cl_page *clpage; struct crypto_comp *cc; enum ll_compr_type type; @@ -141,7 +142,7 @@ int compress_request(const char *obd_name, struct obdo *oa, src_buf_bits = chunk_bits + 1; dest_buf_bits = chunk_bits + 1; - rc = alloc_compr(obd_name, &type, &lvl, &cc, false); + rc = alloc_compr(cli, &type, &lvl, &cc); /* if we're unable to setup compression, alloc_compr prints a warning * but we do not fail the IO - just write data uncompressed */ @@ -380,7 +381,7 @@ int decompress_request(struct osc_brw_async_args *aa, int page_count) if (!cc) { type = llch->llch_compr_type; lvl = llch->llch_compr_level; - rc = alloc_compr(obd_name, &type, &lvl, &cc, true); + rc = alloc_decompr(obd_name, &type, &lvl, &cc); if (rc) GOTO(out, rc); } diff --git a/lustre/osc/osc_compress.h b/lustre/osc/osc_compress.h index c1d2feb..e51829c 100644 --- a/lustre/osc/osc_compress.h +++ b/lustre/osc/osc_compress.h @@ -27,7 +27,7 @@ #ifndef OSC_COMPRESS_H #define OSC_COMPRESS_H -int compress_request(const char *obd_name, struct obdo *oa, +int compress_request(struct client_obd *cli, struct obdo *oa, struct brw_page **pga, struct brw_page ***cpga, u32 *page_count, __u64 kms); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index f789f9b..92155bb 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1652,7 +1652,7 @@ osc_brw_prep_request(int cmd, struct client_obd *cli, struct obdo *oa, chunk_size = (1 << cl_page_compr_bits(clpage)); - rc = compress_request(obd_name, oa, pga, &cpga, &page_count, + rc = compress_request(cli, oa, pga, &cpga, &page_count, kms); if (rc) { /* diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 960ed5f..eae8d25 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -3149,43 +3149,6 @@ static void lov_dump_comp_v1_header(struct find_param *param, char *path, llapi_printf(LLAPI_MSG_NORMAL, "components:\n"); } -static const char *compress_type_2str(__u8 compr_type) -{ - bool found = false; - int i = 0; - - for (i = 0; i < ARRAY_SIZE(compr_type_table); i++) { - if (compr_type == compr_type_table[i].ctn_compr_type) { - found = true; - break; - } - } - if (found) - return compr_type_table[i].ctn_name; - else - return("unknown"); -} - -static int mapback_compress_level(enum ll_compr_type type, __u8 level) -{ - int i; - bool known_type = false; - - for (i = 0; i < ARRAY_SIZE(compr_type_table); i++) { - if (compr_type_table[i].ctn_compr_type == type) { - known_type = true; - if (compr_type_table[i].ctn_to_compr_level != NULL) - return compr_type_table[i].ctn_to_compr_level( - level); - } - } - - if (!known_type) - return 0; - - return level; -} - static void lcme_flags2str(__u32 comp_flags) { bool found = false; -- 1.8.3.1