NFS: Use non-atomic bit ops when initialising struct nfs_client_initdata
Subsystems (3)
PATCH 1/5 NFS: Use non-atomic bit ops when initialising struct nfs_client_initdata
We don't need atomic bit ops when initialising a local structure on the stack.
--- fs/nfs/nfs3client.c | 2 +- fs/nfs/nfs4client.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/nfs/nfs3client.c +1 -1
@@ -106,7 +106,7 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv, cl_init.nconnect = mds_clp->cl_nconnect;if (mds_srv->flags &NFS_MOUNT_NORESVPORT ) -set_bit (NFS_CS_NORESVPORT , &cl_init.init_flags); +__set_bit (NFS_CS_NORESVPORT , &cl_init.init_flags);/* Use the MDS nfs_client cl_ipaddr. */ nfs_init_timeout_values (&ds_timeout, ds_proto, ds_timeo, ds_retrans);
fs/nfs/nfs4client.c +3 -3
@@ -882,11 +882,11 @@ static int nfs4_set_client(struct nfs_server *server,if (minorversion >0 && proto ==XPRT_TRANSPORT_TCP ) cl_init.nconnect = nconnect;if (server->flags &NFS_MOUNT_NORESVPORT ) -set_bit (NFS_CS_NORESVPORT , &cl_init.init_flags); +__set_bit (NFS_CS_NORESVPORT , &cl_init.init_flags);if (server->options &NFS_OPTION_MIGRATION ) -set_bit (NFS_CS_MIGRATION , &cl_init.init_flags); +__set_bit (NFS_CS_MIGRATION , &cl_init.init_flags);if (test_bit (NFS_MIG_TSM_POSSIBLE , &server->mig_status)) -set_bit (NFS_CS_TSM_POSSIBLE , &cl_init.init_flags); +__set_bit (NFS_CS_TSM_POSSIBLE , &cl_init.init_flags); server->port =rpc_get_port (addr);/* Allocate or find a client reference we can use */
Signature · 1 line
2.21.0
PATCH 2/5 NFS: Add a flag to tell nfs_client to set RPC_CLNT_CREATE_NOPING
Add a flag to tell the nfs_client it should set RPC_CLNT_CREATE_NOPING when creating the rpc client.
--- fs/nfs/client.c | 2 ++ include/linux/nfs_fs_sb.h | 1 + 2 files changed, 3 insertions(+)
fs/nfs/client.c +2 -0
@@ -515,6 +515,8 @@ int nfs_create_rpc_client(struct nfs_client *clp, args.flags |=RPC_CLNT_CREATE_NONPRIVPORT ;if (test_bit (NFS_CS_INFINITE_SLOTS , &clp->cl_flags)) args.flags |=RPC_CLNT_CREATE_INFINITE_SLOTS ; +if (test_bit (NFS_CS_NOPING , &clp->cl_flags)) + args.flags |=RPC_CLNT_CREATE_NOPING ;if (!IS_ERR (clp->cl_rpcclient))return 0 ;
include/linux/nfs_fs_sb.h +1 -0
@@ -45,6 +45,7 @@ struct nfs_client {#define NFS_CS_INFINITE_SLOTS 3/* - don't limit TCP slots */ #define NFS_CS_NO_RETRANS_TIMEOUT 4/* - Disable retransmit timeouts */ #define NFS_CS_TSM_POSSIBLE 5/* - Maybe state migration */ +#define NFS_CS_NOPING 6/* - don't ping on connect */ struct sockaddr_storage cl_addr;/* server identifier */ size_t cl_addrlen;char * cl_hostname;/* hostname of server */
Signature · 1 line
2.21.0
PATCH 3/5 pNFS: nfs3_set_ds_client should set NFS_CS_NOPING
Connecting to the DS is a non-interactive, asynchronous task, so there is no reason to fire up an extra RPC null ping in order to ensure that the server is up.
--- fs/nfs/nfs3client.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfs/nfs3client.c +2 -0
@@ -108,6 +108,8 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,if (mds_srv->flags &NFS_MOUNT_NORESVPORT )__set_bit (NFS_CS_NORESVPORT , &cl_init.init_flags); +__set_bit (NFS_CS_NOPING , &cl_init.init_flags); +/* Use the MDS nfs_client cl_ipaddr. */ nfs_init_timeout_values (&ds_timeout, ds_proto, ds_timeo, ds_retrans); clp =nfs_get_client (&cl_init);
Signature · 1 line
2.21.0
PATCH 4/5 NFS/pnfs: Separate NFSv3 DS and MDS traffic
If a NFSv3 server is being used as both a DS and as a regular NFSv3 server, we may want to keep the IO traffic on a separate TCP connection, since it will typically have very different timeout characteristics.
This patch therefore sets up a flag to separate the two modes of operation for the nfs_client.
--- fs/nfs/client.c | 6 ++++++ fs/nfs/nfs3client.c | 1 + include/linux/nfs_fs_sb.h | 1 + 3 files changed, 8 insertions(+)
fs/nfs/client.c +6 -0
@@ -312,6 +312,12 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat/* Match nfsv4 minorversion */ if (clp->cl_minorversion != data->minorversion)continue ; + +/* Match request for a dedicated DS */ +if (test_bit (NFS_CS_DS , &data->init_flags) != +test_bit (NFS_CS_DS , &clp->cl_flags)) +continue ; +/* Match the full socket address */ if (!rpc_cmp_addr_port (sap, clap))/* Match all xprt_switch full socket addresses */
fs/nfs/nfs3client.c +1 -0
@@ -109,6 +109,7 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,__set_bit (NFS_CS_NORESVPORT , &cl_init.init_flags);__set_bit (NFS_CS_NOPING , &cl_init.init_flags); +__set_bit (NFS_CS_DS , &cl_init.init_flags);/* Use the MDS nfs_client cl_ipaddr. */ nfs_init_timeout_values (&ds_timeout, ds_proto, ds_timeo, ds_retrans);
include/linux/nfs_fs_sb.h +1 -0
@@ -46,6 +46,7 @@ struct nfs_client {#define NFS_CS_NO_RETRANS_TIMEOUT 4/* - Disable retransmit timeouts */ #define NFS_CS_TSM_POSSIBLE 5/* - Maybe state migration */ #define NFS_CS_NOPING 6/* - don't ping on connect */ +#define NFS_CS_DS 7/* - Server is a DS */ struct sockaddr_storage cl_addr;/* server identifier */ size_t cl_addrlen;char * cl_hostname;/* hostname of server */
Signature · 1 line
2.21.0
PATCH 5/5 NFSv4.1: Don't rebind to the same source port when reconnecting to the server
NFSv2, v3 and NFSv4 servers often have duplicate replay caches that look at the source port when deciding whether or not an RPC call is a replay of a previous call. This requires clients to perform strange TCP gymnastics in order to ensure that when they reconnect to the server, they bind to the same source port.
NFSv4.1 and NFSv4.2 have sessions that provide proper replay semantics, that do not look at the source port of the connection. This patch therefore ensures they can ignore the rebind requirement.
--- fs/lockd/host.c | 3 ++- fs/nfs/client.c | 3 +++ fs/nfs/nfs4client.c | 5 ++++- include/linux/nfs_fs_sb.h | 1 + include/linux/sunrpc/clnt.h | 1 + include/linux/sunrpc/xprt.h | 3 ++- net/sunrpc/clnt.c | 7 ++++++- net/sunrpc/xprtsock.c | 2 +- 8 files changed, 20 insertions(+), 5 deletions(-)
fs/lockd/host.c +2 -1
@@ -464,7 +464,8 @@ nlm_bind_host(struct nlm_host *host) .version = host->h_version, .authflavor = RPC_AUTH_UNIX, .flags = (RPC_CLNT_CREATE_NOPING | - RPC_CLNT_CREATE_AUTOBIND), +RPC_CLNT_CREATE_AUTOBIND | + RPC_CLNT_CREATE_REUSEPORT), .cred = host->h_cred, };
fs/nfs/client.c +3 -0
@@ -523,6 +523,8 @@ int nfs_create_rpc_client(struct nfs_client *clp, args.flags |=RPC_CLNT_CREATE_INFINITE_SLOTS ;if (test_bit (NFS_CS_NOPING , &clp->cl_flags)) args.flags |=RPC_CLNT_CREATE_NOPING ; +if (test_bit (NFS_CS_REUSEPORT , &clp->cl_flags)) + args.flags |=RPC_CLNT_CREATE_REUSEPORT ;if (!IS_ERR (clp->cl_rpcclient))return 0 ;
@@ -670,6 +672,7 @@ static int nfs_init_server(struct nfs_server *server, .timeparms = &timeparms, .cred = server->cred, .nconnect = data->nfs_server.nconnect, + .init_flags = (1UL << NFS_CS_REUSEPORT), };struct nfs_client *clp;int error;
fs/nfs/nfs4client.c +4 -1
@@ -879,8 +879,11 @@ static int nfs4_set_client(struct nfs_server *server, };struct nfs_client *clp; -if (minorversion >0 && proto ==XPRT_TRANSPORT_TCP ) +if (minorversion ==0 ) +__set_bit (NFS_CS_REUSEPORT , &cl_init.init_flags); +else if (proto ==XPRT_TRANSPORT_TCP ) cl_init.nconnect = nconnect; +if (server->flags &NFS_MOUNT_NORESVPORT )__set_bit (NFS_CS_NORESVPORT , &cl_init.init_flags);if (server->options &NFS_OPTION_MIGRATION )
include/linux/nfs_fs_sb.h +1 -0
@@ -47,6 +47,7 @@ struct nfs_client {#define NFS_CS_TSM_POSSIBLE 5/* - Maybe state migration */ #define NFS_CS_NOPING 6/* - don't ping on connect */ #define NFS_CS_DS 7/* - Server is a DS */ +#define NFS_CS_REUSEPORT 8/* - reuse src port on reconnect */ struct sockaddr_storage cl_addr;/* server identifier */ size_t cl_addrlen;char * cl_hostname;/* hostname of server */
include/linux/sunrpc/clnt.h +1 -0
@@ -149,6 +149,7 @@ struct rpc_add_xprt_test {#define RPC_CLNT_CREATE_NO_IDLE_TIMEOUT (1UL << 8)#define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9)#define RPC_CLNT_CREATE_SOFTERR (1UL << 10) +#define RPC_CLNT_CREATE_REUSEPORT (1UL << 11)struct rpc_clnt *rpc_create (struct rpc_create_args *args); struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
include/linux/sunrpc/xprt.h +2 -1
@@ -207,7 +207,8 @@ struct rpc_xprt {unsigned int min_reqs;/* min number of slots */ unsigned int num_reqs;/* total slots */ unsigned long state;/* transport state */ - unsigned char resvport : 1; /* use a reserved port */ + unsigned char resvport : 1, /* use a reserved port */ + reuseport : 1; /* reuse port on reconnect */atomic_t swapper;/* we're swapping over this transport */ unsigned int bind_index;/* bind function index */
net/sunrpc/clnt.c +6 -1
@@ -591,6 +591,9 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) xprt->resvport =1 ;if (args->flags &RPC_CLNT_CREATE_NONPRIVPORT ) xprt->resvport =0 ; + xprt->reuseport =0 ; +if (args->flags &RPC_CLNT_CREATE_REUSEPORT ) + xprt->reuseport =1 ; clnt =rpc_create_xprt (args, xprt);if (IS_ERR (clnt) || args->nconnect <=1 )
@@ -2906,7 +2909,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,struct rpc_xprt *xprt;unsigned long connect_timeout;unsigned long reconnect_timeout; -unsigned char resvport; +unsigned char resvport, reuseport;int ret =0 ;rcu_read_lock ();
@@ -2918,6 +2921,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,return -EAGAIN ; } resvport = xprt->resvport; + reuseport = xprt->reuseport; connect_timeout = xprt->connect_timeout; reconnect_timeout = xprt->max_reconnect_timeout;rcu_read_unlock ();
@@ -2928,6 +2932,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, goto out_put_switch; } xprt->resvport = resvport; + xprt->reuseport = reuseport;if (xprt->ops->set_connect_timeout !=NULL ) xprt->ops->set_connect_timeout(xprt, connect_timeout,
net/sunrpc/xprtsock.c +1 -1
@@ -1752,7 +1752,7 @@ static void xs_set_port(struct rpc_xprt *xprt, unsigned short port)static void xs_set_srcport (struct sock_xprt *transport,struct socket *sock) { -if (transport->srcport ==0 ) +if (transport->srcport ==0 && transport->xprt.reuseport) transport->srcport =xs_sock_getport (sock); }
Signature · 1 line
2.21.0