Commit a28a5c8f authored by Seth Howell's avatar Seth Howell Committed by Changpeng Liu
Browse files

nvmf: ensure that destroying qpairs have a state_cb



It appears that we can get caught in a loop when shutting down a
subsystem if there is a qpair that has been moved to the deactivating
state due to the target shutting down early. These qpairs don't have a
state cb and won't ever be destroyed or removed from the global list.

Change-Id: I4f9ed774a94e0e2c7ff7bfa3af1776b38a787035
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/419269


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 8a5a15b8
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -669,6 +669,17 @@ _spdk_nvmf_qpair_deactivate(void *ctx)
	struct nvmf_qpair_disconnect_ctx *qpair_ctx = ctx;
	struct spdk_nvmf_qpair *qpair = qpair_ctx->qpair;

	/* Check for outstanding I/O */
	if (!TAILQ_EMPTY(&qpair->outstanding)) {
		if (qpair->state_cb != NULL) {
			qpair->state_cb = _spdk_nvmf_qpair_destroy;
			qpair->state_cb_arg = qpair_ctx;
		} else {
			free(qpair_ctx);
		}
		return;
	}

	if (qpair->state == SPDK_NVMF_QPAIR_DEACTIVATING ||
	    qpair->state == SPDK_NVMF_QPAIR_INACTIVE) {
		/* This can occur if the connection is killed by the target,
@@ -684,13 +695,6 @@ _spdk_nvmf_qpair_deactivate(void *ctx)
	assert(qpair->state == SPDK_NVMF_QPAIR_ACTIVE);
	qpair->state = SPDK_NVMF_QPAIR_DEACTIVATING;

	/* Check for outstanding I/O */
	if (!TAILQ_EMPTY(&qpair->outstanding)) {
		qpair->state_cb = _spdk_nvmf_qpair_destroy;
		qpair->state_cb_arg = qpair_ctx;
		return;
	}

	_spdk_nvmf_qpair_destroy(qpair_ctx, 0);
}