Commit b70b16ac authored by Changpeng Liu's avatar Changpeng Liu Committed by Jim Harris
Browse files

nvmf: don't use request internal variable after req_complete callback



vfio-user transport `req_complete` callback will zero the internal
NVMe command and response fields, the common NVMf library should
not use them after the callback, so here we use stack variables
to save them before the `req_complete` callback.

Fix issue #1965.

Change-Id: Iff2342b6095d9496cdf112d657a0a99ce1fb5d12
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8129


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatar <dongx.yi@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent fdc4c13e
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3579,10 +3579,13 @@ _nvmf_request_complete(void *ctx)
	bool is_aer = false;
	uint32_t nsid;
	bool paused;
	uint8_t opcode;

	rsp->sqid = 0;
	rsp->status.p = 0;
	rsp->cid = req->cmd->nvme_cmd.cid;
	nsid = req->cmd->nvme_cmd.nsid;
	opcode = req->cmd->nvmf_cmd.opcode;

	qpair = req->qpair;
	if (qpair->ctrlr) {
@@ -3615,13 +3618,11 @@ _nvmf_request_complete(void *ctx)

	/* AER cmd is an exception */
	if (sgroup && !is_aer) {
		if (spdk_unlikely(req->cmd->nvmf_cmd.opcode == SPDK_NVME_OPC_FABRIC ||
		if (spdk_unlikely(opcode == SPDK_NVME_OPC_FABRIC ||
				  nvmf_qpair_is_admin_queue(qpair))) {
			assert(sgroup->mgmt_io_outstanding > 0);
			sgroup->mgmt_io_outstanding--;
		} else {
			nsid = req->cmd->nvme_cmd.nsid;

			/* NOTE: This implicitly also checks for 0, since 0 - 1 wraps around to UINT32_MAX. */
			if (spdk_likely(nsid - 1 < sgroup->num_ns)) {
				sgroup->ns_info[nsid - 1].io_outstanding--;