]> granicus.if.org Git - zfs/commitdiff
Bug fix in qat_compress.c when compressed size is < 4KB
authorwli5 <weigang.li@intel.com>
Tue, 7 Nov 2017 22:51:30 +0000 (06:51 +0800)
committerTony Hutter <hutter2@llnl.gov>
Mon, 20 Nov 2017 22:48:26 +0000 (16:48 -0600)
When the 128KB block is compressed to less than 4KB, the pointer
to the Footer is not in the end of the compressed buffer, that's
because the Header offset was added twice for this case. So there
is a gap between the Footer and the compressed buffer.
1. Always compute the Footer pointer address from the start of the
last page.
2. Remove the un-used workaroud code which has been verified fixed
with the latest driver and this fix.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Weigang Li <weigang.li@intel.com>
Closes #6827

module/zfs/qat_compress.c

index ea56f144c1d3b065095c9695adea24893785ce44..4d17d7ac9a18361613da2339812d96803fdc17ec 100644 (file)
@@ -493,7 +493,10 @@ qat_compress(qat_compress_dir_t dir, char *src, int src_len,
                    + ZLIB_FOOT_SZ > PAGE_SIZE)
                        goto fail;
 
-               flat_buf_dst->pData += (compressed_sz + hdr_sz) % PAGE_SIZE;
+               /* jump to the end of the buffer and append footer */
+               flat_buf_dst->pData =
+                   (char *)((unsigned long)flat_buf_dst->pData & PAGE_MASK)
+                   + ((compressed_sz + hdr_sz) % PAGE_SIZE);
                flat_buf_dst->dataLenInBytes = ZLIB_FOOT_SZ;
 
                dc_results.produced = 0;
@@ -505,9 +508,6 @@ qat_compress(qat_compress_dir_t dir, char *src, int src_len,
 
                *c_len = compressed_sz + dc_results.produced + hdr_sz;
 
-               if (*c_len < PAGE_SIZE)
-                       *c_len = 8 * PAGE_SIZE;
-
                QAT_STAT_INCR(comp_total_out_bytes, *c_len);
 
                ret = 0;