From cdd64c1c8c2f2b331ccca5bf17f5e1a9cb94ff98 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 29 Mar 2019 01:26:16 -0700 Subject: [PATCH] ut/reduce: modify write_maps test to write full chunks This test verifies that all of the io_unit_index[] entries are written. For that to really happen, the write for the chunks must not be compressible. Currently the compress algorithm just copies the data and doesn't actually compress - so writing a partial chunk works OK for this test. But upcoming patches will add a 'real' compression unit test algorithm - at which point, writing just part of a chunk will be compressible since the non-written parts will be all zero. Signed-off-by: Jim Harris Change-Id: Ib48b9bb5a782571689b281a955e01682e21ee223 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449566 Reviewed-by: Paul Luse Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- test/unit/lib/reduce/reduce.c/reduce_ut.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/unit/lib/reduce/reduce.c/reduce_ut.c b/test/unit/lib/reduce/reduce.c/reduce_ut.c index 441cbbdd1..0dc7823a3 100644 --- a/test/unit/lib/reduce/reduce.c/reduce_ut.c +++ b/test/unit/lib/reduce/reduce.c/reduce_ut.c @@ -698,14 +698,16 @@ _write_maps(uint32_t backing_blocklen) struct spdk_reduce_vol_params params = {}; struct spdk_reduce_backing_dev backing_dev = {}; struct iovec iov; - char buf[16 * 1024]; /* chunk size */ - uint32_t i; + const int bufsize = 16 * 1024; /* chunk size */ + char buf[bufsize]; + uint32_t num_lbas, i; uint64_t old_chunk0_map_index, new_chunk0_map_index; struct spdk_reduce_chunk_map *old_chunk0_map, *new_chunk0_map; - params.chunk_size = 16 * 1024; + params.chunk_size = bufsize; params.backing_io_unit_size = 4096; params.logical_block_size = 512; + num_lbas = bufsize / params.logical_block_size; spdk_uuid_generate(¶ms.uuid); backing_dev_init(&backing_dev, ¶ms, backing_blocklen); @@ -720,10 +722,11 @@ _write_maps(uint32_t backing_blocklen) CU_ASSERT(_vol_get_chunk_map_index(g_vol, i) == REDUCE_EMPTY_MAP_ENTRY); } + ut_build_data_buffer(buf, bufsize, 0x00, 1); iov.iov_base = buf; - iov.iov_len = params.logical_block_size; + iov.iov_len = bufsize; g_reduce_errno = -1; - spdk_reduce_vol_writev(g_vol, &iov, 1, 0, 1, write_cb, NULL); + spdk_reduce_vol_writev(g_vol, &iov, 1, 0, num_lbas, write_cb, NULL); CU_ASSERT(g_reduce_errno == 0); old_chunk0_map_index = _vol_get_chunk_map_index(g_vol, 0); @@ -738,7 +741,7 @@ _write_maps(uint32_t backing_blocklen) } g_reduce_errno = -1; - spdk_reduce_vol_writev(g_vol, &iov, 1, 0, 1, write_cb, NULL); + spdk_reduce_vol_writev(g_vol, &iov, 1, 0, num_lbas, write_cb, NULL); CU_ASSERT(g_reduce_errno == 0); new_chunk0_map_index = _vol_get_chunk_map_index(g_vol, 0);