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