From aae84b1f0edacd1ed42bd4eba11ac2f385e31c24 Mon Sep 17 00:00:00 2001 From: "Simon A. F. Lund" Date: Wed, 28 Oct 2020 15:46:26 +0100 Subject: [PATCH] examples/nvme_fio_plugin: add plugin-option 'initial_zone_reset' Added plugin-option 'initial_zone_reset', providing the option to reset all zones on all namespaces with the Zoned Command Set enabled upon initialization. The default is not to reset. The option is exposed even when the ZBD plumbing is not available. However, it will then inform the user that ZBD/ZNS is not supported instead of resetting. The plugin-option provides a short-term solution to an observed issue with consecutive invocations of fio exhausting maximum-active-resources. A longer-term solution would be to add a 'max_active_zones' limit in fio and ensure that fio does not exceed that limit. Signed-off-by: Simon A. F. Lund Change-Id: I65341c028a97657370b315fb298bf97651b9bffd Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4949 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Niklas Cassel --- examples/nvme/fio_plugin/fio_plugin.c | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/examples/nvme/fio_plugin/fio_plugin.c b/examples/nvme/fio_plugin/fio_plugin.c index 88e9d9c7a..c4283bbbd 100644 --- a/examples/nvme/fio_plugin/fio_plugin.c +++ b/examples/nvme/fio_plugin/fio_plugin.c @@ -92,6 +92,7 @@ struct spdk_fio_options { int apptag_mask; char *digest_enable; int enable_vmd; + int initial_zone_reset; }; struct spdk_fio_request { @@ -588,6 +589,34 @@ static int spdk_fio_setup(struct thread_data *td) g_td_count++; pthread_mutex_unlock(&g_mutex); + if (fio_options->initial_zone_reset == 1) { +#if FIO_HAS_ZBD + struct spdk_fio_qpair *fio_qpair; + + TAILQ_FOREACH(fio_qpair, &fio_thread->fio_qpair, link) { + const struct spdk_nvme_zns_ns_data *zns_data; + int completed = 0, err; + + if (!fio_qpair->ns) { + continue; + } + zns_data = spdk_nvme_zns_ns_get_data(fio_qpair->ns); + if (!zns_data) { + continue; + } + + err = spdk_nvme_zns_reset_zone(fio_qpair->ns, fio_qpair->qpair, 0x0, true, + pcu_cb, &completed); + if (err || pcu(fio_qpair->qpair, &completed) || completed < 0) { + log_err("spdk/nvme: warn: initial_zone_reset: err: %d, cpl: %d\n", + err, completed); + } + } +#else + log_err("spdk/nvme: ZBD/ZNS is not supported\n"); +#endif + } + return rc; } @@ -1510,6 +1539,16 @@ static struct fio_option options[] = { .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_INVALID, }, + { + .name = "initial_zone_reset", + .lname = "Reset Zones on initialization", + .type = FIO_OPT_INT, + .off1 = offsetof(struct spdk_fio_options, initial_zone_reset), + .def = "0", + .help = "Reset Zones on initialization (0=disable, 1=Reset All Zones)", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_INVALID, + }, { .name = NULL, },