lib/nvmf: Check if I/O qpair is on the same listener as admin qpair

We will have ANA state per listener and per subsystem. On the other hand,
NVMe specification defines ANA state per controller.

However, it is possible that I/O qpair and admin qpair are different
listeners on a single controller.

Let's check if I/O qpair is on the same listener as admin qpair if
ANA reporting is enabled.

The case that I/O qpair is on a different listener from admin qpair
is not usual and so the purpose of this check is just to guard SPDK
from any unexpected behavior.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Idb8d255de7f998e45a59a120c2ed5803258873f4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4026
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Shuhei Matsumoto 2020-09-02 06:50:24 +09:00 committed by Tomasz Zawadzki
parent 7bcff376ab
commit 5b27db6268

View File

@ -512,6 +512,7 @@ _nvmf_ctrlr_add_io_qpair(void *ctx)
struct spdk_nvmf_qpair *admin_qpair;
struct spdk_nvmf_tgt *tgt = qpair->transport->tgt;
struct spdk_nvmf_subsystem *subsystem;
const struct spdk_nvmf_subsystem_listener *listener;
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Connect I/O Queue for controller id 0x%x\n", data->cntlid);
@ -535,6 +536,17 @@ _nvmf_ctrlr_add_io_qpair(void *ctx)
return;
}
/* If ANA reporting is enabled, check if I/O connect is on the same listener. */
if (subsystem->ana_reporting) {
listener = nvmf_subsystem_find_listener(subsystem, qpair->trid);
if (listener != ctrlr->listener) {
SPDK_ERRLOG("I/O connect is on a listener different from admin connect\n");
SPDK_NVMF_INVALID_CONNECT_CMD(rsp, qid);
spdk_nvmf_request_complete(req);
return;
}
}
admin_qpair = ctrlr->admin_qpair;
qpair->ctrlr = ctrlr;
spdk_thread_send_msg(admin_qpair->group->thread, nvmf_ctrlr_add_io_qpair, req);