From patchwork Wed Jun 9 21:53:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12311303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B15BC48BCF for ; Wed, 9 Jun 2021 21:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52F33613DF for ; Wed, 9 Jun 2021 21:53:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbhFIVzf (ORCPT ); Wed, 9 Jun 2021 17:55:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbhFIVzf (ORCPT ); Wed, 9 Jun 2021 17:55:35 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EECB2C061574 for ; Wed, 9 Jun 2021 14:53:23 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id k22so24503221ioa.9 for ; Wed, 09 Jun 2021 14:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f4veoKZ0a0ni8ResyWpIUp4CiHu7n3udp9Mrl0bKQgU=; b=FEiIZIYv0Ntd8Xoe+ExeSIF01Sfpdg52Ph41kgOQ1HlWn7mmSQ/lrwMdufHw5kjJh1 NT/WHqXd6uFZLZATnzg6nxb7GFI5ZHxMmNEBq1KHnq1lt8O5Rv0pIrooFcsuE5ogx1Wc mxQcf1+ABVzh2PaOH58n2X0W/1ynddf4QUOzSSHiYX1sZjqeAPaexfYM4b8584GmcolW bfqRx1GUd5f5alQ/RXx6wqz17ERK0niLQKI7PoZmUj5OVy/32UAmgcvaxUWQyG8AQkVe Iq97elwkLOUlzxkcUiCipxzR2szRWKfhb2t72Uw+v8Eu9WRayzpMZ9l1s4fLaI2sysvF VqWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f4veoKZ0a0ni8ResyWpIUp4CiHu7n3udp9Mrl0bKQgU=; b=YJ+9SkrCxFzxTcCR8BC1a0ZRWGE7uB6yhp+qPYm+EBlRHI02FcCT8IkxtWr0a7Cw+T grPH0FKkSlhS6fQ/sSPi9HrcSXjDQYN3u7oxYVjOG3vMPbXTBOmYUL6wA+AAReePorzd MXh4PVWQvOo5uRkOollXn8kwxvv7NNdLekpTCAXaOo3j8nJ4IGdZpvW9m20ZUFB2qf+3 xZiDTCQprIOnwVhwyT1fHMV/w9fN+dfnV8twCSlmXnSxELDxyL9rXrcLT7be2kjITAd4 7YrlzMoRQOkIJ4aFDrxK2+EjrFTk1H459w3UYBmFlfEc4uoK7kXnRNqOYJrn/ICJSRPn r61w== X-Gm-Message-State: AOAM530+6mc5K5TEeXTHMFRBbbCIQ9Gmtw4ZCknf0126eG1ed+QotQk+ M4E1OOAZYiTxoWssVzK1uwCEj8xUgIvbOg== X-Google-Smtp-Source: ABdhPJwWOEB9gkA3+eeN2PyLIpt/WlHwttcmfuxDbeLkoL7Bed9XVqFzeJPutntD/eGocy2ulDUv0w== X-Received: by 2002:a6b:c30f:: with SMTP id t15mr1159219iof.17.1623275603347; Wed, 09 Jun 2021 14:53: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 w25sm619743iox.18.2021.06.09.14.53.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jun 2021 14:53:22 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 1/3] SUNRPC query xprt switch for number of active transports Date: Wed, 9 Jun 2021 17:53:17 -0400 Message-Id: <20210609215319.5518-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210609215319.5518-1-olga.kornievskaia@gmail.com> References: <20210609215319.5518-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia To keep track of how many transports have already been added, add ability to query the number. Signed-off-by: Olga Kornievskaia --- include/linux/sunrpc/clnt.h | 2 ++ net/sunrpc/clnt.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 02e7a5863d28..27042f1e581f 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -234,6 +234,8 @@ 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); +size_t rpc_clnt_xprt_switch_nactive(struct rpc_clnt *); + 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 42623d6b8f0e..b46262ffcf72 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2959,6 +2959,19 @@ bool rpc_clnt_xprt_switch_has_addr(struct rpc_clnt *clnt, } EXPORT_SYMBOL_GPL(rpc_clnt_xprt_switch_has_addr); +size_t rpc_clnt_xprt_switch_nactive(struct rpc_clnt *clnt) +{ + struct rpc_xprt_switch *xps; + size_t num; + + rcu_read_lock(); + xps = rcu_dereference(clnt->cl_xpi.xpi_xpswitch); + num = xps->xps_nactive; + rcu_read_unlock(); + return num; +} +EXPORT_SYMBOL_GPL(rpc_clnt_xprt_switch_nactive); + #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) static void rpc_show_header(void) { From patchwork Wed Jun 9 21:53:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12311305 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46DB9C48BCD for ; Wed, 9 Jun 2021 21:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 291B0613E1 for ; Wed, 9 Jun 2021 21:53:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229874AbhFIVzf (ORCPT ); Wed, 9 Jun 2021 17:55:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbhFIVzf (ORCPT ); Wed, 9 Jun 2021 17:55:35 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17778C06175F for ; Wed, 9 Jun 2021 14:53:25 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id l64so2817706ioa.7 for ; Wed, 09 Jun 2021 14:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sjubcL8BG/F9TjuwguMV8l5PnfNbKJa0/8XqU2kiLoc=; b=kvChOPSN8UfUy6+orc2dH8wpPD9TKGAKj6acRK2+An3bP5lZ6wtN6H1XPzjg/V2xdM 11ca9cRGopI3jaRG77uPLGqCtgEBYozwDIW8yHQ7tu9NVv78TNVp7g4+M2/O41rIKjwg oehdonLXYwtk9KBivmV4Mq7V2urMeyPkwWH2vHX8nimHdMOGD5oaqM0r0JQxISTi+kNM xqupRW9vDPVZ3UcDMVQHP3Az/nLvJ9efBv/DLFus/r94yENK6+1Z/Voawpf7MCoitdX0 u4PyfmU3vsevdo9xnenypAvrKTi6/QG+aSuZJXS2NEJnwBD2HwBjG9XFPJgkEKf77c8h v4QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sjubcL8BG/F9TjuwguMV8l5PnfNbKJa0/8XqU2kiLoc=; b=BC2TCsL64fsmPzUPkgK+KOabIYPNVxYpSEIbsAibWp2DzS5BV/xfis9s+SVx9ACS/Q TSpDUbxJOWk1WdWfo2/h+bfT9HynicchWazkkFsZxhIRS3eRp6RuZirKhKp0m8hsqgR1 9K9EHrlqjGYLmPvLfN1GeXgJzR07+n+VUhrlvUI214DTt3bj4JYr9dI4ebwewhCXsppa RdZJVVRCkJXpS0gwUscm4R58b3YUkYlqf3GPUFcpnYK6vKz9eI2MVqKdd5CDFjpBTMrP 0uiWFtUgYxHAFQbg0B7Qc+ucBpAQnNt9O+N9PEglj9HULjger+XqqLHKoQJRpTCRyE6x pSvA== X-Gm-Message-State: AOAM533YjU1UZh7DUpXqHgSTbZijevrPeFxxfC4L3iJCs2IYz9/a8IrE ublNasjBKbX14C+MRH2QBtpMMk+jbmX+aA== X-Google-Smtp-Source: ABdhPJxvPA5FUEDIBd0L0u5TKI79fPq5nDdxIye++TTLenm+4a+nXABpAMtEHYivJQNgrsCfCg+iqA== X-Received: by 2002:a6b:f806:: with SMTP id o6mr1183773ioh.204.1623275604421; Wed, 09 Jun 2021 14:53:24 -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 w25sm619743iox.18.2021.06.09.14.53.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jun 2021 14:53:23 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 2/3] NFSv4 introduce max_connect mount options Date: Wed, 9 Jun 2021 17:53:18 -0400 Message-Id: <20210609215319.5518-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210609215319.5518-1-olga.kornievskaia@gmail.com> References: <20210609215319.5518-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia This option will control up to how many xprts can the client establish to the server. This patch parses the value and sets up structures that keep track of max_connect. Signed-off-by: Olga Kornievskaia --- fs/nfs/client.c | 1 + fs/nfs/fs_context.c | 8 ++++++++ fs/nfs/internal.h | 2 ++ fs/nfs/nfs4client.c | 12 ++++++++++-- fs/nfs/super.c | 2 ++ include/linux/nfs_fs_sb.h | 1 + 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 330f65727c45..486dec59972b 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -179,6 +179,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init) clp->cl_proto = cl_init->proto; clp->cl_nconnect = cl_init->nconnect; + clp->cl_max_connect = cl_init->max_connect ? cl_init->max_connect : 1; clp->cl_net = get_net(cl_init->net); clp->cl_principal = "*"; diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index d95c9a39bc70..cfbff7098f8e 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -29,6 +29,7 @@ #endif #define NFS_MAX_CONNECTIONS 16 +#define NFS_MAX_TRANSPORTS 128 enum nfs_param { Opt_ac, @@ -60,6 +61,7 @@ enum nfs_param { Opt_mountvers, Opt_namelen, Opt_nconnect, + Opt_max_connect, Opt_port, Opt_posix, Opt_proto, @@ -158,6 +160,7 @@ static const struct fs_parameter_spec nfs_fs_parameters[] = { fsparam_u32 ("mountvers", Opt_mountvers), fsparam_u32 ("namlen", Opt_namelen), fsparam_u32 ("nconnect", Opt_nconnect), + fsparam_u32 ("max_connect", Opt_max_connect), fsparam_string("nfsvers", Opt_vers), fsparam_u32 ("port", Opt_port), fsparam_flag_no("posix", Opt_posix), @@ -770,6 +773,11 @@ static int nfs_fs_context_parse_param(struct fs_context *fc, goto out_of_bounds; ctx->nfs_server.nconnect = result.uint_32; break; + case Opt_max_connect: + if (result.uint_32 < 1 || result.uint_32 > NFS_MAX_TRANSPORTS) + goto out_of_bounds; + ctx->nfs_server.max_connect = result.uint_32; + break; case Opt_lookupcache: switch (result.uint_32) { case Opt_lookupcache_all: diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index a36af04188c2..66fc936834f2 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -67,6 +67,7 @@ struct nfs_client_initdata { int proto; u32 minorversion; unsigned int nconnect; + unsigned int max_connect; struct net *net; const struct rpc_timeout *timeparms; const struct cred *cred; @@ -121,6 +122,7 @@ struct nfs_fs_context { int port; unsigned short protocol; unsigned short nconnect; + unsigned short max_connect; unsigned short export_path_len; } nfs_server; diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 42719384e25f..640c8235d817 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -863,6 +863,7 @@ static int nfs4_set_client(struct nfs_server *server, const char *ip_addr, int proto, const struct rpc_timeout *timeparms, u32 minorversion, unsigned int nconnect, + unsigned int max_connect, struct net *net) { struct nfs_client_initdata cl_init = { @@ -881,6 +882,8 @@ static int nfs4_set_client(struct nfs_server *server, if (minorversion == 0) __set_bit(NFS_CS_REUSEPORT, &cl_init.init_flags); + else + cl_init.max_connect = max_connect; if (proto == XPRT_TRANSPORT_TCP) cl_init.nconnect = nconnect; @@ -950,8 +953,10 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv, return ERR_PTR(-EINVAL); cl_init.hostname = buf; - if (mds_clp->cl_nconnect > 1 && ds_proto == XPRT_TRANSPORT_TCP) + if (mds_clp->cl_nconnect > 1 && ds_proto == XPRT_TRANSPORT_TCP) { cl_init.nconnect = mds_clp->cl_nconnect; + cl_init.max_connect = mds_clp->cl_max_connect; + } if (mds_srv->flags & NFS_MOUNT_NORESVPORT) __set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags); @@ -1120,6 +1125,7 @@ static int nfs4_init_server(struct nfs_server *server, struct fs_context *fc) &timeparms, ctx->minorversion, ctx->nfs_server.nconnect, + ctx->nfs_server.max_connect, fc->net_ns); if (error < 0) return error; @@ -1209,6 +1215,7 @@ struct nfs_server *nfs4_create_referral_server(struct fs_context *fc) parent_server->client->cl_timeout, parent_client->cl_mvops->minor_version, parent_client->cl_nconnect, + parent_client->cl_max_connect, parent_client->cl_net); if (!error) goto init_server; @@ -1224,6 +1231,7 @@ struct nfs_server *nfs4_create_referral_server(struct fs_context *fc) parent_server->client->cl_timeout, parent_client->cl_mvops->minor_version, parent_client->cl_nconnect, + parent_client->cl_max_connect, parent_client->cl_net); if (error < 0) goto error; @@ -1321,7 +1329,7 @@ int nfs4_update_server(struct nfs_server *server, const char *hostname, error = nfs4_set_client(server, hostname, sap, salen, buf, clp->cl_proto, clnt->cl_timeout, clp->cl_minorversion, - clp->cl_nconnect, net); + clp->cl_nconnect, clp->cl_max_connect, net); clear_bit(NFS_MIG_TSM_POSSIBLE, &server->mig_status); if (error != 0) { nfs_server_insert_lists(server); diff --git a/fs/nfs/super.c b/fs/nfs/super.c index fe58525cfed4..e65c83494c05 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -480,6 +480,8 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, if (clp->cl_nconnect > 0) seq_printf(m, ",nconnect=%u", clp->cl_nconnect); if (version == 4) { + if (clp->cl_max_connect > 1) + seq_printf(m, ",max_connect=%u", clp->cl_max_connect); if (nfss->port != NFS_PORT) seq_printf(m, ",port=%u", nfss->port); } else diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index d71a0e90faeb..2a9acbfe00f0 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -62,6 +62,7 @@ struct nfs_client { u32 cl_minorversion;/* NFSv4 minorversion */ unsigned int cl_nconnect; /* Number of connections */ + unsigned int cl_max_connect; /* max number of xprts allowed */ const char * cl_principal; /* used for machine cred */ #if IS_ENABLED(CONFIG_NFS_V4) From patchwork Wed Jun 9 21:53:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 12311301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC2F8C48BCD for ; Wed, 9 Jun 2021 21:53:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB381613DF for ; Wed, 9 Jun 2021 21:53:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbhFIVzX (ORCPT ); Wed, 9 Jun 2021 17:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbhFIVzV (ORCPT ); Wed, 9 Jun 2021 17:55:21 -0400 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2453BC061760 for ; Wed, 9 Jun 2021 14:53:26 -0700 (PDT) Received: by mail-io1-xd2c.google.com with SMTP id k5so14673019iow.12 for ; Wed, 09 Jun 2021 14:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K/Jq3HAYXNGdn+LtxxcKe5mHX2msEUoBvTHdlrtw9RU=; b=DGblcGY4OFekTORnk76L9JfrXCwEQrGselmRl+3TCRhHgKrmvQMyFVqXDm1SHogCnb LlcZ95u0fVVteAQFrf6u7g+GJRz5oJyL7MSKwabljjaBK2ZVxAO9O+y4E/ZUmau38EcW 0ms7VcdDu/FKVVKO5niDY5nPKwRXERCb8piWtScOt32bxUnqEEQE3z6mmkDrc7hL3FK7 GGPH/l2uoJemQXAlW3w8BysqDGW/eIB7ZgBPlO/0mR2xGrLvZcXAZlP4fRyTF/WXpsvx L8CE/oo8BJx2xg0RpKtgBsteUdSjK8KVrQKV7XuFB1ANqrgOMm8SZUKjHXXQ7ul2hCi2 kyGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K/Jq3HAYXNGdn+LtxxcKe5mHX2msEUoBvTHdlrtw9RU=; b=Z6tKPn52Syd8cl0RWHNgl+A5f742RxVFehSNCYg51zMOOAL2/jPPPoS1zzcdVqNw1V TI7UWL8T87f9mydrIkhPUDDFxRF5MsiaN2aBrogD5IS7feJyapBwcwr/D2EXdiYcG5d5 /53pSjrFXPRcTFX9a2iH0umGhu2MZCuUGToIn0qHvzaAIm5tU14F1rZGBmrO2V57UeEr eG/DHV0Qij2vuyE5NU2itPtHB6N3xbjcKFIaKG3kRrT/y/9L6uK4Jz9kWLWGRPtltBUM mMcf37JKIwxV+oZv6xalhmutDkxvQzaskFe5m2i5UZS7DI17228MfgwcAq/Bleq69iRF f6cw== X-Gm-Message-State: AOAM532hCejeyXp4L9X7i5jrQsHKZVjx0bBLpo9jJ3Yftqdoc2FtgYAa orBwMBhh+fSL5ZB4OZfG8sI= X-Google-Smtp-Source: ABdhPJyyjY3rW901cQDVQpg4WJwliz0rXL9CQdtNQ8VzeRs9PXL2bvjOhRcbpFPjP0Jc9Imjl8MeNw== X-Received: by 2002:a5e:8d02:: with SMTP id m2mr1187514ioj.9.1623275605577; Wed, 09 Jun 2021 14:53:25 -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 w25sm619743iox.18.2021.06.09.14.53.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jun 2021 14:53:25 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 3/3] NFSv4.1+ add trunking when server trunking detected Date: Wed, 9 Jun 2021 17:53:19 -0400 Message-Id: <20210609215319.5518-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210609215319.5518-1-olga.kornievskaia@gmail.com> References: <20210609215319.5518-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia After trunking is discovered in nfs4_discover_server_trunking(), add the transport to the old client structure if the allowed limit of transports has not been reached. An example: there exists a multi-homed server and client mounts one server address and some volume and then doest another mount to a different address of the same server and perhaps a different volume. Previously, the client checks that this is a session trunkable servers (same server), and removes the newly created client structure along with its transport. Now, the client adds the connection from the 2nd mount into the xprt switch of the existing client (it leads to having 2 available connections). Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4client.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 640c8235d817..ece283cd45c8 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -361,6 +361,33 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) return nfs4_init_callback(clp); } +static void nfs4_add_trunk(struct nfs_client *clp, struct nfs_client *old) +{ + struct sockaddr_storage clp_addr, old_addr; + struct sockaddr *clp_sap = (struct sockaddr *)&clp_addr; + struct sockaddr *old_sap = (struct sockaddr *)&old_addr; + size_t clp_salen; + struct xprt_create xprt_args = { + .ident = old->cl_proto, + .net = old->cl_net, + .servername = old->cl_hostname, + }; + + if (clp->cl_proto != old->cl_proto) + return; + clp_salen = rpc_peeraddr(clp->cl_rpcclient, clp_sap, sizeof(clp_addr)); + rpc_peeraddr(old->cl_rpcclient, old_sap, sizeof(old_addr)); + + if (clp_addr.ss_family != old_addr.ss_family) + return; + + xprt_args.dstaddr = clp_sap; + xprt_args.addrlen = clp_salen; + + rpc_clnt_add_xprt(old->cl_rpcclient, &xprt_args, + rpc_clnt_test_and_add_xprt, NULL); +} + /** * nfs4_init_client - Initialise an NFS4 client record * @@ -434,6 +461,10 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp, * won't try to use it. */ nfs_mark_client_ready(clp, -EPERM); + if (old->cl_mvops->session_trunk && + (rpc_clnt_xprt_switch_nactive(old->cl_rpcclient) < + old->cl_max_connect)) + nfs4_add_trunk(clp, old); } clear_bit(NFS_CS_TSM_POSSIBLE, &clp->cl_flags); nfs_put_client(clp);