lib/reduce: fix bug with adding up req->decomp_iovcnt

In the memcpy elimination patches, the same bug exists in 3
places.  When building req->decomp_iov using the host buffers,
req->decomp_iovcnt was being incremented in the loop and also
being used as part of the index messing everything up.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: I485ac32502801c1e11b8392b2df7eba06b4f5a9b
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461053
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
paul luse 2019-07-09 12:03:28 -04:00 committed by Darek Stojaczyk
parent b9bc6254a8
commit 0b3fb2403e

View File

@ -1103,8 +1103,8 @@ _reduce_vol_decompress_chunk(struct spdk_reduce_vol_request *req, reduce_request
req->decomp_iov[i + req->decomp_iovcnt].iov_base = req->iov[i].iov_base; req->decomp_iov[i + req->decomp_iovcnt].iov_base = req->iov[i].iov_base;
req->decomp_iov[i + req->decomp_iovcnt].iov_len = req->iov[i].iov_len; req->decomp_iov[i + req->decomp_iovcnt].iov_len = req->iov[i].iov_len;
ttl_len += req->decomp_iov[i + req->decomp_iovcnt].iov_len; ttl_len += req->decomp_iov[i + req->decomp_iovcnt].iov_len;
req->decomp_iovcnt++;
} }
req->decomp_iovcnt += req->iovcnt;
/* send the rest of the chunk to our scratch buffer */ /* send the rest of the chunk to our scratch buffer */
remainder = vol->params.chunk_size - ttl_len; remainder = vol->params.chunk_size - ttl_len;
@ -1162,8 +1162,8 @@ _write_decompress_done(void *_req, int reduce_errno)
req->decomp_iov[i + req->decomp_iovcnt].iov_base = req->iov[i].iov_base; req->decomp_iov[i + req->decomp_iovcnt].iov_base = req->iov[i].iov_base;
req->decomp_iov[i + req->decomp_iovcnt].iov_len = req->iov[i].iov_len; req->decomp_iov[i + req->decomp_iovcnt].iov_len = req->iov[i].iov_len;
ttl_len += req->decomp_iov[i + req->decomp_iovcnt].iov_len; ttl_len += req->decomp_iov[i + req->decomp_iovcnt].iov_len;
req->decomp_iovcnt++;
} }
req->decomp_iovcnt += req->iovcnt;
if (ttl_len < req->vol->params.chunk_size) { if (ttl_len < req->vol->params.chunk_size) {
req->decomp_iov[req->decomp_iovcnt].iov_base = req->decomp_buf + ttl_len; req->decomp_iov[req->decomp_iovcnt].iov_base = req->decomp_buf + ttl_len;
@ -1407,8 +1407,8 @@ _start_writev_request(struct spdk_reduce_vol_request *req)
req->decomp_iov[i + req->decomp_iovcnt].iov_base = req->iov[i].iov_base; req->decomp_iov[i + req->decomp_iovcnt].iov_base = req->iov[i].iov_base;
req->decomp_iov[i + req->decomp_iovcnt].iov_len = req->iov[i].iov_len; req->decomp_iov[i + req->decomp_iovcnt].iov_len = req->iov[i].iov_len;
ttl_len += req->decomp_iov[i + req->decomp_iovcnt].iov_len; ttl_len += req->decomp_iov[i + req->decomp_iovcnt].iov_len;
req->decomp_iovcnt++;
} }
req->decomp_iovcnt += req->iovcnt;
chunk_offset += req->length; chunk_offset += req->length;
if (chunk_offset != lb_per_chunk) { if (chunk_offset != lb_per_chunk) {