From patchwork Tue May 30 18:14:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 9755023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A92D601D2 for ; Tue, 30 May 2017 18:14:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19A0D26538 for ; Tue, 30 May 2017 18:14:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E841265B9; Tue, 30 May 2017 18:14:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E26E426538 for ; Tue, 30 May 2017 18:14:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751014AbdE3SO3 (ORCPT ); Tue, 30 May 2017 14:14:29 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:33874 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751000AbdE3SO2 (ORCPT ); Tue, 30 May 2017 14:14:28 -0400 Received: by mail-io0-f196.google.com with SMTP id 12so9816238iol.1; Tue, 30 May 2017 11:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=wl2tWvmtTAn5GrVwk/M9XpctWWM3Xp/k5y7UNACdt+k=; b=goYOxkWtg7u4chlvvIgyBOm1kZwxhJfMWwM5QANLcU0Hwvp75woz/tkjJSIMEVkZLa KF3L1WiB1M9A3JuebYaDQfbJgzdlZU25TPpwYTwu1WjBR71aCvNhOsGP0xLga5FYWnRo +xPfHEtk2s6Dp3g91AeLH+SpepXSNUqfh5EU61gpg/Fi8DpqXtbtlNmK51uoQLNViIcD qgXMNtfePGAA28ZFh7NjUp4E92qXYHym//fw3DtnWXQ7N59eV3YRCRoAjD75FEpttyLE gwN0kWfqSa+pDZfB8stIMqS8wxnv+gOY0M2zLmkEyntt+9VzYf2C0K3j2hCux+1Brq9V a/Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=wl2tWvmtTAn5GrVwk/M9XpctWWM3Xp/k5y7UNACdt+k=; b=thpe3SNluZOQRf9pyvamb+HCSFxzH3PY9RPw8NCzr7zSWBapgd11986ACboBaxOrCt y7Il3iQafPRbvSg02y7fmOHH5fbzgT/RBefYIoyBXmzc5y8Fm4p58ET+OHflNMkbq+jm HV5aucIbR7MJ6nxqT750KhMD0BFWUE+ZO8/O/MknGFyFltqr/jfELcxYUw8LUPIBFm1m PqiyByCYwqx6OKfMCx6weiMW12KpvjlZ1lRjo/9rKyP6MTyhatwfi+Bp/+D1eaKWZpOw 8s3dwPCEkXI/aIHTkrvwDn+XMnTKvA2Iyfcp79xpGVwW94JLBViIcFIcbAx/W5Rm7pfO bhaQ== X-Gm-Message-State: AODbwcDblJ0zyuoLnCx5lZRYQO2H8aoAIHPdClr6EbRGtCctBww/16Gj YXc3ZaKjxYwzjh0f X-Received: by 10.107.9.24 with SMTP id j24mr18628256ioi.172.1496168067856; Tue, 30 May 2017 11:14:27 -0700 (PDT) Received: from klimt.1015granger.net (c-68-46-169-226.hsd1.mi.comcast.net. [68.46.169.226]) by smtp.gmail.com with ESMTPSA id b18sm5993243ioa.16.2017.05.30.11.14.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 11:14:27 -0700 (PDT) Subject: [PATCH v1 03/17] svcrdma: Avoid Send Queue overflow From: Chuck Lever To: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org Date: Tue, 30 May 2017 14:14:26 -0400 Message-ID: <20170530181426.2992.48954.stgit@klimt.1015granger.net> In-Reply-To: <20170530175808.2992.60365.stgit@klimt.1015granger.net> References: <20170530175808.2992.60365.stgit@klimt.1015granger.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sanity case: Catch the case where more Work Requests are being posted to the Send Queue than there are Send Queue Entries. This might happen if a client sends a chunk with more segments than there are SQEs for the transport. The server can't send that reply, so the transport will deadlock unless the client drops the RPC. Signed-off-by: Chuck Lever --- net/sunrpc/xprtrdma/svc_rdma_rw.c | 5 +++++ net/sunrpc/xprtrdma/svc_rdma_sendto.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c index 0cf6202..3b35364 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_rw.c +++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c @@ -232,6 +232,9 @@ static int svc_rdma_post_chunk_ctxt(struct svc_rdma_chunk_ctxt *cc) struct ib_cqe *cqe; int ret; + if (cc->cc_sqecount > rdma->sc_sq_depth) + return -EINVAL; + first_wr = NULL; cqe = &cc->cc_cqe; list_for_each(tmp, &cc->cc_rwctxts) { @@ -425,6 +428,7 @@ static int svc_rdma_send_xdr_pagelist(struct svc_rdma_write_info *info, * * Returns a non-negative number of bytes the chunk consumed, or * %-E2BIG if the payload was larger than the Write chunk, + * %-EINVAL if client provided too many segments, * %-ENOMEM if rdma_rw context pool was exhausted, * %-ENOTCONN if posting failed (connection is lost), * %-EIO if rdma_rw initialization failed (DMA mapping, etc). @@ -465,6 +469,7 @@ int svc_rdma_send_write_chunk(struct svcxprt_rdma *rdma, __be32 *wr_ch, * * Returns a non-negative number of bytes the chunk consumed, or * %-E2BIG if the payload was larger than the Reply chunk, + * %-EINVAL if client provided too many segments, * %-ENOMEM if rdma_rw context pool was exhausted, * %-ENOTCONN if posting failed (connection is lost), * %-EIO if rdma_rw initialization failed (DMA mapping, etc). diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c index 5ba6d91..19fd01e 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c @@ -684,7 +684,7 @@ int svc_rdma_sendto(struct svc_rqst *rqstp) return 0; err2: - if (ret != -E2BIG) + if (ret != -E2BIG || ret != -EINVAL) goto err1; ret = svc_rdma_post_recv(rdma, GFP_KERNEL);