reduce: add logical block size to vol params
This will be the logical block size presented by the compressed volume to differ from the backing device's block size. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ie4ef06e131d8e101a0c9ced228c56a02fcbfb7af Reviewed-on: https://review.gerrithub.io/434113 Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> 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: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
7be176e1e6
commit
5ae61d4286
@ -54,10 +54,18 @@ struct spdk_reduce_vol_params {
|
||||
*/
|
||||
uint32_t backing_io_unit_size;
|
||||
|
||||
/**
|
||||
* Size in bytes of a logical block. This is the unit in
|
||||
* which users read or write data to the compressed volume.
|
||||
* Must be greater than 0.
|
||||
*/
|
||||
uint32_t logical_block_size;
|
||||
|
||||
/**
|
||||
* Size in bytes of a chunk on the compressed volume. This
|
||||
* is the unit in which data is compressed. Must be an even
|
||||
* multiple of backing_io_unit_size. Must be greater than 0.
|
||||
* multiple of backing_io_unit_size and logical_block_size.
|
||||
* Must be greater than 0.
|
||||
*/
|
||||
uint32_t chunk_size;
|
||||
|
||||
|
@ -57,7 +57,7 @@
|
||||
struct spdk_reduce_vol_superblock {
|
||||
uint8_t signature[8];
|
||||
struct spdk_reduce_vol_params params;
|
||||
uint8_t reserved[4056];
|
||||
uint8_t reserved[4048];
|
||||
};
|
||||
SPDK_STATIC_ASSERT(sizeof(struct spdk_reduce_vol_superblock) == 4096, "size incorrect");
|
||||
|
||||
@ -82,6 +82,7 @@ struct spdk_reduce_vol_request {
|
||||
struct spdk_reduce_vol {
|
||||
struct spdk_reduce_vol_params params;
|
||||
uint32_t backing_io_units_per_chunk;
|
||||
uint32_t logical_blocks_per_chunk;
|
||||
struct spdk_reduce_pm_file pm_file;
|
||||
struct spdk_reduce_backing_dev *backing_dev;
|
||||
struct spdk_reduce_vol_superblock *backing_super;
|
||||
@ -149,7 +150,8 @@ _get_pm_total_chunks_size(uint64_t vol_size, uint64_t chunk_size, uint64_t backi
|
||||
static int
|
||||
_validate_vol_params(struct spdk_reduce_vol_params *params)
|
||||
{
|
||||
if (params->vol_size == 0 || params->chunk_size == 0 || params->backing_io_unit_size == 0) {
|
||||
if (params->vol_size == 0 || params->chunk_size == 0 ||
|
||||
params->backing_io_unit_size == 0 || params->logical_block_size == 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -158,6 +160,11 @@ _validate_vol_params(struct spdk_reduce_vol_params *params)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Chunk size must be an even multiple of the logical block size. */
|
||||
if ((params->chunk_size % params->logical_block_size) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Volume size must be an even multiple of the chunk size. */
|
||||
if ((params->vol_size % params->chunk_size) != 0) {
|
||||
return -EINVAL;
|
||||
@ -448,6 +455,7 @@ spdk_reduce_vol_init(struct spdk_reduce_vol_params *params,
|
||||
}
|
||||
|
||||
vol->backing_io_units_per_chunk = params->chunk_size / params->backing_io_unit_size;
|
||||
vol->logical_blocks_per_chunk = params->chunk_size / params->logical_block_size;
|
||||
memcpy(&vol->params, params, sizeof(*params));
|
||||
|
||||
rc = _allocate_bit_arrays(vol);
|
||||
@ -515,6 +523,7 @@ _load_read_super_and_path_cpl(void *cb_arg, int ziperrno)
|
||||
|
||||
memcpy(&vol->params, &vol->backing_super->params, sizeof(vol->params));
|
||||
vol->backing_io_units_per_chunk = vol->params.chunk_size / vol->params.backing_io_unit_size;
|
||||
vol->logical_blocks_per_chunk = vol->params.chunk_size / vol->params.logical_block_size;
|
||||
|
||||
rc = _allocate_bit_arrays(vol);
|
||||
if (rc != 0) {
|
||||
|
@ -123,6 +123,7 @@ get_backing_device_size(void)
|
||||
params.vol_size = 0;
|
||||
params.chunk_size = 0;
|
||||
params.backing_io_unit_size = 0;
|
||||
params.logical_block_size = 512;
|
||||
CU_ASSERT(spdk_reduce_get_backing_device_size(¶ms) == -EINVAL);
|
||||
|
||||
/*
|
||||
@ -223,6 +224,7 @@ init_failure(void)
|
||||
params.vol_size = 1024 * 1024; /* 1MB */
|
||||
params.chunk_size = 16 * 1024;
|
||||
params.backing_io_unit_size = backing_dev.blocklen;
|
||||
params.logical_block_size = 512;
|
||||
|
||||
/* backing_dev and pm_file have an invalid size. This should fail. */
|
||||
g_vol = NULL;
|
||||
@ -329,6 +331,7 @@ init_md(void)
|
||||
params.vol_size = 1024 * 1024; /* 1MB */
|
||||
params.chunk_size = 16 * 1024;
|
||||
params.backing_io_unit_size = 512;
|
||||
params.logical_block_size = 512;
|
||||
|
||||
backing_dev_init(&backing_dev, ¶ms);
|
||||
|
||||
@ -380,6 +383,7 @@ init_backing_dev(void)
|
||||
params.vol_size = 1024 * 1024; /* 1MB */
|
||||
params.chunk_size = 16 * 1024;
|
||||
params.backing_io_unit_size = 512;
|
||||
params.logical_block_size = 512;
|
||||
spdk_uuid_generate(¶ms.uuid);
|
||||
|
||||
backing_dev_init(&backing_dev, ¶ms);
|
||||
@ -423,6 +427,7 @@ load(void)
|
||||
params.vol_size = 1024 * 1024; /* 1MB */
|
||||
params.chunk_size = 16 * 1024;
|
||||
params.backing_io_unit_size = 512;
|
||||
params.logical_block_size = 512;
|
||||
spdk_uuid_generate(¶ms.uuid);
|
||||
|
||||
backing_dev_init(&backing_dev, ¶ms);
|
||||
|
Loading…
Reference in New Issue
Block a user