examples/nvme_fio_plugin: help the user with max_open_zones constraints

When a device has resource-limitations such as the
maximum-open-resources (mor) and this threshold is exceeded, then IO
will fail upon completion. Such behavior is not the most user-friendly
way to tell the user that they should provide a value for the
fio-parameter 'max_open_zones'.

This change provides an arguably more user-friendly approach by checking
whether the device is limited and in case it is:

* Provide a default value for 'max_open_zones', inform the user, and
continue
* Verify 'max_open_zones' and in case of error inform the user and
return error

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Change-Id: I76cb045d560b9ec5701d97b82a62947af11960b6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4914
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Simon A. F. Lund 2020-10-27 11:09:30 +01:00 committed by Tomasz Zawadzki
parent 2c9b5b5af5
commit 906c2adb86

View File

@ -1019,6 +1019,7 @@ spdk_fio_get_zoned_model(struct thread_data *td, struct fio_file *f, enum zbd_zo
{
struct spdk_fio_thread *fio_thread = td->io_ops_data;
struct spdk_fio_qpair *fio_qpair = NULL;
const struct spdk_nvme_zns_ns_data *zns_data = NULL;
*model = ZBD_IGNORE;
@ -1045,12 +1046,37 @@ spdk_fio_get_zoned_model(struct thread_data *td, struct fio_file *f, enum zbd_zo
return -ENOSYS;
case SPDK_NVME_CSI_ZNS:
if (!spdk_nvme_zns_ns_get_data(fio_qpair->ns)) {
zns_data = spdk_nvme_zns_ns_get_data(fio_qpair->ns);
if (!zns_data) {
log_err("spdk/nvme: file_name: '%s', ZNS is not enabled\n", f->file_name);
return -EINVAL;
}
*model = ZBD_HOST_MANAGED;
/** Unlimited open resources, skip checking 'max_open_zones' */
if (0xFFFFFFFF == zns_data->mor) {
return 0;
}
if (!td->o.max_open_zones) {
td->o.max_open_zones = spdk_min(ZBD_MAX_OPEN_ZONES, zns_data->mor + 1);
log_info("spdk/nvme: parameter 'max_open_zones' was unset; assigned: %d.\n",
td->o.max_open_zones);
} else if (td->o.max_open_zones < 0) {
log_err("spdk/nvme: invalid parameter 'max_open_zones': %d\n",
td->o.max_open_zones);
return -EINVAL;
} else if (td->o.max_open_zones > ZBD_MAX_OPEN_ZONES) {
log_err("spdk/nvme: parameter 'max_open_zones': %d exceeds fio-limit: %d\n",
td->o.max_open_zones, ZBD_MAX_OPEN_ZONES);
return -EINVAL;
} else if ((uint32_t)td->o.max_open_zones > (zns_data->mor + 1)) {
log_err("spdk/nvme: parameter 'max_open_zones': %d exceeds dev-limit: %u\n",
td->o.max_open_zones, zns_data->mor + 1);
return -EINVAL;
}
return 0;
}