Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp64616pxh; Thu, 7 Apr 2022 14:06:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3swooEZm7FOzMSRm6fWOZCYFcSWrQHd3EsLQ6wJiObmljLmo5cffkbSF0V7ITlKrC7wa8 X-Received: by 2002:a17:902:f64d:b0:14f:fb63:f1a with SMTP id m13-20020a170902f64d00b0014ffb630f1amr15915757plg.159.1649365566838; Thu, 07 Apr 2022 14:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649365566; cv=none; d=google.com; s=arc-20160816; b=kQfEJf53e6T+6+iBeTRRfAyoJheBCRRlqwII8WlQ+oUAaBGwgBjN3xiWnSfOx5i2Aa bXhichjctWHWUCGNIub3oLR71S2PXILtNfClZz0gI/17FrRQyo1/B+uCQ3Db4aju9J0S WlRjLnIjg01tC8JJ8Y9xwyc/CVWUolTeshxcvUXvpQn6Pz/58YMM0N+fI362ePIkqJ7E v++pPsyAiNfnwSGiuXOZOXXA1rKzEiFeP8X7F2fhgWSJgWu4tsj1VjuBKCNUwPeuhwuM oJdlOEXP6VtK30wc7h0XSg33ysyUCtPrG+hbzLptimOJ2xjWv9qUSno8x39EkQDeTbn5 G//A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject; bh=eojgELN3xDt/nQ7K2wab6e3VkU6P0F2KzCNyQXdKP38=; b=cm3rgtUF5QgHUo5lFJMFz1lxz3x4auGA4dF2Z8hpOccXFQSpMiRfkvRzOmXVJLJ43s alYIeWz6zNMqeTyfsP/EyDNaeiazZkzj1kpj+XatQEWWl4WL2/n805wUBxV62w9jawcj QnCXOEKkph5avU6xShPqNSjJsMK4yHkq1YU1lfBaSA9srwzt3cjhh/mzZVvtY04Pl8n4 cmQquNZx4FkFKr6QMMLnz6uHdPbuSx8q8J9TUpUioqh7Bwl6gAilDaRQxz+rJ8XAp5QE 6fd2yLI3xSUMd7yTpbw0HIYk4JC3ZIGs/EwO+SYz6PS4YOmU5oRLzP7V5WSjTN0tq/dV 7K2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q75-20020a632a4e000000b0039cc65bdc50si2996107pgq.599.2022.04.07.14.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:06:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 776952CB116; Thu, 7 Apr 2022 13:11:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232372AbiDGRpa (ORCPT + 99 others); Thu, 7 Apr 2022 13:45:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbiDGRpa (ORCPT ); Thu, 7 Apr 2022 13:45:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3CC422A292 for ; Thu, 7 Apr 2022 10:43:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9D36761AFE for ; Thu, 7 Apr 2022 17:43:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCEBEC385AA; Thu, 7 Apr 2022 17:43:23 +0000 (UTC) Subject: [PATCH v3 1/2] SUNRPC: Fix NFSD's request deferral on RDMA transports From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: rostedt@goodmis.org Date: Thu, 07 Apr 2022 13:43:22 -0400 Message-ID: <164935340273.76813.7096678268046264254.stgit@klimt.1015granger.net> In-Reply-To: <164935330144.76813.17862521591948764594.stgit@klimt.1015granger.net> References: <164935330144.76813.17862521591948764594.stgit@klimt.1015granger.net> User-Agent: StGit/1.5.dev1+g8516920 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Trond Myklebust reports an NFSD crash in svc_rdma_sendto(). Further investigation shows that the crash occurred while NFSD was handling a deferred request. This patch addresses two inter-related issues that prevent request deferral from working correctly for RPC/RDMA requests: 1. Prevent the crash by ensuring that the original svc_rqst::rq_xprt_ctxt value is available when the request is revisited. Otherwise svc_rdma_sendto() does not have a Receive context available with which to construct its reply. 2. Possibly since before commit 71641d99ce03 ("svcrdma: Properly compute .len and .buflen for received RPC Calls"), svc_rdma_recvfrom() did not include the transport header in the returned xdr_buf. There should have been no need for svc_defer() and friends to save and restore that header, as of that commit. This issue is addressed in a backport-friendly way by simply having svc_rdma_recvfrom() set rq_xprt_hlen to zero unconditionally, just as svc_tcp_recvfrom() does. This enables svc_deferred_recv() to correctly reconstruct an RPC message received via RPC/RDMA. Reported-by: Trond Myklebust Link: https://lore.kernel.org/linux-nfs/82662b7190f26fb304eb0ab1bb04279072439d4e.camel@hammerspace.com/ Signed-off-by: Chuck Lever Cc: --- include/linux/sunrpc/svc.h | 1 + net/sunrpc/svc_xprt.c | 3 +++ net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index a5dda4987e8b..217711fc9cac 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -395,6 +395,7 @@ struct svc_deferred_req { size_t addrlen; struct sockaddr_storage daddr; /* where reply must come from */ size_t daddrlen; + void *xprt_ctxt; struct cache_deferred_req handle; size_t xprt_hlen; int argslen; diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 0c117d3bfda8..b42cfffa7395 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -1231,6 +1231,8 @@ static struct cache_deferred_req *svc_defer(struct cache_req *req) dr->daddr = rqstp->rq_daddr; dr->argslen = rqstp->rq_arg.len >> 2; dr->xprt_hlen = rqstp->rq_xprt_hlen; + dr->xprt_ctxt = rqstp->rq_xprt_ctxt; + rqstp->rq_xprt_ctxt = NULL; /* back up head to the start of the buffer and copy */ skip = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len; @@ -1269,6 +1271,7 @@ static noinline int svc_deferred_recv(struct svc_rqst *rqstp) rqstp->rq_xprt_hlen = dr->xprt_hlen; rqstp->rq_daddr = dr->daddr; rqstp->rq_respages = rqstp->rq_pages; + rqstp->rq_xprt_ctxt = dr->xprt_ctxt; svc_xprt_received(rqstp->rq_xprt); return (dr->argslen<<2) - dr->xprt_hlen; } diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c index cf76a6ad127b..864131a9fc6e 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c @@ -831,7 +831,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp) goto out_err; if (ret == 0) goto out_drop; - rqstp->rq_xprt_hlen = ret; + rqstp->rq_xprt_hlen = 0; if (svc_rdma_is_reverse_direction_reply(xprt, ctxt)) goto out_backchannel;