From: Trond Myklebust <trondmy@hammerspace.com>
To: "bcodding@redhat.com" <bcodding@redhat.com>,
"mwakabayashi@vmware.com" <mwakabayashi@vmware.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"aglo@umich.edu" <aglo@umich.edu>,
"SteveD@redhat.com" <SteveD@redhat.com>
Subject: Re: NFSv4: Mounting NFS server which is down, blocks all other NFS mounts on same machine
Date: Wed, 9 Jun 2021 14:41:18 +0000 [thread overview]
Message-ID: <752114495b47624b022bb7de366c6b1771d0599a.camel@hammerspace.com> (raw)
In-Reply-To: <FCDAEE4A-33CB-4939-8001-DAAFD7BC8638@redhat.com>
On Wed, 2021-06-09 at 10:31 -0400, Benjamin Coddington wrote:
>
> It's not disputed that mounts waiting on the transport layer will block
> other mounts.
>
> It might be able to be changed: there's this torch:
> https://lore.kernel.org/linux-nfs/87378omld4.fsf@notabene.neil.brown.name/
>
No.
> ..or there may be another way we don't have to wait ..
>
OK. So let's look at how we can solve the problem of the initial
connection to the server timing out and causing hangs in
nfs41_walk_client_list(), and leave aside any other corner case
problems (such as the server going down while we're mounting).
How about something like the following (compile tested only) patch?
8<--------------------------------------------------------
From 30833f78b5b4c7780c91f705b0867ef5492a9eed Mon Sep 17 00:00:00 2001
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Date: Wed, 9 Jun 2021 10:04:46 -0400
Subject: [PATCH] NFSv4: Initialise connection to the server in
nfs4_alloc_client()
Set up the connection to the NFSv4 server in nfs4_alloc_client(), before
we've added the struct nfs_client to the net-namespace's nfs_client_list
so that a downed server won't cause other mounts to hang in the trunking
detection code.
Reported-by: Michael Wakabayashi <mwakabayashi@vmware.com>
Fixes: 5c6e5b60aae4 ("NFS: Fix an Oops in the pNFS files and flexfiles connection setup to the DS")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/nfs4client.c | 82 +++++++++++++++++++++++----------------------
1 file changed, 42 insertions(+), 40 deletions(-)
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 42719384e25f..28431acd1230 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -197,8 +197,11 @@ void nfs40_shutdown_client(struct nfs_client *clp)
struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
{
- int err;
+ char buf[INET6_ADDRSTRLEN + 1];
+ const char *ip_addr = cl_init->ip_addr;
struct nfs_client *clp = nfs_alloc_client(cl_init);
+ int err;
+
if (IS_ERR(clp))
return clp;
@@ -222,6 +225,44 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
init_waitqueue_head(&clp->cl_lock_waitq);
#endif
INIT_LIST_HEAD(&clp->pending_cb_stateids);
+
+ if (cl_init->minorversion != 0)
+ __set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags);
+ __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
+ __set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags);
+
+ /*
+ * Set up the connection to the server before we add add to the
+ * global list.
+ */
+ err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_GSS_KRB5I);
+ if (err == -EINVAL)
+ err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
+ if (err < 0)
+ goto error;
+
+ /* If no clientaddr= option was specified, find a usable cb address */
+ if (ip_addr == NULL) {
+ struct sockaddr_storage cb_addr;
+ struct sockaddr *sap = (struct sockaddr *)&cb_addr;
+
+ err = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
+ if (err < 0)
+ goto error;
+ err = rpc_ntop(sap, buf, sizeof(buf));
+ if (err < 0)
+ goto error;
+ ip_addr = (const char *)buf;
+ }
+ strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
+
+ err = nfs_idmap_new(clp);
+ if (err < 0) {
+ dprintk("%s: failed to create idmapper. Error = %d\n",
+ __func__, err);
+ goto error;
+ }
+ __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
return clp;
error:
@@ -372,8 +413,6 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp)
struct nfs_client *nfs4_init_client(struct nfs_client *clp,
const struct nfs_client_initdata *cl_init)
{
- char buf[INET6_ADDRSTRLEN + 1];
- const char *ip_addr = cl_init->ip_addr;
struct nfs_client *old;
int error;
@@ -381,43 +420,6 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp,
/* the client is initialised already */
return clp;
- /* Check NFS protocol revision and initialize RPC op vector */
- clp->rpc_ops = &nfs_v4_clientops;
-
- if (clp->cl_minorversion != 0)
- __set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags);
- __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
- __set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags);
-
- error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_GSS_KRB5I);
- if (error == -EINVAL)
- error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
- if (error < 0)
- goto error;
-
- /* If no clientaddr= option was specified, find a usable cb address */
- if (ip_addr == NULL) {
- struct sockaddr_storage cb_addr;
- struct sockaddr *sap = (struct sockaddr *)&cb_addr;
-
- error = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
- if (error < 0)
- goto error;
- error = rpc_ntop(sap, buf, sizeof(buf));
- if (error < 0)
- goto error;
- ip_addr = (const char *)buf;
- }
- strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
-
- error = nfs_idmap_new(clp);
- if (error < 0) {
- dprintk("%s: failed to create idmapper. Error = %d\n",
- __func__, error);
- goto error;
- }
- __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
-
error = nfs4_init_client_minor_version(clp);
if (error < 0)
goto error;
--
2.31.1
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com
next prev parent reply other threads:[~2021-06-09 14:41 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-17 1:37 NFSv4: Mounting NFS server which is down, blocks all other NFS mounts on same machine Michael Wakabayashi
2021-05-19 19:15 ` Olga Kornievskaia
2021-05-20 9:51 ` Michael Wakabayashi
2021-05-20 10:43 ` Michael Wakabayashi
2021-05-20 23:51 ` Olga Kornievskaia
2021-05-21 19:11 ` Michael Wakabayashi
2021-05-20 18:42 ` Steve Dickson
[not found] ` <CO1PR05MB8101FD5E77B386A75786FF41B7299@CO1PR05MB8101.namprd05.prod.outlook.com>
2021-05-21 19:35 ` Olga Kornievskaia
2021-05-21 20:31 ` Michael Wakabayashi
2021-05-21 21:06 ` Olga Kornievskaia
2021-05-21 22:08 ` Trond Myklebust
2021-05-21 22:41 ` Olga Kornievskaia
2021-06-08 9:16 ` Michael Wakabayashi
2021-06-08 16:10 ` Olga Kornievskaia
2021-06-09 5:31 ` Michael Wakabayashi
2021-06-09 13:50 ` Olga Kornievskaia
2021-06-09 20:19 ` Alex Romanenko
2021-06-11 5:26 ` Michael Wakabayashi
2021-06-09 14:31 ` Benjamin Coddington
2021-06-09 14:41 ` Olga Kornievskaia
2021-06-09 17:14 ` Michael Wakabayashi
2021-06-09 14:41 ` Trond Myklebust [this message]
2021-06-09 15:00 ` Benjamin Coddington
2021-06-09 15:19 ` Trond Myklebust
2021-06-09 6:46 ` Alex Romanenko
2021-05-21 22:38 ` Olga Kornievskaia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=752114495b47624b022bb7de366c6b1771d0599a.camel@hammerspace.com \
--to=trondmy@hammerspace.com \
--cc=SteveD@redhat.com \
--cc=aglo@umich.edu \
--cc=bcodding@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=mwakabayashi@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox