svn commit: r236887 - stable/9/sys/fs/nfsserver

Rick Macklem rmacklem at FreeBSD.org
Mon Jun 11 12:34:15 UTC 2012


Author: rmacklem
Date: Mon Jun 11 12:34:14 2012
New Revision: 236887
URL: http://svn.freebsd.org/changeset/base/236887

Log:
  MFC: r235381
  Fix two cases in the new NFS server where a tsleep() is
  used, when the code should actually protect the tested
  variable with a mutex. Since the tsleep()s had a 10sec
  timeout, the race would have only delayed the allocation
  of a new clientid for a client. The sleeps will also
  rarely occur, since having a callback in progress when
  a client acquires a new clientid, is unlikely.
  in practice, since having a callback in progress when
  a fresh clientid is being acquired by a client is unlikely.

Modified:
  stable/9/sys/fs/nfsserver/nfs_nfsdstate.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/dev/   (props changed)
  stable/9/sys/dev/e1000/   (props changed)
  stable/9/sys/dev/ixgbe/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/fs/ntfs/   (props changed)
  stable/9/sys/modules/   (props changed)

Modified: stable/9/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- stable/9/sys/fs/nfsserver/nfs_nfsdstate.c	Mon Jun 11 12:26:23 2012	(r236886)
+++ stable/9/sys/fs/nfsserver/nfs_nfsdstate.c	Mon Jun 11 12:34:14 2012	(r236887)
@@ -331,11 +331,13 @@ nfsrv_setclient(struct nfsrv_descript *n
 		 * Must wait until any outstanding callback on the old clp
 		 * completes.
 		 */
+		NFSLOCKSTATE();
 		while (clp->lc_cbref) {
 			clp->lc_flags |= LCL_WAKEUPWANTED;
-			(void) tsleep((caddr_t)clp, PZERO - 1,
+			(void)mtx_sleep(clp, NFSSTATEMUTEXPTR, PZERO - 1,
 			    "nfsd clp", 10 * hz);
 		}
+		NFSUNLOCKSTATE();
 		nfsrv_zapclient(clp, p);
 		*new_clpp = NULL;
 		goto out;
@@ -385,10 +387,13 @@ nfsrv_setclient(struct nfsrv_descript *n
 	 * Must wait until any outstanding callback on the old clp
 	 * completes.
 	 */
+	NFSLOCKSTATE();
 	while (clp->lc_cbref) {
 		clp->lc_flags |= LCL_WAKEUPWANTED;
-		(void) tsleep((caddr_t)clp, PZERO - 1, "nfsd clp", 10 * hz);
+		(void)mtx_sleep(clp, NFSSTATEMUTEXPTR, PZERO - 1, "nfsd clp",
+		    10 * hz);
 	}
+	NFSUNLOCKSTATE();
 	nfsrv_zapclient(clp, p);
 	*new_clpp = NULL;
 
@@ -3816,11 +3821,9 @@ nfsrv_docallback(struct nfsclient *clp, 
 	clp->lc_cbref--;
 	if ((clp->lc_flags & LCL_WAKEUPWANTED) && clp->lc_cbref == 0) {
 		clp->lc_flags &= ~LCL_WAKEUPWANTED;
-		NFSUNLOCKSTATE();
-		wakeup((caddr_t)clp);
-	} else {
-		NFSUNLOCKSTATE();
+		wakeup(clp);
 	}
+	NFSUNLOCKSTATE();
 
 	NFSEXITCODE(error);
 	return (error);


More information about the svn-src-stable-9 mailing list