Commit a5e6ecf2 authored by Yankun Li's avatar Yankun Li Committed by Jim Harris
Browse files

lib/reduce: Data copy logic in thin read operations



If the read data is not compressed, set req->copy_after_decompress = true,
in the function _read_decompress_done, copies the data to host buffers.

Change-Id: I1385e380cea0e908cd0b69762674508105b9c09e
Signed-off-by: default avatarYankun Li <yankun@staff.sina.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25416


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
parent a333974e
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -1749,9 +1749,6 @@ static void
_read_read_done(void *_req, int reduce_errno)
{
	struct spdk_reduce_vol_request *req = _req;
	uint64_t chunk_offset;
	uint8_t *buf;
	int i;

	if (reduce_errno != 0) {
		req->reduce_errno = reduce_errno;
@@ -1772,15 +1769,10 @@ _read_read_done(void *_req, int reduce_errno)
	} 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.
		 *  host buffers by the decompression operation, if not we need to memcpy
		 *  from req->decomp_buf.
		 */
		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;
		}

		req->copy_after_decompress = true;
		req->backing_cb_args.output_size = req->chunk->compressed_size;

		_read_decompress_done(req, 0);