提交 8fa5c000 编写于 作者: D David Howells 提交者: Trond Myklebust

NFS: Move rpc_ops from nfs_server to nfs_client

Move the rpc_ops from the nfs_server struct to the nfs_client struct as they're
common to all server records of a particular NFS protocol version.
Signed-Off-By: NDavid Howells <dhowells@redhat.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 1f163415
...@@ -1147,7 +1147,7 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle, ...@@ -1147,7 +1147,7 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
} }
if (!(fattr->valid & NFS_ATTR_FATTR)) { if (!(fattr->valid & NFS_ATTR_FATTR)) {
struct nfs_server *server = NFS_SB(dentry->d_sb); struct nfs_server *server = NFS_SB(dentry->d_sb);
error = server->rpc_ops->getattr(server, fhandle, fattr); error = server->nfs_client->rpc_ops->getattr(server, fhandle, fattr);
if (error < 0) if (error < 0)
goto out_err; goto out_err;
} }
......
...@@ -237,13 +237,13 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) ...@@ -237,13 +237,13 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
/* Why so? Because we want revalidate for devices/FIFOs, and /* Why so? Because we want revalidate for devices/FIFOs, and
* that's precisely what we have in nfs_file_inode_operations. * that's precisely what we have in nfs_file_inode_operations.
*/ */
inode->i_op = NFS_SB(sb)->rpc_ops->file_inode_ops; inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->file_inode_ops;
if (S_ISREG(inode->i_mode)) { if (S_ISREG(inode->i_mode)) {
inode->i_fop = &nfs_file_operations; inode->i_fop = &nfs_file_operations;
inode->i_data.a_ops = &nfs_file_aops; inode->i_data.a_ops = &nfs_file_aops;
inode->i_data.backing_dev_info = &NFS_SB(sb)->backing_dev_info; inode->i_data.backing_dev_info = &NFS_SB(sb)->backing_dev_info;
} else if (S_ISDIR(inode->i_mode)) { } else if (S_ISDIR(inode->i_mode)) {
inode->i_op = NFS_SB(sb)->rpc_ops->dir_inode_ops; inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->dir_inode_ops;
inode->i_fop = &nfs_dir_operations; inode->i_fop = &nfs_dir_operations;
if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS)
&& fattr->size <= NFS_LIMIT_READDIRPLUS) && fattr->size <= NFS_LIMIT_READDIRPLUS)
......
...@@ -104,7 +104,9 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) ...@@ -104,7 +104,9 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
goto out_follow; goto out_follow;
/* Look it up again */ /* Look it up again */
parent = dget_parent(nd->dentry); parent = dget_parent(nd->dentry);
err = server->rpc_ops->lookup(parent->d_inode, &nd->dentry->d_name, &fh, &fattr); err = server->nfs_client->rpc_ops->lookup(parent->d_inode,
&nd->dentry->d_name,
&fh, &fattr);
dput(parent); dput(parent);
if (err != 0) if (err != 0)
goto out_err; goto out_err;
...@@ -178,7 +180,7 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server, ...@@ -178,7 +180,7 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
{ {
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
struct vfsmount *mnt = NULL; struct vfsmount *mnt = NULL;
switch (server->rpc_ops->version) { switch (server->nfs_client->cl_nfsversion) {
case 2: case 2:
case 3: case 3:
mnt = vfs_kern_mount(&clone_nfs_fs_type, 0, devname, mountdata); mnt = vfs_kern_mount(&clone_nfs_fs_type, 0, devname, mountdata);
......
...@@ -758,7 +758,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) ...@@ -758,7 +758,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
} }
nfs_confirm_seqid(&data->owner->so_seqid, 0); nfs_confirm_seqid(&data->owner->so_seqid, 0);
if (!(o_res->f_attr->valid & NFS_ATTR_FATTR)) if (!(o_res->f_attr->valid & NFS_ATTR_FATTR))
return server->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr); return server->nfs_client->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr);
return 0; return 0;
} }
......
...@@ -252,7 +252,7 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -252,7 +252,7 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
lock_kernel(); lock_kernel();
error = server->rpc_ops->statfs(server, fh, &res); error = server->nfs_client->rpc_ops->statfs(server, fh, &res);
buf->f_type = NFS_SUPER_MAGIC; buf->f_type = NFS_SUPER_MAGIC;
if (error < 0) if (error < 0)
goto out_err; goto out_err;
...@@ -343,10 +343,11 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, ...@@ -343,10 +343,11 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
{ 0, NULL, NULL } { 0, NULL, NULL }
}; };
const struct proc_nfs_info *nfs_infop; const struct proc_nfs_info *nfs_infop;
struct nfs_client *clp = nfss->nfs_client;
char buf[12]; char buf[12];
const char *proto; const char *proto;
seq_printf(m, ",vers=%d", nfss->rpc_ops->version); seq_printf(m, ",vers=%d", clp->rpc_ops->version);
seq_printf(m, ",rsize=%d", nfss->rsize); seq_printf(m, ",rsize=%d", nfss->rsize);
seq_printf(m, ",wsize=%d", nfss->wsize); seq_printf(m, ",wsize=%d", nfss->wsize);
if (nfss->acregmin != 3*HZ || showdefaults) if (nfss->acregmin != 3*HZ || showdefaults)
...@@ -427,7 +428,7 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt) ...@@ -427,7 +428,7 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
seq_printf(m, ",namelen=%d", nfss->namelen); seq_printf(m, ",namelen=%d", nfss->namelen);
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
if (nfss->rpc_ops->version == 4) { if (nfss->nfs_client->cl_nfsversion == 4) {
seq_printf(m, "\n\tnfsv4:\t"); seq_printf(m, "\n\tnfsv4:\t");
seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]); seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]);
seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]); seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]);
...@@ -503,7 +504,7 @@ nfs_get_root(struct super_block *sb, struct nfs_fh *rootfh, struct nfs_fsinfo *f ...@@ -503,7 +504,7 @@ nfs_get_root(struct super_block *sb, struct nfs_fh *rootfh, struct nfs_fsinfo *f
struct nfs_server *server = NFS_SB(sb); struct nfs_server *server = NFS_SB(sb);
int error; int error;
error = server->rpc_ops->getroot(server, rootfh, fsinfo); error = server->nfs_client->rpc_ops->getroot(server, rootfh, fsinfo);
if (error < 0) { if (error < 0) {
dprintk("nfs_get_root: getattr error = %d\n", -error); dprintk("nfs_get_root: getattr error = %d\n", -error);
return ERR_PTR(error); return ERR_PTR(error);
...@@ -553,14 +554,14 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor) ...@@ -553,14 +554,14 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor)
no_root_error = -ENOMEM; no_root_error = -ENOMEM;
goto out_no_root; goto out_no_root;
} }
sb->s_root->d_op = server->rpc_ops->dentry_ops; sb->s_root->d_op = server->nfs_client->rpc_ops->dentry_ops;
/* mount time stamp, in seconds */ /* mount time stamp, in seconds */
server->mount_time = jiffies; server->mount_time = jiffies;
/* Get some general file system info */ /* Get some general file system info */
if (server->namelen == 0 && if (server->namelen == 0 &&
server->rpc_ops->pathconf(server, &server->fh, &pathinfo) >= 0) server->nfs_client->rpc_ops->pathconf(server, &server->fh, &pathinfo) >= 0)
server->namelen = pathinfo.max_namelen; server->namelen = pathinfo.max_namelen;
/* Work out a lot of parameters */ /* Work out a lot of parameters */
if (server->rsize == 0) if (server->rsize == 0)
...@@ -663,9 +664,14 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data) ...@@ -663,9 +664,14 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data)
struct rpc_xprt *xprt = NULL; struct rpc_xprt *xprt = NULL;
struct rpc_clnt *clnt = NULL; struct rpc_clnt *clnt = NULL;
int proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP; int proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP;
int nfsversion = 2;
clp = nfs_get_client(server->hostname, &server->addr, #ifdef CONFIG_NFS_V3
server->rpc_ops->version); if (server->flags & NFS_MOUNT_VER3)
nfsversion = 3;
#endif
clp = nfs_get_client(server->hostname, &server->addr, nfsversion);
if (!clp) { if (!clp) {
dprintk("%s: failed to create NFS4 client.\n", __FUNCTION__); dprintk("%s: failed to create NFS4 client.\n", __FUNCTION__);
return ERR_PTR(PTR_ERR(clp)); return ERR_PTR(PTR_ERR(clp));
...@@ -676,6 +682,19 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data) ...@@ -676,6 +682,19 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data)
server->retrans_timeo = timeparms.to_initval; server->retrans_timeo = timeparms.to_initval;
server->retrans_count = timeparms.to_retries; server->retrans_count = timeparms.to_retries;
/* Check NFS protocol revision and initialize RPC op vector
* and file handle pool. */
#ifdef CONFIG_NFS_V3
if (nfsversion == 3) {
clp->rpc_ops = &nfs_v3_clientops;
server->caps |= NFS_CAP_READDIRPLUS;
} else {
clp->rpc_ops = &nfs_v2_clientops;
}
#else
clp->rpc_ops = &nfs_v2_clientops;
#endif
/* create transport and client */ /* create transport and client */
xprt = xprt_create_proto(proto, &server->addr, &timeparms); xprt = xprt_create_proto(proto, &server->addr, &timeparms);
if (IS_ERR(xprt)) { if (IS_ERR(xprt)) {
...@@ -686,7 +705,7 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data) ...@@ -686,7 +705,7 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data)
return (struct rpc_clnt *)xprt; return (struct rpc_clnt *)xprt;
} }
clnt = rpc_create_client(xprt, server->hostname, &nfs_program, clnt = rpc_create_client(xprt, server->hostname, &nfs_program,
server->rpc_ops->version, data->pseudoflavor); clp->cl_nfsversion, data->pseudoflavor);
if (IS_ERR(clnt)) { if (IS_ERR(clnt)) {
dprintk("%s: cannot create RPC client. Error = %ld\n", dprintk("%s: cannot create RPC client. Error = %ld\n",
__FUNCTION__, PTR_ERR(xprt)); __FUNCTION__, PTR_ERR(xprt));
...@@ -750,7 +769,7 @@ static struct nfs_server *nfs_clone_server(struct super_block *sb, struct nfs_cl ...@@ -750,7 +769,7 @@ static struct nfs_server *nfs_clone_server(struct super_block *sb, struct nfs_cl
fsinfo.fattr = data->fattr; fsinfo.fattr = data->fattr;
if (NFS_PROTO(root_inode)->fsinfo(server, data->fh, &fsinfo) == 0) if (NFS_PROTO(root_inode)->fsinfo(server, data->fh, &fsinfo) == 0)
nfs_super_set_maxbytes(sb, fsinfo.maxfilesize); nfs_super_set_maxbytes(sb, fsinfo.maxfilesize);
sb->s_root->d_op = server->rpc_ops->dentry_ops; sb->s_root->d_op = server->nfs_client->rpc_ops->dentry_ops;
sb->s_flags |= MS_ACTIVE; sb->s_flags |= MS_ACTIVE;
return server; return server;
out_put_root: out_put_root:
...@@ -865,19 +884,6 @@ nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent) ...@@ -865,19 +884,6 @@ nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent)
return -ENOMEM; return -ENOMEM;
strcpy(server->hostname, data->hostname); strcpy(server->hostname, data->hostname);
/* Check NFS protocol revision and initialize RPC op vector
* and file handle pool. */
#ifdef CONFIG_NFS_V3
if (server->flags & NFS_MOUNT_VER3) {
server->rpc_ops = &nfs_v3_clientops;
server->caps |= NFS_CAP_READDIRPLUS;
} else {
server->rpc_ops = &nfs_v2_clientops;
}
#else
server->rpc_ops = &nfs_v2_clientops;
#endif
/* Fill in pseudoflavor for mount version < 5 */ /* Fill in pseudoflavor for mount version < 5 */
if (!(data->flags & NFS_MOUNT_SECFLAVOUR)) if (!(data->flags & NFS_MOUNT_SECFLAVOUR))
data->pseudoflavor = RPC_AUTH_UNIX; data->pseudoflavor = RPC_AUTH_UNIX;
...@@ -888,6 +894,7 @@ nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent) ...@@ -888,6 +894,7 @@ nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent)
server->client = nfs_create_client(server, data); server->client = nfs_create_client(server, data);
if (IS_ERR(server->client)) if (IS_ERR(server->client))
return PTR_ERR(server->client); return PTR_ERR(server->client);
/* RFC 2623, sec 2.3.2 */ /* RFC 2623, sec 2.3.2 */
if (authflavor != RPC_AUTH_UNIX) { if (authflavor != RPC_AUTH_UNIX) {
struct rpc_auth *auth; struct rpc_auth *auth;
...@@ -1129,6 +1136,8 @@ static struct rpc_clnt *nfs4_create_client(struct nfs_server *server, ...@@ -1129,6 +1136,8 @@ static struct rpc_clnt *nfs4_create_client(struct nfs_server *server,
/* Now create transport and client */ /* Now create transport and client */
if (clp->cl_cons_state == NFS_CS_INITING) { if (clp->cl_cons_state == NFS_CS_INITING) {
clp->rpc_ops = &nfs_v4_clientops;
xprt = xprt_create_proto(proto, &server->addr, timeparms); xprt = xprt_create_proto(proto, &server->addr, timeparms);
if (IS_ERR(xprt)) { if (IS_ERR(xprt)) {
err = PTR_ERR(xprt); err = PTR_ERR(xprt);
...@@ -1139,7 +1148,7 @@ static struct rpc_clnt *nfs4_create_client(struct nfs_server *server, ...@@ -1139,7 +1148,7 @@ static struct rpc_clnt *nfs4_create_client(struct nfs_server *server,
/* Bind to a reserved port! */ /* Bind to a reserved port! */
xprt->resvport = 1; xprt->resvport = 1;
clnt = rpc_create_client(xprt, server->hostname, &nfs_program, clnt = rpc_create_client(xprt, server->hostname, &nfs_program,
server->rpc_ops->version, flavor); clp->cl_nfsversion, flavor);
if (IS_ERR(clnt)) { if (IS_ERR(clnt)) {
err = PTR_ERR(clnt); err = PTR_ERR(clnt);
dprintk("%s: cannot create RPC client. Error = %d\n", dprintk("%s: cannot create RPC client. Error = %d\n",
...@@ -1215,8 +1224,6 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data, ...@@ -1215,8 +1224,6 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data,
server->acdirmin = data->acdirmin*HZ; server->acdirmin = data->acdirmin*HZ;
server->acdirmax = data->acdirmax*HZ; server->acdirmax = data->acdirmax*HZ;
server->rpc_ops = &nfs_v4_clientops;
nfs_init_timeout_values(&timeparms, data->proto, data->timeo, data->retrans); nfs_init_timeout_values(&timeparms, data->proto, data->timeo, data->retrans);
server->retrans_timeo = timeparms.to_initval; server->retrans_timeo = timeparms.to_initval;
......
...@@ -215,7 +215,7 @@ static inline struct nfs_inode *NFS_I(struct inode *inode) ...@@ -215,7 +215,7 @@ static inline struct nfs_inode *NFS_I(struct inode *inode)
#define NFS_FH(inode) (&NFS_I(inode)->fh) #define NFS_FH(inode) (&NFS_I(inode)->fh)
#define NFS_SERVER(inode) (NFS_SB(inode->i_sb)) #define NFS_SERVER(inode) (NFS_SB(inode->i_sb))
#define NFS_CLIENT(inode) (NFS_SERVER(inode)->client) #define NFS_CLIENT(inode) (NFS_SERVER(inode)->client)
#define NFS_PROTO(inode) (NFS_SERVER(inode)->rpc_ops) #define NFS_PROTO(inode) (NFS_SERVER(inode)->nfs_client->rpc_ops)
#define NFS_ADDR(inode) (RPC_PEERADDR(NFS_CLIENT(inode))) #define NFS_ADDR(inode) (RPC_PEERADDR(NFS_CLIENT(inode)))
#define NFS_COOKIEVERF(inode) (NFS_I(inode)->cookieverf) #define NFS_COOKIEVERF(inode) (NFS_I(inode)->cookieverf)
#define NFS_READTIME(inode) (NFS_I(inode)->read_cache_jiffies) #define NFS_READTIME(inode) (NFS_I(inode)->read_cache_jiffies)
......
...@@ -25,6 +25,7 @@ struct nfs_client { ...@@ -25,6 +25,7 @@ struct nfs_client {
struct list_head cl_superblocks; /* List of nfs_server structs */ struct list_head cl_superblocks; /* List of nfs_server structs */
struct rpc_clnt * cl_rpcclient; struct rpc_clnt * cl_rpcclient;
const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
u64 cl_clientid; /* constant */ u64 cl_clientid; /* constant */
...@@ -74,7 +75,6 @@ struct nfs_server { ...@@ -74,7 +75,6 @@ struct nfs_server {
struct rpc_clnt * client; /* RPC client handle */ struct rpc_clnt * client; /* RPC client handle */
struct rpc_clnt * client_sys; /* 2nd handle for FSINFO */ struct rpc_clnt * client_sys; /* 2nd handle for FSINFO */
struct rpc_clnt * client_acl; /* ACL RPC client handle */ struct rpc_clnt * client_acl; /* ACL RPC client handle */
const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
struct nfs_iostats * io_stats; /* I/O statistics */ struct nfs_iostats * io_stats; /* I/O statistics */
struct backing_dev_info backing_dev_info; struct backing_dev_info backing_dev_info;
int flags; /* various flags */ int flags; /* various flags */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册