Date: Thu, 15 Mar 2007 22:20:51 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 115949 for review Message-ID: <200703152220.l2FMKpIw085615@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=115949 Change 115949 by jhb@jhb_mutex on 2007/03/15 22:20:40 Remove a bunch of crap to handle a race that is already handled. If we hit this race, then the file will get cleaned up when the fdrop() at the end calls closef(). This is how all the other places that create file descriptors handle this race. Affected files ... .. //depot/projects/smpng/sys/kern/vfs_syscalls.c#124 edit Differences ... ==== //depot/projects/smpng/sys/kern/vfs_syscalls.c#124 (text+ko) ==== @@ -1025,31 +1025,8 @@ NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; - /* - * There should be 2 references on the file, one from the descriptor - * table, and one for us. - * - * Handle the case where someone closed the file (via its file - * descriptor) while we were blocked. The end result should look - * like opening the file succeeded but it was immediately closed. - * We call vn_close() manually because we haven't yet hooked up - * the various 'struct file' fields. - */ - FILEDESC_LOCK(fdp); + FILEDESC_LOCK_FAST(fdp); FILE_LOCK(fp); - if (fp->f_count == 1) { - mp = vp->v_mount; - KASSERT(fdp->fd_ofiles[indx] != fp, - ("Open file descriptor lost all refs")); - FILE_UNLOCK(fp); - FILEDESC_UNLOCK(fdp); - VOP_UNLOCK(vp, 0, td); - vn_close(vp, flags & FMASK, fp->f_cred, td); - VFS_UNLOCK_GIANT(vfslocked); - fdrop(fp, td); - td->td_retval[0] = indx; - return (0); - } fp->f_vnode = vp; if (fp->f_data == NULL) fp->f_data = vp; @@ -1059,7 +1036,7 @@ fp->f_seqcount = 1; fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE); FILE_UNLOCK(fp); - FILEDESC_UNLOCK(fdp); + FILEDESC_UNLOCK_FAST(fdp); VOP_UNLOCK(vp, 0, td); if (flags & (O_EXLOCK | O_SHLOCK)) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703152220.l2FMKpIw085615>