From owner-p4-projects@FreeBSD.ORG Tue Mar 21 19:03:30 2006 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 D911116A448; Tue, 21 Mar 2006 19:03:29 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6502616A427 for ; Tue, 21 Mar 2006 19:03:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0CF843D76 for ; Tue, 21 Mar 2006 19:03:20 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2LJ3KYf073752 for ; Tue, 21 Mar 2006 19:03:20 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2LJ3K5x073749 for perforce@freebsd.org; Tue, 21 Mar 2006 19:03:20 GMT (envelope-from jhb@freebsd.org) Date: Tue, 21 Mar 2006 19:03:20 GMT Message-Id: <200603211903.k2LJ3K5x073749@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 93725 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: Tue, 21 Mar 2006 19:03:30 -0000 http://perforce.freebsd.org/chv.cgi?CH=93725 Change 93725 by jhb@jhb_slimer on 2006/03/21 19:02:21 Change vn_open() to honor MPSAFE flag in nameidata rather than using fdidx != -1. Affected files ... .. //depot/projects/smpng/sys/kern/kern_sig.c#122 edit .. //depot/projects/smpng/sys/kern/vfs_syscalls.c#101 edit .. //depot/projects/smpng/sys/kern/vfs_vnops.c#68 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_sig.c#122 (text+ko) ==== @@ -3093,7 +3093,7 @@ name = expand_name(p->p_comm, td->td_ucred->cr_uid, p->p_pid); if (name == NULL) return (EINVAL); - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td); + NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, name, td); flags = O_CREAT | FWRITE | O_NOFOLLOW; error = vn_open(&nd, &flags, S_IRUSR | S_IWUSR, -1); free(name, M_TEMP); ==== //depot/projects/smpng/sys/kern/vfs_syscalls.c#101 (text+ko) ==== @@ -1005,7 +1005,7 @@ /* An extra reference on `nfp' has been held for us by falloc(). */ fp = nfp; cmode = ((mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT; - NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, td); + NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, path, td); td->td_dupfd = -1; /* XXX check for fdopen */ error = vn_open(&nd, &flags, cmode, indx); if (error) { ==== //depot/projects/smpng/sys/kern/vfs_vnops.c#68 (text+ko) ==== @@ -111,8 +111,9 @@ struct vattr vat; struct vattr *vap = &vat; int mode, fmode, error; - int vfslocked; + int vfslocked, mpsafe; + mpsafe = ndp->ni_cnd.cn_flags & MPSAFE; restart: vfslocked = 0; fmode = *flagp; @@ -125,8 +126,9 @@ bwillwrite(); if ((error = namei(ndp)) != 0) return (error); - vfslocked = (ndp->ni_cnd.cn_flags & GIANTHELD) != 0; - ndp->ni_cnd.cn_flags &= ~MPSAFE; + vfslocked = NDHASGIANT(ndp); + if (!mpsafe) + ndp->ni_cnd.cn_flags &= ~MPSAFE; if (ndp->ni_vp == NULL) { VATTR_NULL(vap); vap->va_type = VREG; @@ -182,8 +184,9 @@ LOCKSHARED | LOCKLEAF | MPSAFE | AUDITVNODE1; if ((error = namei(ndp)) != 0) return (error); - ndp->ni_cnd.cn_flags &= ~MPSAFE; - vfslocked = (ndp->ni_cnd.cn_flags & GIANTHELD) != 0; + if (!mpsafe) + ndp->ni_cnd.cn_flags &= ~MPSAFE; + vfslocked = NDHASGIANT(ndp); vp = ndp->ni_vp; } if (vp->v_type == VLNK) { @@ -230,7 +233,7 @@ vp->v_writecount++; *flagp = fmode; ASSERT_VOP_LOCKED(vp, "vn_open_cred"); - if (fdidx == -1) + if (!mpsafe) VFS_UNLOCK_GIANT(vfslocked); return (0); bad: