aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r--fs/nfs/super.c155
1 files changed, 103 insertions, 52 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index f9219024f31a..fa220dc74609 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -198,7 +198,7 @@ static match_table_t nfs_secflavor_tokens = {
198}; 198};
199 199
200 200
201static void nfs_umount_begin(struct vfsmount *, int); 201static void nfs_umount_begin(struct super_block *);
202static int nfs_statfs(struct dentry *, struct kstatfs *); 202static int nfs_statfs(struct dentry *, struct kstatfs *);
203static int nfs_show_options(struct seq_file *, struct vfsmount *); 203static int nfs_show_options(struct seq_file *, struct vfsmount *);
204static int nfs_show_stats(struct seq_file *, struct vfsmount *); 204static int nfs_show_stats(struct seq_file *, struct vfsmount *);
@@ -441,10 +441,52 @@ static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour)
441 return sec_flavours[i].str; 441 return sec_flavours[i].str;
442} 442}
443 443
444static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
445 int showdefaults)
446{
447 struct sockaddr *sap = (struct sockaddr *)&nfss->mountd_address;
448
449 switch (sap->sa_family) {
450 case AF_INET: {
451 struct sockaddr_in *sin = (struct sockaddr_in *)sap;
452 seq_printf(m, ",mountaddr=" NIPQUAD_FMT,
453 NIPQUAD(sin->sin_addr.s_addr));
454 break;
455 }
456 case AF_INET6: {
457 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
458 seq_printf(m, ",mountaddr=" NIP6_FMT,
459 NIP6(sin6->sin6_addr));
460 break;
461 }
462 default:
463 if (showdefaults)
464 seq_printf(m, ",mountaddr=unspecified");
465 }
466
467 if (nfss->mountd_version || showdefaults)
468 seq_printf(m, ",mountvers=%u", nfss->mountd_version);
469 if (nfss->mountd_port || showdefaults)
470 seq_printf(m, ",mountport=%u", nfss->mountd_port);
471
472 switch (nfss->mountd_protocol) {
473 case IPPROTO_UDP:
474 seq_printf(m, ",mountproto=udp");
475 break;
476 case IPPROTO_TCP:
477 seq_printf(m, ",mountproto=tcp");
478 break;
479 default:
480 if (showdefaults)
481 seq_printf(m, ",mountproto=auto");
482 }
483}
484
444/* 485/*
445 * Describe the mount options in force on this server representation 486 * Describe the mount options in force on this server representation
446 */ 487 */
447static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, int showdefaults) 488static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
489 int showdefaults)
448{ 490{
449 static const struct proc_nfs_info { 491 static const struct proc_nfs_info {
450 int flag; 492 int flag;
@@ -452,6 +494,8 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
452 const char *nostr; 494 const char *nostr;
453 } nfs_info[] = { 495 } nfs_info[] = {
454 { NFS_MOUNT_SOFT, ",soft", ",hard" }, 496 { NFS_MOUNT_SOFT, ",soft", ",hard" },
497 { NFS_MOUNT_INTR, ",intr", ",nointr" },
498 { NFS_MOUNT_POSIX, ",posix", "" },
455 { NFS_MOUNT_NOCTO, ",nocto", "" }, 499 { NFS_MOUNT_NOCTO, ",nocto", "" },
456 { NFS_MOUNT_NOAC, ",noac", "" }, 500 { NFS_MOUNT_NOAC, ",noac", "" },
457 { NFS_MOUNT_NONLM, ",nolock", "" }, 501 { NFS_MOUNT_NONLM, ",nolock", "" },
@@ -462,18 +506,22 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
462 }; 506 };
463 const struct proc_nfs_info *nfs_infop; 507 const struct proc_nfs_info *nfs_infop;
464 struct nfs_client *clp = nfss->nfs_client; 508 struct nfs_client *clp = nfss->nfs_client;
465 509 u32 version = clp->rpc_ops->version;
466 seq_printf(m, ",vers=%d", clp->rpc_ops->version); 510
467 seq_printf(m, ",rsize=%d", nfss->rsize); 511 seq_printf(m, ",vers=%u", version);
468 seq_printf(m, ",wsize=%d", nfss->wsize); 512 seq_printf(m, ",rsize=%u", nfss->rsize);
513 seq_printf(m, ",wsize=%u", nfss->wsize);
514 if (nfss->bsize != 0)
515 seq_printf(m, ",bsize=%u", nfss->bsize);
516 seq_printf(m, ",namlen=%u", nfss->namelen);
469 if (nfss->acregmin != 3*HZ || showdefaults) 517 if (nfss->acregmin != 3*HZ || showdefaults)
470 seq_printf(m, ",acregmin=%d", nfss->acregmin/HZ); 518 seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ);
471 if (nfss->acregmax != 60*HZ || showdefaults) 519 if (nfss->acregmax != 60*HZ || showdefaults)
472 seq_printf(m, ",acregmax=%d", nfss->acregmax/HZ); 520 seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ);
473 if (nfss->acdirmin != 30*HZ || showdefaults) 521 if (nfss->acdirmin != 30*HZ || showdefaults)
474 seq_printf(m, ",acdirmin=%d", nfss->acdirmin/HZ); 522 seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ);
475 if (nfss->acdirmax != 60*HZ || showdefaults) 523 if (nfss->acdirmax != 60*HZ || showdefaults)
476 seq_printf(m, ",acdirmax=%d", nfss->acdirmax/HZ); 524 seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ);
477 for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { 525 for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) {
478 if (nfss->flags & nfs_infop->flag) 526 if (nfss->flags & nfs_infop->flag)
479 seq_puts(m, nfs_infop->str); 527 seq_puts(m, nfs_infop->str);
@@ -482,9 +530,24 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
482 } 530 }
483 seq_printf(m, ",proto=%s", 531 seq_printf(m, ",proto=%s",
484 rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO)); 532 rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO));
533 if (version == 4) {
534 if (nfss->port != NFS_PORT)
535 seq_printf(m, ",port=%u", nfss->port);
536 } else
537 if (nfss->port)
538 seq_printf(m, ",port=%u", nfss->port);
539
485 seq_printf(m, ",timeo=%lu", 10U * nfss->client->cl_timeout->to_initval / HZ); 540 seq_printf(m, ",timeo=%lu", 10U * nfss->client->cl_timeout->to_initval / HZ);
486 seq_printf(m, ",retrans=%u", nfss->client->cl_timeout->to_retries); 541 seq_printf(m, ",retrans=%u", nfss->client->cl_timeout->to_retries);
487 seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor)); 542 seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor));
543
544 if (version != 4)
545 nfs_show_mountd_options(m, nfss, showdefaults);
546
547#ifdef CONFIG_NFS_V4
548 if (clp->rpc_ops->version == 4)
549 seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr);
550#endif
488} 551}
489 552
490/* 553/*
@@ -529,10 +592,10 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
529 592
530 seq_printf(m, "\n\tcaps:\t"); 593 seq_printf(m, "\n\tcaps:\t");
531 seq_printf(m, "caps=0x%x", nfss->caps); 594 seq_printf(m, "caps=0x%x", nfss->caps);
532 seq_printf(m, ",wtmult=%d", nfss->wtmult); 595 seq_printf(m, ",wtmult=%u", nfss->wtmult);
533 seq_printf(m, ",dtsize=%d", nfss->dtsize); 596 seq_printf(m, ",dtsize=%u", nfss->dtsize);
534 seq_printf(m, ",bsize=%d", nfss->bsize); 597 seq_printf(m, ",bsize=%u", nfss->bsize);
535 seq_printf(m, ",namelen=%d", nfss->namelen); 598 seq_printf(m, ",namlen=%u", nfss->namelen);
536 599
537#ifdef CONFIG_NFS_V4 600#ifdef CONFIG_NFS_V4
538 if (nfss->nfs_client->rpc_ops->version == 4) { 601 if (nfss->nfs_client->rpc_ops->version == 4) {
@@ -546,9 +609,9 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
546 /* 609 /*
547 * Display security flavor in effect for this mount 610 * Display security flavor in effect for this mount
548 */ 611 */
549 seq_printf(m, "\n\tsec:\tflavor=%d", auth->au_ops->au_flavor); 612 seq_printf(m, "\n\tsec:\tflavor=%u", auth->au_ops->au_flavor);
550 if (auth->au_flavor) 613 if (auth->au_flavor)
551 seq_printf(m, ",pseudoflavor=%d", auth->au_flavor); 614 seq_printf(m, ",pseudoflavor=%u", auth->au_flavor);
552 615
553 /* 616 /*
554 * Display superblock I/O counters 617 * Display superblock I/O counters
@@ -584,13 +647,11 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
584 * Begin unmount by attempting to remove all automounted mountpoints we added 647 * Begin unmount by attempting to remove all automounted mountpoints we added
585 * in response to xdev traversals and referrals 648 * in response to xdev traversals and referrals
586 */ 649 */
587static void nfs_umount_begin(struct vfsmount *vfsmnt, int flags) 650static void nfs_umount_begin(struct super_block *sb)
588{ 651{
589 struct nfs_server *server = NFS_SB(vfsmnt->mnt_sb); 652 struct nfs_server *server = NFS_SB(sb);
590 struct rpc_clnt *rpc; 653 struct rpc_clnt *rpc;
591 654
592 if (!(flags & MNT_FORCE))
593 return;
594 /* -EIO all pending I/O */ 655 /* -EIO all pending I/O */
595 rpc = server->client_acl; 656 rpc = server->client_acl;
596 if (!IS_ERR(rpc)) 657 if (!IS_ERR(rpc))
@@ -683,7 +744,6 @@ static int nfs_parse_mount_options(char *raw,
683 struct nfs_parsed_mount_data *mnt) 744 struct nfs_parsed_mount_data *mnt)
684{ 745{
685 char *p, *string, *secdata; 746 char *p, *string, *secdata;
686 unsigned short port = 0;
687 int rc; 747 int rc;
688 748
689 if (!raw) { 749 if (!raw) {
@@ -798,7 +858,7 @@ static int nfs_parse_mount_options(char *raw,
798 return 0; 858 return 0;
799 if (option < 0 || option > 65535) 859 if (option < 0 || option > 65535)
800 return 0; 860 return 0;
801 port = option; 861 mnt->nfs_server.port = option;
802 break; 862 break;
803 case Opt_rsize: 863 case Opt_rsize:
804 if (match_int(args, &mnt->rsize)) 864 if (match_int(args, &mnt->rsize))
@@ -1048,7 +1108,8 @@ static int nfs_parse_mount_options(char *raw,
1048 } 1108 }
1049 } 1109 }
1050 1110
1051 nfs_set_port((struct sockaddr *)&mnt->nfs_server.address, port); 1111 nfs_set_port((struct sockaddr *)&mnt->nfs_server.address,
1112 mnt->nfs_server.port);
1052 1113
1053 return 1; 1114 return 1;
1054 1115
@@ -1169,7 +1230,9 @@ static int nfs_validate_mount_data(void *options,
1169 args->acregmax = 60; 1230 args->acregmax = 60;
1170 args->acdirmin = 30; 1231 args->acdirmin = 30;
1171 args->acdirmax = 60; 1232 args->acdirmax = 60;
1233 args->mount_server.port = 0; /* autobind unless user sets port */
1172 args->mount_server.protocol = XPRT_TRANSPORT_UDP; 1234 args->mount_server.protocol = XPRT_TRANSPORT_UDP;
1235 args->nfs_server.port = 0; /* autobind unless user sets port */
1173 args->nfs_server.protocol = XPRT_TRANSPORT_TCP; 1236 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1174 1237
1175 switch (data->version) { 1238 switch (data->version) {
@@ -1208,7 +1271,6 @@ static int nfs_validate_mount_data(void *options,
1208 args->flags = data->flags; 1271 args->flags = data->flags;
1209 args->rsize = data->rsize; 1272 args->rsize = data->rsize;
1210 args->wsize = data->wsize; 1273 args->wsize = data->wsize;
1211 args->flags = data->flags;
1212 args->timeo = data->timeo; 1274 args->timeo = data->timeo;
1213 args->retrans = data->retrans; 1275 args->retrans = data->retrans;
1214 args->acregmin = data->acregmin; 1276 args->acregmin = data->acregmin;
@@ -1230,6 +1292,8 @@ static int nfs_validate_mount_data(void *options,
1230 args->namlen = data->namlen; 1292 args->namlen = data->namlen;
1231 args->bsize = data->bsize; 1293 args->bsize = data->bsize;
1232 args->auth_flavors[0] = data->pseudoflavor; 1294 args->auth_flavors[0] = data->pseudoflavor;
1295 if (!args->nfs_server.hostname)
1296 goto out_nomem;
1233 1297
1234 /* 1298 /*
1235 * The legacy version 6 binary mount data from userspace has a 1299 * The legacy version 6 binary mount data from userspace has a
@@ -1276,6 +1340,8 @@ static int nfs_validate_mount_data(void *options,
1276 len = c - dev_name; 1340 len = c - dev_name;
1277 /* N.B. caller will free nfs_server.hostname in all cases */ 1341 /* N.B. caller will free nfs_server.hostname in all cases */
1278 args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL); 1342 args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL);
1343 if (!args->nfs_server.hostname)
1344 goto out_nomem;
1279 1345
1280 c++; 1346 c++;
1281 if (strlen(c) > NFS_MAXPATHLEN) 1347 if (strlen(c) > NFS_MAXPATHLEN)
@@ -1319,6 +1385,10 @@ out_v3_not_compiled:
1319 return -EPROTONOSUPPORT; 1385 return -EPROTONOSUPPORT;
1320#endif /* !CONFIG_NFS_V3 */ 1386#endif /* !CONFIG_NFS_V3 */
1321 1387
1388out_nomem:
1389 dfprintk(MOUNT, "NFS: not enough memory to handle mount options\n");
1390 return -ENOMEM;
1391
1322out_no_address: 1392out_no_address:
1323 dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n"); 1393 dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n");
1324 return -EINVAL; 1394 return -EINVAL;
@@ -1706,28 +1776,6 @@ static void nfs4_fill_super(struct super_block *sb)
1706} 1776}
1707 1777
1708/* 1778/*
1709 * If the user didn't specify a port, set the port number to
1710 * the NFS version 4 default port.
1711 */
1712static void nfs4_default_port(struct sockaddr *sap)
1713{
1714 switch (sap->sa_family) {
1715 case AF_INET: {
1716 struct sockaddr_in *ap = (struct sockaddr_in *)sap;
1717 if (ap->sin_port == 0)
1718 ap->sin_port = htons(NFS_PORT);
1719 break;
1720 }
1721 case AF_INET6: {
1722 struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
1723 if (ap->sin6_port == 0)
1724 ap->sin6_port = htons(NFS_PORT);
1725 break;
1726 }
1727 }
1728}
1729
1730/*
1731 * Validate NFSv4 mount options 1779 * Validate NFSv4 mount options
1732 */ 1780 */
1733static int nfs4_validate_mount_data(void *options, 1781static int nfs4_validate_mount_data(void *options,
@@ -1751,6 +1799,7 @@ static int nfs4_validate_mount_data(void *options,
1751 args->acregmax = 60; 1799 args->acregmax = 60;
1752 args->acdirmin = 30; 1800 args->acdirmin = 30;
1753 args->acdirmax = 60; 1801 args->acdirmax = 60;
1802 args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */
1754 args->nfs_server.protocol = XPRT_TRANSPORT_TCP; 1803 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1755 1804
1756 switch (data->version) { 1805 switch (data->version) {
@@ -1767,9 +1816,6 @@ static int nfs4_validate_mount_data(void *options,
1767 &args->nfs_server.address)) 1816 &args->nfs_server.address))
1768 goto out_no_address; 1817 goto out_no_address;
1769 1818
1770 nfs4_default_port((struct sockaddr *)
1771 &args->nfs_server.address);
1772
1773 switch (data->auth_flavourlen) { 1819 switch (data->auth_flavourlen) {
1774 case 0: 1820 case 0:
1775 args->auth_flavors[0] = RPC_AUTH_UNIX; 1821 args->auth_flavors[0] = RPC_AUTH_UNIX;
@@ -1827,9 +1873,6 @@ static int nfs4_validate_mount_data(void *options,
1827 &args->nfs_server.address)) 1873 &args->nfs_server.address))
1828 return -EINVAL; 1874 return -EINVAL;
1829 1875
1830 nfs4_default_port((struct sockaddr *)
1831 &args->nfs_server.address);
1832
1833 switch (args->auth_flavor_len) { 1876 switch (args->auth_flavor_len) {
1834 case 0: 1877 case 0:
1835 args->auth_flavors[0] = RPC_AUTH_UNIX; 1878 args->auth_flavors[0] = RPC_AUTH_UNIX;
@@ -1852,12 +1895,16 @@ static int nfs4_validate_mount_data(void *options,
1852 return -ENAMETOOLONG; 1895 return -ENAMETOOLONG;
1853 /* N.B. caller will free nfs_server.hostname in all cases */ 1896 /* N.B. caller will free nfs_server.hostname in all cases */
1854 args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL); 1897 args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL);
1898 if (!args->nfs_server.hostname)
1899 goto out_nomem;
1855 1900
1856 c++; /* step over the ':' */ 1901 c++; /* step over the ':' */
1857 len = strlen(c); 1902 len = strlen(c);
1858 if (len > NFS4_MAXPATHLEN) 1903 if (len > NFS4_MAXPATHLEN)
1859 return -ENAMETOOLONG; 1904 return -ENAMETOOLONG;
1860 args->nfs_server.export_path = kstrndup(c, len, GFP_KERNEL); 1905 args->nfs_server.export_path = kstrndup(c, len, GFP_KERNEL);
1906 if (!args->nfs_server.export_path)
1907 goto out_nomem;
1861 1908
1862 dprintk("NFS: MNTPATH: '%s'\n", args->nfs_server.export_path); 1909 dprintk("NFS: MNTPATH: '%s'\n", args->nfs_server.export_path);
1863 1910
@@ -1879,6 +1926,10 @@ out_inval_auth:
1879 data->auth_flavourlen); 1926 data->auth_flavourlen);
1880 return -EINVAL; 1927 return -EINVAL;
1881 1928
1929out_nomem:
1930 dfprintk(MOUNT, "NFS4: not enough memory to handle mount options\n");
1931 return -ENOMEM;
1932
1882out_no_address: 1933out_no_address:
1883 dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n"); 1934 dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
1884 return -EINVAL; 1935 return -EINVAL;