From afc432ba9635eabb2352688a3e06c89e2356e8c4 Mon Sep 17 00:00:00 2001 From: Niklas Cassel Date: Mon, 17 May 2021 08:55:21 +0000 Subject: [PATCH] bdev/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. Signed-off-by: Niklas Cassel Change-Id: Ia9c281290e11e4204d270ba4090edb73212ce20f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7896 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: John Kariuki Reviewed-by: Aleksey Marchuk --- examples/bdev/fio_plugin/README.md | 3 +++ examples/bdev/fio_plugin/fio_plugin.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/examples/bdev/fio_plugin/README.md b/examples/bdev/fio_plugin/README.md index ee9519926..7794cd539 100644 --- a/examples/bdev/fio_plugin/README.md +++ b/examples/bdev/fio_plugin/README.md @@ -94,6 +94,9 @@ state at any point in time. It is very important to not exceed this limit. You can control how many zones fio will keep in an open state by using the ``--max_open_zones`` option. +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 Zoned block devices may also have a resource constraint on the number of zones that can be active at diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index fba1ea2dd..2ce5c8104 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -1067,6 +1067,24 @@ 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_bdev *bdev; + + bdev = spdk_bdev_get_by_name(f->file_name); + if (!bdev) { + SPDK_ERRLOG("Cannot get max open zones, no bdev with name: %s\n", f->file_name); + return -ENODEV; + } + + *max_open_zones = spdk_bdev_get_max_open_zones(bdev); + + return 0; +} +#endif + static int spdk_fio_handle_options(struct thread_data *td, struct fio_file *f, struct spdk_bdev *bdev) { @@ -1203,6 +1221,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 .option_struct_size = sizeof(struct spdk_fio_options), .options = options,