Date: Tue, 21 Mar 2006 19:03:20 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 93725 for review Message-ID: <200603211903.k2LJ3K5x073749@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603211903.k2LJ3K5x073749>