Commit 2e565122 authored by Jim Harris's avatar Jim Harris Committed by Ben Walker
Browse files

nvmf: fix comparison in nvmf_stop_listen_disconnect_qpairs



This function disconnects any qpairs that match both
the listen trid and the subsystem pointer.  If the
specified subsystem is NULL, it will just disconnect
all qpairs matching the listen trid.

But there are cases where a qpair doesn't yet have an
associated subsystem - for example, before a CONNECT
is received.

Currently we would always disconnect such a qpair, even
if a subsystem pointer is passed.  Presumably this check
was added to ensure we don't dereference qpair->ctrlr
when it is NULL but it was added incorrectly.

Also while here, move and improve the comment about
skipping qpairs.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I8b7988b22799de2a069be692f4a5b4da59c2bad4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17854


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 4c7b5046
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -493,14 +493,16 @@ nvmf_stop_listen_disconnect_qpairs(struct spdk_io_channel_iter *i)
	group = spdk_io_channel_get_ctx(ch);
	group = spdk_io_channel_get_ctx(ch);


	TAILQ_FOREACH_SAFE(qpair, &group->qpairs, link, tmp_qpair) {
	TAILQ_FOREACH_SAFE(qpair, &group->qpairs, link, tmp_qpair) {
		/* skip qpairs that don't match the TRID. */
		if (spdk_nvmf_qpair_get_listen_trid(qpair, &tmp_trid)) {
		if (spdk_nvmf_qpair_get_listen_trid(qpair, &tmp_trid)) {
			continue;
			continue;
		}
		}


		/* Skip qpairs that don't match the listen trid and subsystem pointer.  If
		 * the ctx->subsystem is NULL, it means disconnect all qpairs that match
		 * the listen trid. */
		if (!spdk_nvme_transport_id_compare(&ctx->trid, &tmp_trid)) {
		if (!spdk_nvme_transport_id_compare(&ctx->trid, &tmp_trid)) {
			if (ctx->subsystem == NULL || qpair->ctrlr == NULL ||
			if (ctx->subsystem == NULL ||
			    ctx->subsystem == qpair->ctrlr->subsys) {
			    (qpair->ctrlr != NULL && ctx->subsystem == qpair->ctrlr->subsys)) {
				spdk_nvmf_qpair_disconnect(qpair, NULL, NULL);
				spdk_nvmf_qpair_disconnect(qpair, NULL, NULL);
				qpair_found = true;
				qpair_found = true;
			}
			}