From owner-cvs-all@FreeBSD.ORG Tue Dec 7 07:20:26 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E694C16A4CE; Tue, 7 Dec 2004 07:20:26 +0000 (GMT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8753343D39; Tue, 7 Dec 2004 07:20:24 +0000 (GMT) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 777D65CAEA; Mon, 6 Dec 2004 23:20:24 -0800 (PST) Date: Mon, 6 Dec 2004 23:20:24 -0800 From: Alfred Perlstein To: Poul-Henning Kamp Message-ID: <20041207072024.GE20783@elvis.mu.org> References: <200412060831.iB68VX5t058248@repoman.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200412060831.iB68VX5t058248@repoman.freebsd.org> User-Agent: Mutt/1.4.2.1i cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/nfsclient nfs.h nfs_lock.c nfs_lock.h nfs_nfsiod.c nfs_subs.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Dec 2004 07:20:27 -0000 * Poul-Henning Kamp [041206 00:31] wrote: > phk 2004-12-06 08:31:33 UTC > > FreeBSD src repository > > Modified files: > sys/nfsclient nfs.h nfs_lock.c nfs_lock.h nfs_nfsiod.c > nfs_subs.c > Log: > For reasons unknown, the nfs locking code used a fifo to send requests to > userland and a dedicated system call to get replies. Cool, thank you. The reason it did this was that it was the code I got from BSD/OS. :) Anyhow, I think you can now commit this fix for filedesc locking: Basically, others should be able to use the fdesc_mtx to make sure that a fdesc wasn't going to disapear out from under you and also that if you grabbed one, it would be locked valid, but because of the nfs fifo there was a race that had to be in, which was we didn't NULL out the fdesc pointer until too late. Sorry if that's not so clear, but here's what should be done if it's safe now. :) Index: kern_descrip.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_descrip.c,v retrieving revision 1.265 diff -u -r1.265 kern_descrip.c --- kern_descrip.c 3 Dec 2004 21:29:25 -0000 1.265 +++ kern_descrip.c 7 Dec 2004 07:15:37 -0000 @@ -1570,17 +1570,17 @@ * safely assume it will not change out from under us. */ FILEDESC_UNLOCK(fdp); + + mtx_lock(&fdesc_mtx); + td->td_proc->p_fd = NULL; + mtx_unlock(&fdesc_mtx); + fpp = fdp->fd_ofiles; for (i = fdp->fd_lastfile; i-- >= 0; fpp++) { if (*fpp) (void) closef(*fpp, td); } - /* XXX This should happen earlier. */ - mtx_lock(&fdesc_mtx); - td->td_proc->p_fd = NULL; - mtx_unlock(&fdesc_mtx); - if (fdp->fd_nfiles > NDFILE) FREE(fdp->fd_ofiles, M_FILEDESC); if (NDSLOTS(fdp->fd_nfiles) > NDSLOTS(NDFILE)) -- - Alfred Perlstein - Research Engineering Development Inc. - email: bright@mu.org cell: 408-480-4684