From fe5282b5e432402d9efe548c6093821abeaf2619 Mon Sep 17 00:00:00 2001 From: trasz Date: Sat, 29 Nov 2014 15:41:55 +0000 Subject: [PATCH] MFC r273849: Add support for "timeo", "actimeo", "noac", and "proto" options to mount_nfs(8). They are implemented on Linux, OS X, and Solaris, and thus can be expected to appear in automounter maps. Sponsored by: The FreeBSD Foundation git-svn-id: svn://svn.freebsd.org/base/stable/10@275249 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sbin/mount_nfs/mount_nfs.8 | 18 ++++++++++++++- sbin/mount_nfs/mount_nfs.c | 29 ++++++++++++++++++++++++ sys/fs/nfsclient/nfs_clvfsops.c | 40 ++++++++++++++++++++++++++++----- 3 files changed, 80 insertions(+), 7 deletions(-) diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8 index 124ba7d60..55080e9c8 100644 --- a/sbin/mount_nfs/mount_nfs.8 +++ b/sbin/mount_nfs/mount_nfs.8 @@ -28,7 +28,7 @@ .\" @(#)mount_nfs.8 8.3 (Berkeley) 3/29/95 .\" $FreeBSD$ .\" -.Dd August 5, 2014 +.Dd October 30, 2014 .Dt MOUNT_NFS 8 .Os .Sh NAME @@ -118,6 +118,8 @@ for regular files, and 30 -> 60 seconds for directories. The algorithm to calculate the timeout is based on the age of the file. The older the file, the longer the cache is considered valid, subject to the limits above. +.It Cm actimeo Ns = Ns Aq Ar seconds +Set four cache timeouts above to specified value. .It Cm allgssname This option can be used along with .Fl o Cm gssname @@ -211,6 +213,8 @@ NFS Version 4 protocol. This option is only meaningful when used with the .Cm minorversion option. +.It Cm noac +Disable attribute caching. .It Cm noconn For UDP mount points, do not do a .Xr connect 2 . @@ -282,6 +286,15 @@ use a reserved socket port number (see below). .It Cm port Ns = Ns Aq Ar port_number Use specified port number for NFS requests. The default is to query the portmapper for the NFS port. +.It Cm proto Ns = Ns Aq Ar protocol +Specify transport protocol version to use. +Currently, they are: +.Bd -literal +udp - Use UDP over IPv4 +tcp - Use TCP over IPv4 +udp6 - Use UDP over IPv6 +tcp6 - Use TCP over IPv6 +.Ed .It Cm rdirplus Used with NFSV3 to specify that the \fBReaddirPlus\fR RPC should be used. @@ -369,6 +382,9 @@ value if there is a low retransmit rate but long response delay observed. option should be specified when using this option to manually tune the timeout interval.) +.It Cm timeo Ns = Ns Aq Ar value +Alias for +.Cm timeout . .It Cm udp Use UDP transport. .It Cm vers Ns = Ns Aq Ar vers_number diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index 383f47547..dc3872009 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -284,6 +284,35 @@ main(int argc, char *argv[]) err(1, "asprintf"); } else if (strcmp(opt, "principal") == 0) { got_principal = 1; + } else if (strcmp(opt, "proto") == 0) { + pass_flag_to_nmount=0; + if (strcmp(val, "tcp") == 0) { + nfsproto = IPPROTO_TCP; + opflags |= OF_NOINET6; + build_iovec(&iov, &iovlen, + "tcp", NULL, 0); + } else if (strcmp(val, "udp") == 0) { + mnttcp_ok = 0; + nfsproto = IPPROTO_UDP; + opflags |= OF_NOINET6; + build_iovec(&iov, &iovlen, + "udp", NULL, 0); + } else if (strcmp(val, "tcp6") == 0) { + nfsproto = IPPROTO_TCP; + opflags |= OF_NOINET4; + build_iovec(&iov, &iovlen, + "tcp", NULL, 0); + } else if (strcmp(val, "udp6") == 0) { + mnttcp_ok = 0; + nfsproto = IPPROTO_UDP; + opflags |= OF_NOINET4; + build_iovec(&iov, &iovlen, + "udp", NULL, 0); + } else { + errx(1, + "illegal proto value -- %s", + val); + } } else if (strcmp(opt, "sec") == 0) { /* * Don't add this option to diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 4cbbb24b3..469fa1d18 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -722,15 +722,15 @@ nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp, } static const char *nfs_opts[] = { "from", "nfs_args", - "noatime", "noexec", "suiddir", "nosuid", "nosymfollow", "union", + "noac", "noatime", "noexec", "suiddir", "nosuid", "nosymfollow", "union", "noclusterr", "noclusterw", "multilabel", "acls", "force", "update", "async", "noconn", "nolockd", "conn", "lockd", "intr", "rdirplus", "readdirsize", "soft", "hard", "mntudp", "tcp", "udp", "wsize", "rsize", - "retrans", "acregmin", "acregmax", "acdirmin", "acdirmax", "resvport", - "readahead", "hostname", "timeout", "addr", "fh", "nfsv3", "sec", - "principal", "nfsv4", "gssname", "allgssname", "dirpath", "minorversion", - "nametimeo", "negnametimeo", "nocto", "noncontigwr", "pnfs", - "wcommitsize", + "retrans", "actimeo", "acregmin", "acregmax", "acdirmin", "acdirmax", + "resvport", "readahead", "hostname", "timeo", "timeout", "addr", "fh", + "nfsv3", "sec", "principal", "nfsv4", "gssname", "allgssname", "dirpath", + "minorversion", "nametimeo", "negnametimeo", "nocto", "noncontigwr", + "pnfs", "wcommitsize", NULL }; /* @@ -815,6 +815,12 @@ nfs_mount(struct mount *mp) } /* Handle the new style options. */ + if (vfs_getopt(mp->mnt_optnew, "noac", NULL, NULL) == 0) { + args.acdirmin = args.acdirmax = + args.acregmin = args.acregmax = 0; + args.flags |= NFSMNT_ACDIRMIN | NFSMNT_ACDIRMAX | + NFSMNT_ACREGMIN | NFSMNT_ACREGMAX; + } if (vfs_getopt(mp->mnt_optnew, "noconn", NULL, NULL) == 0) args.flags |= NFSMNT_NOCONN; if (vfs_getopt(mp->mnt_optnew, "conn", NULL, NULL) == 0) @@ -930,6 +936,18 @@ nfs_mount(struct mount *mp) } args.flags |= NFSMNT_RETRANS; } + if (vfs_getopt(mp->mnt_optnew, "actimeo", (void **)&opt, NULL) == 0) { + ret = sscanf(opt, "%d", &args.acregmin); + if (ret != 1 || args.acregmin < 0) { + vfs_mount_error(mp, "illegal actimeo: %s", + opt); + error = EINVAL; + goto out; + } + args.acdirmin = args.acdirmax = args.acregmax = args.acregmin; + args.flags |= NFSMNT_ACDIRMIN | NFSMNT_ACDIRMAX | + NFSMNT_ACREGMIN | NFSMNT_ACREGMAX; + } if (vfs_getopt(mp->mnt_optnew, "acregmin", (void **)&opt, NULL) == 0) { ret = sscanf(opt, "%d", &args.acregmin); if (ret != 1 || args.acregmin < 0) { @@ -979,6 +997,16 @@ nfs_mount(struct mount *mp) } args.flags |= NFSMNT_WCOMMITSIZE; } + if (vfs_getopt(mp->mnt_optnew, "timeo", (void **)&opt, NULL) == 0) { + ret = sscanf(opt, "%d", &args.timeo); + if (ret != 1 || args.timeo <= 0) { + vfs_mount_error(mp, "illegal timeo: %s", + opt); + error = EINVAL; + goto out; + } + args.flags |= NFSMNT_TIMEO; + } if (vfs_getopt(mp->mnt_optnew, "timeout", (void **)&opt, NULL) == 0) { ret = sscanf(opt, "%d", &args.timeo); if (ret != 1 || args.timeo <= 0) { -- 2.45.0