Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8570294rwp; Wed, 19 Jul 2023 11:46:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlEzJOYid469vjZR3bAncdK4sxvgwewmSsgf7QMbQ9kRtVtrX3shFwNKmk7xYQ+eA7UPKPm7 X-Received: by 2002:a05:6358:590e:b0:135:24ed:5106 with SMTP id g14-20020a056358590e00b0013524ed5106mr8433639rwf.9.1689792394013; Wed, 19 Jul 2023 11:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689792393; cv=none; d=google.com; s=arc-20160816; b=BuviwVhmmsB1r/5q788v3kX23pOTdqKYV8u2viXmZZXyskad/O24soEyGs7AEokkao zQV5q5lExFgTU4hlwA572+tTLUdke9a6MwSOx9sgh5gmIJ8MMdtd4NatR6YAq/CKFUd7 FdEXQ/FRVUU4UCHh7jZAaHEsJ0QI9NG9naCEiTC95Ip16ZIM8wJbWkft2/7EqY0KH38Q ioO6omP8Zqm3O4XCBg+2Kd3zqCQrzuJSv6KyQmMjQL7/IM++Oo4IwnJ4zJpYPn2qU0Gl tC2Tq4nDdXhr22Cw8Co6LI9yy7YnS9E5r2fD9St1oTl1qjkEp0UGcm4u7/oT6sjzkQKd NPGA== 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:dkim-signature; bh=MjaRjPxFS+tBXQAijW3g3Q2hXWkhDMX4Xf/7iEigRo4=; fh=LzETK1JzzmIO7ms4Hpbej0ts/h/5wADyVoPBGQWqyqI=; b=mssrkoRxUBdotKdO33C3Yxp0ank3yLmyV7+vHjXGjC1z4QPwhpN9kgHWJEI8ahs1Ew awAUt/ccBqv6xvGWUIVNl52lMjMwNV+PeRebpvZxdsXeRFpyOZxRPrYklAex6tkXX2Ff K2q0Otcq+VngiKi/cV56ZqJop4oFWzBnSMusq05DZ5+wu51hoaMQbN3eVLe8YPrJtbiz hp2ieK6R0NbOV/cO3I1vhAMsaSQtp+7ThWoIJiyJXDqgTKDbAmYZ7KSbwaOdoDBg5RSB oNSTseVpOe5g0Xf1JSVpW9MqZnK+Qw8578BHZzx3S7wRqIhfuoNmYVUIeBjymwKBh7ey 9OFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eVonETjN; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z127-20020a633385000000b0056339e5afaesi3486729pgz.331.2023.07.19.11.46.20; Wed, 19 Jul 2023 11:46:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eVonETjN; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbjGSSbT (ORCPT + 99 others); Wed, 19 Jul 2023 14:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjGSSbT (ORCPT ); Wed, 19 Jul 2023 14:31:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 597A3B6 for ; Wed, 19 Jul 2023 11:31:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EC8B6617C2 for ; Wed, 19 Jul 2023 18:31:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19B8CC433C8; Wed, 19 Jul 2023 18:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689791477; bh=D6DwcPwywvoVU7CXOxDCIrUiHzrDx4usY5dx9EsKCaI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=eVonETjNis11TjJ1oRLkrr3NJ4iHzlF7nw72KDfLquSbo2B4zMpOWrTfYToeZuGDP sriFE2tNBDGZrTo4tCMhmITUnid9+1HjIUJZ3YLbPTj3vw21s8ZEJRC/lpMQsZnE+b 9WWuDQ3DEoSAR/ztkxluu8RCQeYyvWTzQ493WSRjUt8B+99EAJQZffLXon+XUvC239 5kU2/bT29ZXOwxH10FnCahbw7T3KNIH93COT+4cqOGJlFIShXnsVpSvfKcidjoJgCm 3O1FhQXDtIrEpkFcdWkNv+3G8Tw+hM3wXu5NwsYDT3NPgCcLsgdooE8sbCFMLvs2yR EgWJgrvrzJItg== Subject: [PATCH v3 3/5] SUNRPC: Convert svc_udp_sendto() to use the per-socket bio_vec array From: Chuck Lever To: linux-nfs@vger.kernel.org, netdev@vger.kernel.org Cc: Chuck Lever , dhowells@redhat.com Date: Wed, 19 Jul 2023 14:31:16 -0400 Message-ID: <168979147611.1905271.944494362977362823.stgit@morisot.1015granger.net> In-Reply-To: <168979108540.1905271.9720708849149797793.stgit@morisot.1015granger.net> References: <168979108540.1905271.9720708849149797793.stgit@morisot.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Chuck Lever Commit da1661b93bf4 ("SUNRPC: Teach server to use xprt_sock_sendmsg for socket sends") modified svc_udp_sendto() to use xprt_sock_sendmsg() because we originally believed xprt_sock_sendmsg() would be needed for TLS support. That does not actually appear to be the case. In addition, the linkage between the client and server send code has been a bit of a maintenance headache because of the distinct ways that the client and server handle memory allocation. Going forward, eventually the XDR layer will deal with its buffers in the form of bio_vec arrays, so convert this function accordingly. Signed-off-by: Chuck Lever --- net/sunrpc/svcsock.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index d4d816036c04..f28790f282c2 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -695,7 +695,7 @@ static int svc_udp_sendto(struct svc_rqst *rqstp) .msg_control = cmh, .msg_controllen = sizeof(buffer), }; - unsigned int sent; + unsigned int count; int err; svc_udp_release_ctxt(xprt, rqstp->rq_xprt_ctxt); @@ -708,22 +708,23 @@ static int svc_udp_sendto(struct svc_rqst *rqstp) if (svc_xprt_is_dead(xprt)) goto out_notconn; - err = xdr_alloc_bvec(xdr, GFP_KERNEL); - if (err < 0) - goto out_unlock; + count = xdr_buf_to_bvec(rqstp->rq_bvec, + ARRAY_SIZE(rqstp->rq_bvec), xdr); - err = xprt_sock_sendmsg(svsk->sk_sock, &msg, xdr, 0, 0, &sent); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, rqstp->rq_bvec, + count, 0); + err = sock_sendmsg(svsk->sk_sock, &msg); if (err == -ECONNREFUSED) { /* ICMP error on earlier request. */ - err = xprt_sock_sendmsg(svsk->sk_sock, &msg, xdr, 0, 0, &sent); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, rqstp->rq_bvec, + count, 0); + err = sock_sendmsg(svsk->sk_sock, &msg); } - xdr_free_bvec(xdr); + trace_svcsock_udp_send(xprt, err); -out_unlock: + mutex_unlock(&xprt->xpt_mutex); - if (err < 0) - return err; - return sent; + return err; out_notconn: mutex_unlock(&xprt->xpt_mutex);