mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 09:31:50 +00:00
NFS: make NFS client allocated per network namespace context
This patch adds new net variable to nfs_client structure. This variable is set on NFS client creation and cheched during matching NFS client search. Initially current->nsproxy->net_ns is used as network namespace owner for new NFS client to create. This network namespace pointer is set during mount options parsing and thus can be passed from user-spave utils in future if will be necessary. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
ad6b134008
commit
e50a7a1a42
@ -135,6 +135,7 @@ struct nfs_client_initdata {
|
|||||||
const struct nfs_rpc_ops *rpc_ops;
|
const struct nfs_rpc_ops *rpc_ops;
|
||||||
int proto;
|
int proto;
|
||||||
u32 minorversion;
|
u32 minorversion;
|
||||||
|
struct net *net;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -189,6 +190,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
|
|||||||
if (!IS_ERR(cred))
|
if (!IS_ERR(cred))
|
||||||
clp->cl_machine_cred = cred;
|
clp->cl_machine_cred = cred;
|
||||||
nfs_fscache_get_client_cookie(clp);
|
nfs_fscache_get_client_cookie(clp);
|
||||||
|
clp->net = cl_init->net;
|
||||||
|
|
||||||
return clp;
|
return clp;
|
||||||
|
|
||||||
@ -481,6 +483,9 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
|
|||||||
/* Match the full socket address */
|
/* Match the full socket address */
|
||||||
if (!nfs_sockaddr_cmp(sap, clap))
|
if (!nfs_sockaddr_cmp(sap, clap))
|
||||||
continue;
|
continue;
|
||||||
|
/* Match network namespace */
|
||||||
|
if (clp->net != data->net)
|
||||||
|
continue;
|
||||||
|
|
||||||
atomic_inc(&clp->cl_count);
|
atomic_inc(&clp->cl_count);
|
||||||
return clp;
|
return clp;
|
||||||
@ -831,6 +836,7 @@ static int nfs_init_server(struct nfs_server *server,
|
|||||||
.addrlen = data->nfs_server.addrlen,
|
.addrlen = data->nfs_server.addrlen,
|
||||||
.rpc_ops = &nfs_v2_clientops,
|
.rpc_ops = &nfs_v2_clientops,
|
||||||
.proto = data->nfs_server.protocol,
|
.proto = data->nfs_server.protocol,
|
||||||
|
.net = data->net,
|
||||||
};
|
};
|
||||||
struct rpc_timeout timeparms;
|
struct rpc_timeout timeparms;
|
||||||
struct nfs_client *clp;
|
struct nfs_client *clp;
|
||||||
@ -1393,7 +1399,7 @@ static int nfs4_set_client(struct nfs_server *server,
|
|||||||
const char *ip_addr,
|
const char *ip_addr,
|
||||||
rpc_authflavor_t authflavour,
|
rpc_authflavor_t authflavour,
|
||||||
int proto, const struct rpc_timeout *timeparms,
|
int proto, const struct rpc_timeout *timeparms,
|
||||||
u32 minorversion)
|
u32 minorversion, struct net *net)
|
||||||
{
|
{
|
||||||
struct nfs_client_initdata cl_init = {
|
struct nfs_client_initdata cl_init = {
|
||||||
.hostname = hostname,
|
.hostname = hostname,
|
||||||
@ -1402,6 +1408,7 @@ static int nfs4_set_client(struct nfs_server *server,
|
|||||||
.rpc_ops = &nfs_v4_clientops,
|
.rpc_ops = &nfs_v4_clientops,
|
||||||
.proto = proto,
|
.proto = proto,
|
||||||
.minorversion = minorversion,
|
.minorversion = minorversion,
|
||||||
|
.net = net,
|
||||||
};
|
};
|
||||||
struct nfs_client *clp;
|
struct nfs_client *clp;
|
||||||
int error;
|
int error;
|
||||||
@ -1453,6 +1460,7 @@ struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp,
|
|||||||
.rpc_ops = &nfs_v4_clientops,
|
.rpc_ops = &nfs_v4_clientops,
|
||||||
.proto = ds_proto,
|
.proto = ds_proto,
|
||||||
.minorversion = mds_clp->cl_minorversion,
|
.minorversion = mds_clp->cl_minorversion,
|
||||||
|
.net = mds_clp->net,
|
||||||
};
|
};
|
||||||
struct rpc_timeout ds_timeout = {
|
struct rpc_timeout ds_timeout = {
|
||||||
.to_initval = 15 * HZ,
|
.to_initval = 15 * HZ,
|
||||||
@ -1580,7 +1588,8 @@ static int nfs4_init_server(struct nfs_server *server,
|
|||||||
data->auth_flavors[0],
|
data->auth_flavors[0],
|
||||||
data->nfs_server.protocol,
|
data->nfs_server.protocol,
|
||||||
&timeparms,
|
&timeparms,
|
||||||
data->minorversion);
|
data->minorversion,
|
||||||
|
data->net);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -1677,7 +1686,8 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
|
|||||||
data->authflavor,
|
data->authflavor,
|
||||||
parent_server->client->cl_xprt->prot,
|
parent_server->client->cl_xprt->prot,
|
||||||
parent_server->client->cl_timeout,
|
parent_server->client->cl_timeout,
|
||||||
parent_client->cl_mvops->minor_version);
|
parent_client->cl_mvops->minor_version,
|
||||||
|
parent_client->net);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ struct nfs_parsed_mount_data {
|
|||||||
} nfs_server;
|
} nfs_server;
|
||||||
|
|
||||||
struct security_mnt_opts lsm_opts;
|
struct security_mnt_opts lsm_opts;
|
||||||
|
struct net *net;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* mount_clnt.c */
|
/* mount_clnt.c */
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#include <linux/nfs_xdr.h>
|
#include <linux/nfs_xdr.h>
|
||||||
#include <linux/magic.h>
|
#include <linux/magic.h>
|
||||||
#include <linux/parser.h>
|
#include <linux/parser.h>
|
||||||
|
#include <linux/nsproxy.h>
|
||||||
|
|
||||||
#include <asm/system.h>
|
#include <asm/system.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
@ -1107,6 +1108,8 @@ static int nfs_parse_mount_options(char *raw,
|
|||||||
|
|
||||||
free_secdata(secdata);
|
free_secdata(secdata);
|
||||||
|
|
||||||
|
mnt->net = current->nsproxy->net_ns;
|
||||||
|
|
||||||
while ((p = strsep(&raw, ",")) != NULL) {
|
while ((p = strsep(&raw, ",")) != NULL) {
|
||||||
substring_t args[MAX_OPT_ARGS];
|
substring_t args[MAX_OPT_ARGS];
|
||||||
unsigned long option;
|
unsigned long option;
|
||||||
|
@ -85,6 +85,7 @@ struct nfs_client {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct server_scope *server_scope; /* from exchange_id */
|
struct server_scope *server_scope; /* from exchange_id */
|
||||||
|
struct net *net;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user