diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-03-02 13:59:49 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-03-02 13:59:49 -0500 |
commit | 0d71b058092fc98cfef8e8f6d913180a10a55397 (patch) | |
tree | 54dd66684853a75b86a19ad3eb9fa4c124468a08 /fs/nfs/super.c | |
parent | 7d2ed9ac22bc6bf0d34e8fd291a5295f373b384e (diff) |
NFS: Extend the -overs= mount option to allow 4.x minorversions
Allow the user to mount an NFSv4.0 or NFSv4.1 partition using a
standard syntax of '-overs=4.0', or '-overs=4.1' rather than the
more cumbersome '-overs=4,minorversion=1'.
See also the earlier patch by Dros Adamson, which added the
Linux-specific syntax '-ov4.0', '-ov4.1'.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r-- | fs/nfs/super.c | 84 |
1 files changed, 62 insertions, 22 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 8154accd1168..ab58bb9b6115 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -98,10 +98,10 @@ enum { | |||
98 | Opt_namelen, | 98 | Opt_namelen, |
99 | Opt_mountport, | 99 | Opt_mountport, |
100 | Opt_mountvers, | 100 | Opt_mountvers, |
101 | Opt_nfsvers, | ||
102 | Opt_minorversion, | 101 | Opt_minorversion, |
103 | 102 | ||
104 | /* Mount options that take string arguments */ | 103 | /* Mount options that take string arguments */ |
104 | Opt_nfsvers, | ||
105 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, | 105 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, |
106 | Opt_addr, Opt_mountaddr, Opt_clientaddr, | 106 | Opt_addr, Opt_mountaddr, Opt_clientaddr, |
107 | Opt_lookupcache, | 107 | Opt_lookupcache, |
@@ -166,9 +166,10 @@ static const match_table_t nfs_mount_option_tokens = { | |||
166 | { Opt_namelen, "namlen=%s" }, | 166 | { Opt_namelen, "namlen=%s" }, |
167 | { Opt_mountport, "mountport=%s" }, | 167 | { Opt_mountport, "mountport=%s" }, |
168 | { Opt_mountvers, "mountvers=%s" }, | 168 | { Opt_mountvers, "mountvers=%s" }, |
169 | { Opt_minorversion, "minorversion=%s" }, | ||
170 | |||
169 | { Opt_nfsvers, "nfsvers=%s" }, | 171 | { Opt_nfsvers, "nfsvers=%s" }, |
170 | { Opt_nfsvers, "vers=%s" }, | 172 | { Opt_nfsvers, "vers=%s" }, |
171 | { Opt_minorversion, "minorversion=%s" }, | ||
172 | 173 | ||
173 | { Opt_sec, "sec=%s" }, | 174 | { Opt_sec, "sec=%s" }, |
174 | { Opt_proto, "proto=%s" }, | 175 | { Opt_proto, "proto=%s" }, |
@@ -262,6 +263,22 @@ static match_table_t nfs_local_lock_tokens = { | |||
262 | { Opt_local_lock_err, NULL } | 263 | { Opt_local_lock_err, NULL } |
263 | }; | 264 | }; |
264 | 265 | ||
266 | enum { | ||
267 | Opt_vers_2, Opt_vers_3, Opt_vers_4, Opt_vers_4_0, | ||
268 | Opt_vers_4_1, | ||
269 | |||
270 | Opt_vers_err | ||
271 | }; | ||
272 | |||
273 | static match_table_t nfs_vers_tokens = { | ||
274 | { Opt_vers_2, "2" }, | ||
275 | { Opt_vers_3, "3" }, | ||
276 | { Opt_vers_4, "4" }, | ||
277 | { Opt_vers_4_0, "4.0" }, | ||
278 | { Opt_vers_4_1, "4.1" }, | ||
279 | |||
280 | { Opt_vers_err, NULL } | ||
281 | }; | ||
265 | 282 | ||
266 | static void nfs_umount_begin(struct super_block *); | 283 | static void nfs_umount_begin(struct super_block *); |
267 | static int nfs_statfs(struct dentry *, struct kstatfs *); | 284 | static int nfs_statfs(struct dentry *, struct kstatfs *); |
@@ -1064,6 +1081,40 @@ static int nfs_parse_security_flavors(char *value, | |||
1064 | return 1; | 1081 | return 1; |
1065 | } | 1082 | } |
1066 | 1083 | ||
1084 | static int nfs_parse_version_string(char *string, | ||
1085 | struct nfs_parsed_mount_data *mnt, | ||
1086 | substring_t *args) | ||
1087 | { | ||
1088 | mnt->flags &= ~NFS_MOUNT_VER3; | ||
1089 | switch (match_token(string, nfs_vers_tokens, args)) { | ||
1090 | case Opt_vers_2: | ||
1091 | mnt->version = 2; | ||
1092 | break; | ||
1093 | case Opt_vers_3: | ||
1094 | mnt->flags |= NFS_MOUNT_VER3; | ||
1095 | mnt->version = 3; | ||
1096 | break; | ||
1097 | case Opt_vers_4: | ||
1098 | /* Backward compatibility option. In future, | ||
1099 | * the mount program should always supply | ||
1100 | * a NFSv4 minor version number. | ||
1101 | */ | ||
1102 | mnt->version = 4; | ||
1103 | break; | ||
1104 | case Opt_vers_4_0: | ||
1105 | mnt->version = 4; | ||
1106 | mnt->minorversion = 0; | ||
1107 | break; | ||
1108 | case Opt_vers_4_1: | ||
1109 | mnt->version = 4; | ||
1110 | mnt->minorversion = 1; | ||
1111 | break; | ||
1112 | default: | ||
1113 | return 0; | ||
1114 | } | ||
1115 | return 1; | ||
1116 | } | ||
1117 | |||
1067 | static int nfs_get_option_str(substring_t args[], char **option) | 1118 | static int nfs_get_option_str(substring_t args[], char **option) |
1068 | { | 1119 | { |
1069 | kfree(*option); | 1120 | kfree(*option); |
@@ -1317,26 +1368,6 @@ static int nfs_parse_mount_options(char *raw, | |||
1317 | goto out_invalid_value; | 1368 | goto out_invalid_value; |
1318 | mnt->mount_server.version = option; | 1369 | mnt->mount_server.version = option; |
1319 | break; | 1370 | break; |
1320 | case Opt_nfsvers: | ||
1321 | if (nfs_get_option_ul(args, &option)) | ||
1322 | goto out_invalid_value; | ||
1323 | switch (option) { | ||
1324 | case NFS2_VERSION: | ||
1325 | mnt->flags &= ~NFS_MOUNT_VER3; | ||
1326 | mnt->version = 2; | ||
1327 | break; | ||
1328 | case NFS3_VERSION: | ||
1329 | mnt->flags |= NFS_MOUNT_VER3; | ||
1330 | mnt->version = 3; | ||
1331 | break; | ||
1332 | case NFS4_VERSION: | ||
1333 | mnt->flags &= ~NFS_MOUNT_VER3; | ||
1334 | mnt->version = 4; | ||
1335 | break; | ||
1336 | default: | ||
1337 | goto out_invalid_value; | ||
1338 | } | ||
1339 | break; | ||
1340 | case Opt_minorversion: | 1371 | case Opt_minorversion: |
1341 | if (nfs_get_option_ul(args, &option)) | 1372 | if (nfs_get_option_ul(args, &option)) |
1342 | goto out_invalid_value; | 1373 | goto out_invalid_value; |
@@ -1348,6 +1379,15 @@ static int nfs_parse_mount_options(char *raw, | |||
1348 | /* | 1379 | /* |
1349 | * options that take text values | 1380 | * options that take text values |
1350 | */ | 1381 | */ |
1382 | case Opt_nfsvers: | ||
1383 | string = match_strdup(args); | ||
1384 | if (string == NULL) | ||
1385 | goto out_nomem; | ||
1386 | rc = nfs_parse_version_string(string, mnt, args); | ||
1387 | kfree(string); | ||
1388 | if (!rc) | ||
1389 | goto out_invalid_value; | ||
1390 | break; | ||
1351 | case Opt_sec: | 1391 | case Opt_sec: |
1352 | string = match_strdup(args); | 1392 | string = match_strdup(args); |
1353 | if (string == NULL) | 1393 | if (string == NULL) |