lib/reduce: minor cleanup for consistency in recent changes

Had used a few different means to determine if there's space
remaining in a chunk after accounting for offset and host data,
just making them all consistent. Nothing functionally changes.

Change-Id: Iffd3b0b6d8ab1253f5b1bebda88d6f63d5061e19
Signed-off-by: paul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463023
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: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
paul luse 2019-07-23 18:05:16 -04:00 committed by Jim Harris
parent 3def834c65
commit f9cae9d20f

View File

@ -1186,7 +1186,7 @@ _write_decompress_done(void *_req, int reduce_errno)
{ {
struct spdk_reduce_vol_request *req = _req; struct spdk_reduce_vol_request *req = _req;
struct spdk_reduce_vol *vol = req->vol; struct spdk_reduce_vol *vol = req->vol;
uint64_t chunk_offset, ttl_len = 0; uint64_t chunk_offset, remainder, ttl_len = 0;
int i; int i;
/* Negative reduce_errno indicates failure for compression operations. */ /* Negative reduce_errno indicates failure for compression operations. */
@ -1221,9 +1221,10 @@ _write_decompress_done(void *_req, int reduce_errno)
} }
req->decomp_iovcnt += req->iovcnt; req->decomp_iovcnt += req->iovcnt;
if (ttl_len < req->vol->params.chunk_size) { remainder = vol->params.chunk_size - ttl_len;
if (remainder) {
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;
req->decomp_iov[req->decomp_iovcnt].iov_len = req->vol->params.chunk_size - ttl_len; req->decomp_iov[req->decomp_iovcnt].iov_len = remainder;
ttl_len += req->decomp_iov[req->decomp_iovcnt].iov_len; ttl_len += req->decomp_iov[req->decomp_iovcnt].iov_len;
req->decomp_iovcnt++; req->decomp_iovcnt++;
} }
@ -1444,7 +1445,7 @@ _start_writev_request(struct spdk_reduce_vol_request *req)
struct spdk_reduce_vol *vol = req->vol; struct spdk_reduce_vol *vol = req->vol;
uint64_t chunk_offset, ttl_len = 0; uint64_t chunk_offset, ttl_len = 0;
uint64_t remainder = 0; uint64_t remainder = 0;
uint32_t lbsize, lb_per_chunk; uint32_t lbsize;
int i; int i;
TAILQ_INSERT_TAIL(&req->vol->executing_requests, req, tailq); TAILQ_INSERT_TAIL(&req->vol->executing_requests, req, tailq);
@ -1459,11 +1460,10 @@ _start_writev_request(struct spdk_reduce_vol_request *req)
} }
lbsize = vol->params.logical_block_size; lbsize = vol->params.logical_block_size;
lb_per_chunk = vol->logical_blocks_per_chunk;
req->decomp_iovcnt = 0; req->decomp_iovcnt = 0;
/* Note: point to our zero buf for offset into the chunk. */ /* Note: point to our zero buf for offset into the chunk. */
chunk_offset = req->offset % lb_per_chunk; chunk_offset = req->offset % vol->logical_blocks_per_chunk;
if (chunk_offset != 0) { if (chunk_offset != 0) {
ttl_len += chunk_offset * lbsize; ttl_len += chunk_offset * lbsize;
req->decomp_iov[0].iov_base = g_zero_buf; req->decomp_iov[0].iov_base = g_zero_buf;
@ -1471,7 +1471,7 @@ _start_writev_request(struct spdk_reduce_vol_request *req)
req->decomp_iovcnt = 1; req->decomp_iovcnt = 1;
} }
/* now the user data iov, direct to the user buffer */ /* now the user data iov, direct from the user buffer */
for (i = 0; i < req->iovcnt; i++) { for (i = 0; i < req->iovcnt; i++) {
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;
@ -1479,9 +1479,8 @@ _start_writev_request(struct spdk_reduce_vol_request *req)
} }
req->decomp_iovcnt += req->iovcnt; req->decomp_iovcnt += req->iovcnt;
chunk_offset += req->length; remainder = vol->params.chunk_size - ttl_len;
if (chunk_offset != lb_per_chunk) { if (remainder) {
remainder = (lb_per_chunk - chunk_offset) * lbsize;
req->decomp_iov[req->decomp_iovcnt].iov_base = g_zero_buf; req->decomp_iov[req->decomp_iovcnt].iov_base = g_zero_buf;
req->decomp_iov[req->decomp_iovcnt].iov_len = remainder; req->decomp_iov[req->decomp_iovcnt].iov_len = remainder;
ttl_len += req->decomp_iov[req->decomp_iovcnt].iov_len; ttl_len += req->decomp_iov[req->decomp_iovcnt].iov_len;