svn commit: r211953 - head/sys/fs/nfsserver

Rick Macklem rmacklem at FreeBSD.org
Sat Aug 28 23:50:09 UTC 2010


Author: rmacklem
Date: Sat Aug 28 23:50:09 2010
New Revision: 211953
URL: http://svn.freebsd.org/changeset/base/211953

Log:
  Add acquisition of a reference count on nfsv4root_lock to the
  nfsd_recalldelegation() function, since this function is called
  by nfsd threads when they are handling NFSv2 or NFSv3 RPCs, where
  no reference count would have been acquired.
  
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdstate.c	Sat Aug 28 22:14:24 2010	(r211952)
+++ head/sys/fs/nfsserver/nfs_nfsdstate.c	Sat Aug 28 23:50:09 2010	(r211953)
@@ -4563,6 +4563,14 @@ nfsd_recalldelegation(vnode_t vp, NFSPRO
 		return;
 
 	/*
+	 * First, get a reference on the nfsv4rootfs_lock so that an
+	 * exclusive lock cannot be acquired by another thread.
+	 */
+	NFSLOCKV4ROOTMUTEX();
+	nfsv4_getref(&nfsv4rootfs_lock, NULL, NFSV4ROOTLOCKMUTEXPTR);
+	NFSUNLOCKV4ROOTMUTEX();
+
+	/*
 	 * Now, call nfsrv_checkremove() in a loop while it returns
 	 * NFSERR_DELAY. Return upon any other error or when timed out.
 	 */
@@ -4576,11 +4584,14 @@ nfsd_recalldelegation(vnode_t vp, NFSPRO
 			    NFS_REMOVETIMEO &&
 			    ((u_int32_t)mytime.tv_sec - starttime) <
 			    100000)
-				return;
+				break;
 			/* Sleep for a short period of time */
 			(void) nfs_catnap(PZERO, 0, "nfsremove");
 		}
 	} while (error == NFSERR_DELAY);
+	NFSLOCKV4ROOTMUTEX();
+	nfsv4_relref(&nfsv4rootfs_lock);
+	NFSUNLOCKV4ROOTMUTEX();
 }
 
 APPLESTATIC void


More information about the svn-src-all mailing list