From owner-svn-src-all@FreeBSD.ORG Sat May 12 22:20:56 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 59F9C106564A; Sat, 12 May 2012 22:20:56 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2B0E78FC14; Sat, 12 May 2012 22:20:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4CMKu9r055104; Sat, 12 May 2012 22:20:56 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4CMKt7n055102; Sat, 12 May 2012 22:20:55 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201205122220.q4CMKt7n055102@svn.freebsd.org> From: Rick Macklem Date: Sat, 12 May 2012 22:20:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235381 - head/sys/fs/nfsserver X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 May 2012 22:20:56 -0000 Author: rmacklem Date: Sat May 12 22:20:55 2012 New Revision: 235381 URL: http://svn.freebsd.org/changeset/base/235381 Log: 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. MFC after: 1 month Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdstate.c Sat May 12 21:25:48 2012 (r235380) +++ head/sys/fs/nfsserver/nfs_nfsdstate.c Sat May 12 22:20:55 2012 (r235381) @@ -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);