Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp29868imi; Thu, 21 Jul 2022 15:15:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vkyIW1wSbHVZ46aRTgqYxUYCOi8QaxkrwEqfwUCMOE+qV0Q7Z+cKNq0wIg1AI4ybyfXgc3 X-Received: by 2002:a17:907:761b:b0:72b:379e:39ea with SMTP id jx27-20020a170907761b00b0072b379e39eamr558014ejc.591.1658441713715; Thu, 21 Jul 2022 15:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658441713; cv=none; d=google.com; s=arc-20160816; b=Fi/kpwl4KVxRozAKfhyznY78FUWVNlXavC2kbVtRHFdx1x9QUl3/atKUsGMQa9ta3H mZejJEehwujA1QqW1FeTOvybouoHKFsYIV7h0xFDk4YHDFZoDiVbZDq3M4/BT0nYdsQL 8YRz/KJdUgmxVoQWY+rAz4+jykFY+VOptiq0qjCNKEjZCiVJxBymbjC/Nq30AqqV+vLm +ieClk0XGuxEs9nFq8VIMmMC7+0g/CKlOjlsc3ox9uj9x6EK0UYu3Ze65OZXy3hlCTz5 s/ovHRSJjlV4mrMtETc6TNwT1ahnCqPl28yhrF5W0nA9RfWO0/IzvuC/FBvziemXNt1G xUBQ== 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=Tv7+BXQfUtmPW8f36OVJmuLUqqT8kBfIbwZL2xjHZaw=; b=muY0mg4HeQFALFKrVVI4j2yqbsGgdeT28WaVIej7xXRcJRhiPCP/sfFzurWP7NU5bk yoxMIFYcQVWOuAkwHMEAgVkWr/M5Yr+BFc2KYxDsQcCeBQSygJJm8GpA5iOREVn4X8J7 qDhd0d2aTjWds2yxhjs/XK71uFRY+ItFanfvwIOIa6m/YiS9w6KBhoBoYeAToiGwg9g7 yUdDFJzMNMz73p4C/3DEQqgFcBvQEkCM0SiAYLmoF6c3PXfgivAzHyzzu86bR+yn36+R eJVQ9b4mAMOGV1u15zTeQy5Cpj7t0WO0Grv1M893LLcLLGpM5phohVISRQ4sUC0bWJXx +2HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YdrxKhRb; 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 ht20-20020a170907609400b0072b7dab918csi4255998ejc.255.2022.07.21.15.14.49; Thu, 21 Jul 2022 15:15:13 -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=YdrxKhRb; 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 S231761AbiGUWHV (ORCPT + 99 others); Thu, 21 Jul 2022 18:07:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232613AbiGUWHU (ORCPT ); Thu, 21 Jul 2022 18:07:20 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B48AB93C2B for ; Thu, 21 Jul 2022 15:07:19 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id l24so2420293ion.13 for ; Thu, 21 Jul 2022 15:07:19 -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=Tv7+BXQfUtmPW8f36OVJmuLUqqT8kBfIbwZL2xjHZaw=; b=YdrxKhRbMyJUYP71zewWvp0/hgCpjzLsC29WM60TnSb7YDOhhMMdQvUXs90Ly04Y3o oQl+bgB3oSURT8wf2RfpCwnV8h7//Rzqg2UxO/aghKsrRucD6L//vYjjvaX3thTsMpbI qENUKs4cgetzFW9PHLZ5m3cRM/PJbIKQuHUhqfxcjoS0+x8yljwpeIxLMiA/yQJB2DQd +HJrLO0W0f1fakbV406tSa6B5h+X/sk8D3iDpZNZ9bTQpttQmCLwRZmlMh1Q5xyyw1J9 WLeaHuE24RbSnsIvJE7Jbo14pHzK4wugnjPjy3AJMdTeY3TlaThZsF6dhsvLhrdot/yU 5TMg== 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=Tv7+BXQfUtmPW8f36OVJmuLUqqT8kBfIbwZL2xjHZaw=; b=3HMA0I3K0xjRInzEIJlFn1CRQU55vxa/V+1goB2gp1835KSFvkD0TfB4RMslkSjUl6 JkLbp203PC1gebr9+OCUHGKd50TdfAPeTBinh9likMOzE21RaVuGaQYWfNFjn+SC7ZlP 6xQww4hezZOMDg4NKEV7YqwUETBU0Y+oZuZMOVi5L334vICmD9GUK5hgKbYtlRmEtq4+ nxLb2xBgoclvatvflrXnbVVuLfsBPoOBUTuxFtm6RCegfmvYrVGxOuNv1a5piZCD5+9w kZ2L7VWL59pAuOGOqNiC6eHVXxoX6Hqf0CcjQsn/czywAeE4+AzRn3DQekkT9SdZekcX u3/Q== X-Gm-Message-State: AJIora+BxEmsWnxXohe+V4vgEHy7Ez9+Hago0QkvsQmE1e63jLvCf/pV HS0At5V1kMgbwWeRHUw6B7k= X-Received: by 2002:a05:6602:2d16:b0:67c:1472:815e with SMTP id c22-20020a0566022d1600b0067c1472815emr213399iow.86.1658441239438; Thu, 21 Jul 2022 15:07:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 15:07:18 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 02/11] SUNRPC add function to offline remove trunkable transports Date: Thu, 21 Jul 2022 18:07:05 -0400 Message-Id: <20220721220714.22620-3-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 Iterate thru available transports in the xprt_switch for all trunkable transports offline and possibly remote them as well. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 90501404fa49..d14333f4947a 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -234,6 +234,7 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *, struct rpc_xprt_switch *, struct rpc_xprt *, void *); +void rpc_clnt_manage_trunked_xprts(struct rpc_clnt *); const char *rpc_proc_name(const struct rpc_task *task); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index b6781ada3aa8..6417ccc283f4 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -3000,6 +3000,52 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, } EXPORT_SYMBOL_GPL(rpc_clnt_add_xprt); +static int rpc_xprt_offline(struct rpc_clnt *clnt, + struct rpc_xprt *xprt, + void *data) +{ + struct rpc_xprt *main_xprt; + struct rpc_xprt_switch *xps; + int err = 0; + + xprt_get(xprt); + + rcu_read_lock(); + main_xprt = xprt_get(rcu_dereference(clnt->cl_xprt)); + xps = xprt_switch_get(rcu_dereference(clnt->cl_xpi.xpi_xpswitch)); + err = rpc_cmp_addr_port((struct sockaddr *)&xprt->addr, + (struct sockaddr *)&main_xprt->addr); + rcu_read_unlock(); + xprt_put(main_xprt); + if (err) + goto out; + + if (wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE)) { + err = -EINTR; + goto out; + } + xprt_set_offline_locked(xprt, xps); + + xprt_release_write(xprt, NULL); +out: + xprt_put(xprt); + xprt_switch_put(xps); + return err; +} + +/* rpc_clnt_manage_trunked_xprts -- offline trunked transports + * @clnt rpc_clnt structure + * + * For each active transport found in the rpc_clnt structure call + * the function rpc_xprt_offline() which will identify trunked transports + * and will mark them offline. + */ +void rpc_clnt_manage_trunked_xprts(struct rpc_clnt *clnt) +{ + rpc_clnt_iterate_for_each_xprt(clnt, rpc_xprt_offline, NULL); +} +EXPORT_SYMBOL_GPL(rpc_clnt_manage_trunked_xprts); + struct connect_timeout_data { unsigned long connect_timeout; unsigned long reconnect_timeout; -- 2.27.0