From 5a04099b0141b71926cc24fe800642a37eaa4753 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 22 Mar 2019 05:55:15 -0700 Subject: [PATCH] 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 Change-Id: I499a89590349e4816fe0fef77cc1bfabde6871bf Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449078 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Paul Luse Reviewed-by: Changpeng Liu --- lib/reduce/reduce.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/reduce/reduce.c b/lib/reduce/reduce.c index f9c72ace5..bb7f29a17 100644 --- a/lib/reduce/reduce.c +++ b/lib/reduce/reduce.c @@ -82,6 +82,8 @@ struct spdk_reduce_pm_file { #define REDUCE_IO_WRITEV 2 struct spdk_reduce_chunk_map { + uint32_t compressed_size; + uint32_t reserved; 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); 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++) { 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); 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 */); }