Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Dec 2004 23:20:24 -0800
From:      Alfred Perlstein <alfred@freebsd.org>
To:        Poul-Henning Kamp <phk@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
Message-ID:  <20041207072024.GE20783@elvis.mu.org>
In-Reply-To: <200412060831.iB68VX5t058248@repoman.freebsd.org>
References:  <200412060831.iB68VX5t058248@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
* Poul-Henning Kamp <phk@FreeBSD.org> [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



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