Skip to content

Commit

Permalink
nvmf: duplicate qid retry fix
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Savitskiy <[email protected]>
  • Loading branch information
dsavitskiy committed Mar 29, 2024
1 parent 275950e commit 131dc6f
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lib/nvmf/ctrlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#define NVMF_CTRLR_RESET_SHN_TIMEOUT_IN_MS (NVMF_CC_RESET_SHN_TIMEOUT_IN_MS + 5000)

#define DUPLICATE_QID_RETRY_US 100
#define DUPLICATE_QID_RETRY_US 10000

/*
* Report the SPDK version as the firmware revision.
Expand Down Expand Up @@ -240,15 +240,16 @@ ctrlr_add_qpair_and_send_rsp(struct spdk_nvmf_qpair *qpair,

if (spdk_bit_array_get(ctrlr->qpair_mask, qpair->qid)) {
if (qpair->connect_req != NULL) {
SPDK_ERRLOG("Got I/O connect with duplicate QID %u\n", qpair->qid);
SPDK_ERRLOG("Got I/O connect with duplicate QID %u on ctrlr %p [%s]\n",
qpair->qid, ctrlr, ctrlr->hostnqn);
rsp->status.sct = SPDK_NVME_SCT_COMMAND_SPECIFIC;
rsp->status.sc = SPDK_NVME_SC_INVALID_QUEUE_IDENTIFIER;
qpair->connect_req = NULL;
qpair->ctrlr = NULL;
spdk_nvmf_request_complete(req);
} else {
SPDK_WARNLOG("Duplicate QID detected, re-check in %dus\n",
DUPLICATE_QID_RETRY_US);
SPDK_WARNLOG("Duplicate QID %u detected on ctrlr %p [%s], re-check in %dus\n",
qpair->qid, ctrlr, ctrlr->hostnqn, DUPLICATE_QID_RETRY_US);
qpair->connect_req = req;
/* Set qpair->ctrlr here so that we'll have it when the poller expires. */
qpair->ctrlr = ctrlr;
Expand All @@ -263,6 +264,16 @@ ctrlr_add_qpair_and_send_rsp(struct spdk_nvmf_qpair *qpair,

rsp->status.sc = SPDK_NVME_SC_SUCCESS;
rsp->status_code_specific.success.cntlid = ctrlr->cntlid;

/* Reset `connect_req` after a retry.
* (Note it shares the union with `first_fused_req`).
*/
if (qpair->connect_req != NULL) {
SPDK_WARNLOG("Added QID %u on ctrlr %p [%s] after duplicate QID retry\n",
qpair->qid, ctrlr, ctrlr->hostnqn);
qpair->connect_req = NULL;
}

SPDK_DEBUGLOG(nvmf, "connect capsule response: cntlid = 0x%04x\n",
rsp->status_code_specific.success.cntlid);
spdk_nvmf_request_complete(req);
Expand Down Expand Up @@ -4265,7 +4276,8 @@ nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req)
} else if (spdk_unlikely(req->qpair->first_fused_req != NULL)) {
struct spdk_nvme_cpl *fused_response = &req->qpair->first_fused_req->rsp->nvme_cpl;

SPDK_ERRLOG("Expected second of fused commands - failing first of fused commands\n");
SPDK_ERRLOG("Ctrlr %p [%s]: Expected second of fused commands - failing first of fused commands: qpair id %u\n",
req->qpair->ctrlr, req->qpair->ctrlr ? req->qpair->ctrlr->hostnqn : "<null>", req->qpair->qid);

/* abort req->qpair->first_fused_request and continue with new command */
fused_response->status.sc = SPDK_NVME_SC_ABORTED_MISSING_FUSED;
Expand Down

0 comments on commit 131dc6f

Please sign in to comment.