From owner-p4-projects@FreeBSD.ORG Thu Mar 15 22:20:52 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D139916A403; Thu, 15 Mar 2007 22:20:51 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 97B1416A401 for ; Thu, 15 Mar 2007 22:20:51 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 8A55D13C484 for ; Thu, 15 Mar 2007 22:20:51 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l2FMKpwU085619 for ; Thu, 15 Mar 2007 22:20:51 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l2FMKpIw085615 for perforce@freebsd.org; Thu, 15 Mar 2007 22:20:51 GMT (envelope-from jhb@freebsd.org) Date: Thu, 15 Mar 2007 22:20:51 GMT Message-Id: <200703152220.l2FMKpIw085615@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 115949 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2007 22:20:52 -0000 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)) {