From 12a44d47456ea72d8b3242d4a5b4274201887003 Mon Sep 17 00:00:00 2001 From: "Simon A. F. Lund" Date: Tue, 27 Oct 2020 12:48:30 +0100 Subject: [PATCH] examples/nvme_fio_plugin: fix reset_wp() When _reset_wp() received a range to reset, then the loop kept resetting the first zone in the range. Also, the processing of command-completion were re-using the same 'completion' state, thus a previous completion would short-circuit command-completion such that it would never be processed. This change fixes that. Also, the reset-loop assumes that the given offset is a valid zone-start LBA, a check is added to verify that and return -EINVAL if it is not. Signed-off-by: Simon A. F. Lund Change-Id: I1a1e4be2e1f67c2d8fecb5fc36a211b2dbb5a921 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4915 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: Niklas Cassel --- examples/nvme/fio_plugin/fio_plugin.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/nvme/fio_plugin/fio_plugin.c b/examples/nvme/fio_plugin/fio_plugin.c index c4787175e..93a79e5af 100644 --- a/examples/nvme/fio_plugin/fio_plugin.c +++ b/examples/nvme/fio_plugin/fio_plugin.c @@ -1236,7 +1236,6 @@ spdk_fio_reset_wp(struct thread_data *td, struct fio_file *f, uint64_t offset, u struct spdk_fio_qpair *fio_qpair = NULL; const struct spdk_nvme_zns_ns_data *zns = NULL; uint64_t zsze_nbytes, lba_nbytes; - int completed = 0; int err = 0; fio_qpair = get_fio_qpair(fio_thread, f); @@ -1252,8 +1251,16 @@ spdk_fio_reset_wp(struct thread_data *td, struct fio_file *f, uint64_t offset, u zsze_nbytes = spdk_nvme_zns_ns_get_zone_size(fio_qpair->ns); lba_nbytes = spdk_nvme_ns_get_sector_size(fio_qpair->ns); + /** check the assumption that offset is valid zone-start lba */ + if (offset % zsze_nbytes) { + log_err("spdk/nvme: offset: %zu is not a valid zslba\n", offset); + return -EINVAL; + } + for (uint64_t cur = offset; cur < offset + length; cur += zsze_nbytes) { - err = spdk_nvme_zns_reset_zone(fio_qpair->ns, fio_qpair->qpair, offset / lba_nbytes, + int completed = 0; + + err = spdk_nvme_zns_reset_zone(fio_qpair->ns, fio_qpair->qpair, cur / lba_nbytes, false, pcu_cb, &completed); if (err || pcu(fio_qpair->qpair, &completed) || completed < 0) { log_err("spdk/nvme: report_zones(): err: %d, cpl: %d\n", err, completed);