From: Greg Kroah-Hartman Date: Mon, 24 Jan 2022 18:32:59 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v4.4.300~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1ce6e6e67404f7fc3260279862524ae9498864d;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: nfsv4-initialise-connection-to-the-server-in-nfs4_alloc_client.patch --- diff --git a/queue-4.14/nfsv4-initialise-connection-to-the-server-in-nfs4_alloc_client.patch b/queue-4.14/nfsv4-initialise-connection-to-the-server-in-nfs4_alloc_client.patch new file mode 100644 index 00000000000..6a04888428a --- /dev/null +++ b/queue-4.14/nfsv4-initialise-connection-to-the-server-in-nfs4_alloc_client.patch @@ -0,0 +1,135 @@ +From dd99e9f98fbf423ff6d365b37a98e8879170f17c Mon Sep 17 00:00:00 2001 +From: Trond Myklebust +Date: Wed, 9 Jun 2021 10:04:46 -0400 +Subject: NFSv4: Initialise connection to the server in nfs4_alloc_client() + +From: Trond Myklebust + +commit dd99e9f98fbf423ff6d365b37a98e8879170f17c upstream. + +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 +Fixes: 5c6e5b60aae4 ("NFS: Fix an Oops in the pNFS files and flexfiles connection setup to the DS") +Signed-off-by: Trond Myklebust +Signed-off-by: Greg Kroah-Hartman +--- + fs/nfs/nfs4client.c | 82 ++++++++++++++++++++++++++-------------------------- + 1 file changed, 42 insertions(+), 40 deletions(-) + +--- a/fs/nfs/nfs4client.c ++++ b/fs/nfs/nfs4client.c +@@ -177,8 +177,11 @@ void nfs40_shutdown_client(struct nfs_cl + + 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; + +@@ -202,6 +205,44 @@ struct nfs_client *nfs4_alloc_client(con + #if IS_ENABLED(CONFIG_NFS_V4_1) + init_waitqueue_head(&clp->cl_lock_waitq); + #endif ++ ++ 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: +@@ -354,8 +395,6 @@ static int nfs4_init_client_minor_versio + 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; + +@@ -363,43 +402,6 @@ struct nfs_client *nfs4_init_client(stru + /* 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; diff --git a/queue-4.14/series b/queue-4.14/series index 44a47179d34..5eb63111f07 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -183,3 +183,4 @@ fuse-fix-bad-inode.patch fuse-fix-live-lock-in-fuse_iget.patch gianfar-simplify-fcs-handling-and-fix-memory-leak.patch gianfar-fix-jumbo-packets-napi-rx-overrun-crash.patch +nfsv4-initialise-connection-to-the-server-in-nfs4_alloc_client.patch