Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Jul 2010 18:54:56 +0000 (UTC)
From:      John Baldwin <jhb@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: r210512 - stable/8/sys/nfsclient
Message-ID:  <201007261854.o6QIsuFs056195@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Mon Jul 26 18:54:56 2010
New Revision: 210512
URL: http://svn.freebsd.org/changeset/base/210512

Log:
  MFC 209948:
  A previous change moved the GETATTR RPC for open() calls that hit in the
  name cache up into nfs_lookup() instead of nfs_open().  Continue this
  trend by flushing the attribute cache for leaf nodes in nfs_lookup() during
  an open() if we do a LOOKUP RPC.  For NFSv3 this should generally be a NOP
  as the attributes are flushed before fetching the post-op attributes from
  the LOOKUP RPC which most (all?) NFSv3 servers provide, so the post-op
  attributes should populate the cache.
  
  Now all NFS open() calls will always clear the cached attributes during the
  nfs_lookup() prior to nfs_open() in the !NMODIFIED case to provide CTOC.
  As a result, we can remove the conditional flushing of the attribute
  cache from nfs_open().

Modified:
  stable/8/sys/nfsclient/nfs_vnops.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/nfsclient/nfs_vnops.c
==============================================================================
--- stable/8/sys/nfsclient/nfs_vnops.c	Mon Jul 26 18:33:33 2010	(r210511)
+++ stable/8/sys/nfsclient/nfs_vnops.c	Mon Jul 26 18:54:56 2010	(r210512)
@@ -538,15 +538,6 @@ nfs_open(struct vop_open_args *ap)
 		np->n_mtime = vattr.va_mtime;
 		mtx_unlock(&np->n_mtx);
 	} else {
-		struct thread *td = curthread;
-
-		if (np->n_ac_ts_syscalls != td->td_syscalls ||
-		    np->n_ac_ts_tid != td->td_tid || 
-		    td->td_proc == NULL ||
-		    np->n_ac_ts_pid != td->td_proc->p_pid) {
-			np->n_attrstamp = 0;
-			KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
-		}
 		mtx_unlock(&np->n_mtx);						
 		error = VOP_GETATTR(vp, &vattr, ap->a_cred);
 		if (error)
@@ -1123,6 +1114,20 @@ nfs_lookup(struct vop_lookup_args *ap)
 			return (error);
 		}
 		newvp = NFSTOV(np);
+
+		/*
+		 * Flush the attribute cache when opening a leaf node
+		 * to ensure that fresh attributes are fetched in
+		 * nfs_open() if we are unable to fetch attributes
+		 * from the LOOKUP reply.
+		 */
+		if ((flags & (ISLASTCN | ISOPEN)) == (ISLASTCN | ISOPEN) &&
+		    !(np->n_flag & NMODIFIED)) {
+			mtx_lock(&np->n_mtx);
+			np->n_attrstamp = 0;
+			KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(newvp);
+			mtx_unlock(&np->n_mtx);
+		}
 	}
 	if (v3) {
 		nfsm_postop_attr(newvp, attrflag);



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