From patchwork Mon Jun 20 15:23:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08091C43334 for ; Mon, 20 Jun 2022 15:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244743AbiFTPZz (ORCPT ); Mon, 20 Jun 2022 11:25:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239950AbiFTPZW (ORCPT ); Mon, 20 Jun 2022 11:25:22 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAA07CF9 for ; Mon, 20 Jun 2022 08:24:32 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id 88so12811540qva.9 for ; Mon, 20 Jun 2022 08:24:32 -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=1HQd2B/YkNYnZSu99acmqUXErKGwuXvN6tYgl+XEJ6A=; b=mLlyN5eCfD9MyWiqDlYWwU19roYac7YV5tk4wFbec8JWtlL3XTXOfnQ2H1uvzaNosF cxSfbc9hi61M9TmIFOXEuySFWqH+yNodeAuaRlXlq1fbheSdN8WXo4NYKaIAS7f5kOd4 dMLGysIoZMGtAKvJV4SlykJRfj+0QtgUmIROH5KZDbsRTbMeCv3K8h9ywhqqnNoLgfyp 080CIbLiBU0+ON057KDmfo8t45OLMRsWGON5BYn1Wl2+4PsOTudblCjeM4uShlZPJ10o oHIiTEzh3xUJsLQWWNg1Q36W3asXYCHaeo6KUDs1n2BIh6ubcxzqDMQOz3ONKJEifKFw NQ1Q== 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=1HQd2B/YkNYnZSu99acmqUXErKGwuXvN6tYgl+XEJ6A=; b=Bmd1dRb0tmBCxUBGU9I07kh7JqUexuauPwnBveCEsIg+9t/JmyCFnzU+vuB+u5ZK5l enndJyK2bNrjWnWrSKKpQ0MVx85dYSq/N5xjio+ZKgWX3h9Mo1KYFE9UTOGFleq9PkGP 4+UoxpoXMwGR7+LxX9L/dH+BDmIafilqSDUskHS4uWB/W0hLxvTWeX1mUsWgM5uS2Sup IJe63rOmklajsH2Lac5gSevBc2LZIt3kQJHZ+R0RhonJOpeE1lEKpYLxibDKAmk4bebm yl7H/eJPGy1hwJuGYrXAJSVt5LSDWgp8Vv9/yjBsj+YZUU13lIOgILhzb4LTvwLFY0ss PubQ== X-Gm-Message-State: AJIora8d8DvrsVbFuHmyoX4s0qHEduSqcxGVOPXL/7Y29TccI3ffwiG3 /UJCzp8Lvc34IdYeDnZEf7w= X-Google-Smtp-Source: AGRyM1tdIO+ZJ33ED4UEwRmrCf2wDOSTbUkCSoiGyGHPLIJL9Y/32nfT4FKWrhUkuHtSf+6va+e6zQ== X-Received: by 2002:ac8:5d87:0:b0:305:bbf:cd85 with SMTP id d7-20020ac85d87000000b003050bbfcd85mr20398526qtx.618.1655738671755; Mon, 20 Jun 2022 08:24:31 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:31 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 01/12] SUNRPC expose functions for offline remote xprt functionality Date: Mon, 20 Jun 2022 11:23:56 -0400 Message-Id: <20220620152407.63127-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Re-arrange the code that make offline transport and delete transport callable functions. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/xprt.h | 3 +++ net/sunrpc/sysfs.c | 28 +++++----------------------- net/sunrpc/xprt.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 522bbf937957..0d51b9f9ea37 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -505,4 +505,7 @@ static inline int xprt_test_and_set_binding(struct rpc_xprt *xprt) return test_and_set_bit(XPRT_BINDING, &xprt->state); } +void xprt_set_offline_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps); +void xprt_set_online_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps); +void xprt_delete_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps); #endif /* _LINUX_SUNRPC_XPRT_H */ diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index a3a2f8aeb80e..7330eb9a70cf 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -314,32 +314,14 @@ static ssize_t rpc_sysfs_xprt_state_change(struct kobject *kobj, goto release_tasks; } if (offline) { - if (!test_and_set_bit(XPRT_OFFLINE, &xprt->state)) { - spin_lock(&xps->xps_lock); - xps->xps_nactive--; - spin_unlock(&xps->xps_lock); - } + xprt_set_offline_locked(xprt, xps); } else if (online) { - if (test_and_clear_bit(XPRT_OFFLINE, &xprt->state)) { - spin_lock(&xps->xps_lock); - xps->xps_nactive++; - spin_unlock(&xps->xps_lock); - } + xprt_set_online_locked(xprt, xps); } else if (remove) { - if (test_bit(XPRT_OFFLINE, &xprt->state)) { - if (!test_and_set_bit(XPRT_REMOVE, &xprt->state)) { - xprt_force_disconnect(xprt); - if (test_bit(XPRT_CONNECTED, &xprt->state)) { - if (!xprt->sending.qlen && - !xprt->pending.qlen && - !xprt->backlog.qlen && - !atomic_long_read(&xprt->queuelen)) - rpc_xprt_switch_remove_xprt(xps, xprt); - } - } - } else { + if (test_bit(XPRT_OFFLINE, &xprt->state)) + xprt_delete_locked(xprt, xps); + else count = -EINVAL; - } } release_tasks: diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 86d62cffba0d..6480ae324b27 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -2152,3 +2152,38 @@ void xprt_put(struct rpc_xprt *xprt) kref_put(&xprt->kref, xprt_destroy_kref); } EXPORT_SYMBOL_GPL(xprt_put); + +void xprt_set_offline_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps) +{ + if (!test_and_set_bit(XPRT_OFFLINE, &xprt->state)) { + spin_lock(&xps->xps_lock); + xps->xps_nactive--; + spin_unlock(&xps->xps_lock); + } +} +EXPORT_SYMBOL(xprt_set_offline_locked); + +void xprt_set_online_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps) +{ + if (test_and_clear_bit(XPRT_OFFLINE, &xprt->state)) { + spin_lock(&xps->xps_lock); + xps->xps_nactive++; + spin_unlock(&xps->xps_lock); + } +} +EXPORT_SYMBOL(xprt_set_online_locked); + +void xprt_delete_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps) +{ + if (test_and_set_bit(XPRT_REMOVE, &xprt->state)) + return; + + xprt_force_disconnect(xprt); + if (!test_bit(XPRT_CONNECTED, &xprt->state)) + return; + + if (!xprt->sending.qlen && !xprt->pending.qlen && + !xprt->backlog.qlen && !atomic_long_read(&xprt->queuelen)) + rpc_xprt_switch_remove_xprt(xps, xprt); +} +EXPORT_SYMBOL(xprt_delete_locked); From patchwork Mon Jun 20 15:23:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1E92CCA47C for ; Mon, 20 Jun 2022 15:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244363AbiFTPZ4 (ORCPT ); Mon, 20 Jun 2022 11:25:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243890AbiFTPZX (ORCPT ); Mon, 20 Jun 2022 11:25:23 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C149DD5B for ; Mon, 20 Jun 2022 08:24:33 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id d128so8021950qkg.8 for ; Mon, 20 Jun 2022 08:24:33 -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=GoaoM6ogY4Mum6uu9CHrMnGbDA5hu/5lbm7nPIoCHRI=; b=lk/FT0PoLGS5U1RSeu2ksB1pfWRVsaXQ9KuAWJmAwUTsdpdiJ7vkOqmBrAWVcTMuxN nFpZTRH+B2UyavWbNc+1tCDHi84hwMoKrKXHDUS9huf0wu89ruFnMAFv2TIaQMktdnbW IOr0KOkoT8b35Wibuy5tx3/k3P4lVjJ6FMhYf+XU6kSe+hnqa1EOdXPZR6Fv9omV4NML S7oLA4rQQfFpwL5AU0DezQZKQDJkNrGJb4OIhmhVXwWHooZyZWKzcgibAYLQ42Z25YBu RXROfYrnM8oR294xX8qZWBV+gnAiZjzq+i0sOHwVuI5G9YnAgJkZdUvZ1kNT4gzUIFHT ffrQ== 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=GoaoM6ogY4Mum6uu9CHrMnGbDA5hu/5lbm7nPIoCHRI=; b=Yj4CQSivNaJYS89/RzTeWHlA4GWKLrXpm2WHCjlq/vKCa4itTDgOYaBqGalGFGV5g2 ioBx16mQh0oRj9c3jgPg6xthBF0HMLldsEDbQBiEaeVz+XKjYLyhKJ8hhSLm0HxJUVxy GRD8uUnDsuCy+k0CUNNLGQ7mQH8zrdGU9UHQz8NDTLIkT2P82fKB9eMKaf+0T+NTDfk0 dXLnDU+AX2H2YDFZQ9qSsoc2YRnuIq2EGLWWeLynFlxMB56YtSRXnkCcUsNcy9OvW85r ROgaw68MJNMx3ODMpuuBRjGdfklSdE+miOtrbZbDa2irD7mTAA/z6jeIlPVMPqvGRwCw OGSA== X-Gm-Message-State: AJIora9/1QezOU/hhe28n84p779/IkNPcHif2MnSkNKtbH6OX78Ii42C t4JALvRl1QyfZkJoPm72bfA= X-Google-Smtp-Source: AGRyM1uOKbz3OSpVRP6/brJgzV6OjAgfa8mYbI2poZE09dXbe5P2JQzxsFiwsj/IHzjckMJSYpOBDg== X-Received: by 2002:a05:620a:29c7:b0:6a7:4252:2607 with SMTP id s7-20020a05620a29c700b006a742522607mr16905411qkp.115.1655738672873; Mon, 20 Jun 2022 08:24:32 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:32 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 02/12] SUNRPC add function to offline remove trunkable transports Date: Mon, 20 Jun 2022 11:23:57 -0400 Message-Id: <20220620152407.63127-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia 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 | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 90501404fa49..e74a0740603b 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 *, void *); const char *rpc_proc_name(const struct rpc_task *task); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index e2c6eca0271b..544b55a3aa20 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2999,6 +2999,48 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, } EXPORT_SYMBOL_GPL(rpc_clnt_add_xprt); +static int rpc_xprt_offline_destroy(struct rpc_clnt *clnt, + struct rpc_xprt *xprt, + void *data) +{ + struct rpc_xprt *main_xprt; + struct rpc_xprt_switch *xps; + int err = 0; + int *offline_destroy = (int *)data; + + 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); + if (*offline_destroy) + xprt_delete_locked(xprt, xps); + + xprt_release_write(xprt, NULL); +out: + xprt_put(xprt); + xprt_switch_put(xps); + return err; +} + +void rpc_clnt_manage_trunked_xprts(struct rpc_clnt *clnt, void *data) +{ + rpc_clnt_iterate_for_each_xprt(clnt, rpc_xprt_offline_destroy, data); +} +EXPORT_SYMBOL_GPL(rpc_clnt_manage_trunked_xprts); + struct connect_timeout_data { unsigned long connect_timeout; unsigned long reconnect_timeout; From patchwork Mon Jun 20 15:23:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76B3AC43334 for ; Mon, 20 Jun 2022 15:26:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244416AbiFTPZ5 (ORCPT ); Mon, 20 Jun 2022 11:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244612AbiFTPZX (ORCPT ); Mon, 20 Jun 2022 11:25:23 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A8AEDC6 for ; Mon, 20 Jun 2022 08:24:35 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id 89so16384637qvc.0 for ; Mon, 20 Jun 2022 08:24:35 -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=9FyxGlb8wrzVlWXd/m4jVF2xUpvcFWGXIfAh3DX6L4E=; b=p3uPJU0bUcEKR+IpYw6TApHqxeESdU2AytligxoT21eSy++Rse52bSoPrcuVrYIIFU vtPMaxuToUsR0WGdk8ZkbQWcwx5w+dC39bceB5uzg+61ezxoyDQCReLH0+vsEU4WuoAF CvFEiDXdmDgVBOUAAfLu04usaYRv3aUItUgokNuzmqul81GH7VnCfOgtHLoiSKIZHEE7 3V2yRBjPr6++IQvGgajlf9ngqGOZkZYeXR4O+RVYdA3VGYoPUM/EeGCtdNG2VWL4Ywh+ nGdmAtWr5/QTX7UfDE9nx6DLkpOg67D0rVJKe6Aq5KMeK/E7l0FloANnod3cYRb/dqfB /zbw== 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=9FyxGlb8wrzVlWXd/m4jVF2xUpvcFWGXIfAh3DX6L4E=; b=icdZXuAQvuRqY67PeZLJJ1EqLVQ7PhA6m1ouNHxkGU4yIFYIPLU8/wuHOcWJO8YxT+ EXlRHlammTnS5thCVxRPhv/vO35kfKOeltwsekfz0hm/aa9siBmPyb561vtwcuEfLl/4 BTf9KpQR1gPqxSPEVM0OwJ3vZAmyjf2bGUnwW+YJPSr2017izFdfNhc32dvqogdcNriD ngGbElTGTvWpfqhaiT5K6Vw3cAB2JypjzdzlzzFKqim2k6xhG2eLJ/i+Oqlzwc6bEEOf 3jI8xOstzIdEgnPXqDg76rzdNrnH3ASrSbL2OM4E4RKDrK9yys9PnDOfSZu57wrKXtbQ RKSg== X-Gm-Message-State: AJIora+xsJmmnqxWiq4hVOvQ+z5RrcJ8muO07Vmil3lOSAlc4ynrezlF R40fw4xpUMZqI3v3HF+vX/E= X-Google-Smtp-Source: AGRyM1vRorNCn/XYxZjkRDobrGwOsud499eh6S9hb+Nhksm5VJTRYwDgl55c3kyywKuzSVHP6MIk5g== X-Received: by 2002:ac8:5d49:0:b0:305:2d22:3242 with SMTP id g9-20020ac85d49000000b003052d223242mr20104132qtx.470.1655738674049; Mon, 20 Jun 2022 08:24:34 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:33 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 03/12] NFSv4.1 offline trunkable transports on DESTROY_SESSION Date: Mon, 20 Jun 2022 11:23:58 -0400 Message-Id: <20220620152407.63127-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia When session is destroy, some of the transports might no longer be valid trunks for the new session. Offline existing transports. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c0fdcf8c0032..cf898bea3bfd 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9273,7 +9273,7 @@ int nfs4_proc_destroy_session(struct nfs4_session *session, .rpc_argp = session, .rpc_cred = cred, }; - int status = 0; + int status = 0, offline = 0; /* session is still being setup */ if (!test_and_clear_bit(NFS4_SESSION_ESTABLISHED, &session->session_state)) @@ -9286,6 +9286,7 @@ int nfs4_proc_destroy_session(struct nfs4_session *session, if (status) dprintk("NFS: Got error %d from the server on DESTROY_SESSION. " "Session has been destroyed regardless...\n", status); + rpc_clnt_manage_trunked_xprts(session->clp->cl_rpcclient, &offline); return status; } From patchwork Mon Jun 20 15:23:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BFB3CCA479 for ; Mon, 20 Jun 2022 15:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244612AbiFTPZ6 (ORCPT ); Mon, 20 Jun 2022 11:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244387AbiFTPZY (ORCPT ); Mon, 20 Jun 2022 11:25:24 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25917E01 for ; Mon, 20 Jun 2022 08:24:36 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id p63so8011543qkd.10 for ; Mon, 20 Jun 2022 08:24:36 -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=1v4+ZxnCO/CE/1Ve4CstINsmXzqfmZHhiLoXQ2o8VjU=; b=USIA4FATjAIuBhKYvhXGG17e1sUJiXT0qczEX1YtGZGayZJFIHzsjFj8oS7bcQRYmH yTqzCX0ahE2Kw09KT/yzzDryzQWmu+DtsH23C/aau+VaLblBkHrNsLHShvRtutLINsHs 7yhxUlBykgxwojaVNdt5azwFnnU5mgeP5A15oaQ0D0vIB+7o3OYZ/IYG42+WXxp5vNnv tU/11Hww5cyI5KxfWRSPgoM3+dQMPALp04EzQxQSVM88UlKkRQ4qcvmcPMmSfFHFdtZk lPmFfylzbAseGaY9wwd95ut1Y/nSMgHblZWUY9iHvyiCohS7x9XaDwsVdnHuU9SJYT5o YHDA== 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=1v4+ZxnCO/CE/1Ve4CstINsmXzqfmZHhiLoXQ2o8VjU=; b=2fLiSECPLuXnrKmg8LMYVTJ4S+fj6VUU+pd3pGwfI+MksLlufmIjD1FQ/D4eWZw9gj R57zExcIsHRtwkrVR2AEJ+ZQT3UGG5Rl/ey7iFyW6dodpaQRMhzRcfBe2zB3kGc2EsUF frROuNFlqOO4cOCisH49pdqWsSDTcXqgADq/GMuCrJc54lqM/UR9MxzxE6mEJwUw+tR6 GjMrrakXkcIjATyFfHnjsoGKezbedIP4YVSg+arPT2GoIlFYJXjXYQBavXSBLGQiqAba Aa7KEdOUxQVxb6sfSW+Rirqc9q4FlHw+ZIxpQcIvWRY6+h3VjeGnH3RnKaIVwCEYNAfw OIEA== X-Gm-Message-State: AJIora+cuoGpMx7vd0Ex7KS9YLtq94k9Ov5MKme/1zAi9mCPqJY+cY2C +RDmFZ7/4GdDksP8C6LDzSw= X-Google-Smtp-Source: AGRyM1uYkqucyK2wdRs2Eid57zuVLz44Y0MkJcnF6oQn/xBvwM1CsRfZLXwqqKEoXFFCijLpb2IKKg== X-Received: by 2002:a05:620a:142a:b0:6a6:8a05:f862 with SMTP id k10-20020a05620a142a00b006a68a05f862mr16519063qkj.11.1655738675218; Mon, 20 Jun 2022 08:24:35 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:34 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 04/12] SUNRPC create an iterator to list only OFFLINE xprts Date: Mon, 20 Jun 2022 11:23:59 -0400 Message-Id: <20220620152407.63127-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Create a new iterator helper that will go thru the all the transports in the switch and return transports that are marked OFFLINE. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/xprtmultipath.h | 3 + net/sunrpc/clnt.c | 19 +++++- net/sunrpc/xprtmultipath.c | 98 +++++++++++++++++++++++++--- 3 files changed, 108 insertions(+), 12 deletions(-) diff --git a/include/linux/sunrpc/xprtmultipath.h b/include/linux/sunrpc/xprtmultipath.h index bbb8a5fa0816..688ca7eb1d01 100644 --- a/include/linux/sunrpc/xprtmultipath.h +++ b/include/linux/sunrpc/xprtmultipath.h @@ -63,6 +63,9 @@ extern void xprt_iter_init(struct rpc_xprt_iter *xpi, extern void xprt_iter_init_listall(struct rpc_xprt_iter *xpi, struct rpc_xprt_switch *xps); +extern void xprt_iter_init_listoffline(struct rpc_xprt_iter *xpi, + struct rpc_xprt_switch *xps); + extern void xprt_iter_destroy(struct rpc_xprt_iter *xpi); extern struct rpc_xprt_switch *xprt_iter_xchg_switch( diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 544b55a3aa20..410bd6c352ad 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -785,7 +785,9 @@ int rpc_switch_client_transport(struct rpc_clnt *clnt, EXPORT_SYMBOL_GPL(rpc_switch_client_transport); static -int rpc_clnt_xprt_iter_init(struct rpc_clnt *clnt, struct rpc_xprt_iter *xpi) +int _rpc_clnt_xprt_iter_init(struct rpc_clnt *clnt, struct rpc_xprt_iter *xpi, + void func(struct rpc_xprt_iter *xpi, + struct rpc_xprt_switch *xps)) { struct rpc_xprt_switch *xps; @@ -794,11 +796,24 @@ int rpc_clnt_xprt_iter_init(struct rpc_clnt *clnt, struct rpc_xprt_iter *xpi) rcu_read_unlock(); if (xps == NULL) return -EAGAIN; - xprt_iter_init_listall(xpi, xps); + func(xpi, xps); xprt_switch_put(xps); return 0; } +static +int rpc_clnt_xprt_iter_init(struct rpc_clnt *clnt, struct rpc_xprt_iter *xpi) +{ + return _rpc_clnt_xprt_iter_init(clnt, xpi, xprt_iter_init_listall); +} + +static +int rpc_clnt_xprt_iter_offline_init(struct rpc_clnt *clnt, + struct rpc_xprt_iter *xpi) +{ + return _rpc_clnt_xprt_iter_init(clnt, xpi, xprt_iter_init_listoffline); +} + /** * rpc_clnt_iterate_for_each_xprt - Apply a function to all transports * @clnt: pointer to client diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index 1693f81aae37..4374cd6acc55 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -27,6 +27,7 @@ typedef struct rpc_xprt *(*xprt_switch_find_xprt_t)(struct rpc_xprt_switch *xps, static const struct rpc_xprt_iter_ops rpc_xprt_iter_singular; static const struct rpc_xprt_iter_ops rpc_xprt_iter_roundrobin; static const struct rpc_xprt_iter_ops rpc_xprt_iter_listall; +static const struct rpc_xprt_iter_ops rpc_xprt_iter_listoffline; static void xprt_switch_add_xprt_locked(struct rpc_xprt_switch *xps, struct rpc_xprt *xprt) @@ -248,6 +249,18 @@ struct rpc_xprt *xprt_switch_find_first_entry(struct list_head *head) return NULL; } +static +struct rpc_xprt *xprt_switch_find_first_entry_offline(struct list_head *head) +{ + struct rpc_xprt *pos; + + list_for_each_entry_rcu(pos, head, xprt_switch) { + if (!xprt_is_active(pos)) + return pos; + } + return NULL; +} + static struct rpc_xprt *xprt_iter_first_entry(struct rpc_xprt_iter *xpi) { @@ -259,8 +272,8 @@ struct rpc_xprt *xprt_iter_first_entry(struct rpc_xprt_iter *xpi) } static -struct rpc_xprt *xprt_switch_find_current_entry(struct list_head *head, - const struct rpc_xprt *cur) +struct rpc_xprt *_xprt_switch_find_current_entry(struct list_head *head, + const struct rpc_xprt *cur, bool find_active) { struct rpc_xprt *pos; bool found = false; @@ -268,14 +281,25 @@ struct rpc_xprt *xprt_switch_find_current_entry(struct list_head *head, list_for_each_entry_rcu(pos, head, xprt_switch) { if (cur == pos) found = true; - if (found && xprt_is_active(pos)) + if (found && ((find_active && xprt_is_active(pos)) || + (!find_active && xprt_is_active(pos)))) return pos; } return NULL; } static -struct rpc_xprt *xprt_iter_current_entry(struct rpc_xprt_iter *xpi) +struct rpc_xprt *xprt_switch_find_current_entry(struct list_head *head, + const struct rpc_xprt *cur) +{ + return _xprt_switch_find_current_entry(head, cur, true); +} + +static +struct rpc_xprt * _xprt_iter_current_entry(struct rpc_xprt_iter *xpi, + struct rpc_xprt *first_entry(struct list_head *head), + struct rpc_xprt *current_entry(struct list_head *head, + const struct rpc_xprt *cur)) { struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); struct list_head *head; @@ -284,8 +308,30 @@ struct rpc_xprt *xprt_iter_current_entry(struct rpc_xprt_iter *xpi) return NULL; head = &xps->xps_xprt_list; if (xpi->xpi_cursor == NULL || xps->xps_nxprts < 2) - return xprt_switch_find_first_entry(head); - return xprt_switch_find_current_entry(head, xpi->xpi_cursor); + return first_entry(head); + return current_entry(head, xpi->xpi_cursor); +} + +static +struct rpc_xprt *xprt_iter_current_entry(struct rpc_xprt_iter *xpi) +{ + return _xprt_iter_current_entry(xpi, xprt_switch_find_first_entry, + xprt_switch_find_current_entry); +} + +static +struct rpc_xprt *xprt_switch_find_current_entry_offline(struct list_head *head, + const struct rpc_xprt *cur) +{ + return _xprt_switch_find_current_entry(head, cur, false); +} + +static +struct rpc_xprt *xprt_iter_current_entry_offline(struct rpc_xprt_iter *xpi) +{ + return _xprt_iter_current_entry(xpi, + xprt_switch_find_first_entry_offline, + xprt_switch_find_current_entry_offline); } bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps, @@ -310,7 +356,7 @@ bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps, static struct rpc_xprt *xprt_switch_find_next_entry(struct list_head *head, - const struct rpc_xprt *cur) + const struct rpc_xprt *cur, bool check_active) { struct rpc_xprt *pos, *prev = NULL; bool found = false; @@ -318,7 +364,12 @@ struct rpc_xprt *xprt_switch_find_next_entry(struct list_head *head, list_for_each_entry_rcu(pos, head, xprt_switch) { if (cur == prev) found = true; - if (found && xprt_is_active(pos)) + /* for request to return active transports return only + * active, for request to return offline transports + * return only offline + */ + if (found && ((check_active && xprt_is_active(pos)) || + (!check_active && !xprt_is_active(pos)))) return pos; prev = pos; } @@ -355,7 +406,7 @@ struct rpc_xprt *__xprt_switch_find_next_entry_roundrobin(struct list_head *head { struct rpc_xprt *ret; - ret = xprt_switch_find_next_entry(head, cur); + ret = xprt_switch_find_next_entry(head, cur, true); if (ret != NULL) return ret; return xprt_switch_find_first_entry(head); @@ -397,7 +448,14 @@ static struct rpc_xprt *xprt_switch_find_next_entry_all(struct rpc_xprt_switch *xps, const struct rpc_xprt *cur) { - return xprt_switch_find_next_entry(&xps->xps_xprt_list, cur); + return xprt_switch_find_next_entry(&xps->xps_xprt_list, cur, true); +} + +static +struct rpc_xprt *xprt_switch_find_next_entry_offline(struct rpc_xprt_switch *xps, + const struct rpc_xprt *cur) +{ + return xprt_switch_find_next_entry(&xps->xps_xprt_list, cur, false); } static @@ -407,6 +465,13 @@ struct rpc_xprt *xprt_iter_next_entry_all(struct rpc_xprt_iter *xpi) xprt_switch_find_next_entry_all); } +static +struct rpc_xprt *xprt_iter_next_entry_offline(struct rpc_xprt_iter *xpi) +{ + return xprt_iter_next_entry_multiple(xpi, + xprt_switch_find_next_entry_offline); +} + /* * xprt_iter_rewind - Resets the xprt iterator * @xpi: pointer to rpc_xprt_iter @@ -460,6 +525,12 @@ void xprt_iter_init_listall(struct rpc_xprt_iter *xpi, __xprt_iter_init(xpi, xps, &rpc_xprt_iter_listall); } +void xprt_iter_init_listoffline(struct rpc_xprt_iter *xpi, + struct rpc_xprt_switch *xps) +{ + __xprt_iter_init(xpi, xps, &rpc_xprt_iter_listoffline); +} + /** * xprt_iter_xchg_switch - Atomically swap out the rpc_xprt_switch * @xpi: pointer to rpc_xprt_iter @@ -574,3 +645,10 @@ const struct rpc_xprt_iter_ops rpc_xprt_iter_listall = { .xpi_xprt = xprt_iter_current_entry, .xpi_next = xprt_iter_next_entry_all, }; + +static +const struct rpc_xprt_iter_ops rpc_xprt_iter_listoffline = { + .xpi_rewind = xprt_iter_default_rewind, + .xpi_xprt = xprt_iter_current_entry_offline, + .xpi_next = xprt_iter_next_entry_offline, +}; From patchwork Mon Jun 20 15:24:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3026BCCA479 for ; Mon, 20 Jun 2022 15:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243890AbiFTPZ4 (ORCPT ); Mon, 20 Jun 2022 11:25:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244756AbiFTPZZ (ORCPT ); Mon, 20 Jun 2022 11:25:25 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51406E0F for ; Mon, 20 Jun 2022 08:24:37 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id o73so8021181qke.7 for ; Mon, 20 Jun 2022 08:24:37 -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=hiOpeOldRv5C+cpYA4d1f38bxNJH8q04syRxbARTC6c=; b=ay0q7cQkXAZSzBhHJ6PnnFHvbGnGRbn/98lGjYuHobUzkyCUC4rGbB/P8Sag4HJe/M dtEblkAw0cVd/SNbKj8mpkAqsSW7eV4E/nHxd6KhHhFwKnq/YWfiGLPUhEW3RH7zlxZz K7oIUUaMnJOHwhaxDFPfuw9VknELrO95fjzKyRm3kAx3Zx5+V8Q0sQjoZ1hSwIG8MhRF LBsdk4Di9HJ1y5MqlSIj/qwGGrmy1w2cubuyKxqVtt8gF5FZpHZ5AyJyG6KIFeZAZH+r C2heJ2g4fczXx+UmTyJARIKcyBQ+v/D5FV8NmUMArNUWG0TcVxpNjxwoD8A0ky+Cj5sn szGg== 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=hiOpeOldRv5C+cpYA4d1f38bxNJH8q04syRxbARTC6c=; b=ceGZRpQeJRjIasAJ22R0AfJnXIct+cZS6o7fnKZZ4IBPA4UWHthF5FZhkrnZfC0+wg CdsolL3WsSxC4bzB2Qy1k0z0sp8dnYyscifH7NNbg03Y/z11cAZ+LLnIGYrO7Lymvcg+ E+gli98dpZ/BwEvdNS0enoD+CajpV+brKeVwuqMSMcPZ+zX1O+/cWlEcuggei7jLT8zg Kg0BqWnRM8eHqEAvdmeKOeUgv0sIw58yD88KhHv/4q3b4ifhNBCNfuwFj3HJwBfnPDij k5tk7WmcbK4ul6NbpD0BfsEGfpj9SdSYXT8Owxw4hqVnZNPeJWcQ3Sp4VIj9LMBLH03u MALg== X-Gm-Message-State: AJIora+O3EXz4pqv1zjOFk156Nb5tg9X0PiP6sUYBtTgceir4qZamJvB w4GBqO3r1gyx63cIB+AyHTmYQDB87EjGPw== X-Google-Smtp-Source: AGRyM1uOOjjPjbihuV+Uc9iy/l+cY1LRtZVrLOXieSegrvr0XwQpeoNsVPOF3f0eYtGIC4lMqq+ZhQ== X-Received: by 2002:a05:620a:1b98:b0:6a7:7e6d:d886 with SMTP id dv24-20020a05620a1b9800b006a77e6dd886mr16934958qkb.595.1655738676423; Mon, 20 Jun 2022 08:24:36 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:35 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 05/12] SUNRPC parameterize rpc_clnt_iterate_for_each_xprt with iterator init function Date: Mon, 20 Jun 2022 11:24:00 -0400 Message-Id: <20220620152407.63127-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Allow for rpc_clnt_iterate_for_each_xprt() to take in an iterator initialization function if no function passed in a default initiator is used. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4proc.c | 2 +- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 17 ++++++++++++----- net/sunrpc/debugfs.c | 2 +- net/sunrpc/stats.c | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index cf898bea3bfd..5e4c32924347 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -8532,7 +8532,7 @@ int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, const struct cred *cr .clp = clp, .cred = cred, }; - return rpc_clnt_iterate_for_each_xprt(clp->cl_rpcclient, + return rpc_clnt_iterate_for_each_xprt(clp->cl_rpcclient, NULL, nfs4_proc_bind_conn_to_session_callback, &data); } diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index e74a0740603b..20aed14fe222 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -213,6 +213,7 @@ const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t); int rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt, + int (*setup)(struct rpc_clnt *, struct rpc_xprt_iter *), int (*fn)(struct rpc_clnt *, struct rpc_xprt *, void *), void *data); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 410bd6c352ad..b26267606de0 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -817,6 +817,8 @@ int rpc_clnt_xprt_iter_offline_init(struct rpc_clnt *clnt, /** * rpc_clnt_iterate_for_each_xprt - Apply a function to all transports * @clnt: pointer to client + * @setup: an optional iterator init function to use, if none supplied + * default rpc_clnt_xprt_iter_init() iterator is used * @fn: function to apply * @data: void pointer to function data * @@ -826,13 +828,17 @@ int rpc_clnt_xprt_iter_offline_init(struct rpc_clnt *clnt, * On error, the iteration stops, and the function returns the error value. */ int rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt, + int (*setup)(struct rpc_clnt *, struct rpc_xprt_iter *), int (*fn)(struct rpc_clnt *, struct rpc_xprt *, void *), void *data) { struct rpc_xprt_iter xpi; int ret; - ret = rpc_clnt_xprt_iter_init(clnt, &xpi); + if (!setup) + ret = rpc_clnt_xprt_iter_init(clnt, &xpi); + else + ret = setup(clnt, &xpi); if (ret) return ret; for (;;) { @@ -3052,7 +3058,8 @@ static int rpc_xprt_offline_destroy(struct rpc_clnt *clnt, void rpc_clnt_manage_trunked_xprts(struct rpc_clnt *clnt, void *data) { - rpc_clnt_iterate_for_each_xprt(clnt, rpc_xprt_offline_destroy, data); + rpc_clnt_iterate_for_each_xprt(clnt, NULL, rpc_xprt_offline_destroy, + data); } EXPORT_SYMBOL_GPL(rpc_clnt_manage_trunked_xprts); @@ -3084,7 +3091,7 @@ rpc_set_connect_timeout(struct rpc_clnt *clnt, .connect_timeout = connect_timeout, .reconnect_timeout = reconnect_timeout, }; - rpc_clnt_iterate_for_each_xprt(clnt, + rpc_clnt_iterate_for_each_xprt(clnt, NULL, rpc_xprt_set_connect_timeout, &timeout); } @@ -3181,7 +3188,7 @@ rpc_clnt_swap_activate(struct rpc_clnt *clnt) while (clnt != clnt->cl_parent) clnt = clnt->cl_parent; if (atomic_inc_return(&clnt->cl_swapper) == 1) - return rpc_clnt_iterate_for_each_xprt(clnt, + return rpc_clnt_iterate_for_each_xprt(clnt, NULL, rpc_clnt_swap_activate_callback, NULL); return 0; } @@ -3200,7 +3207,7 @@ void rpc_clnt_swap_deactivate(struct rpc_clnt *clnt) { if (atomic_dec_if_positive(&clnt->cl_swapper) == 0) - rpc_clnt_iterate_for_each_xprt(clnt, + rpc_clnt_iterate_for_each_xprt(clnt, NULL, rpc_clnt_swap_deactivate_callback, NULL); } EXPORT_SYMBOL_GPL(rpc_clnt_swap_deactivate); diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c index 7dc9cc929bfd..ab60b4d3deb2 100644 --- a/net/sunrpc/debugfs.c +++ b/net/sunrpc/debugfs.c @@ -160,7 +160,7 @@ rpc_clnt_debugfs_register(struct rpc_clnt *clnt) debugfs_create_file("tasks", S_IFREG | 0400, clnt->cl_debugfs, clnt, &tasks_fops); - rpc_clnt_iterate_for_each_xprt(clnt, do_xprt_debugfs, &xprtnum); + rpc_clnt_iterate_for_each_xprt(clnt, NULL, do_xprt_debugfs, &xprtnum); } void diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index 52908f9e6eab..e50f73a4aca5 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c @@ -258,7 +258,7 @@ void rpc_clnt_show_stats(struct seq_file *seq, struct rpc_clnt *clnt) seq_printf(seq, "p/v: %u/%u (%s)\n", clnt->cl_prog, clnt->cl_vers, clnt->cl_program->name); - rpc_clnt_iterate_for_each_xprt(clnt, do_print_stats, seq); + rpc_clnt_iterate_for_each_xprt(clnt, NULL, do_print_stats, seq); seq_printf(seq, "\tper-op statistics\n"); for (op = 0; op < maxproc; op++) { From patchwork Mon Jun 20 15:24:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16393C433EF for ; Mon, 20 Jun 2022 15:26:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244430AbiFTPZ7 (ORCPT ); Mon, 20 Jun 2022 11:25:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244800AbiFTPZZ (ORCPT ); Mon, 20 Jun 2022 11:25:25 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 915D5E2E for ; Mon, 20 Jun 2022 08:24:38 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id b142so8029625qkg.2 for ; Mon, 20 Jun 2022 08:24:38 -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=bAI8gGH9avnmA+NDRHBSfMccao83qkbgBJ+Hjofwigk=; b=Xbtm1MaKT836KRHr51Znlq7oaV+zKFi+DIoW6SjfderN7BERl19vOBq/h9SnzhGCgm GAe6D4SF5e9l8Hb1iwkAfbNgcZCvvfNOxcA3no/CPdu5kOKS2HSaYUtE2shgbID6/4lH aploBZNv7SY2FzpbJjQbkB1VE0O/EVwuWcldG99OEiEMT7QEyMUZZfCIa21A+MCyvOpS pVmbqzzpC6m1n1rWqTZbWD2oaLus3rt5XcSTlRtPXJmzzD9THnfzmQAa0qaGc6wv/Bqu 9TOLY4O405iTC7Hv2u+Kkm4en/YR9Id8UQn8hIpsRqy8j/4LNluuy4vB1Z68vu3Orv+y cbrQ== 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=bAI8gGH9avnmA+NDRHBSfMccao83qkbgBJ+Hjofwigk=; b=hBHvfXqdbpHoWyBclDkgvlY9a07z+rOgqp8hmUYold+6/awEVliq8wc1l5R9ADuGRL vbpCMrs+nEpPtHf0a8271Nvt25WARuoC7kSI0PoH4OUef/9K8H0iB15R9yfKc8mGpZwo F+EI4E+7ihwV+gDHxe0tX4Q9la3brFJPkubJsqlKRW0c7XqYMVINBuqMiEZdb47xvZoZ OX2m1ap4zhhQQV5f3ZmOw6sL7GWzYH4IgKrUc2sdgiHwdmywNgBdJhqly2ayx/wqLcMX 55BO7InwKx4v0ao79ssUeHmD+3bVm/gLBso+IugyasKc8XAVVqNv2g68fpxFcrSuShO0 mclw== X-Gm-Message-State: AJIora8FsHAK2JfBwUzAcRiPCBL6E7gRaRX/MAs5mJY+QGZ0erTFN2Uo 2uvTUGOCdldzsDBCu9sBIpM7JSZLA5/sXw== X-Google-Smtp-Source: AGRyM1tWKm5IydFqFIFIkxq9NkRm/UPPMtidPzyHsUVNu89TFBSGtIjzR0nrJV5Yjkg9bVFx+Q1BOA== X-Received: by 2002:a05:620a:1272:b0:6a6:bdc1:8f92 with SMTP id b18-20020a05620a127200b006a6bdc18f92mr16608710qkl.330.1655738677643; Mon, 20 Jun 2022 08:24:37 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:37 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 06/12] SUNRPC enable back offline transports in trunking discovery Date: Mon, 20 Jun 2022 11:24:01 -0400 Message-Id: <20220620152407.63127-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia When we are adding a transport to a xprt_switch that's already on the list but has been marked OFFLINE, then make the state ONLINE since it's been tested now. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 20aed14fe222..319bcd3a3593 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -243,6 +243,7 @@ void rpc_clnt_xprt_switch_put(struct rpc_clnt *); void rpc_clnt_xprt_switch_add_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); void rpc_cleanup_clids(void); static inline int rpc_reply_expected(struct rpc_task *task) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index b26267606de0..1cbd598f596c 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -3105,8 +3105,22 @@ void rpc_clnt_xprt_switch_put(struct rpc_clnt *clnt) } EXPORT_SYMBOL_GPL(rpc_clnt_xprt_switch_put); +void rpc_clnt_xprt_set_online(struct rpc_clnt *clnt, struct rpc_xprt *xprt) +{ + struct rpc_xprt_switch *xps; + + rcu_read_lock(); + xps = rcu_dereference(clnt->cl_xpi.xpi_xpswitch); + rcu_read_unlock(); + xprt_set_online_locked(xprt, xps); +} + void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt) { + if (rpc_clnt_xprt_switch_has_addr(clnt, + (const struct sockaddr *)&xprt->addr)) { + return rpc_clnt_xprt_set_online(clnt, xprt); + } rcu_read_lock(); rpc_xprt_switch_add_xprt(rcu_dereference(clnt->cl_xpi.xpi_xpswitch), xprt); From patchwork Mon Jun 20 15:24:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887778 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88090C43334 for ; Mon, 20 Jun 2022 15:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241997AbiFTP0B (ORCPT ); Mon, 20 Jun 2022 11:26:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244815AbiFTPZZ (ORCPT ); Mon, 20 Jun 2022 11:25:25 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89A80E39 for ; Mon, 20 Jun 2022 08:24:39 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id d128so8021950qkg.8 for ; Mon, 20 Jun 2022 08:24:39 -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=wo2lc3yDrzVJrgHzbPVSfEJMuBh8U7/O8f4S+8ndsSE=; b=DsoMwPjtu4DQdEZRwrXd1GhWWkAAUbAc3636kjyrViEjYE1xLmk79oAC5Z5Nf/RhwG tZ59P5RF15L9RL3T42Rby1D1kbOzXXG2hI/ssx9lEepmoIFBxw1gRJBm3EI6z+RveX6A hgGEvu7xBDv4pLtrscNsEpQ3+a7RdvNTM9bzkeML9i36EFO4K9/sYsofLld2uPjH8o3t MWJbakX0DOFSpc+G4c5TG7bQBykgp82Qoxf8mTzt6OQR3QirivMkYq7jA+XZ1L4dfaWI OFXDSU2gj1DMZSfl4tq6P5uHoaG64EIApEFAdomgkPNOaPA3PA/k82iIibc9qhcqsx/8 P+yg== 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=wo2lc3yDrzVJrgHzbPVSfEJMuBh8U7/O8f4S+8ndsSE=; b=yC9SiNaMtKHahyhywAYCqY8k0J5wMJ+dAKx/qMI6S5pbG0DqvLH33ICu0TGqWKVaQY Gi0Km10CnFcOefeMqFr6sw+BJPLCiVuRIlxKzvxNpaA2eZYY5bbpZS6GemcumbQWK46G C82gC1hr1ke+SNgqq4gNSqGMCpNxcbockjkAHszTV9HKF9GNQL+V2FspJCplOfdaVvhe mBFKf7p8Gt7Mxmw2YILN7m3EhFaihf33rtb3aNMXI6DC9HkgCLY7iS5zCuIfR/UkdZGE PODL/+db8x7oiLfI6jg16hvcqmmysL1SVRcuF4og5LKGbXtXtDabBUu6SARjmKuIgEmF QNEA== X-Gm-Message-State: AJIora/d6RNaA9WQ1EXa3e6GnKnMJIjppru2SKi54AATw7iOWnELTFYz GkcHTRRQimWV6qsBNOAYusz93RE4QJeLZw== X-Google-Smtp-Source: AGRyM1sxtrj1CKTcQk944amoz9slJ52QuVmfM9X2CbHF7HgQq452Xrk8Gq9nfY/YhEmZ3bqIO8+FeA== X-Received: by 2002:a05:620a:240f:b0:6a7:7b60:fa5a with SMTP id d15-20020a05620a240f00b006a77b60fa5amr16235985qkn.601.1655738679154; Mon, 20 Jun 2022 08:24:39 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:38 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 07/12] SUNRPC create an rpc function that allows xprt removal from rpc_clnt Date: Mon, 20 Jun 2022 11:24:02 -0400 Message-Id: <20220620152407.63127-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia 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 319bcd3a3593..ac1024da86c5 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -241,6 +241,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 1cbd598f596c..2b2515c121fa 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2157,7 +2157,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; @@ -3128,6 +3129,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 6480ae324b27..ac02bf6d109a 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -2184,6 +2184,6 @@ 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); } EXPORT_SYMBOL(xprt_delete_locked); diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index 4374cd6acc55..41ec46e5f1a3 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); From patchwork Mon Jun 20 15:24:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F14B3C433EF for ; Mon, 20 Jun 2022 15:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244792AbiFTP0D (ORCPT ); Mon, 20 Jun 2022 11:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244822AbiFTPZZ (ORCPT ); Mon, 20 Jun 2022 11:25:25 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E019DE3 for ; Mon, 20 Jun 2022 08:24:41 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id n197so8032403qke.1 for ; Mon, 20 Jun 2022 08:24:41 -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=/HmcZzdxdf4F8eA9MR87GKLepSrbSvTKoPRKJ2aJz3E=; b=HO86txAgLpdZQ+QNDLpvPdwTrsUcgkz0C9JewG+MvSwJteluw8ggBS/Q34kugZZbI3 0+cRfOmLy3aWXR8FDpSxHg1aYentMXeWcIpBX0RKFHwzXLWJhKa8lbqMtXuATMheP1Pb kv54K3MLJeFLwgK61Ba8TME9PZuR70ZA1Rc1+CbvJMjgDixp1v2R63ivD1/fyoieqGqQ 0e8liATwyEZtmnElct/FGtKG8nE0/CGB6pIltLoUclhJkuVM80HGXbWz2a+9HUcAHuGc 4MD3BniWuI4HPMrZL+xZ8o+YUEJBLmlGX0HeJyUdlk3NrQrtTvJufm4bvuPFlwZ5h/hP gEmA== 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=/HmcZzdxdf4F8eA9MR87GKLepSrbSvTKoPRKJ2aJz3E=; b=JsoJdPJzqICn2/LcjEGyaictWYtBWDUg1snlMHe0HYH9K7riDHSAXyV3VXjZtshxky dLzKvp/uTo2ggVE0dPy/rWS7hLJvqcXM7GZX4DCV4I9R9dXRI+Eeofxd0Bq1oEwHHeVU Z0+Mt1GO+iLqm2nHXkhphjtRNUse9vC8+CP03jxg312opVb6CcdOAUQz8yW2p8yZ/PrL 7nVwAw28enJMgGUarmTsBIo1Q6jrUYB6r+ocLqs07sNetic4FsiIx0CHuxHhuhhB4Oin RhJGnaRPNDgfLBw2Mi3IshSR31i5KRY3X6trBN0uozPMqgbgfFlq8pdTH9/ZFEgWTOWe 2nnA== X-Gm-Message-State: AJIora9LFicp7aRZlFvgXiRnx4+qjSolHvWSFtaBRL2oOb731MTswjnO BvOACm2takM1MCmuSDFvsHpn0hKVl7fmSg== X-Google-Smtp-Source: AGRyM1vcgbEb3mbpTmML3bBG1ghVJ9t+eAh7uIYDiiitRu+tVvTgpkYgMPDCgAtf8vQSRYMLWvYCKw== X-Received: by 2002:a37:ef02:0:b0:6ac:470a:cf96 with SMTP id j2-20020a37ef02000000b006ac470acf96mr7071006qkk.763.1655738680368; Mon, 20 Jun 2022 08:24:40 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:39 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 08/12] NFSv4.1 remove xprt from xprt_switch if session trunking test fails Date: Mon, 20 Jun 2022 11:24:03 -0400 Message-Id: <20220620152407.63127-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia If we are doing a session trunking test and it fails for the transport, then remove this transport from the xprt_switch group. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4proc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 5e4c32924347..152da2bc5100 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -8917,6 +8917,9 @@ void nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt, if (status == 0) rpc_clnt_xprt_switch_add_xprt(clnt, xprt); + else if (rpc_clnt_xprt_switch_has_addr(clnt, + (struct sockaddr *)&xprt->addr)) + rpc_clnt_xprt_switch_remove_xprt(clnt, xprt); rpc_put_task(task); } From patchwork Mon Jun 20 15:24:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887780 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 711DCCCA479 for ; Mon, 20 Jun 2022 15:26:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243762AbiFTP0E (ORCPT ); Mon, 20 Jun 2022 11:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244646AbiFTPZ0 (ORCPT ); Mon, 20 Jun 2022 11:25:26 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B008254 for ; Mon, 20 Jun 2022 08:24:42 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id 15so8022699qki.6 for ; Mon, 20 Jun 2022 08:24:42 -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=0VyjboFzsu/G6oZ+tax3StcECwDLW9wHRaQJ9kf/U4c=; b=CcFExt9KEh4TlFsX+QhnG4hE7XWQGM9c09SqsYpUTrB56xMldxEvqVL28KFstjeWUq P/ICCiWQQib/MrG0hu8QrOcLwH0p6CmqoMGLiCWc5AXh83ht69uErlN1sLV9NQ9bcN11 TrbXyXmTvgYR8eogPPLnaNi8uI3F7+Xt58XHGVO/85Lcl9E0lWzLSMrb0CXtWu2QHyJK Y9i5XmlSBTmf6weUUgu0JzQiEVSsaY9lR3skMRfphZkDAx0d5WkTvziOtovj61fCrKW+ UJ00L9pTkP9QiWSn5V6BPVqIoLs4kYGcunhAoHb3MAe69HnWNdkYOFvVkJo6/KoQ+T/0 KFNA== 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=0VyjboFzsu/G6oZ+tax3StcECwDLW9wHRaQJ9kf/U4c=; b=md5KPUyiIWekpUNh1hej9aMVc93n1+quRJl4sVHy2l4jV1nn+1zkT20CBsBUy7haGn Ab6vRHRNqJj8KzddEIYibyJg8JkyclcToqOGsmBhfZlh4H9tIOnlxlRT4ZDqHHolyOaK PllE8REJzXeaLUiO/9KS9+Svu7W/6VPPEzkXnpeT+y0rLnoiW4VGELbI4zTpMcpwJ/Ya P6R7cEuXArLUhRVx69+a3xgeUlL5qbQmW2Qplxj1JbXgPopohOImUqMV6THyjcHMDFKh J2LeigRgrzOqHj7AnTkcLQXBBsT+xILOJG9LxQaX7N/MHmuNt2Ip7QKGgfbKxhwAgAzP 2zrQ== X-Gm-Message-State: AJIora9uR/Uv/3/stWgxae+BLFsjfGbmI3YDfgDlfo6jXaaqh1CCK0+3 fJTm7BDLXUkJrPRjppK4gNCpd4PuNkosgw== X-Google-Smtp-Source: AGRyM1seUrhJGBOHQeM9GKCqjoUciCmUozuYALfs2uvHPp9KmtRmyymy0aQG8MDXT90VrGkm8DDuGg== X-Received: by 2002:a37:6704:0:b0:6a6:fc41:864a with SMTP id b4-20020a376704000000b006a6fc41864amr16437872qkc.165.1655738681547; Mon, 20 Jun 2022 08:24:41 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:41 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 09/12] SUNRPC restructure rpc_clnt_setup_test_and_add_xprt Date: Mon, 20 Jun 2022 11:24:04 -0400 Message-Id: <20220620152407.63127-10-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia In preparation for code re-use, pull out the part of the rpc_clnt_setup_test_and_add_xprt() portion that sends a NULL rpc and then calls a session trunking function into a helper function. Re-organize the end of the function for code re-use. Signed-off-by: Olga Kornievskaia --- net/sunrpc/clnt.c | 53 ++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 2b2515c121fa..6b04b29bf842 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2887,6 +2887,31 @@ int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt, } EXPORT_SYMBOL_GPL(rpc_clnt_test_and_add_xprt); +static int rpc_clnt_add_xprt_helper(struct rpc_clnt *clnt, + struct rpc_xprt *xprt, + void *data) +{ + struct rpc_task *task; + struct rpc_add_xprt_test *xtest = (struct rpc_add_xprt_test *)data; + int status = -EADDRINUSE; + + /* Test the connection */ + task = rpc_call_null_helper(clnt, xprt, NULL, 0, NULL, NULL); + if (IS_ERR(task)) + return PTR_ERR(task); + + status = task->tk_status; + rpc_put_task(task); + + if (status < 0) + return status; + + /* rpc_xprt_switch and rpc_xprt are deferrenced by add_xprt_test() */ + xtest->add_xprt_test(clnt, xprt, xtest->data); + + return 0; +} + /** * rpc_clnt_setup_test_and_add_xprt() * @@ -2910,8 +2935,6 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *data) { - struct rpc_task *task; - struct rpc_add_xprt_test *xtest = (struct rpc_add_xprt_test *)data; int status = -EADDRINUSE; xprt = xprt_get(xprt); @@ -2920,31 +2943,19 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt, if (rpc_xprt_switch_has_addr(xps, (struct sockaddr *)&xprt->addr)) goto out_err; - /* Test the connection */ - task = rpc_call_null_helper(clnt, xprt, NULL, 0, NULL, NULL); - if (IS_ERR(task)) { - status = PTR_ERR(task); - goto out_err; - } - status = task->tk_status; - rpc_put_task(task); - + status = rpc_clnt_add_xprt_helper(clnt, xprt, data); if (status < 0) goto out_err; - /* rpc_xprt_switch and rpc_xprt are deferrenced by add_xprt_test() */ - xtest->add_xprt_test(clnt, xprt, xtest->data); - - xprt_put(xprt); - xprt_switch_put(xps); - - /* so that rpc_clnt_add_xprt does not call rpc_xprt_switch_add_xprt */ - return 1; + status = 1; out_err: xprt_put(xprt); xprt_switch_put(xps); - pr_info("RPC: rpc_clnt_test_xprt failed: %d addr %s not added\n", - status, xprt->address_strings[RPC_DISPLAY_ADDR]); + if (status < 0) + pr_info("RPC: rpc_clnt_test_xprt failed: %d addr %s not " + "added\n", status, + xprt->address_strings[RPC_DISPLAY_ADDR]); + /* so that rpc_clnt_add_xprt does not call rpc_xprt_switch_add_xprt */ return status; } EXPORT_SYMBOL_GPL(rpc_clnt_setup_test_and_add_xprt); From patchwork Mon Jun 20 15:24:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887782 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81063C43334 for ; Mon, 20 Jun 2022 15:26:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244000AbiFTP0F (ORCPT ); Mon, 20 Jun 2022 11:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244639AbiFTPZ0 (ORCPT ); Mon, 20 Jun 2022 11:25:26 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F992E48 for ; Mon, 20 Jun 2022 08:24:43 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id g15so8018180qke.4 for ; Mon, 20 Jun 2022 08:24:43 -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=AAh9dzPILMHQWI8/F4SQx4JCHCxKzo11Zr+T4oaJSao=; b=PR5qTNGRhwRdExCn+/SVMM61J5hWqY06ps1bkPBZUgx6QpG2HeXODeLNM8rdwMsBrc RyNZA/uo26CbFEOC3RHKltlJ/pPenUJ4+kxu+7eiJO2xi7eSx5ta4EaB5iMuiZj8/qXF XB7MwnygUXwOwS65oTFwlFTTgkLP6zs8cW5EX6RaHgHSTZ45xnMIwuweFuAxKt+ktWiF zmhpjjVlDr6NB7iPC2rTZtZf0vCXUpj0/bqAZU0Ma+fz/b3Rpwck3NZ9pfJuft5TddZ+ nisXN7VsJdj85dKFtRkX6iT4+54ZpxFGZ8y5XwyymTrKUsa4EW0tpnhxeF8WbfSzREjZ Zn+w== 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=AAh9dzPILMHQWI8/F4SQx4JCHCxKzo11Zr+T4oaJSao=; b=FMLulj0YW9t3gfe2o3ZP96alhcDk8yaG+BqJ+wu/wT1CrRsSG6bJOCMylx51RHrcS6 0c1pYgrw0flLjV2eotFCHJZYpnSIeL8LxbpdC+O0jka6z5GnlzdRs1UFBuh2cskMnc7l KxJ/WHiGZLWdRCUHX4c2aQ+g5eug+OYaGDQK9is9a0DvN+xTILahaCZJchwu5w6fhrpj /HpVVS1oeo6gxDQujoArwBzvuA0JrerBT/jO+kulrBy/xUzG2VEYiMC/klZj/Urko79O plu26c9HQjhqEdt0MpX8j4iP2WmlHBZMbP7sZUeZF5DFbH9NKo/GJsqIsizPwlmjfV3e QlOw== X-Gm-Message-State: AJIora8jc1OoOJUgepQx5rrKw59udFtgnrfVdjsUlg2lRKMXDdR6AHZm G8RoKuRiWXCylNEPM4usJ4oyyWJuaI14cA== X-Google-Smtp-Source: AGRyM1vec9RvD5EKD1ZO0kuRwC9zD07tKqDgSUfKElOI6phUGhHw4KhetTrmpZKI2/aixIOxYHlmlw== X-Received: by 2002:a05:620a:2681:b0:67e:933e:54b6 with SMTP id c1-20020a05620a268100b0067e933e54b6mr16710169qkp.428.1655738682745; Mon, 20 Jun 2022 08:24:42 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:42 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 10/12] SUNRPC export xprt_iter_rewind function Date: Mon, 20 Jun 2022 11:24:05 -0400 Message-Id: <20220620152407.63127-11-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Make xprt_iter_rewind callable outside of xprtmultipath.c Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/xprtmultipath.h | 2 ++ net/sunrpc/xprtmultipath.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/sunrpc/xprtmultipath.h b/include/linux/sunrpc/xprtmultipath.h index 9fff0768d942..c0514c684b2c 100644 --- a/include/linux/sunrpc/xprtmultipath.h +++ b/include/linux/sunrpc/xprtmultipath.h @@ -68,6 +68,8 @@ extern void xprt_iter_init_listoffline(struct rpc_xprt_iter *xpi, extern void xprt_iter_destroy(struct rpc_xprt_iter *xpi); +extern void xprt_iter_rewind(struct rpc_xprt_iter *xpi); + extern struct rpc_xprt_switch *xprt_iter_xchg_switch( struct rpc_xprt_iter *xpi, struct rpc_xprt_switch *newswitch); diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index 41ec46e5f1a3..154bb6cf27ad 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -479,7 +479,6 @@ struct rpc_xprt *xprt_iter_next_entry_offline(struct rpc_xprt_iter *xpi) * Resets xpi to ensure that it points to the first entry in the list * of transports. */ -static void xprt_iter_rewind(struct rpc_xprt_iter *xpi) { rcu_read_lock(); From patchwork Mon Jun 20 15:24:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 014D2CCA47C for ; Mon, 20 Jun 2022 15:26:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244074AbiFTP0F (ORCPT ); Mon, 20 Jun 2022 11:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244668AbiFTPZ0 (ORCPT ); Mon, 20 Jun 2022 11:25:26 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1B6A329 for ; Mon, 20 Jun 2022 08:24:44 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id i17so9677747qvo.13 for ; Mon, 20 Jun 2022 08:24:44 -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=EtphTpz7ijVKD36pVaA+RVVdZdeigjx2bTQbCQuaqA4=; b=b895MBCUP2wjX9Se8uTc4rOByk0LDR9lHLaNMaz2WBKTc15VavL7lVDb6UlnRDWkb0 aiT3iWgo1Zo4XRKhYwlftExvSm0NsrswHYCpYr+myQGRqBcwLylJC09C7AjkRpeSCxUG xmU6TfWUw9wdQwhSNhmlbZmTz5Ky8psQ8UvfEQmSJKJOzYxyXL5D4+n4H5POdg6RPMkh iwDA+177zX7d1DUKZcSZf9Ru8ybNmZsPtHMx5Y+N3D9m1enIIobyluEB8YAFnrWtG7U1 l6VRaSXBE8+7OGWmCqGgbFB1PUjn9rzGJRZMBBZMuL2aqiwmT0AZUYc4wr8lXwqHEJMx mP6Q== 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=EtphTpz7ijVKD36pVaA+RVVdZdeigjx2bTQbCQuaqA4=; b=qaN3d64DjApKz0zolGyeIPnTrhlHNUegtUUk1gCOW5aXTP8ZWGcLJiSefN2FxzIhI1 wYIgpBFmuz1QAp6xiGSmrcD4lXLg6/KwC4/gah7iQKM8D8++srZCNKczZs3ZwGMFoa6y xhg6LyPMtYZ+A7D9OiszVANH2zEB0SnvLN3UAMMSo2jNVPpmyzX5rzJZBJy6AXxpePUf xGQ6DTTWXzQKYwR6kYw5vcM484F2L8b3EP207sDqNY7iY/Uqpfw5c07SqvW9/vC3DMRM oKHKyNkkJDHZHeEkOB/Rn98s8O75qy1cm/8oO7QnKfMm8nwhdSEvFYYej/ZbOCJ+FL1b QJaA== X-Gm-Message-State: AJIora8C3EmyYdXJUkL+zkc4wy/YulhEXWGKifihqH0iaFyXiVzgCv+M FYjzMCZg7kSpd+Kf5QBVEnD4X3O6Wm2dQQ== X-Google-Smtp-Source: AGRyM1vjihN/I1e42DwkTxf/7sy4/1BchAp0Y6WdajcFpM6vEghmwL7N454BdDCdUqewCaI6yo0D4Q== X-Received: by 2002:a05:6214:c26:b0:464:3fdd:a3e6 with SMTP id a6-20020a0562140c2600b004643fdda3e6mr19147415qvd.113.1655738683914; Mon, 20 Jun 2022 08:24:43 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:43 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 11/12] SUNRPC create a function that probes only offline transports Date: Mon, 20 Jun 2022 11:24:06 -0400 Message-Id: <20220620152407.63127-12-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia For only offline transports, attempt to check connectivity via a NULL call and, if that succeeds, call a provided session trunking detection function. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4proc.c | 2 +- include/linux/sunrpc/clnt.h | 3 ++- net/sunrpc/clnt.c | 47 +++++++++++++++++++++++++++++++++---- net/sunrpc/debugfs.c | 3 ++- net/sunrpc/stats.c | 2 +- 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 152da2bc5100..00778f351283 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -8533,7 +8533,7 @@ int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, const struct cred *cr .cred = cred, }; return rpc_clnt_iterate_for_each_xprt(clp->cl_rpcclient, NULL, - nfs4_proc_bind_conn_to_session_callback, &data); + nfs4_proc_bind_conn_to_session_callback, &data, false); } /* diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index ac1024da86c5..a0160b83d4a4 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -215,7 +215,7 @@ int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t); int rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt, int (*setup)(struct rpc_clnt *, struct rpc_xprt_iter *), int (*fn)(struct rpc_clnt *, struct rpc_xprt *, void *), - void *data); + void *data, bool do_rewind); int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt, struct rpc_xprt_switch *xps, @@ -236,6 +236,7 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *, struct rpc_xprt *, void *); void rpc_clnt_manage_trunked_xprts(struct rpc_clnt *, void *); +void rpc_probe_trunked_xprts(struct rpc_clnt *, void *); const char *rpc_proc_name(const struct rpc_task *task); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 6b04b29bf842..348d0772c91d 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -830,7 +830,7 @@ int rpc_clnt_xprt_iter_offline_init(struct rpc_clnt *clnt, int rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt, int (*setup)(struct rpc_clnt *, struct rpc_xprt_iter *), int (*fn)(struct rpc_clnt *, struct rpc_xprt *, void *), - void *data) + void *data, bool do_rewind) { struct rpc_xprt_iter xpi; int ret; @@ -850,6 +850,9 @@ int rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt, xprt_put(xprt); if (ret < 0) break; + + if (do_rewind) + xprt_iter_rewind(&xpi); } xprt_iter_destroy(&xpi); return ret; @@ -3032,6 +3035,40 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, } EXPORT_SYMBOL_GPL(rpc_clnt_add_xprt); +static int rpc_xprt_probe_trunked(struct rpc_clnt *clnt, + struct rpc_xprt *xprt, + void *data) +{ + struct rpc_xprt_switch *xps; + struct rpc_xprt *main_xprt; + int status = 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)); + status = rpc_cmp_addr_port((struct sockaddr *)&xprt->addr, + (struct sockaddr *)&main_xprt->addr); + rcu_read_unlock(); + xprt_put(main_xprt); + if (status || !test_bit(XPRT_OFFLINE, &xprt->state)) + goto out; + + status = rpc_clnt_add_xprt_helper(clnt, xprt, data); +out: + xprt_put(xprt); + xprt_switch_put(xps); + return status; +} + +void rpc_probe_trunked_xprts(struct rpc_clnt *clnt, void *data) +{ + rpc_clnt_iterate_for_each_xprt(clnt, rpc_clnt_xprt_iter_offline_init, + rpc_xprt_probe_trunked, data, true); +} +EXPORT_SYMBOL_GPL(rpc_probe_trunked_xprts); + static int rpc_xprt_offline_destroy(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *data) @@ -3071,7 +3108,7 @@ static int rpc_xprt_offline_destroy(struct rpc_clnt *clnt, void rpc_clnt_manage_trunked_xprts(struct rpc_clnt *clnt, void *data) { rpc_clnt_iterate_for_each_xprt(clnt, NULL, rpc_xprt_offline_destroy, - data); + data, false); } EXPORT_SYMBOL_GPL(rpc_clnt_manage_trunked_xprts); @@ -3105,7 +3142,7 @@ rpc_set_connect_timeout(struct rpc_clnt *clnt, }; rpc_clnt_iterate_for_each_xprt(clnt, NULL, rpc_xprt_set_connect_timeout, - &timeout); + &timeout, false); } EXPORT_SYMBOL_GPL(rpc_set_connect_timeout); @@ -3228,7 +3265,7 @@ rpc_clnt_swap_activate(struct rpc_clnt *clnt) clnt = clnt->cl_parent; if (atomic_inc_return(&clnt->cl_swapper) == 1) return rpc_clnt_iterate_for_each_xprt(clnt, NULL, - rpc_clnt_swap_activate_callback, NULL); + rpc_clnt_swap_activate_callback, NULL, false); return 0; } EXPORT_SYMBOL_GPL(rpc_clnt_swap_activate); @@ -3247,7 +3284,7 @@ rpc_clnt_swap_deactivate(struct rpc_clnt *clnt) { if (atomic_dec_if_positive(&clnt->cl_swapper) == 0) rpc_clnt_iterate_for_each_xprt(clnt, NULL, - rpc_clnt_swap_deactivate_callback, NULL); + rpc_clnt_swap_deactivate_callback, NULL, false); } EXPORT_SYMBOL_GPL(rpc_clnt_swap_deactivate); #endif /* CONFIG_SUNRPC_SWAP */ diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c index ab60b4d3deb2..9c700bad1ec5 100644 --- a/net/sunrpc/debugfs.c +++ b/net/sunrpc/debugfs.c @@ -160,7 +160,8 @@ rpc_clnt_debugfs_register(struct rpc_clnt *clnt) debugfs_create_file("tasks", S_IFREG | 0400, clnt->cl_debugfs, clnt, &tasks_fops); - rpc_clnt_iterate_for_each_xprt(clnt, NULL, do_xprt_debugfs, &xprtnum); + rpc_clnt_iterate_for_each_xprt(clnt, NULL, do_xprt_debugfs, &xprtnum, + false); } void diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index e50f73a4aca5..60e2d738a8f1 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c @@ -258,7 +258,7 @@ void rpc_clnt_show_stats(struct seq_file *seq, struct rpc_clnt *clnt) seq_printf(seq, "p/v: %u/%u (%s)\n", clnt->cl_prog, clnt->cl_vers, clnt->cl_program->name); - rpc_clnt_iterate_for_each_xprt(clnt, NULL, do_print_stats, seq); + rpc_clnt_iterate_for_each_xprt(clnt, NULL, do_print_stats, seq, false); seq_printf(seq, "\tper-op statistics\n"); for (op = 0; op < maxproc; op++) { From patchwork Mon Jun 20 15:24:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12887783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 495FCCCA480 for ; Mon, 20 Jun 2022 15:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244110AbiFTP0G (ORCPT ); Mon, 20 Jun 2022 11:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242342AbiFTPZ0 (ORCPT ); Mon, 20 Jun 2022 11:25:26 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C8FBB75 for ; Mon, 20 Jun 2022 08:24:45 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id 88so12811540qva.9 for ; Mon, 20 Jun 2022 08:24:45 -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=fRVISB0NdIuXGCNg5DG78rIz0nv0rsDBtLdW1M5C4To=; b=nxxrdC5LZu7hzoqFtoTRUJ+a/BqLFHti6XMnSqzoYxH2+R/Ns1SldP/cV59f/azDwU IcqR4vzCP9/dy0s7JIdvyW0009wS6BYBzstATyBL3Ug0j5vs8FqYZXgO5vW0BLmfFNNn p+jkVodDsFEPcetuNXReq6l15AOIDZneK//Xyqj3iU3REfVeKLp3JaYQeZzuiNZrNoGC HfRQtsaE8LWCzAMR7XsGs6PJzg+vTqUF1PqPO0vabbEOcdU4eQeJG1DSoYllMN+57otd tBxk1MfWQWxCfyAJffR9e8U75VdakUntt1loDjQWdVQXGTB2+UUmmCIfKZRSjKqLvxgD mymw== 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=fRVISB0NdIuXGCNg5DG78rIz0nv0rsDBtLdW1M5C4To=; b=grtBhZqouVG7AtVOw0M6FsXSfubix72mwxVE8sY2WfQcpcIOhtypimlILsKrsF5une RV6NASwARL1BU9uBxDBLcqHIsqZ9XiNb8VWBgiAosjfgRiADdq+cFzO+OE3A3xM8eiVZ 3Dka2ER6pcVaW6NDW13I04PqG/vqHsI3HOZJbJ1m/5DRJEJ1Uu41xDpLH3lzOam86Y9I dSk006mYw1KTdlnsWwd268N+Z8liRmiyqDgX/0ykJgdAcW/Pa3cI6HEXMJXcjWnCS1e3 x+JOC0zkupjcJNQN9edfPD0981TeBcTmcYtPs5gxVIbcUIeEzN4nenEKmPv88LLNCVS1 SHig== X-Gm-Message-State: AJIora+NrrBQ9Z8g9L8hT3XutmBkTiLdDw+XNTExSKJwtCpbBvYm4KsE RzMXmHlu8VGIwwUlWQbi6Eo= X-Google-Smtp-Source: AGRyM1v/8jqRRIDKg2H0UT0zWjHe5+etA2k34Ixx7s6PfEV6QdUqmg/Ntj92ooeWty2eITMcicpKfw== X-Received: by 2002:a05:6214:2422:b0:467:d777:7cda with SMTP id gy2-20020a056214242200b00467d7777cdamr19631672qvb.118.1655738685052; Mon, 20 Jun 2022 08:24:45 -0700 (PDT) Received: from kolga-mac-1.attlocal.net ([2600:1700:6a10:2e90:48cb:6eb8:1da1:a5c0]) by smtp.gmail.com with ESMTPSA id g10-20020a05620a40ca00b006a791a42693sm12517862qko.133.2022.06.20.08.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:24:44 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 12/12] NFSv4.1 probe offline transports for trunking on session creation Date: Mon, 20 Jun 2022 11:24:07 -0400 Message-Id: <20220620152407.63127-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220620152407.63127-1-olga.kornievskaia@gmail.com> References: <20220620152407.63127-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia Once the session is established call into the SUNRPC layer to check if any offlined trunking connections should be re-enabled. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4proc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 00778f351283..6bf21bc8c074 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9244,6 +9244,13 @@ int nfs4_proc_create_session(struct nfs_client *clp, const struct cred *cred) int status; unsigned *ptr; struct nfs4_session *session = clp->cl_session; + struct nfs4_add_xprt_data xprtdata = { + .clp = clp, + }; + struct rpc_add_xprt_test rpcdata = { + .add_xprt_test = clp->cl_mvops->session_trunk, + .data = &xprtdata, + }; dprintk("--> %s clp=%p session=%p\n", __func__, clp, session); @@ -9260,6 +9267,7 @@ int nfs4_proc_create_session(struct nfs_client *clp, const struct cred *cred) ptr = (unsigned *)&session->sess_id.data[0]; dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__, clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]); + rpc_probe_trunked_xprts(clp->cl_rpcclient, &rpcdata); out: return status; }