Commit 7251e4c2 authored by Jim Harris's avatar Jim Harris Committed by Konrad Sztyber
Browse files

nvmf/rdma: let OPC_FABRIC requests jump the pending_buf_queue



We want to avoid CONNECT commands timing out under heavy workloads with
buffer shortages. So let OPC_FABRIC commands enter the pending_buf_queue
before any non-OPC_FABRIC commands.

Fixes issue #3556.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: I8c05bad67c11c61b889b694243a0d6315f70311f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25294


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Clay Mayers
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
parent 1d36ed84
Loading
Loading
Loading
Loading
+32 −1
Original line number Diff line number Diff line
@@ -2051,7 +2051,38 @@ static void
nvmf_rdma_poll_group_insert_need_buffer_req(struct spdk_nvmf_rdma_poll_group *rgroup,
		struct spdk_nvmf_rdma_request *rdma_req)
{
	struct spdk_nvmf_request *r;

	/* CONNECT commands have a timeout, so we need to avoid a CONNECT command
	 * from getting buried behind a long list of other non-FABRIC requests
	 * waiting for a buffer. Note that even though the CONNECT command's data is
	 * in-capsule, the request still goes to this STAILQ.
	 */
	if (spdk_likely(rdma_req->req.cmd->nvme_cmd.opc != SPDK_NVME_OPC_FABRIC)) {
		/* This is the most likely case. */
		STAILQ_INSERT_TAIL(&rgroup->group.pending_buf_queue, &rdma_req->req, buf_link);
		return;
	} else {
		/* STAILQ doesn't have INSERT_BEFORE, so we need to either INSERT_HEAD
		 * or INSERT_AFTER. Put it after any other FABRIC commands that are
		 * already in the queue.
		 */
		r = STAILQ_FIRST(&rgroup->group.pending_buf_queue);
		if (r == NULL || r->cmd->nvme_cmd.opc != SPDK_NVME_OPC_FABRIC) {
			STAILQ_INSERT_HEAD(&rgroup->group.pending_buf_queue, &rdma_req->req, buf_link);
			return;
		}
		while (true) {
			struct spdk_nvmf_request *next;

			next = STAILQ_NEXT(r, buf_link);
			if (next == NULL || next->cmd->nvme_cmd.opc != SPDK_NVME_OPC_FABRIC) {
				STAILQ_INSERT_AFTER(&rgroup->group.pending_buf_queue, r, &rdma_req->req, buf_link);
				return;
			}
			r = next;
		}
	}
}

bool