1 From e85103e27b7591337d3240cf0ab2670d0ab73d52 Mon Sep 17 00:00:00 2001
2 From: Jason Wessel <jason.wessel@windriver.com>
3 Date: Wed, 7 Jan 2009 00:59:33 -0500
4 Subject: [PATCH] NFS: allow nfs root mount to use alternate rpc ports
6 Allow an nfs root mount to use alternate RPC ports for mountd and nfsd.
8 Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
9 [forward port to 2.6.33+]
10 Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
12 fs/nfs/client.c | 10 ++++++++++
13 fs/nfs/internal.h | 4 +++-
14 fs/nfs/mount_clnt.c | 3 ++-
15 fs/nfs/super.c | 33 ++++++++++++++++++++++++++++++++-
16 include/linux/nfs_fs_sb.h | 1 +
17 include/linux/nfs_mount.h | 4 +++-
18 6 files changed, 51 insertions(+), 4 deletions(-)
20 diff --git a/fs/nfs/client.c b/fs/nfs/client.c
21 index d25b525..b706c02 100644
24 @@ -105,6 +105,7 @@ struct nfs_client_initdata {
25 const struct nfs_rpc_ops *rpc_ops;
32 @@ -123,6 +124,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
35 clp->rpc_ops = cl_init->rpc_ops;
36 + clp->nfs_prog = cl_init->nfs_prog;
38 atomic_set(&clp->cl_count, 1);
39 clp->cl_cons_state = NFS_CS_INITING;
40 @@ -448,6 +450,9 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
41 /* Match nfsv4 minorversion */
42 if (clp->cl_minorversion != data->minorversion)
44 + if (clp->nfs_prog != data->nfs_prog)
47 /* Match the full socket address */
48 if (!nfs_sockaddr_cmp(sap, clap))
50 @@ -618,6 +623,10 @@ static int nfs_create_rpc_client(struct nfs_client *clp,
51 if (!IS_ERR(clp->cl_rpcclient))
55 + nfs_program.number = clp->nfs_prog;
57 + nfs_program.number = NFS_PROGRAM;
58 clnt = rpc_create(&args);
60 dprintk("%s: cannot create RPC client. Error = %ld\n",
61 @@ -786,6 +795,7 @@ static int nfs_init_server(struct nfs_server *server,
62 .addrlen = data->nfs_server.addrlen,
63 .rpc_ops = &nfs_v2_clientops,
64 .proto = data->nfs_server.protocol,
65 + .nfs_prog = data->nfs_prog,
67 struct rpc_timeout timeparms;
68 struct nfs_client *clp;
69 diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
70 index e70f44b..3e2649f 100644
71 --- a/fs/nfs/internal.h
72 +++ b/fs/nfs/internal.h
73 @@ -71,6 +71,8 @@ struct nfs_parsed_mount_data {
75 int acregmin, acregmax,
82 @@ -116,7 +118,7 @@ struct nfs_mount_request {
83 rpc_authflavor_t *auth_flavs;
86 -extern int nfs_mount(struct nfs_mount_request *info);
87 +extern int nfs_mount(struct nfs_mount_request *info, int prog);
88 extern void nfs_umount(const struct nfs_mount_request *info);
91 diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
92 index 59047f8..0a2bd63 100644
93 --- a/fs/nfs/mount_clnt.c
94 +++ b/fs/nfs/mount_clnt.c
95 @@ -141,7 +141,7 @@ struct mnt_fhstatus {
97 * Uses default timeout parameters specified by underlying transport.
99 -int nfs_mount(struct nfs_mount_request *info)
100 +int nfs_mount(struct nfs_mount_request *info, int m_prog)
102 struct mountres result = {
104 @@ -171,6 +171,7 @@ int nfs_mount(struct nfs_mount_request *info)
105 if (info->noresvport)
106 args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
108 + mnt_program.number = m_prog;
109 mnt_clnt = rpc_create(&args);
110 if (IS_ERR(mnt_clnt))
112 diff --git a/fs/nfs/super.c b/fs/nfs/super.c
113 index f9df16d..0b3bbf8 100644
116 @@ -94,6 +94,8 @@ enum {
123 /* Mount options that take string arguments */
124 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
125 @@ -160,6 +162,8 @@ static const match_table_t nfs_mount_option_tokens = {
126 { Opt_nfsvers, "nfsvers=%s" },
127 { Opt_nfsvers, "vers=%s" },
128 { Opt_minorversion, "minorversion=%s" },
129 + { Opt_mountprog, "mountprog=%s" },
130 + { Opt_nfsprog, "nfsprog=%s" },
132 { Opt_sec, "sec=%s" },
133 { Opt_proto, "proto=%s" },
134 @@ -787,6 +791,8 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int ve
135 data->acregmax = NFS_DEF_ACREGMAX;
136 data->acdirmin = NFS_DEF_ACDIRMIN;
137 data->acdirmax = NFS_DEF_ACDIRMAX;
138 + data->nfs_prog = NFS_PROGRAM;
139 + data->mount_prog = NFS_MNT_PROGRAM;
140 data->mount_server.port = NFS_UNSPEC_PORT;
141 data->nfs_server.port = NFS_UNSPEC_PORT;
142 data->nfs_server.protocol = XPRT_TRANSPORT_TCP;
143 @@ -1168,6 +1174,26 @@ static int nfs_parse_mount_options(char *raw,
144 goto out_invalid_value;
145 mnt->acdirmax = option;
147 + case Opt_mountprog:
148 + string = match_strdup(args);
149 + if (string == NULL)
151 + rc = strict_strtoul(string, 10, &option);
154 + goto out_invalid_value;
155 + mnt->mount_prog = option;
158 + string = match_strdup(args);
159 + if (string == NULL)
161 + rc = strict_strtoul(string, 10, &option);
164 + goto out_invalid_value;
165 + mnt->nfs_prog = option;
168 string = match_strdup(args);
170 @@ -1566,7 +1592,7 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args,
171 * Now ask the mount server to map our export path
174 - status = nfs_mount(&request);
175 + status = nfs_mount(&request,args->mount_prog);
177 dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n",
178 request.hostname, status);
179 @@ -1739,6 +1765,7 @@ static int nfs_validate_mount_data(void *options,
181 struct nfs_mount_data *data = (struct nfs_mount_data *)options;
182 struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address;
183 + args->nfs_prog = NFS_PROGRAM;
187 @@ -1758,6 +1785,8 @@ static int nfs_validate_mount_data(void *options,
190 memset(data->context, 0, sizeof(data->context));
192 + args->nfs_prog = (data->version >= 7) ? data->nfs_prog : NFS_PROGRAM;
194 if (data->flags & NFS_MOUNT_VER3) {
195 if (data->root.size > NFS3_FHSIZE || data->root.size == 0)
196 @@ -2476,6 +2505,8 @@ static int nfs4_validate_mount_data(void *options,
200 + args->nfs_prog = NFS_PROGRAM;
202 switch (data->version) {
204 if (data->host_addrlen > sizeof(args->nfs_server.address))
205 diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
206 index d6e10a4..585cba4 100644
207 --- a/include/linux/nfs_fs_sb.h
208 +++ b/include/linux/nfs_fs_sb.h
209 @@ -41,6 +41,7 @@ struct nfs_client {
211 u32 cl_minorversion;/* NFSv4 minorversion */
212 struct rpc_cred *cl_machine_cred;
216 u64 cl_clientid; /* constant */
217 diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
218 index 4499016..86beb0c 100644
219 --- a/include/linux/nfs_mount.h
220 +++ b/include/linux/nfs_mount.h
222 * mount-to-kernel version compatibility. Some of these aren't used yet
223 * but here they are anyway.
225 -#define NFS_MOUNT_VERSION 6
226 +#define NFS_MOUNT_VERSION 7
227 #define NFS_MAX_CONTEXT_LEN 256
229 struct nfs_mount_data {
230 @@ -43,6 +43,8 @@ struct nfs_mount_data {
231 struct nfs3_fh root; /* 4 */
232 int pseudoflavor; /* 5 */
233 char context[NFS_MAX_CONTEXT_LEN + 1]; /* 6 */
234 + int nfs_prog; /* 7 */
235 + int mount_prog; /* 7 */
238 /* bits in the flags field visible to user space */