nvmf: add max_io_size validation

The max_io_size transport option should be a power of 2 and be >= 8KB.

Max data tranfer size is defined in NVMe-oF spec as 2^(mdts cmd field) * 4KB.
Mdts cmd field is calculated as spdk_u32log2(transport->opts.max_io_size / 4096),
so max_io_size < 8KB results in mdts=0, which means no size limit (according to spec).

User can set max_io_size = 0 explicitly to allow no size limit.

Signed-off-by: Maciej Szulik <maciej.szulik@intel.com>
Change-Id: Id88a77efce5f217e1fc7750f61c0bd330aaa3791
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6384
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jacek Kalwas <jacek.kalwas@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Maciej Szulik 2021-02-10 09:44:21 -05:00 committed by Tomasz Zawadzki
parent 201ad2f917
commit 6497b0774e
2 changed files with 8 additions and 0 deletions

View File

@ -76,6 +76,7 @@ struct spdk_nvmf_transport_opts {
uint16_t max_queue_depth;
uint16_t max_qpairs_per_ctrlr;
uint32_t in_capsule_data_size;
/* used to calculate mdts */
uint32_t max_io_size;
uint32_t io_unit_size;
uint32_t max_aq_depth;

View File

@ -168,6 +168,13 @@ spdk_nvmf_transport_create(const char *transport_name, struct spdk_nvmf_transpor
}
nvmf_transport_opts_copy(&opts_local, opts, opts->opts_size);
if (opts_local.max_io_size != 0 && (!spdk_u32_is_pow2(opts_local.max_io_size) ||
opts_local.max_io_size < 8192)) {
SPDK_ERRLOG("max_io_size %u must be a power of 2 and be greater than or equal 8KB\n",
opts_local.max_io_size);
return NULL;
}
if (opts_local.max_aq_depth < SPDK_NVMF_MIN_ADMIN_MAX_SQ_SIZE) {
SPDK_ERRLOG("max_aq_depth %u is less than minimum defined by NVMf spec, use min value\n",
opts_local.max_aq_depth);