From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387915; b=Ua8L/WuXrOIVb2zIcKebs2webWIPMIxtVf47RVUb5ylsuZxc7zdX+eLwQbQ44umK/+p1 xQmSP+wYEM6TNjyM+bLym/VCZG3chzctH+i/pQ2a4zOTF84Uv3IJhJ7DYzkB3plkeV+WF q+24XxrtxHVu/A8TAiadZEBYLdnELxoSObHs0K4wEPb2cpW1SZwkhzLLTasOs3uEI1ISq gvaYl2s8W7JJFtEEIfUFN1QBrT5qGozugmgY+pDTw5p2GTMbwpYtAOOqDfdfg6jWwlg6W vqZII7SSVhsaW+wkRC3HYmVgUviGY4XNsRG1RmGw7vtP5PXR5TPzIsKlBRp6lNt/Ppw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387915; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Vx6BwWNsH7kXlv4vVoCIhpRAi3+jvzL/y4rG5PCCRrA=; b=LbQBqJdmKQrLAwW1TpKRSnO4L5REx1FAMM8LcfdabZSt8fkd2lvXqfFB9AXKm6RuVrH3 +cLMZu9GOx8BDKQdsXXlc3p0Xrs83baHCtO1lbB+PmtF6ltwEfbDXMuRum19ui5v/9z6I pIswJEY8y9/6od4ytt/1iEm64bsjYcbwMqiKj9lgwoxFWvoGrSAmI+cEvbNBHX+xIQ4X1 /k6h8UTNe4uu3GLL0/VkjtqE04tyw9NnlXVANhyUbGGIXNojsG6jtwJqodq9B3Ou4MfYs gyTal8YLGs7wWqkiZr3yCtTUplmEewkyOnA/pYNbo1nD3TebzyCTlx69OkIa7/hzkrw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OLqosJf+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B56B606A322; Fri, 4 Dec 2026 12:38:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OLqosJf+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id A53701F000C2; Fri, 4 Dec 2026 12:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387915; bh=Vx6BwWNsH7kXlv4vVoCIhpRAi3+jvzL/y4rG5PCCRrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OLqosJf+5gx21yM+eR/fbxwScZ6EKfv2FPfyG//XF2dH+DkieGxYBbIN+mOD/Dah+ 3ohmxBqtAm1deibT8M9Wk8c3tlQfjohryOrLVYrMn5LW966vXdWoMURe+/vmKrhmXG K+ScnVCezAFKbhfcz56HScwlHXdkdjiYAZyH5e+U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Quanye Yang , Farhad Alemi , Jack Wang , Leon Romanovsky , Sasha Levin Subject: [PATCH 6.1 0369/1059] RDMA/rtrs-clt: Fix recv repost to satisfy ib_drain_rq Date: Fri, 4 Dec 2026 18:58:20 +0900 Message-ID: <20261204100653.839417033@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Quanye Yang [ Upstream commit 3255d6b83491574b115806ec958d8f6ca090fa9c ] On disconnect the client error recovery path calls ib_drain_qp(), which requires one free RQ slot and that no recv WQEs are posted while the queue is being drained. When the server is loaded with always_invalidate=N, the path does not advertise RTRS_MSG_NEW_RKEY_F. A client-requested invalidation is then a standalone SEND_WITH_INV. The recv completion path did not repost that WQE; it posted two empty recv WQEs later, when the RDMA-with-IMM response carried RTRS_IO_RSP_W_INV_IMM. If the invalidate receive never arrived, each such response increased RQ occupancy by one until ib_post_recv() started returning -ENOMEM and __ib_drain_rq() failed with: failed to drain recv queue: -12 Repost one empty recv WQE for every receive completion, including SEND_WITH_INV completions on the always_invalidate=N path, and only while the path is still connected so CQ polling cannot race with ib_drain_qp(). Size IO connection RQs to 2 * queue_depth + 1 to match the posted recv count and leave the drain slot. Tested with a synthetic RTRS client flooding unpaired RTRS_IO_RSP_W_INV_IMM messages; error recovery no longer triggers __ib_drain_rq() warnings. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Signed-off-by: Quanye Yang Link: https://lore.kernel.org/linux-rdma/CA+0ovCihE2_pxLimjmmR8NMz4g-ie8dvvq1jmAj-Om33y3Vzfg@mail.gmail.com Link: https://patch.msgid.link/20261005-rtrs-fix-ib-drain-rq-v2-1-35535a3ed115@proton.me Tested-by: Quanye Yang Reported-by: Farhad Alemi Acked-by: Jack Wang Signed-off-by: Leon Romanovsky [ sashal: kept the branch's existing min_t(int, ...) layout and %d error print, changing only the recv WR factor from 3 to 2 instead of upstream's plain min() form. ] Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 45 +++++++++----------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 7e592e3c04c6c..846a3b17afcd6 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -582,25 +582,21 @@ static struct ib_cqe io_comp_cqe = { .done = rtrs_clt_rdma_done }; -/* - * Post x2 empty WRs: first is for this RDMA with IMM, - * second is for RECV with INV, which happened earlier. - */ -static int rtrs_post_recv_empty_x2(struct rtrs_con *con, struct ib_cqe *cqe) +static int rtrs_clt_repost_recv(struct rtrs_clt_con *con) { - struct ib_recv_wr wr_arr[2], *wr; - int i; + struct rtrs_clt_path *clt_path = to_clt_path(con->c.path); + int err; - memset(wr_arr, 0, sizeof(wr_arr)); - for (i = 0; i < ARRAY_SIZE(wr_arr); i++) { - wr = &wr_arr[i]; - wr->wr_cqe = cqe; - if (i) - /* Chain backwards */ - wr->next = &wr_arr[i - 1]; - } + if (READ_ONCE(clt_path->state) != RTRS_CLT_CONNECTED) + return 0; - return ib_post_recv(con->qp, wr, NULL); + err = rtrs_post_recv_empty(&con->c, &io_comp_cqe); + if (err) { + rtrs_err(con->c.path, "rtrs_post_recv_empty(): %pe\n", + ERR_PTR(err)); + rtrs_rdma_error_recovery(con); + } + return err; } static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) @@ -661,19 +657,7 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) rtrs_wrn(con->c.path, "Unknown IMM type %u\n", imm_type); } - if (w_inval) - /* - * Post x2 empty WRs: first is for this RDMA with IMM, - * second is for RECV with INV, which happened earlier. - */ - err = rtrs_post_recv_empty_x2(&con->c, &io_comp_cqe); - else - err = rtrs_post_recv_empty(&con->c, &io_comp_cqe); - if (err) { - rtrs_err(con->c.path, "rtrs_post_recv_empty(): %d\n", - err); - rtrs_rdma_error_recovery(con); - } + rtrs_clt_repost_recv(con); break; case IB_WC_RECV: /* @@ -689,6 +673,7 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) return rtrs_clt_rkey_rsp_done(con, wc); } + rtrs_clt_repost_recv(con); break; case IB_WC_RDMA_WRITE: /* @@ -1709,7 +1694,7 @@ static int create_con_cq_qp(struct rtrs_clt_con *con) /* QD * (REQ + RSP + FR REGS or INVS) + drain */ clt_path->queue_depth * 4 + 1); max_recv_wr = min_t(int, wr_limit, - clt_path->queue_depth * 3 + 1); + clt_path->queue_depth * 2 + 1); max_send_sge = 2; } atomic_set(&con->c.sq_wr_avail, max_send_wr); -- 2.53.0