From 7384ca015b9d8e5c9d8f706d35d833c0ec3d047f Mon Sep 17 00:00:00 2001 From: paul luse Date: Mon, 22 Jul 2019 15:32:26 -0400 Subject: [PATCH] lib/reduce: for compress path, copy data from host buffers if needed If the data was not compressed for whatever reason, it needs to be copied from the host buffers much in the same way as the patch before this did. Signed-off-by: paul luse Change-Id: I5c92db16afbce3ca573c556ee78a51ba6511c564 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462895 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- lib/reduce/reduce.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/reduce/reduce.c b/lib/reduce/reduce.c index be22cfe2a3..ecbbbf01ec 100644 --- a/lib/reduce/reduce.c +++ b/lib/reduce/reduce.c @@ -1045,6 +1045,9 @@ _reduce_vol_write_chunk(struct spdk_reduce_vol_request *req, reduce_request_fn n { struct spdk_reduce_vol *vol = req->vol; uint32_t i; + uint64_t chunk_offset; + uint8_t *buf; + int j; req->chunk_map_index = spdk_bit_array_find_first_clear(vol->allocated_chunk_maps, 0); @@ -1061,6 +1064,16 @@ _reduce_vol_write_chunk(struct spdk_reduce_vol_request *req, reduce_request_fn n req->chunk->compressed_size = req->chunk_is_compressed ? compressed_size : vol->params.chunk_size; + /* if the chunk is uncompressed we need to copy the data from the host buffers. */ + if (req->chunk_is_compressed == false) { + chunk_offset = req->offset % vol->logical_blocks_per_chunk; + buf = req->decomp_buf + chunk_offset * vol->params.logical_block_size; + for (j = 0; j < req->iovcnt; j++) { + memcpy(buf, req->iov[j].iov_base, req->iov[j].iov_len); + buf += req->iov[j].iov_len; + } + } + for (i = 0; i < req->num_io_units; i++) { req->chunk->io_unit_index[i] = spdk_bit_array_find_first_clear(vol->allocated_backing_io_units, 0); /* TODO: fail if no backing block found - but really this should also not