nvmf: ctrlr_get_ana_state() always returns optimized if ana_reporting is disabled

if ctrlr->listener was NULL, nvmf_ctrlr_get_ana_state() returned
inaccessible even if ana_reporting was disabled. Then the corresponding
initiator received unexpected ANA error and could not process it
appropriately.

Change nvmf_ctrlr_get_ana_state() to return optimized always if
ana_reporting is disabled.

Additionally, check if ctrlr->listener is not NULL before calling
SPDK_DTRACE_PROBE3().

Fixes #2335

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: Ib2376694cf89d85ec5687fba7e87439f494f30b0
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11402
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2022-02-04 12:00:55 +09:00 committed by Jim Harris
parent fcc426bda8
commit c777cfa700

View File

@ -2141,6 +2141,10 @@ typedef enum spdk_nvme_ana_state spdk_nvme_ana_state_t;
static inline spdk_nvme_ana_state_t
nvmf_ctrlr_get_ana_state(struct spdk_nvmf_ctrlr *ctrlr, uint32_t anagrpid)
{
if (!ctrlr->subsys->flags.ana_reporting) {
return SPDK_NVME_ANA_OPTIMIZED_STATE;
}
if (spdk_unlikely(ctrlr->listener == NULL)) {
return SPDK_NVME_ANA_INACCESSIBLE_STATE;
}
@ -3967,9 +3971,11 @@ nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req)
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}
SPDK_DTRACE_PROBE3(nvmf_request_io_exec_path, req,
req->qpair->ctrlr->listener->trid->traddr,
req->qpair->ctrlr->listener->trid->trsvcid);
if (spdk_likely(ctrlr->listener != NULL)) {
SPDK_DTRACE_PROBE3(nvmf_request_io_exec_path, req,
ctrlr->listener->trid->traddr,
ctrlr->listener->trid->trsvcid);
}
/* scan-build falsely reporting dereference of null pointer */
assert(group != NULL && group->sgroups != NULL);