nvme/fio_plugin: implement support for fio .get_max_open_zones callback

Implement support for the recently added fio .get_max_open_zones callback.

If our ioengine does not implement this callback, fio will always result
in an error when using --zonemode=zbd, on platforms which does not have a
fio oslib implementation for this callback, e.g. FreeBSD.

On Linux, fio will by default try to parse sysfs, which will of course not
work on SPDK.

Implement this callback so that our ioengine will be able to provide fio
with the proper max open zones limit.

This will ensure that fio will be able to fetch the proper max open zones
limit, regardless of OS.

While our SPDK nvme ioengine did overwrite the max_open_zones option if it
was set to zero, this is a bit of a hack. The new fio callback is the
proper way to inform fio about the max open zones limit, so that fio itself
can have access to the actual device limit.
(Just overwriting the requested max_open_zones option will not allow fio
to know if the requested max_open_zones option exceeds the device limit.)
Remove the SPDK specific hack and update our README.md accordingly.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I532a0fa065b9e215ee6229b9100135e5403f198e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7898
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: John Kariuki <John.K.Kariuki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Niklas Cassel 2021-05-17 10:42:54 +00:00 committed by Tomasz Zawadzki
parent ddf27c3d15
commit 6e57273783
2 changed files with 24 additions and 24 deletions

View File

@ -125,7 +125,8 @@ Zoned Namespaces has a resource constraint on the amount of zones which can be i
any point in time. You can control how many zones fio will keep in an open state by using the
``--max_open_zones`` option.
The SPDK/NVMe fio io-engine will set a default value if you do not provide one.
If you use a fio version newer than 3.26, fio will automatically detect and set the proper value.
If you use an old version of fio, make sure to provide the proper --max_open_zones value yourself.
## Maximum Active Zones

View File

@ -1186,29 +1186,6 @@ spdk_fio_get_zoned_model(struct thread_data *td, struct fio_file *f, enum zbd_zo
*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;
}
@ -1378,6 +1355,25 @@ spdk_fio_reset_wp(struct thread_data *td, struct fio_file *f, uint64_t offset, u
}
#endif
#if FIO_IOOPS_VERSION >= 30
static int spdk_fio_get_max_open_zones(struct thread_data *td, struct fio_file *f,
unsigned int *max_open_zones)
{
struct spdk_fio_thread *fio_thread = td->io_ops_data;
struct spdk_fio_qpair *fio_qpair = NULL;
fio_qpair = get_fio_qpair(fio_thread, f);
if (!fio_qpair) {
log_err("spdk/nvme: no ns/qpair or file_name: '%s'\n", f->file_name);
return -ENODEV;
}
*max_open_zones = spdk_nvme_zns_ns_get_max_open_zones(fio_qpair->ns);
return 0;
}
#endif
static void spdk_fio_cleanup(struct thread_data *td)
{
struct spdk_fio_thread *fio_thread = td->io_ops_data;
@ -1669,6 +1665,9 @@ struct ioengine_ops ioengine = {
.get_zoned_model = spdk_fio_get_zoned_model,
.report_zones = spdk_fio_report_zones,
.reset_wp = spdk_fio_reset_wp,
#endif
#if FIO_IOOPS_VERSION >= 30
.get_max_open_zones = spdk_fio_get_max_open_zones,
#endif
.flags = FIO_RAWIO | FIO_NOEXTEND | FIO_NODISKUTIL | FIO_MEMALIGN,
.options = options,