]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFS/pNFS: Set the connect timeout for the pNFS flexfiles driver
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 19 Aug 2023 21:32:25 +0000 (17:32 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 24 Aug 2023 17:24:15 +0000 (13:24 -0400)
Ensure that the connect timeout for the pNFS flexfiles driver is of the
same order as the I/O timeout, so that we can fail over quickly when
trying to read from a data server that is down.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/client.c
fs/nfs/internal.h
fs/nfs/nfs3client.c
fs/nfs/pnfs_nfs.c

index e4c5f193ed5e8d6353b3871b441d9a31f5c75e51..44eca51b28085d9deff764bfe6f9286388e93983 100644 (file)
@@ -517,6 +517,8 @@ int nfs_create_rpc_client(struct nfs_client *clp,
                .authflavor     = flavor,
                .cred           = cl_init->cred,
                .xprtsec        = cl_init->xprtsec,
+               .connect_timeout = cl_init->connect_timeout,
+               .reconnect_timeout = cl_init->reconnect_timeout,
        };
 
        if (test_bit(NFS_CS_DISCRTRY, &clp->cl_flags))
index 41abea340ad84a9e2973b5705f92097fd38f903b..9c9cf764f6000d551af567b770c368ee15f117b8 100644 (file)
@@ -82,6 +82,8 @@ struct nfs_client_initdata {
        const struct rpc_timeout *timeparms;
        const struct cred *cred;
        struct xprtsec_parms xprtsec;
+       unsigned long connect_timeout;
+       unsigned long reconnect_timeout;
 };
 
 /*
index eff3802c5e03516f47b5a842f0a9953fc39d2df3..674c012868b1a250b869e6586496db24915ce7da 100644 (file)
@@ -86,6 +86,7 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,
                int ds_proto, unsigned int ds_timeo, unsigned int ds_retrans)
 {
        struct rpc_timeout ds_timeout;
+       unsigned long connect_timeout = ds_timeo * (ds_retrans + 1) * HZ / 10;
        struct nfs_client *mds_clp = mds_srv->nfs_client;
        struct nfs_client_initdata cl_init = {
                .addr = ds_addr,
@@ -98,6 +99,8 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,
                .timeparms = &ds_timeout,
                .cred = mds_srv->cred,
                .xprtsec = mds_clp->cl_xprtsec,
+               .connect_timeout = connect_timeout,
+               .reconnect_timeout = connect_timeout,
        };
        struct nfs_client *clp;
        char buf[INET6_ADDRSTRLEN + 1];
index a0112ad4937aa2435ead2394dde209def12f974a..a08cfda6fff1f6dd84b4d8736cb11dae740c5980 100644 (file)
@@ -852,6 +852,7 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,
 {
        struct nfs_client *clp = ERR_PTR(-EIO);
        struct nfs4_pnfs_ds_addr *da;
+       unsigned long connect_timeout = timeo * (retrans + 1) * HZ / 10;
        int status = 0;
 
        dprintk("--> %s DS %s\n", __func__, ds->ds_remotestr);
@@ -870,6 +871,8 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv,
                                .dstaddr = (struct sockaddr *)&da->da_addr,
                                .addrlen = da->da_addrlen,
                                .servername = clp->cl_hostname,
+                               .connect_timeout = connect_timeout,
+                               .reconnect_timeout = connect_timeout,
                        };
 
                        if (da->da_transport != clp->cl_proto)