@@ -297,6 +297,10 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
if (clp->cl_cons_state < 0)
continue;
+ /* Don't match clients that don't want to be shared */
+ if (test_bit(NFS_CS_UNSHARED, &clp->cl_flags))
+ continue;
+
/* Different NFS versions cannot share the same nfs_client */
if (clp->rpc_ops != data->nfs_mod->rpc_ops)
continue;
@@ -386,7 +390,7 @@ nfs_found_client(const struct nfs_client_initdata *cl_init,
*/
struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init)
{
- struct nfs_client *clp, *new = NULL;
+ struct nfs_client *clp = NULL, *new = NULL;
struct nfs_net *nn = net_generic(cl_init->net, nfs_net_id);
const struct nfs_rpc_ops *rpc_ops = cl_init->nfs_mod->rpc_ops;
@@ -399,7 +403,8 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init)
do {
spin_lock(&nn->nfs_client_lock);
- clp = nfs_match_client(cl_init);
+ if (!test_bit(NFS_CS_UNSHARED, &cl_init->init_flags))
+ clp = nfs_match_client(cl_init);
if (clp) {
spin_unlock(&nn->nfs_client_lock);
if (new)
@@ -102,6 +102,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);
+ if (mds_srv->flags & NFS_MOUNT_UNSHARED)
+ __set_bit(NFS_CS_UNSHARED, &cl_init.init_flags);
/* Use the MDS nfs_client cl_ipaddr. */
nfs_init_timeout_values(&ds_timeout, ds_proto, ds_timeo, ds_retrans);
@@ -852,6 +852,8 @@ static int nfs4_set_client(struct nfs_server *server,
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);
+ if (server->flags & NFS_MOUNT_UNSHARED)
+ __set_bit(NFS_CS_UNSHARED, &cl_init.init_flags);
/* Allocate or find a client reference we can use */
clp = nfs_get_client(&cl_init);
@@ -910,6 +912,8 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_server *mds_srv,
if (mds_srv->flags & NFS_MOUNT_NORESVPORT)
__set_bit(NFS_CS_NORESVPORT, &cl_init.init_flags);
+ if (mds_srv->flags & NFS_MOUNT_UNSHARED)
+ __set_bit(NFS_CS_UNSHARED, &cl_init.init_flags);
/*
* Set an authflavor equual to the MDS value. Use the MDS nfs_client
@@ -44,6 +44,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_UNSHARED 6 /* - Client state is not shared */
struct sockaddr_storage cl_addr; /* server identifier */
size_t cl_addrlen;
char * cl_hostname; /* hostname of server */
Propagating the flag allows operations to be performed on the client without affecting other mounts to the same client, much like operations on the superblock will not affect other superblocks. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> --- fs/nfs/client.c | 9 +++++++-- fs/nfs/nfs3client.c | 2 ++ fs/nfs/nfs4client.c | 4 ++++ include/linux/nfs_fs_sb.h | 1 + 4 files changed, 14 insertions(+), 2 deletions(-)