Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp600116rwo; Wed, 2 Aug 2023 00:41:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlEexismD5MdhsoHR9heYr7SUMkjou2kPypuHRAql3TMkYhmBs7Sj/nqCW9iFRXJZNiVHbsT X-Received: by 2002:a05:6808:190f:b0:3a3:91f8:d3da with SMTP id bf15-20020a056808190f00b003a391f8d3damr17681241oib.13.1690962085715; Wed, 02 Aug 2023 00:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690962085; cv=none; d=google.com; s=arc-20160816; b=QkzD6YgL8gqIbLjp5pdjkWUPuByNDNnk2GWBmNfY7FNi/sAc0WkqUEng+sx2xmofA6 oCbmZWWxupj55VBOf7WmLKh7oxK/Qadjbyha5EDLeAkLpJN5sKMQ7Bs97QNxJTFRqKsH h6ZZA8wseATNMRbQEXyofzkD732xP1ei74IsD5iGtRybID9GUBRm7cIpRymh1ISFoBCM Qa7Wo1K9I5EiJ/QXWj8K+n4da6hAGLn0aASluq8CcXjCT7jpQ4QFZHRC8r98HuJRe02f 2Ws7MWkE8Im+sYqUiuk4z0VoLHnJgIlp8XwfXp57wWjfoTmzFJuIFQYWdgl8ECj2Alm/ YyPg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=KEew3uv1dC1rzT83vlUoIJ+Jv8LW47z1hghGXJETLys=; fh=BG1K0WrNCDl2IiSLnDtgJLHPQBaNsmsTJjqgDAImPg0=; b=p+QiN40WekLgxEM+vsz6uN+3ZR+58yq6E8XgY36vcgU8FqraLs1187mUKVcebqukgu Xyl5AlJHS1x/4KtrXz7XhVORdpoj8KdKUQrfbq/JKwxQAESY9r9mznsXFld9W+7SV6t2 Zaq3lpkg79Bz3Z1/WbDL29PMoAa+o1i5U6sjhXm+N7VMVCJs+dOGRmtFbnhFVPPrUsWc 93+WDAztMm2+kSWVm2g4pEEufmYNAonUQ5HsVPl5gGBcP29hR+say2fULyXsr1AmDqlg 4IUtv1V1RIOuIAmvDaOfkIa2fcThy+6UWdyB+JpiqMD+8nRFdD40lruOcqm0FUKOTpjr 8JYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=fqRLDis8; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n127-20020a632785000000b0055c7eb346e1si10419302pgn.757.2023.08.02.00.41.13; Wed, 02 Aug 2023 00:41:25 -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=@suse.de header.s=susede2_rsa header.b=fqRLDis8; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231322AbjHBHfh (ORCPT + 99 others); Wed, 2 Aug 2023 03:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232869AbjHBHff (ORCPT ); Wed, 2 Aug 2023 03:35:35 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0180F1BF1 for ; Wed, 2 Aug 2023 00:35:04 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B909E1F8A4; Wed, 2 Aug 2023 07:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1690961703; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KEew3uv1dC1rzT83vlUoIJ+Jv8LW47z1hghGXJETLys=; b=fqRLDis8Og/JfvsWNPvlWyZqySa9C4RRUZKtXuT12z+K5L2vYBYrNY++RteJ+u8XYb+Zgj VlmUYicYDBsRGu9SEYKjyUstOKSogaB7vsyL0rPKAa0oepRq+8qO8R1k+JpsdBN0Own4q7 vTrdYGk+iKZys3mbQvX97MR3sfsJjGE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1690961703; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KEew3uv1dC1rzT83vlUoIJ+Jv8LW47z1hghGXJETLys=; b=ANDGXTqX+OXP3nz3sgWtTxNy20YqkznGnkLdszvOrwS4z1xUp8SZJQoG5qFh2Wkw/xdAMI G1mChXWsffRHWeCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7B0B513909; Wed, 2 Aug 2023 07:35:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KTIrCCYHymTrIwAAMHmgww (envelope-from ); Wed, 02 Aug 2023 07:35:02 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/6] SUNRPC: move all of xprt handling into svc_xprt_handle() Date: Wed, 2 Aug 2023 17:34:38 +1000 Message-Id: <20230802073443.17965-2-neilb@suse.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230802073443.17965-1-neilb@suse.de> References: <20230802073443.17965-1-neilb@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 svc_xprt_handle() does lots of things itself, but leaves some to the caller - svc_recv(). This isn't elegant. Move that code out of svc_recv() into svc_xprt_handle() Remove the calls to svc_xprt_release() from svc_send() and svc_drop() (the two possible final steps in svc_process()) and from svc_recv() (in the case where svc_process() wasn't called) into svc_xprt_handle(). Signed-off-by: NeilBrown --- net/sunrpc/svc_xprt.c | 53 ++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 4cfe9640df48..60759647fee4 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -785,7 +785,7 @@ static void svc_add_new_temp_xprt(struct svc_serv *serv, struct svc_xprt *newxpt svc_xprt_received(newxpt); } -static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt) +static void svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt) { struct svc_serv *serv = rqstp->rq_server; int len = 0; @@ -826,11 +826,26 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt) len = xprt->xpt_ops->xpo_recvfrom(rqstp); rqstp->rq_reserved = serv->sv_max_mesg; atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); + if (len <= 0) + goto out; + + trace_svc_xdr_recvfrom(&rqstp->rq_arg); + + clear_bit(XPT_OLD, &xprt->xpt_flags); + + rqstp->rq_chandle.defer = svc_defer; + + if (serv->sv_stats) + serv->sv_stats->netcnt++; + percpu_counter_inc(&rqstp->rq_pool->sp_messages_arrived); + rqstp->rq_stime = ktime_get(); + svc_process(rqstp); } else svc_xprt_received(xprt); out: - return len; + rqstp->rq_res.len = 0; + svc_xprt_release(rqstp); } /** @@ -844,11 +859,9 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt) void svc_recv(struct svc_rqst *rqstp) { struct svc_xprt *xprt = NULL; - struct svc_serv *serv = rqstp->rq_server; - int len; if (!svc_alloc_arg(rqstp)) - goto out; + return; try_to_freeze(); cond_resched(); @@ -856,31 +869,9 @@ void svc_recv(struct svc_rqst *rqstp) goto out; xprt = svc_get_next_xprt(rqstp); - if (!xprt) - goto out; - - len = svc_handle_xprt(rqstp, xprt); - - /* No data, incomplete (TCP) read, or accept() */ - if (len <= 0) - goto out_release; - - trace_svc_xdr_recvfrom(&rqstp->rq_arg); - - clear_bit(XPT_OLD, &xprt->xpt_flags); - - rqstp->rq_chandle.defer = svc_defer; - - if (serv->sv_stats) - serv->sv_stats->netcnt++; - percpu_counter_inc(&rqstp->rq_pool->sp_messages_arrived); - rqstp->rq_stime = ktime_get(); - svc_process(rqstp); + if (xprt) + svc_handle_xprt(rqstp, xprt); out: - return; -out_release: - rqstp->rq_res.len = 0; - svc_xprt_release(rqstp); } EXPORT_SYMBOL_GPL(svc_recv); @@ -890,7 +881,6 @@ EXPORT_SYMBOL_GPL(svc_recv); void svc_drop(struct svc_rqst *rqstp) { trace_svc_drop(rqstp); - svc_xprt_release(rqstp); } EXPORT_SYMBOL_GPL(svc_drop); @@ -906,8 +896,6 @@ void svc_send(struct svc_rqst *rqstp) int status; xprt = rqstp->rq_xprt; - if (!xprt) - return; /* calculate over-all length */ xb = &rqstp->rq_res; @@ -920,7 +908,6 @@ void svc_send(struct svc_rqst *rqstp) status = xprt->xpt_ops->xpo_sendto(rqstp); trace_svc_send(rqstp, status); - svc_xprt_release(rqstp); } /* -- 2.40.1