reduce: save compressed data size in chunk map

Upcoming patches will try to compress the data before
writing it to backing I/O units, and we'll need to save
the exact number of compressed bytes.

For now, since we're not actually compressing data yet,
just save the uncompressed data size to this field.  There
will be cases when we cannot realize any compression
savings and will just store the uncompressed data, so
handling this now is one less path we'll need to add later.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I499a89590349e4816fe0fef77cc1bfabde6871bf

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449078
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Jim Harris 2019-03-22 05:55:15 -07:00
parent 3c070c97ff
commit 5a04099b01

View File

@ -82,6 +82,8 @@ struct spdk_reduce_pm_file {
#define REDUCE_IO_WRITEV 2 #define REDUCE_IO_WRITEV 2
struct spdk_reduce_chunk_map { struct spdk_reduce_chunk_map {
uint32_t compressed_size;
uint32_t reserved;
uint64_t io_unit_index[0]; uint64_t io_unit_index[0];
}; };
@ -958,6 +960,7 @@ _reduce_vol_write_chunk(struct spdk_reduce_vol_request *req, reduce_request_fn n
spdk_bit_array_set(vol->allocated_chunk_maps, req->chunk_map_index); spdk_bit_array_set(vol->allocated_chunk_maps, req->chunk_map_index);
req->chunk = _reduce_vol_get_chunk_map(vol, req->chunk_map_index); req->chunk = _reduce_vol_get_chunk_map(vol, req->chunk_map_index);
req->chunk->compressed_size = vol->params.chunk_size;
for (i = 0; i < vol->backing_io_units_per_chunk; i++) { for (i = 0; i < vol->backing_io_units_per_chunk; i++) {
req->chunk->io_unit_index[i] = spdk_bit_array_find_first_clear(vol->allocated_backing_io_units, 0); req->chunk->io_unit_index[i] = spdk_bit_array_find_first_clear(vol->allocated_backing_io_units, 0);
@ -1043,6 +1046,7 @@ _reduce_vol_read_chunk(struct spdk_reduce_vol_request *req, reduce_request_fn ne
assert(req->chunk_map_index != UINT32_MAX); assert(req->chunk_map_index != UINT32_MAX);
req->chunk = _reduce_vol_get_chunk_map(vol, req->chunk_map_index); req->chunk = _reduce_vol_get_chunk_map(vol, req->chunk_map_index);
assert(req->chunk->compressed_size == vol->params.chunk_size);
_issue_backing_ops(req, vol, next_fn, false /* read */); _issue_backing_ops(req, vol, next_fn, false /* read */);
} }