Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp29940imi; Thu, 21 Jul 2022 15:15:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tLFNV2pREU/QnZsiHQHyRsUZHtpbKaJ0YXZobB3s2U+4fDdYjgEhzOs6fxHpGipR+j4h8K X-Received: by 2002:a05:6402:1d4a:b0:43a:ca49:abc6 with SMTP id dz10-20020a0564021d4a00b0043aca49abc6mr522614edb.376.1658441718829; Thu, 21 Jul 2022 15:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658441718; cv=none; d=google.com; s=arc-20160816; b=WTJSFveqcVQsoOFUVr+DyEU5esamyU1VvqDK9W6buoEoM0SCG6b5NCU3K7ZXdMyJNL Mp9dESTRSbYE3yoGC0If2QUbscnGYys5BtTCaPOdIjnbAvgmBtzmx6czfBtGu63nxKup m+rEnuySEb6wa9brqrJzw/Sz2g9nmoAiw+GYJVX/ciWQIRSQXcZmJs/04qr9fq4Q7dgP I58LsgggXPjJj3xLC/v0AxLvsbBCozjlMtIsDRMFbYAN0LzvFJ6p0sQ1nBOrERueakmg /nv8Aldmja+J9chCxnv06E2u8jWf9a/4avi5zm/sUkS5EfsynOUzL4C/0DhPgohBgb2Z oG0A== 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; bh=CQAt8edP4jBxj/fXQ78ofDRK5ysG6X+fFnsG4SDF2y4=; b=T+QVLENW2CBeC7ytgVsaO4xBIaiqAHBm0PypEmXnSi8BOLpqgw07K+bGIQROcrDp7E 0bOkeRisdCklavxbXzQb/y/2KzlPIOYjNnNN084jIcJQznGj4kfn3QZ8Bk/VBxOjejzJ Xm5YU96tRFCuipAU8fGiwVPag/bngxPXXG5RJ32m55GtdnSPeUpbNeGuX+SuPES/5HuG C08hKBn01deuKj86tGcDHwSPnOMNTBlBgX2P9V7N0/JVFLQwKJhAa0vCc5EsOpnWOnOE U/yQZ1Gtgy5sm1l2yYeBCnoMzNtVpjnaw4r+NSvW+JUU7YWs/nWxBjKrJu8lgFDcVbPD bGyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ewqNfflJ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs18-20020a170906dc9200b0072ee27ef788si3976427ejc.838.2022.07.21.15.14.54; Thu, 21 Jul 2022 15:15:18 -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=@gmail.com header.s=20210112 header.b=ewqNfflJ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233686AbiGUWHZ (ORCPT + 99 others); Thu, 21 Jul 2022 18:07:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232613AbiGUWHZ (ORCPT ); Thu, 21 Jul 2022 18:07:25 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D9C38875F for ; Thu, 21 Jul 2022 15:07:24 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id y13so1433081ilv.5 for ; Thu, 21 Jul 2022 15:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CQAt8edP4jBxj/fXQ78ofDRK5ysG6X+fFnsG4SDF2y4=; b=ewqNfflJv2boZm6KB3Yisj5d6afivKWk99QjKvGsx60+XB1IGQCGQ6OOT+ijDeg0B7 zVrd8dhKfzIxgUFotOXTP5gQ/QU62DSg6SMql7Pm1VJCoKTERmON7eADIHzOH8+D7O5w Lz8zliTsDjHyMhgtt1JV6isaeWpHRyIjKl8pu3Gl3qIyzjZzgY1l/ulNvvee/m0oeZEw yIc9+tqsRNLinTV36LW/Ngn7qedZz619PhF918aRQU7hdnRknvi16tLGnHIjNDh2sO6H nJiFJ789bazBftUc2UmZW6PZVYNS4A4CgIFBK2sr/2IT9DxDeVJpEAanhlgI1srxuHNg dSjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CQAt8edP4jBxj/fXQ78ofDRK5ysG6X+fFnsG4SDF2y4=; b=PSLQFArCFoyMqBCJlPRA1kIe0hNaUaZK8HCX3/Em+VvVuiRt9/qx3vDSUFpnRmRsYf T2sYjIb7z8R3WHl90kbsSl/GltlxHkGcz9+2aUm2Ta53gTpke98fNH7lLE5i+USk5TSb LN5xhsFKKCD32fOLiS/r6BWoQKAhaRM4fQJlVP2ip2koGGFOQk1JShHDjhspNoXEkuJ3 jGsSr8XTE34t+gx4SCkfzZ7ey8HCUl+eu/cmOZaeyUJaHiHbk2rjQdkI48seNyOEwwms UbX9/kWbzwhHFC5iAKtQa8tCT/rb90GO+cbrqkNWB8s1wf8y3pjJK+9/zIMnLN2NmMpm Kfdw== X-Gm-Message-State: AJIora9bwq3bTy1Dg/aIQqkViNn99LlZCJDH+2l+r6oNCJLAlrHR0BU5 JS2870UWWLLNvsKfh9d0gwI= X-Received: by 2002:a05:6e02:1906:b0:2dc:731b:561 with SMTP id w6-20020a056e02190600b002dc731b0561mr207343ilu.284.1658441243667; Thu, 21 Jul 2022 15:07:23 -0700 (PDT) Received: from kolga-mac-1.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id g11-20020a05663811cb00b00341668383cfsm1281105jas.33.2022.07.21.15.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 15:07:23 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 06/11] SUNRPC create an rpc function that allows xprt removal from rpc_clnt Date: Thu, 21 Jul 2022 18:07:09 -0400 Message-Id: <20220721220714.22620-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220721220714.22620-1-olga.kornievskaia@gmail.com> References: <20220721220714.22620-1-olga.kornievskaia@gmail.com> 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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Expose a function that allows a removal of xprt from the rpc_clnt. When called from NFS that's running a trunked transport then don't decrement the active transport counter. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/clnt.h | 1 + include/linux/sunrpc/xprtmultipath.h | 2 +- net/sunrpc/clnt.c | 16 +++++++++++++++- net/sunrpc/xprt.c | 2 +- net/sunrpc/xprtmultipath.c | 10 +++++----- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 71a3a1dd7e81..7a43fd514398 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -240,6 +240,7 @@ const char *rpc_proc_name(const struct rpc_task *task); void rpc_clnt_xprt_switch_put(struct rpc_clnt *); void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *, struct rpc_xprt *); +void rpc_clnt_xprt_switch_remove_xprt(struct rpc_clnt *, struct rpc_xprt *); bool rpc_clnt_xprt_switch_has_addr(struct rpc_clnt *clnt, const struct sockaddr *sap); void rpc_clnt_xprt_set_online(struct rpc_clnt *clnt, struct rpc_xprt *xprt); diff --git a/include/linux/sunrpc/xprtmultipath.h b/include/linux/sunrpc/xprtmultipath.h index 688ca7eb1d01..9fff0768d942 100644 --- a/include/linux/sunrpc/xprtmultipath.h +++ b/include/linux/sunrpc/xprtmultipath.h @@ -55,7 +55,7 @@ extern void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps); extern void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps, struct rpc_xprt *xprt); extern void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps, - struct rpc_xprt *xprt); + struct rpc_xprt *xprt, bool offline); extern void xprt_iter_init(struct rpc_xprt_iter *xpi, struct rpc_xprt_switch *xps); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 036ccf01bd25..82a829798d96 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2144,7 +2144,8 @@ call_connect_status(struct rpc_task *task) xprt_release(task); value = atomic_long_dec_return(&xprt->queuelen); if (value == 0) - rpc_xprt_switch_remove_xprt(xps, saved); + rpc_xprt_switch_remove_xprt(xps, saved, + true); xprt_put(saved); task->tk_xprt = NULL; task->tk_action = call_start; @@ -3118,6 +3119,19 @@ void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt) } EXPORT_SYMBOL_GPL(rpc_clnt_xprt_switch_add_xprt); +void rpc_clnt_xprt_switch_remove_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt) +{ + struct rpc_xprt_switch *xps; + + rcu_read_lock(); + xps = rcu_dereference(clnt->cl_xpi.xpi_xpswitch); + rpc_xprt_switch_remove_xprt(rcu_dereference(clnt->cl_xpi.xpi_xpswitch), + xprt, 0); + xps->xps_nunique_destaddr_xprts--; + rcu_read_unlock(); +} +EXPORT_SYMBOL_GPL(rpc_clnt_xprt_switch_remove_xprt); + bool rpc_clnt_xprt_switch_has_addr(struct rpc_clnt *clnt, const struct sockaddr *sap) { diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 8f8e3c952f24..44348c9f4b00 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -2182,5 +2182,5 @@ void xprt_delete_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps) if (!xprt->sending.qlen && !xprt->pending.qlen && !xprt->backlog.qlen && !atomic_long_read(&xprt->queuelen)) - rpc_xprt_switch_remove_xprt(xps, xprt); + rpc_xprt_switch_remove_xprt(xps, xprt, true); } diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index 8def8423fc0a..39a8a2f9c982 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -62,11 +62,11 @@ void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps, } static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps, - struct rpc_xprt *xprt) + struct rpc_xprt *xprt, bool offline) { if (unlikely(xprt == NULL)) return; - if (!test_bit(XPRT_OFFLINE, &xprt->state)) + if (!test_bit(XPRT_OFFLINE, &xprt->state) && offline) xps->xps_nactive--; xps->xps_nxprts--; if (xps->xps_nxprts == 0) @@ -83,10 +83,10 @@ static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps, * Removes xprt from the list of struct rpc_xprt in xps. */ void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps, - struct rpc_xprt *xprt) + struct rpc_xprt *xprt, bool offline) { spin_lock(&xps->xps_lock); - xprt_switch_remove_xprt_locked(xps, xprt); + xprt_switch_remove_xprt_locked(xps, xprt, offline); spin_unlock(&xps->xps_lock); xprt_put(xprt); } @@ -155,7 +155,7 @@ static void xprt_switch_free_entries(struct rpc_xprt_switch *xps) xprt = list_first_entry(&xps->xps_xprt_list, struct rpc_xprt, xprt_switch); - xprt_switch_remove_xprt_locked(xps, xprt); + xprt_switch_remove_xprt_locked(xps, xprt, true); spin_unlock(&xps->xps_lock); xprt_put(xprt); spin_lock(&xps->xps_lock); -- 2.27.0