Commit a6aaf848 authored by John Levon's avatar John Levon Committed by Tomasz Zawadzki
Browse files

nvme/fio_plugin: fix race during startup



We can crash with spdk_nvme_qpair_process_completions(qpair=0x0) when
called from spdk_fio_getevents(). This was observed when passing more
than two namespaces to an fio job.

This is because this callback can be called concurrently with
spdk_fio_open(), which assigns ->qpair. We'll just skip any
non-initialized qpairs in the processing loop, as eventually
spdk_fio_open() will set them.

Fixes: "f69367c7 fio_nvme: defer qpair allocation to file_open callback"

Signed-off-by: default avatarJohn Levon <john.levon@nutanix.com>
Change-Id: Ie8f1ac37726e202bb971ffeb497f9e32656392aa
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12338


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent bc797a7b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1165,6 +1165,15 @@ static int spdk_fio_getevents(struct thread_data *td, unsigned int min,
		}

		while (fio_qpair != NULL) {
			/*
			 * We can be called while spdk_fio_open()s are still
			 * ongoing, in which case, ->qpair can still be NULL.
			 */
			if (fio_qpair->qpair == NULL) {
				fio_qpair = TAILQ_NEXT(fio_qpair, link);
				continue;
			}

			spdk_nvme_qpair_process_completions(fio_qpair->qpair, max - fio_thread->iocq_count);

			if (fio_thread->iocq_count >= min) {