lib/reduce: conditionally memcpy data to host follow decompression
If the decompression code path runs into a chunk that wasn't compressed, the data needs to be copied to the host as the compression engine was not engaged. Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: Ibabd6d6bd2bc5db79953a0a55d7f49d556c08af7 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462892 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
0242a80793
commit
907ec7268d
@ -1273,6 +1273,9 @@ static void
|
|||||||
_read_read_done(void *_req, int reduce_errno)
|
_read_read_done(void *_req, int reduce_errno)
|
||||||
{
|
{
|
||||||
struct spdk_reduce_vol_request *req = _req;
|
struct spdk_reduce_vol_request *req = _req;
|
||||||
|
uint64_t chunk_offset;
|
||||||
|
uint8_t *buf;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (reduce_errno != 0) {
|
if (reduce_errno != 0) {
|
||||||
req->reduce_errno = reduce_errno;
|
req->reduce_errno = reduce_errno;
|
||||||
@ -1291,6 +1294,17 @@ _read_read_done(void *_req, int reduce_errno)
|
|||||||
if (req->chunk_is_compressed) {
|
if (req->chunk_is_compressed) {
|
||||||
_reduce_vol_decompress_chunk(req, _read_decompress_done);
|
_reduce_vol_decompress_chunk(req, _read_decompress_done);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
/* If the chunk was compressed, the data would have been sent to the
|
||||||
|
* host buffers by the decompression operation, if not we need to memcpy here.
|
||||||
|
*/
|
||||||
|
chunk_offset = req->offset % req->vol->logical_blocks_per_chunk;
|
||||||
|
buf = req->decomp_buf + chunk_offset * req->vol->params.logical_block_size;
|
||||||
|
for (i = 0; i < req->iovcnt; i++) {
|
||||||
|
memcpy(req->iov[i].iov_base, buf, req->iov[i].iov_len);
|
||||||
|
buf += req->iov[i].iov_len;
|
||||||
|
}
|
||||||
|
|
||||||
_read_decompress_done(req, req->chunk->compressed_size);
|
_read_decompress_done(req, req->chunk->compressed_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user