diff options
author | cfzhu <[email protected]> | 2019-04-17 03:38:36 +0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-04-16 12:38:36 -0700 |
commit | 5090f72743f5a587b1a8b64aaa1023913735d0bf (patch) | |
tree | 6ab4731f14ffebc4895e31c7aed85ce8970fa45e /module/zfs/qat_compress.c | |
parent | 59f6594cf605635c22311c7f0752bbc67807a508 (diff) |
Code improvement and bug fixes for QAT support
1. Support QAT when ZFS is root file-system:
When ZFS module is loaded before QAT started, the QAT can
be started again in post-process, e.g.:
echo 0 > /sys/module/zfs/parameters/zfs_qat_compress_disable
echo 0 > /sys/module/zfs/parameters/zfs_qat_encrypt_disable
echo 0 > /sys/module/zfs/parameters/zfs_qat_checksum_disable
2. Verify alder checksum of the de-compress result
3. Allocate Digest, IV and AAD buffer in physical contiguous
memory by QAT_PHYS_CONTIG_ALLOC.
4. Update the documentation for zfs_qat_compress_disable,
zfs_qat_checksum_disable, zfs_qat_encrypt_disable.
Reviewed-by: Tom Caputi <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Weigang Li <[email protected]>
Signed-off-by: Chengfeix Zhu <[email protected]>
Closes #8323
Closes #8610
Diffstat (limited to 'module/zfs/qat_compress.c')
-rw-r--r-- | module/zfs/qat_compress.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/module/zfs/qat_compress.c b/module/zfs/qat_compress.c index 8c1410c9e..1c5c0a4e7 100644 --- a/module/zfs/qat_compress.c +++ b/module/zfs/qat_compress.c @@ -24,7 +24,9 @@ #include <linux/vmalloc.h> #include <linux/pagemap.h> #include <linux/completion.h> +#include <linux/mod_compat.h> #include <sys/zfs_context.h> +#include <sys/byteorder.h> #include <sys/zio.h> #include "qat.h" @@ -111,6 +113,9 @@ qat_dc_init(void) Cpa32U buff_meta_size = 0; CpaDcSessionSetupData sd = {0}; + if (qat_dc_init_done) + return (0); + status = cpaDcGetNumInstances(&num_inst); if (status != CPA_STATUS_SUCCESS) return (-1); @@ -252,6 +257,7 @@ qat_compress_impl(qat_compress_dir_t dir, char *src, int src_len, Cpa32U num_add_buf = (add_len >> PAGE_SHIFT) + 2; Cpa32U bytes_left; Cpa32U dst_pages = 0; + Cpa32U adler32 = 0; char *data; struct page *page; struct page **in_pages = NULL; @@ -468,6 +474,12 @@ qat_compress_impl(qat_compress_dir_t dir, char *src, int src_len, goto fail; } + /* verify adler checksum */ + adler32 = *(Cpa32U *)(src + dc_results.consumed + ZLIB_HEAD_SZ); + if (adler32 != BSWAP_32(dc_results.checksum)) { + status = CPA_STATUS_FAIL; + goto fail; + } *c_len = dc_results.produced; QAT_STAT_INCR(decomp_total_out_bytes, *c_len); } @@ -534,7 +546,30 @@ qat_compress(qat_compress_dir_t dir, char *src, int src_len, return (ret); } -module_param(zfs_qat_compress_disable, int, 0644); -MODULE_PARM_DESC(zfs_qat_compress_disable, "Disable QAT compression"); +static int +param_set_qat_compress(const char *val, struct kernel_param *kp) +{ + int ret; + int *pvalue = kp->arg; + ret = param_set_int(val, kp); + if (ret) + return (ret); + /* + * zfs_qat_compress_disable = 0: enable qat compress + * try to initialize qat instance if it has not been done + */ + if (*pvalue == 0 && !qat_dc_init_done) { + ret = qat_dc_init(); + if (ret != 0) { + zfs_qat_compress_disable = 1; + return (ret); + } + } + return (ret); +} + +module_param_call(zfs_qat_compress_disable, param_set_qat_compress, + param_get_int, &zfs_qat_compress_disable, 0644); +MODULE_PARM_DESC(zfs_qat_compress_disable, "Enable/Disable QAT compression"); #endif |