Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 May 2011 07:33:06 +0000 (UTC)
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r221759 - in stable/8: sbin/mount_nfs sys/fs/nfsclient sys/nfsclient
Message-ID:  <201105110733.p4B7X6df079216@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ru
Date: Wed May 11 07:33:06 2011
New Revision: 221759
URL: http://svn.freebsd.org/changeset/base/221759

Log:
  MFC r221436:
  
  Implemented a mount option "nocto" that disables cache coherency
  checking at open time.  It may improve performance for read-only
  NFS mounts.

Modified:
  stable/8/sbin/mount_nfs/mount_nfs.8
  stable/8/sys/fs/nfsclient/nfs_clvfsops.c
  stable/8/sys/fs/nfsclient/nfs_clvnops.c
  stable/8/sys/fs/nfsclient/nfsargs.h
  stable/8/sys/nfsclient/nfs_diskless.c
  stable/8/sys/nfsclient/nfs_vfsops.c
  stable/8/sys/nfsclient/nfs_vnops.c
  stable/8/sys/nfsclient/nfsargs.h
Directory Properties:
  stable/8/sbin/mount_nfs/   (props changed)
  stable/8/sys/   (props changed)

Modified: stable/8/sbin/mount_nfs/mount_nfs.8
==============================================================================
--- stable/8/sbin/mount_nfs/mount_nfs.8	Wed May 11 06:03:12 2011	(r221758)
+++ stable/8/sbin/mount_nfs/mount_nfs.8	Wed May 11 07:33:06 2011	(r221759)
@@ -28,7 +28,7 @@
 .\"	@(#)mount_nfs.8	8.3 (Berkeley) 3/29/95
 .\" $FreeBSD$
 .\"
-.Dd July 28, 2009
+.Dd May 3, 2011
 .Dt MOUNT_NFS 8
 .Os
 .Sh NAME
@@ -176,6 +176,17 @@ NFS port number 2049 or replies to reque
 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

Modified: stable/8/sys/fs/nfsclient/nfs_clvfsops.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clvfsops.c	Wed May 11 06:03:12 2011	(r221758)
+++ stable/8/sys/fs/nfsclient/nfs_clvfsops.c	Wed May 11 07:33:06 2011	(r221759)
@@ -700,7 +700,7 @@ static const char *nfs_opts[] = { "from"
     "retrans", "acregmin", "acregmax", "acdirmin", "acdirmax", "resvport",
     "readahead", "hostname", "timeout", "addr", "fh", "nfsv3", "sec",
     "principal", "nfsv4", "gssname", "allgssname", "dirpath",
-    "negnametimeo",
+    "negnametimeo", "nocto",
     NULL };
 
 /*
@@ -799,6 +799,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");

Modified: stable/8/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clvnops.c	Wed May 11 06:03:12 2011	(r221758)
+++ stable/8/sys/fs/nfsclient/nfs_clvnops.c	Wed May 11 07:33:06 2011	(r221759)
@@ -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;

Modified: stable/8/sys/fs/nfsclient/nfsargs.h
==============================================================================
--- stable/8/sys/fs/nfsclient/nfsargs.h	Wed May 11 06:03:12 2011	(r221758)
+++ stable/8/sys/fs/nfsclient/nfsargs.h	Wed May 11 07:33:06 2011	(r221759)
@@ -100,5 +100,6 @@ struct nfs_args {
 #define	NFSMNT_HASSETFSID	0x02000000 /* Has set FSID */
 #define	NFSMNT_RESVPORT		0x04000000 /* Use a reserved port (Bunk!!) */
 #define	NFSMNT_AUTOM		0x08000000 /* Done by autofs */
+#define	NFSMNT_NOCTO		0x20000000 /* Don't flush attrcache on open */
 
 #endif	/* _NFSCLIENT_NFSARGS_H_ */

Modified: stable/8/sys/nfsclient/nfs_diskless.c
==============================================================================
--- stable/8/sys/nfsclient/nfs_diskless.c	Wed May 11 06:03:12 2011	(r221758)
+++ stable/8/sys/nfsclient/nfs_diskless.c	Wed May 11 07:33:06 2011	(r221759)
@@ -103,6 +103,8 @@ nfs_parse_options(const char *envopts, s
 			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) {

Modified: stable/8/sys/nfsclient/nfs_vfsops.c
==============================================================================
--- stable/8/sys/nfsclient/nfs_vfsops.c	Wed May 11 06:03:12 2011	(r221758)
+++ stable/8/sys/nfsclient/nfs_vfsops.c	Wed May 11 07:33:06 2011	(r221759)
@@ -781,7 +781,7 @@ static const char *nfs_opts[] = { "from"
     "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 };
 
 /*
@@ -896,6 +896,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");

Modified: stable/8/sys/nfsclient/nfs_vnops.c
==============================================================================
--- stable/8/sys/nfsclient/nfs_vnops.c	Wed May 11 06:03:12 2011	(r221758)
+++ stable/8/sys/nfsclient/nfs_vnops.c	Wed May 11 07:33:06 2011	(r221759)
@@ -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;

Modified: stable/8/sys/nfsclient/nfsargs.h
==============================================================================
--- stable/8/sys/nfsclient/nfsargs.h	Wed May 11 06:03:12 2011	(r221758)
+++ stable/8/sys/nfsclient/nfsargs.h	Wed May 11 07:33:06 2011	(r221759)
@@ -93,5 +93,6 @@ struct nfs_args {
 #define	NFSMNT_NOLOCKD		0x00400000 /* Locks are local */
 #define	NFSMNT_NFSV4		0x00800000 /* Use NFS Version 4 protocol */
 #define	NFSMNT_HASWRITEVERF	0x01000000 /* NFSv4 Write verifier */
+#define	NFSMNT_NOCTO		0x20000000 /* Don't flush attrcache on open */
 
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105110733.p4B7X6df079216>