test/reduce: create common function for initializing backing dev

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

Reviewed-on: https://review.gerrithub.io/432501
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Jim Harris 2018-10-01 12:20:44 -07:00
parent 649a585f2f
commit 3981ba698b

View File

@ -240,6 +240,13 @@ init_failure(void)
pm_file_destroy();
}
static void
backing_dev_init(struct spdk_reduce_backing_dev *backing_dev, struct spdk_reduce_vol_params *params)
{
backing_dev->blocklen = params->backing_io_unit_size;
backing_dev->blockcnt = spdk_reduce_get_backing_device_size(params) / backing_dev->blocklen;
}
static void
init_md(void)
{
@ -248,14 +255,12 @@ init_md(void)
struct spdk_reduce_backing_dev backing_dev = {};
struct spdk_reduce_pm_file pm_file = {};
backing_dev.blocklen = 512;
params.vol_size = 1024 * 1024; /* 1MB */
params.chunk_size = 16 * 1024;
params.backing_io_unit_size = backing_dev.blocklen;
params.backing_io_unit_size = 512;
spdk_uuid_generate(&params.uuid);
backing_dev.blockcnt = spdk_reduce_get_backing_device_size(&params) / backing_dev.blocklen;
backing_dev_init(&backing_dev, &params);
pm_file_init(&pm_file, &params);
g_vol = NULL;