diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2008-03-14 14:10:22 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-03-19 18:00:19 -0400 |
commit | f22d6d79fe227245363a8849ea8c85fe6c6598c3 (patch) | |
tree | 5496ddd3e912a399e0be9a7116fc1a66d6c79a10 /fs/nfs | |
parent | 78fa701f341564e60461de91cd08ff5f7fb09b31 (diff) |
NFS: Save the value of the "port=" mount option
During a remount based on the mount options displayed in /proc/mounts, we
want to preserve the original behavior of the mount request. Let's save
the original setting of the "port=" mount option in the mount's nfs_server
structure.
This allows us to simplify the default behavior of port setting for NFSv4
mounts: by default, NFSv2/3 mounts first try an RPC bind to determine the
NFS server's port, unless the user specified the "port=" mount option;
Users can force the client to skip the RPC bind by explicitly specifying
"port=<value>".
NFSv4, by contrast, assumes the NFS server port is 2049 and skips the RPC
bind, unless the user specifies "port=". Users can force an RPC bind for
NFSv4 by explicitly specifying "port=0".
I added a couple of extra comments to clarify this behavior.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/client.c | 4 | ||||
-rw-r--r-- | fs/nfs/internal.h | 1 | ||||
-rw-r--r-- | fs/nfs/super.c | 37 |
3 files changed, 11 insertions, 31 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 06f064d8fbbe..874018113d0e 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -682,6 +682,8 @@ static int nfs_init_server(struct nfs_server *server, | |||
682 | if (error < 0) | 682 | if (error < 0) |
683 | goto error; | 683 | goto error; |
684 | 684 | ||
685 | server->port = data->nfs_server.port; | ||
686 | |||
685 | error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]); | 687 | error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]); |
686 | if (error < 0) | 688 | if (error < 0) |
687 | goto error; | 689 | goto error; |
@@ -1064,6 +1066,8 @@ static int nfs4_init_server(struct nfs_server *server, | |||
1064 | server->acdirmin = data->acdirmin * HZ; | 1066 | server->acdirmin = data->acdirmin * HZ; |
1065 | server->acdirmax = data->acdirmax * HZ; | 1067 | server->acdirmax = data->acdirmax * HZ; |
1066 | 1068 | ||
1069 | server->port = data->nfs_server.port; | ||
1070 | |||
1067 | error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]); | 1071 | error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]); |
1068 | 1072 | ||
1069 | error: | 1073 | error: |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index e89688a955bf..999ad8ee0645 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -56,6 +56,7 @@ struct nfs_parsed_mount_data { | |||
56 | size_t addrlen; | 56 | size_t addrlen; |
57 | char *hostname; | 57 | char *hostname; |
58 | char *export_path; | 58 | char *export_path; |
59 | unsigned short port; | ||
59 | unsigned short protocol; | 60 | unsigned short protocol; |
60 | } nfs_server; | 61 | } nfs_server; |
61 | 62 | ||
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 53a67c6d4d2a..3c6f53aa7317 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -685,7 +685,6 @@ static int nfs_parse_mount_options(char *raw, | |||
685 | struct nfs_parsed_mount_data *mnt) | 685 | struct nfs_parsed_mount_data *mnt) |
686 | { | 686 | { |
687 | char *p, *string, *secdata; | 687 | char *p, *string, *secdata; |
688 | unsigned short port = 0; | ||
689 | int rc; | 688 | int rc; |
690 | 689 | ||
691 | if (!raw) { | 690 | if (!raw) { |
@@ -800,7 +799,7 @@ static int nfs_parse_mount_options(char *raw, | |||
800 | return 0; | 799 | return 0; |
801 | if (option < 0 || option > 65535) | 800 | if (option < 0 || option > 65535) |
802 | return 0; | 801 | return 0; |
803 | port = option; | 802 | mnt->nfs_server.port = option; |
804 | break; | 803 | break; |
805 | case Opt_rsize: | 804 | case Opt_rsize: |
806 | if (match_int(args, &mnt->rsize)) | 805 | if (match_int(args, &mnt->rsize)) |
@@ -1050,7 +1049,8 @@ static int nfs_parse_mount_options(char *raw, | |||
1050 | } | 1049 | } |
1051 | } | 1050 | } |
1052 | 1051 | ||
1053 | nfs_set_port((struct sockaddr *)&mnt->nfs_server.address, port); | 1052 | nfs_set_port((struct sockaddr *)&mnt->nfs_server.address, |
1053 | mnt->nfs_server.port); | ||
1054 | 1054 | ||
1055 | return 1; | 1055 | return 1; |
1056 | 1056 | ||
@@ -1171,7 +1171,9 @@ static int nfs_validate_mount_data(void *options, | |||
1171 | args->acregmax = 60; | 1171 | args->acregmax = 60; |
1172 | args->acdirmin = 30; | 1172 | args->acdirmin = 30; |
1173 | args->acdirmax = 60; | 1173 | args->acdirmax = 60; |
1174 | args->mount_server.port = 0; /* autobind unless user sets port */ | ||
1174 | args->mount_server.protocol = XPRT_TRANSPORT_UDP; | 1175 | args->mount_server.protocol = XPRT_TRANSPORT_UDP; |
1176 | args->nfs_server.port = 0; /* autobind unless user sets port */ | ||
1175 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1177 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
1176 | 1178 | ||
1177 | switch (data->version) { | 1179 | switch (data->version) { |
@@ -1708,28 +1710,6 @@ static void nfs4_fill_super(struct super_block *sb) | |||
1708 | } | 1710 | } |
1709 | 1711 | ||
1710 | /* | 1712 | /* |
1711 | * If the user didn't specify a port, set the port number to | ||
1712 | * the NFS version 4 default port. | ||
1713 | */ | ||
1714 | static void nfs4_default_port(struct sockaddr *sap) | ||
1715 | { | ||
1716 | switch (sap->sa_family) { | ||
1717 | case AF_INET: { | ||
1718 | struct sockaddr_in *ap = (struct sockaddr_in *)sap; | ||
1719 | if (ap->sin_port == 0) | ||
1720 | ap->sin_port = htons(NFS_PORT); | ||
1721 | break; | ||
1722 | } | ||
1723 | case AF_INET6: { | ||
1724 | struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap; | ||
1725 | if (ap->sin6_port == 0) | ||
1726 | ap->sin6_port = htons(NFS_PORT); | ||
1727 | break; | ||
1728 | } | ||
1729 | } | ||
1730 | } | ||
1731 | |||
1732 | /* | ||
1733 | * Validate NFSv4 mount options | 1713 | * Validate NFSv4 mount options |
1734 | */ | 1714 | */ |
1735 | static int nfs4_validate_mount_data(void *options, | 1715 | static int nfs4_validate_mount_data(void *options, |
@@ -1753,6 +1733,7 @@ static int nfs4_validate_mount_data(void *options, | |||
1753 | args->acregmax = 60; | 1733 | args->acregmax = 60; |
1754 | args->acdirmin = 30; | 1734 | args->acdirmin = 30; |
1755 | args->acdirmax = 60; | 1735 | args->acdirmax = 60; |
1736 | args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */ | ||
1756 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1737 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
1757 | 1738 | ||
1758 | switch (data->version) { | 1739 | switch (data->version) { |
@@ -1769,9 +1750,6 @@ static int nfs4_validate_mount_data(void *options, | |||
1769 | &args->nfs_server.address)) | 1750 | &args->nfs_server.address)) |
1770 | goto out_no_address; | 1751 | goto out_no_address; |
1771 | 1752 | ||
1772 | nfs4_default_port((struct sockaddr *) | ||
1773 | &args->nfs_server.address); | ||
1774 | |||
1775 | switch (data->auth_flavourlen) { | 1753 | switch (data->auth_flavourlen) { |
1776 | case 0: | 1754 | case 0: |
1777 | args->auth_flavors[0] = RPC_AUTH_UNIX; | 1755 | args->auth_flavors[0] = RPC_AUTH_UNIX; |
@@ -1829,9 +1807,6 @@ static int nfs4_validate_mount_data(void *options, | |||
1829 | &args->nfs_server.address)) | 1807 | &args->nfs_server.address)) |
1830 | return -EINVAL; | 1808 | return -EINVAL; |
1831 | 1809 | ||
1832 | nfs4_default_port((struct sockaddr *) | ||
1833 | &args->nfs_server.address); | ||
1834 | |||
1835 | switch (args->auth_flavor_len) { | 1810 | switch (args->auth_flavor_len) { |
1836 | case 0: | 1811 | case 0: |
1837 | args->auth_flavors[0] = RPC_AUTH_UNIX; | 1812 | args->auth_flavors[0] = RPC_AUTH_UNIX; |