summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2011-05-04 13:27:45 +0000
committerru <ru@FreeBSD.org>2011-05-04 13:27:45 +0000
commitb0a86c9f257a1311ae8daa811c6c3b6e199f05e5 (patch)
tree4b861261899defb3fa31ca5958853bd86a0388d8
parentc5a0d73cf16c8dff00d2586d802bc17e15a00566 (diff)
downloadFreeBSD-src-b0a86c9f257a1311ae8daa811c6c3b6e199f05e5.zip
FreeBSD-src-b0a86c9f257a1311ae8daa811c6c3b6e199f05e5.tar.gz
Implemented a mount option "nocto" that disables cache coherency
checking at open time. It may improve performance for read-only NFS mounts. Use deliberately. MFC after: 1 week Reviewed by: rmacklem, jhb (earlier version)
-rw-r--r--sbin/mount_nfs/mount_nfs.813
-rw-r--r--sys/fs/nfsclient/nfs_clvfsops.c4
-rw-r--r--sys/fs/nfsclient/nfs_clvnops.c3
-rw-r--r--sys/nfs/nfs_diskless.c2
-rw-r--r--sys/nfsclient/nfs_vfsops.c4
-rw-r--r--sys/nfsclient/nfs_vnops.c3
-rw-r--r--sys/nfsclient/nfsargs.h1
7 files changed, 25 insertions, 5 deletions
diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8
index 59d6cb4..be9e309 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 April 27, 2011
+.Dd May 3, 2011
.Dt MOUNT_NFS 8
.Os
.Sh NAME
@@ -180,6 +180,17 @@ NFS port number 2049 or replies to requests using a different IP address
Setting the
.Va vfs.nfs.nfs_ip_paranoia
sysctl to 0 will make this option the default.
+.It Cm nocto
+Normally, NFS clients maintain the close-to-open cache coherency.
+This works by flushing at close time and checking at open time.
+Checking at open time is implemented by getting attributes from
+the server and purging the data cache if they do not match
+attributes cached by the client.
+.Pp
+This option disables checking at open time.
+It may improve performance for read-only mounts,
+but should only be used if the data on the server changes rarely.
+Be sure to understand the consequences before enabling this option.
.It Cm noinet4 , noinet6
Disables
.Dv AF_INET
diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c
index 9280f41..8b4fc6a 100644
--- a/sys/fs/nfsclient/nfs_clvfsops.c
+++ b/sys/fs/nfsclient/nfs_clvfsops.c
@@ -716,7 +716,7 @@ static const char *nfs_opts[] = { "from", "nfs_args",
"retrans", "acregmin", "acregmax", "acdirmin", "acdirmax", "resvport",
"readahead", "hostname", "timeout", "addr", "fh", "nfsv3", "sec",
"principal", "nfsv4", "gssname", "allgssname", "dirpath",
- "negnametimeo",
+ "negnametimeo", "nocto",
NULL };
/*
@@ -833,6 +833,8 @@ nfs_mount(struct mount *mp)
}
if (vfs_getopt(mp->mnt_optnew, "allgssname", NULL, NULL) == 0)
args.flags |= NFSMNT_ALLGSSNAME;
+ if (vfs_getopt(mp->mnt_optnew, "nocto", NULL, NULL) == 0)
+ args.flags |= NFSMNT_NOCTO;
if (vfs_getopt(mp->mnt_optnew, "readdirsize", (void **)&opt, NULL) == 0) {
if (opt == NULL) {
vfs_mount_error(mp, "illegal readdirsize");
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index cc9563a..6dc709f 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -1026,7 +1026,8 @@ nfs_lookup(struct vop_lookup_args *ap)
*/
newvp = *vpp;
newnp = VTONFS(newvp);
- if ((flags & (ISLASTCN | ISOPEN)) == (ISLASTCN | ISOPEN) &&
+ if (!(nmp->nm_flag & NFSMNT_NOCTO) &&
+ (flags & (ISLASTCN | ISOPEN)) == (ISLASTCN | ISOPEN) &&
!(newnp->n_flag & NMODIFIED)) {
mtx_lock(&newnp->n_mtx);
newnp->n_attrstamp = 0;
diff --git a/sys/nfs/nfs_diskless.c b/sys/nfs/nfs_diskless.c
index fad6ef0..26f5036 100644
--- a/sys/nfs/nfs_diskless.c
+++ b/sys/nfs/nfs_diskless.c
@@ -112,6 +112,8 @@ nfs_parse_options(const char *envopts, struct nfs_args *nd)
nd->flags |= NFSMNT_NOCONN;
else if (strcmp(o, "nolockd") == 0)
nd->flags |= NFSMNT_NOLOCKD;
+ else if (strcmp(o, "nocto") == 0)
+ nd->flags |= NFSMNT_NOCTO;
else if (strcmp(o, "nfsv2") == 0)
nd->flags &= ~(NFSMNT_NFSV3 | NFSMNT_NFSV4);
else if (strcmp(o, "nfsv3") == 0) {
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index ec60c94..ba3f41d 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -786,7 +786,7 @@ static const char *nfs_opts[] = { "from", "nfs_args",
"readahead", "readdirsize", "soft", "hard", "mntudp", "tcp", "udp",
"wsize", "rsize", "retrans", "acregmin", "acregmax", "acdirmin",
"acdirmax", "deadthresh", "hostname", "timeout", "addr", "fh", "nfsv3",
- "sec", "maxgroups", "principal", "negnametimeo",
+ "sec", "maxgroups", "principal", "negnametimeo", "nocto",
NULL };
/*
@@ -901,6 +901,8 @@ nfs_mount(struct mount *mp)
args.sotype = SOCK_STREAM;
if (vfs_getopt(mp->mnt_optnew, "nfsv3", NULL, NULL) == 0)
args.flags |= NFSMNT_NFSV3;
+ if (vfs_getopt(mp->mnt_optnew, "nocto", NULL, NULL) == 0)
+ args.flags |= NFSMNT_NOCTO;
if (vfs_getopt(mp->mnt_optnew, "readdirsize", (void **)&opt, NULL) == 0) {
if (opt == NULL) {
vfs_mount_error(mp, "illegal readdirsize");
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index cb2a126..33506a4 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -960,7 +960,8 @@ nfs_lookup(struct vop_lookup_args *ap)
*/
newvp = *vpp;
newnp = VTONFS(newvp);
- if ((flags & (ISLASTCN | ISOPEN)) == (ISLASTCN | ISOPEN) &&
+ if (!(nmp->nm_flag & NFSMNT_NOCTO) &&
+ (flags & (ISLASTCN | ISOPEN)) == (ISLASTCN | ISOPEN) &&
!(newnp->n_flag & NMODIFIED)) {
mtx_lock(&newnp->n_mtx);
newnp->n_attrstamp = 0;
diff --git a/sys/nfsclient/nfsargs.h b/sys/nfsclient/nfsargs.h
index a46677a..f71a555 100644
--- a/sys/nfsclient/nfsargs.h
+++ b/sys/nfsclient/nfsargs.h
@@ -97,5 +97,6 @@ struct nfs_args {
#define NFSMNT_PRIVACY 0x04000000 /* Use privacy with RPCSEC_GSS */
#define NFSMNT_ALLGSSNAME 0x08000000 /* Use principal for all accesses */
#define NFSMNT_STRICT3530 0x10000000 /* Adhere strictly to RFC3530 */
+#define NFSMNT_NOCTO 0x20000000 /* Don't flush attrcache on open */
#endif
OpenPOWER on IntegriCloud