Index: sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c =================================================================== --- sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c +++ sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c @@ -1324,7 +1324,6 @@ cnp->cn_flags = ISLASTCN | SAVENAME; cnp->cn_lkflags = LK_EXCLUSIVE | LK_RETRY; cnp->cn_cred = kcred; - cnp->cn_thread = curthread; if (zfsvfs->z_use_namecache && !zfsvfs->z_replay) { struct vop_lookup_args a; @@ -4579,7 +4578,7 @@ strlcpy(nm, cnp->cn_nameptr, MIN(cnp->cn_namelen + 1, sizeof (nm))); return (zfs_lookup(ap->a_dvp, nm, ap->a_vpp, cnp, cnp->cn_nameiop, - cnp->cn_cred, cnp->cn_thread, 0, cached)); + cnp->cn_cred, curthread, 0, cached)); } static int Index: sys/fs/autofs/autofs_vnops.c =================================================================== --- sys/fs/autofs/autofs_vnops.c +++ sys/fs/autofs/autofs_vnops.c @@ -250,7 +250,7 @@ } if (autofs_cached(anp, cnp->cn_nameptr, cnp->cn_namelen) == false && - autofs_ignore_thread(cnp->cn_thread) == false) { + autofs_ignore_thread(curthread) == false) { error = autofs_trigger_vn(dvp, cnp->cn_nameptr, cnp->cn_namelen, &newvp); if (error != 0) Index: sys/fs/devfs/devfs_vnops.c =================================================================== --- sys/fs/devfs/devfs_vnops.c +++ sys/fs/devfs/devfs_vnops.c @@ -1044,11 +1044,11 @@ int error, flags, nameiop, dvplocked; char specname[SPECNAMELEN + 1], *pname; + td = curthread; cnp = ap->a_cnp; vpp = ap->a_vpp; dvp = ap->a_dvp; pname = cnp->cn_nameptr; - td = cnp->cn_thread; flags = cnp->cn_flags; nameiop = cnp->cn_nameiop; mp = dvp->v_mount; Index: sys/fs/ext2fs/ext2_lookup.c =================================================================== --- sys/fs/ext2fs/ext2_lookup.c +++ sys/fs/ext2fs/ext2_lookup.c @@ -492,7 +492,7 @@ * Access for write is interpreted as allowing * creation of files in the directory. */ - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, curthread)) != 0) return (error); /* * Return an indication of where the new directory @@ -571,7 +571,7 @@ /* * Write access to directory required to delete files. */ - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, curthread)) != 0) return (error); /* * Return pointer to current entry in dp->i_offset, @@ -623,7 +623,7 @@ * regular file, or empty directory. */ if (nameiop == RENAME && (flags & ISLASTCN)) { - if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0) + if ((error = VOP_ACCESS(vdp, VWRITE, cred, curthread)) != 0) return (error); /* * Careful about locking second inode. @@ -992,7 +992,7 @@ error = ext2_add_entry(dvp, &newdir); if (!error && dp->i_endoff && dp->i_endoff < dp->i_size) error = ext2_truncate(dvp, (off_t)dp->i_endoff, IO_SYNC, - cnp->cn_cred, cnp->cn_thread); + cnp->cn_cred, curthread); return (error); } Index: sys/fs/ext2fs/ext2_vnops.c =================================================================== --- sys/fs/ext2fs/ext2_vnops.c +++ sys/fs/ext2fs/ext2_vnops.c @@ -906,7 +906,7 @@ * to namei, as the parent directory is unlocked by the * call to checkpath(). */ - error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); + error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, curthread); VOP_UNLOCK(fvp); if (oldparent != dp->i_number) newparent = dp->i_number; @@ -1031,7 +1031,7 @@ if (xp->i_nlink > 2) panic("ext2_rename: linked directory"); error = ext2_truncate(tvp, (off_t)0, IO_SYNC, - tcnp->cn_cred, tcnp->cn_thread); + tcnp->cn_cred, curthread); xp->i_nlink = 0; } xp->i_flag |= IN_CHANGE; @@ -1424,7 +1424,7 @@ #ifdef UFS_ACL if (dvp->v_mount->mnt_flag & MNT_ACLS) { error = ext2_do_posix1e_acl_inheritance_dir(dvp, tvp, dmode, - cnp->cn_cred, cnp->cn_thread); + cnp->cn_cred, curthread); if (error) goto bad; } @@ -1504,7 +1504,7 @@ */ ip->i_nlink = 0; error = ext2_truncate(vp, (off_t)0, IO_SYNC, cnp->cn_cred, - cnp->cn_thread); + curthread); cache_purge(ITOV(ip)); if (vn_lock(dvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) { VOP_UNLOCK(vp); @@ -2004,7 +2004,7 @@ #ifdef UFS_ACL if (dvp->v_mount->mnt_flag & MNT_ACLS) { error = ext2_do_posix1e_acl_inheritance_file(dvp, tvp, mode, - cnp->cn_cred, cnp->cn_thread); + cnp->cn_cred, curthread); if (error) goto bad; } Index: sys/fs/fdescfs/fdesc_vnops.c =================================================================== --- sys/fs/fdescfs/fdesc_vnops.c +++ sys/fs/fdescfs/fdesc_vnops.c @@ -293,7 +293,7 @@ struct vnode *dvp = ap->a_dvp; struct componentname *cnp = ap->a_cnp; char *pname = cnp->cn_nameptr; - struct thread *td = cnp->cn_thread; + struct thread *td = curthread; struct file *fp; struct fdesc_get_ino_args arg; int nlen = cnp->cn_namelen; Index: sys/fs/fuse/fuse_internal.c =================================================================== --- sys/fs/fuse/fuse_internal.c +++ sys/fs/fuse/fuse_internal.c @@ -477,7 +477,6 @@ cn.cn_nameiop = LOOKUP; cn.cn_flags = 0; /* !MAKEENTRY means free cached entry */ - cn.cn_thread = curthread; cn.cn_cred = curthread->td_ucred; cn.cn_lkflags = LK_SHARED; cn.cn_pnbuf = NULL; @@ -729,7 +728,7 @@ int err = 0; fdisp_init(&fdi, cnp->cn_namelen + 1); - fdisp_make_vp(&fdi, op, dvp, cnp->cn_thread, cnp->cn_cred); + fdisp_make_vp(&fdi, op, dvp, curthread, cnp->cn_cred); memcpy(fdi.indata, cnp->cn_nameptr, cnp->cn_namelen); ((char *)fdi.indata)[cnp->cn_namelen] = '\0'; @@ -781,7 +780,7 @@ int err = 0; fdisp_init(&fdi, sizeof(*fri) + fcnp->cn_namelen + tcnp->cn_namelen + 2); - fdisp_make_vp(&fdi, FUSE_RENAME, fdvp, tcnp->cn_thread, tcnp->cn_cred); + fdisp_make_vp(&fdi, FUSE_RENAME, fdvp, curthread, tcnp->cn_cred); fri = fdi.indata; fri->newdir = VTOI(tdvp); @@ -813,7 +812,7 @@ { fdip->iosize = bufsize + cnp->cn_namelen + 1; - fdisp_make(fdip, op, mp, dnid, cnp->cn_thread, cnp->cn_cred); + fdisp_make(fdip, op, mp, dnid, curthread, cnp->cn_cred); memcpy(fdip->indata, buf, bufsize); memcpy((char *)fdip->indata + bufsize, cnp->cn_nameptr, cnp->cn_namelen); ((char *)fdip->indata)[bufsize + cnp->cn_namelen] = '\0'; @@ -840,7 +839,7 @@ } err = fuse_vnode_get(mp, feo, feo->nodeid, dvp, vpp, cnp, vtyp); if (err) { - fuse_internal_forget_send(mp, cnp->cn_thread, cnp->cn_cred, + fuse_internal_forget_send(mp, curthread, cnp->cn_cred, feo->nodeid, 1); return err; } Index: sys/fs/fuse/fuse_node.c =================================================================== --- sys/fs/fuse/fuse_node.c +++ sys/fs/fuse/fuse_node.c @@ -286,7 +286,7 @@ struct componentname *cnp, enum vtype vtyp) { - struct thread *td = (cnp != NULL ? cnp->cn_thread : curthread); + struct thread *td = curthread; /* * feo should only be NULL for the root directory, which (when libfuse * is used) always has generation 0 Index: sys/fs/fuse/fuse_vnops.c =================================================================== --- sys/fs/fuse/fuse_vnops.c +++ sys/fs/fuse/fuse_vnops.c @@ -788,7 +788,7 @@ struct vnode **vpp = ap->a_vpp; struct componentname *cnp = ap->a_cnp; struct vattr *vap = ap->a_vap; - struct thread *td = cnp->cn_thread; + struct thread *td = curthread; struct ucred *cred = cnp->cn_cred; struct fuse_data *data; @@ -1203,7 +1203,7 @@ struct vnode *dvp = ap->a_dvp; struct vnode **vpp = ap->a_vpp; struct componentname *cnp = ap->a_cnp; - struct thread *td = cnp->cn_thread; + struct thread *td = curthread; struct ucred *cred = cnp->cn_cred; int nameiop = cnp->cn_nameiop; @@ -1849,7 +1849,7 @@ data = fuse_get_mpdata(vnode_mount(tdvp)); if (data->dataflags & FSESS_DEFAULT_PERMISSIONS && isdir && newparent) { err = fuse_internal_access(fvp, VWRITE, - tcnp->cn_thread, tcnp->cn_cred); + curthread, tcnp->cn_cred); if (err) goto out; } Index: sys/fs/msdosfs/msdosfs_lookup.c =================================================================== --- sys/fs/msdosfs/msdosfs_lookup.c +++ sys/fs/msdosfs/msdosfs_lookup.c @@ -381,7 +381,7 @@ * Access for write is interpreted as allowing * creation of files in the directory. */ - error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_thread); + error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, curthread); if (error) return (error); /* @@ -485,7 +485,7 @@ /* * Write access to directory required to delete files. */ - error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_thread); + error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, curthread); if (error) return (error); @@ -515,7 +515,7 @@ if (blkoff == MSDOSFSROOT_OFS) return (EBUSY); - error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_thread); + error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, curthread); if (error) return (error); Index: sys/fs/msdosfs/msdosfs_vnops.c =================================================================== --- sys/fs/msdosfs/msdosfs_vnops.c +++ sys/fs/msdosfs/msdosfs_vnops.c @@ -1109,7 +1109,7 @@ * to namei, as the parent directory is unlocked by the * call to doscheckpath(). */ - error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); + error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, curthread); if (fdip->de_StartCluster != tdip->de_StartCluster) newparent = true; if (doingdirectory && newparent) { Index: sys/fs/nfsclient/nfs_clvnops.c =================================================================== --- sys/fs/nfsclient/nfs_clvnops.c +++ sys/fs/nfsclient/nfs_clvnops.c @@ -1165,7 +1165,7 @@ struct nfsmount *nmp; struct nfsnode *np, *newnp; int error = 0, attrflag, dattrflag, ltype, ncticks; - struct thread *td = cnp->cn_thread; + struct thread *td = curthread; struct nfsfh *nfhp; struct nfsvattr dnfsva, nfsva; struct vattr vattr; @@ -1596,17 +1596,17 @@ if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred))) return (error); error = nfsrpc_mknod(dvp, cnp->cn_nameptr, cnp->cn_namelen, vap, - rdev, vap->va_type, cnp->cn_cred, cnp->cn_thread, &dnfsva, + rdev, vap->va_type, cnp->cn_cred, curthread, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, NULL); if (!error) { if (!nfhp) (void) nfsrpc_lookup(dvp, cnp->cn_nameptr, - cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, + cnp->cn_namelen, cnp->cn_cred, curthread, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, NULL, 0); if (nfhp) error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, - cnp->cn_thread, &np, NULL, LK_EXCLUSIVE); + curthread, &np, NULL, LK_EXCLUSIVE); } if (dattrflag) (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); @@ -1622,7 +1622,7 @@ if (!error) { *vpp = newvp; } else if (NFS_ISV4(dvp)) { - error = nfscl_maperr(cnp->cn_thread, error, vap->va_uid, + error = nfscl_maperr(curthread, error, vap->va_uid, vap->va_gid); } dnp = VTONFS(dvp); @@ -1712,17 +1712,17 @@ cverf = nfs_get_cverf(); error = nfsrpc_create(dvp, cnp->cn_nameptr, cnp->cn_namelen, - vap, cverf, fmode, cnp->cn_cred, cnp->cn_thread, &dnfsva, &nfsva, + vap, cverf, fmode, cnp->cn_cred, curthread, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, NULL); if (!error) { if (nfhp == NULL) (void) nfsrpc_lookup(dvp, cnp->cn_nameptr, - cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread, + cnp->cn_namelen, cnp->cn_cred, curthread, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, NULL, 0); if (nfhp != NULL) error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, - cnp->cn_thread, &np, NULL, LK_EXCLUSIVE); + curthread, &np, NULL, LK_EXCLUSIVE); } if (dattrflag) (void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1); @@ -1730,7 +1730,7 @@ newvp = NFSTOV(np); if (attrflag == 0) error = nfsrpc_getattr(newvp, cnp->cn_cred, - cnp->cn_thread, &nfsva, NULL); + curthread, &nfsva, NULL); if (error == 0) error = nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL, 0, 1); @@ -1748,14 +1748,14 @@ } else if (NFS_ISV34(dvp) && (fmode & O_EXCL)) { if (nfscl_checksattr(vap, &nfsva)) { error = nfsrpc_setattr(newvp, vap, NULL, cnp->cn_cred, - cnp->cn_thread, &nfsva, &attrflag, NULL); + curthread, &nfsva, &attrflag, NULL); if (error && (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL)) { /* try again without setting uid/gid */ vap->va_uid = (uid_t)VNOVAL; vap->va_gid = (uid_t)VNOVAL; error = nfsrpc_setattr(newvp, vap, NULL, - cnp->cn_cred, cnp->cn_thread, &nfsva, + cnp->cn_cred, curthread, &nfsva, &attrflag, NULL); } if (attrflag) @@ -1776,7 +1776,7 @@ } *ap->a_vpp = newvp; } else if (NFS_ISV4(dvp)) { - error = nfscl_maperr(cnp->cn_thread, error, vap->va_uid, + error = nfscl_maperr(curthread, error, vap->va_uid, vap->va_gid); } NFSLOCKNODE(dnp); @@ -1829,11 +1829,11 @@ * throw away biocache buffers, mainly to avoid * unnecessary delayed writes later. */ - error = ncl_vinvalbuf(vp, 0, cnp->cn_thread, 1); + error = ncl_vinvalbuf(vp, 0, curthread, 1); if (error != EINTR && error != EIO) /* Do the rpc */ error = nfs_removerpc(dvp, vp, cnp->cn_nameptr, - cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread); + cnp->cn_namelen, cnp->cn_cred, curthread); /* * Kludge City: If the first reply to the remove rpc is lost.. * the reply to the retransmitted request will be ENOENT @@ -1953,10 +1953,10 @@ * that was written back to our cache earlier. Not checking for * this condition can result in potential (silent) data loss. */ - error = VOP_FSYNC(fvp, MNT_WAIT, fcnp->cn_thread); + error = VOP_FSYNC(fvp, MNT_WAIT, curthread); NFSVOPUNLOCK(fvp); if (!error && tvp) - error = VOP_FSYNC(tvp, MNT_WAIT, tcnp->cn_thread); + error = VOP_FSYNC(tvp, MNT_WAIT, curthread); if (error) goto out; @@ -1973,7 +1973,7 @@ error = nfs_renamerpc(fdvp, fvp, fcnp->cn_nameptr, fcnp->cn_namelen, tdvp, tvp, tcnp->cn_nameptr, tcnp->cn_namelen, tcnp->cn_cred, - tcnp->cn_thread); + curthread); if (error == 0 && NFS_ISV4(tdvp)) { /* @@ -2050,7 +2050,7 @@ return (nfs_renamerpc(sdvp, svp, scnp->cn_nameptr, scnp->cn_namelen, sdvp, NULL, sp->s_name, sp->s_namlen, scnp->cn_cred, - scnp->cn_thread)); + curthread)); } /* @@ -2112,10 +2112,10 @@ * doesn't get "out of sync" with the server. * XXX There should be a better way! */ - VOP_FSYNC(vp, MNT_WAIT, cnp->cn_thread); + VOP_FSYNC(vp, MNT_WAIT, curthread); error = nfsrpc_link(tdvp, vp, cnp->cn_nameptr, cnp->cn_namelen, - cnp->cn_cred, cnp->cn_thread, &dnfsva, &nfsva, &attrflag, + cnp->cn_cred, curthread, &dnfsva, &nfsva, &attrflag, &dattrflag, NULL); tdnp = VTONFS(tdvp); NFSLOCKNODE(tdnp); @@ -2152,7 +2152,7 @@ "the directory as the new link\n"); } if (error && NFS_ISV4(vp)) - error = nfscl_maperr(cnp->cn_thread, error, (uid_t)0, + error = nfscl_maperr(curthread, error, (uid_t)0, (gid_t)0); return (error); } @@ -2174,10 +2174,10 @@ vap->va_type = VLNK; error = nfsrpc_symlink(dvp, cnp->cn_nameptr, cnp->cn_namelen, - ap->a_target, vap, cnp->cn_cred, cnp->cn_thread, &dnfsva, + ap->a_target, vap, cnp->cn_cred, curthread, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, NULL); if (nfhp) { - ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread, + ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, curthread, &np, NULL, LK_EXCLUSIVE); if (!ret) newvp = NFSTOV(np); @@ -2195,7 +2195,7 @@ * have to do a lookup in order to obtain a newvp to return. */ error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen, - cnp->cn_cred, cnp->cn_thread, &np); + cnp->cn_cred, curthread, &np); if (!error) newvp = NFSTOV(np); } @@ -2203,7 +2203,7 @@ if (newvp) vput(newvp); if (NFS_ISV4(dvp)) - error = nfscl_maperr(cnp->cn_thread, error, + error = nfscl_maperr(curthread, error, vap->va_uid, vap->va_gid); } else { *ap->a_vpp = newvp; @@ -2258,7 +2258,7 @@ return (error); vap->va_type = VDIR; error = nfsrpc_mkdir(dvp, cnp->cn_nameptr, cnp->cn_namelen, - vap, cnp->cn_cred, cnp->cn_thread, &dnfsva, &nfsva, &nfhp, + vap, cnp->cn_cred, curthread, &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag, NULL); dnp = VTONFS(dvp); NFSLOCKNODE(dnp); @@ -2272,7 +2272,7 @@ KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp); } if (nfhp) { - ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread, + ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, curthread, &np, NULL, LK_EXCLUSIVE); if (!ret) { newvp = NFSTOV(np); @@ -2284,7 +2284,7 @@ } if (!error && newvp == NULL) { error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen, - cnp->cn_cred, cnp->cn_thread, &np); + cnp->cn_cred, curthread, &np); if (!error) { newvp = NFSTOV(np); if (newvp->v_type != VDIR) @@ -2295,7 +2295,7 @@ if (newvp) vput(newvp); if (NFS_ISV4(dvp)) - error = nfscl_maperr(cnp->cn_thread, error, + error = nfscl_maperr(curthread, error, vap->va_uid, vap->va_gid); } else { /* @@ -2336,7 +2336,7 @@ if (dvp == vp) return (EINVAL); error = nfsrpc_rmdir(dvp, cnp->cn_nameptr, cnp->cn_namelen, - cnp->cn_cred, cnp->cn_thread, &dnfsva, &dattrflag, NULL); + cnp->cn_cred, curthread, &dnfsva, &dattrflag, NULL); dnp = VTONFS(dvp); NFSLOCKNODE(dnp); dnp->n_flag |= NMODIFIED; @@ -2352,7 +2352,7 @@ cache_purge(dvp); cache_purge(vp); if (error && NFS_ISV4(dvp)) - error = nfscl_maperr(cnp->cn_thread, error, (uid_t)0, + error = nfscl_maperr(curthread, error, (uid_t)0, (gid_t)0); /* * Kludge: Map ENOENT => 0 assuming that you have a reply to a retry. @@ -2591,14 +2591,14 @@ * The name is now changed to .nfs...4, where ticks is * CPU ticks since boot. */ - pid = cnp->cn_thread->td_proc->p_pid; + pid = curthread->td_proc->p_pid; lticks = (unsigned int)ticks; for ( ; ; ) { sp->s_namlen = sprintf(sp->s_name, ".nfs.%08x.%04x4.4", lticks, pid); if (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, - cnp->cn_thread, NULL)) + curthread, NULL)) break; lticks++; } @@ -2606,7 +2606,7 @@ if (error) goto bad; error = nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred, - cnp->cn_thread, &np); + curthread, &np); np->n_sillyrename = sp; return (0); bad: Index: sys/fs/nfsserver/nfs_nfsdport.c =================================================================== --- sys/fs/nfsserver/nfs_nfsdport.c +++ sys/fs/nfsserver/nfs_nfsdport.c @@ -661,7 +661,6 @@ * because lookup() will dereference ni_startdir. */ - cnp->cn_thread = curthread; ndp->ni_startdir = dp; ndp->ni_rootdir = rootvnode; ndp->ni_topdir = NULL; @@ -2526,7 +2525,6 @@ cn.cn_nameiop = LOOKUP; cn.cn_lkflags = LK_SHARED | LK_RETRY; cn.cn_cred = nd->nd_cred; - cn.cn_thread = p; } else if (r == 0) vput(nvp); } @@ -2626,7 +2624,6 @@ LK_RETRY; cn.cn_cred = nd->nd_cred; - cn.cn_thread = p; } cn.cn_nameptr = dp->d_name; cn.cn_namelen = nlen; @@ -4183,7 +4180,6 @@ LOCKPARENT | LOCKLEAF | SAVESTART | NOCACHE); nfsvno_setpathbuf(&named, &bufp, &hashp); named.ni_cnd.cn_lkflags = LK_EXCLUSIVE; - named.ni_cnd.cn_thread = p; named.ni_cnd.cn_nameptr = bufp; if (fnamep != NULL) { strlcpy(bufp, fnamep, PNFS_FILENAME_LEN + 1); @@ -4567,7 +4563,6 @@ named.ni_cnd.cn_nameiop = DELETE; named.ni_cnd.cn_lkflags = LK_EXCLUSIVE | LK_RETRY; named.ni_cnd.cn_cred = tcred; - named.ni_cnd.cn_thread = p; named.ni_cnd.cn_flags = ISLASTCN | LOCKPARENT | LOCKLEAF | SAVENAME; nfsvno_setpathbuf(&named, &bufp, &hashp); named.ni_cnd.cn_nameptr = bufp; @@ -6341,7 +6336,6 @@ named.ni_cnd.cn_nameiop = LOOKUP; named.ni_cnd.cn_lkflags = LK_SHARED | LK_RETRY; named.ni_cnd.cn_cred = tcred; - named.ni_cnd.cn_thread = p; named.ni_cnd.cn_flags = ISLASTCN | LOCKPARENT | LOCKLEAF | SAVENAME; nfsvno_setpathbuf(&named, &bufp, &hashp); named.ni_cnd.cn_nameptr = bufp; Index: sys/fs/smbfs/smbfs_vnops.c =================================================================== --- sys/fs/smbfs/smbfs_vnops.c +++ sys/fs/smbfs/smbfs_vnops.c @@ -560,7 +560,7 @@ if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred))) return error; scred = smbfs_malloc_scred(); - smb_makescred(scred, cnp->cn_thread, cnp->cn_cred); + smb_makescred(scred, curthread, cnp->cn_cred); error = smbfs_smb_create(dnp, name, nmlen, scred); if (error) @@ -598,7 +598,7 @@ if (vp->v_type == VDIR || (np->n_flag & NOPEN) != 0 || vrefcnt(vp) != 1) return EPERM; scred = smbfs_malloc_scred(); - smb_makescred(scred, cnp->cn_thread, cnp->cn_cred); + smb_makescred(scred, curthread, cnp->cn_cred); error = smbfs_smb_delete(np, scred); if (error == 0) np->n_flag |= NGONE; @@ -652,7 +652,7 @@ return EINVAL; } scred = smbfs_malloc_scred(); - smb_makescred(scred, tcnp->cn_thread, tcnp->cn_cred); + smb_makescred(scred, curthread, tcnp->cn_cred); /* * It seems that Samba doesn't implement SMB_COM_MOVE call... */ @@ -769,7 +769,7 @@ if ((name[0] == '.') && ((len == 1) || ((len == 2) && (name[1] == '.')))) return EEXIST; scred = smbfs_malloc_scred(); - smb_makescred(scred, cnp->cn_thread, cnp->cn_cred); + smb_makescred(scred, curthread, cnp->cn_cred); error = smbfs_smb_mkdir(dnp, name, len, scred); if (error) goto out; @@ -809,7 +809,7 @@ return EINVAL; scred = smbfs_malloc_scred(); - smb_makescred(scred, cnp->cn_thread, cnp->cn_cred); + smb_makescred(scred, curthread, cnp->cn_cred); error = smbfs_smb_rmdir(np, scred); if (error == 0) np->n_flag |= NGONE; @@ -1170,7 +1170,7 @@ } */ *ap; { struct componentname *cnp = ap->a_cnp; - struct thread *td = cnp->cn_thread; + struct thread *td = curthread; struct vnode *dvp = ap->a_dvp; struct vnode **vpp = ap->a_vpp; struct vnode *vp; Index: sys/fs/tmpfs/tmpfs_vnops.c =================================================================== --- sys/fs/tmpfs/tmpfs_vnops.c +++ sys/fs/tmpfs/tmpfs_vnops.c @@ -136,7 +136,7 @@ cnp->cn_flags & DOWHITEOUT && cnp->cn_flags & ISWHITEOUT))) { error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, - cnp->cn_thread); + curthread); if (error != 0) goto out; @@ -180,7 +180,7 @@ (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) { error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, - cnp->cn_thread); + curthread); if (error != 0) goto out; @@ -192,8 +192,8 @@ if ((dnode->tn_mode & S_ISTXT) && VOP_ACCESS(dvp, VADMIN, cnp->cn_cred, - cnp->cn_thread) && VOP_ACCESS(*vpp, VADMIN, - cnp->cn_cred, cnp->cn_thread)) { + curthread) && VOP_ACCESS(*vpp, VADMIN, + cnp->cn_cred, curthread)) { error = EPERM; vput(*vpp); *vpp = NULL; Index: sys/fs/unionfs/union_subr.c =================================================================== --- sys/fs/unionfs/union_subr.c +++ sys/fs/unionfs/union_subr.c @@ -630,7 +630,6 @@ cn->cn_nameiop = nameiop; cn->cn_flags = (LOCKPARENT | LOCKLEAF | HASBUF | SAVENAME | ISLASTCN); cn->cn_lkflags = LK_EXCLUSIVE; - cn->cn_thread = td; cn->cn_cred = cnp->cn_cred; cn->cn_nameptr = cn->cn_pnbuf; @@ -975,7 +974,6 @@ nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | HASBUF | SAVENAME | ISLASTCN; nd.ni_cnd.cn_lkflags = LK_EXCLUSIVE; - nd.ni_cnd.cn_thread = td; nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameptr = nd.ni_cnd.cn_pnbuf; NDPREINIT(&nd); @@ -1250,7 +1248,6 @@ cn.cn_flags = LOCKPARENT | LOCKLEAF | SAVENAME | RDONLY | ISLASTCN; cn.cn_lkflags = LK_EXCLUSIVE; - cn.cn_thread = td; cn.cn_cred = cred; /* Index: sys/kern/uipc_mqueue.c =================================================================== --- sys/kern/uipc_mqueue.c +++ sys/kern/uipc_mqueue.c @@ -853,12 +853,12 @@ char *pname; struct thread *td; + td = curthread; cnp = ap->a_cnp; vpp = ap->a_vpp; dvp = ap->a_dvp; pname = cnp->cn_nameptr; namelen = cnp->cn_namelen; - td = cnp->cn_thread; flags = cnp->cn_flags; nameiop = cnp->cn_nameiop; pd = VTON(dvp); @@ -869,7 +869,7 @@ if (dvp->v_type != VDIR) return (ENOTDIR); - error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, cnp->cn_thread); + error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td); if (error) return (error); Index: sys/kern/vfs_cache.c =================================================================== --- sys/kern/vfs_cache.c +++ sys/kern/vfs_cache.c @@ -4219,7 +4219,7 @@ ndp = fpl->ndp; cnp = fpl->cnp; - td = cnp->cn_thread; + td = curthread; if (!atomic_load_char(&cache_fast_lookup_enabled)) { cache_fpl_aborted_early(fpl); @@ -5984,7 +5984,6 @@ fpl.ndp = ndp; fpl.cnp = cnp = &ndp->ni_cnd; MPASS(ndp->ni_lcf == 0); - MPASS(curthread == cnp->cn_thread); KASSERT ((cnp->cn_flags & CACHE_FPL_INTERNAL_CN_FLAGS) == 0, ("%s: internal flags found in cn_flags %" PRIx64, __func__, cnp->cn_flags)); Index: sys/kern/vfs_lookup.c =================================================================== --- sys/kern/vfs_lookup.c +++ sys/kern/vfs_lookup.c @@ -294,7 +294,7 @@ bool startdir_used; cnp = &ndp->ni_cnd; - td = cnp->cn_thread; + td = curthread; startdir_used = false; *pwdp = NULL; @@ -552,10 +552,8 @@ enum cache_fpl_status status; cnp = &ndp->ni_cnd; - td = cnp->cn_thread; + td = curthread; #ifdef INVARIANTS - KASSERT(cnp->cn_thread == curthread, - ("namei not using curthread")); KASSERT((ndp->ni_debugflags & NAMEI_DBG_CALLED) == 0, ("%s: repeated call to namei without NDREINIT", __func__)); KASSERT(ndp->ni_debugflags == NAMEI_DBG_INITED, @@ -581,7 +579,7 @@ */ cnp->cn_origflags = cnp->cn_flags; #endif - ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_thread->td_ucred; + ndp->ni_cnd.cn_cred = td->td_ucred; KASSERT(ndp->ni_resflags == 0, ("%s: garbage in ni_resflags: %x\n", __func__, ndp->ni_resflags)); KASSERT(cnp->cn_cred && td->td_proc, ("namei: bad cred/proc")); @@ -1096,7 +1094,7 @@ */ unionlookup: #ifdef MAC - error = mac_vnode_check_lookup(cnp->cn_thread->td_ucred, dp, cnp); + error = mac_vnode_check_lookup(cnp->cn_cred, dp, cnp); if (error) goto bad; #endif Index: sys/kern/vfs_subr.c =================================================================== --- sys/kern/vfs_subr.c +++ sys/kern/vfs_subr.c @@ -6821,7 +6821,7 @@ return (0); } - return (VOP_ACCESS(vp, VEXEC, cnp->cn_cred, cnp->cn_thread)); + return (VOP_ACCESS(vp, VEXEC, cnp->cn_cred, curthread)); } /* Index: sys/kern/vfs_vnops.c =================================================================== --- sys/kern/vfs_vnops.c +++ sys/kern/vfs_vnops.c @@ -190,7 +190,7 @@ int vn_open(struct nameidata *ndp, int *flagp, int cmode, struct file *fp) { - struct thread *td = ndp->ni_cnd.cn_thread; + struct thread *td = curthread; return (vn_open_cred(ndp, flagp, cmode, 0, td->td_ucred, fp)); } @@ -230,7 +230,6 @@ { struct vnode *vp; struct mount *mp; - struct thread *td = ndp->ni_cnd.cn_thread; struct vattr vat; struct vattr *vap = &vat; int fmode, error; @@ -332,7 +331,7 @@ return (error); vp = ndp->ni_vp; } - error = vn_open_vnode(vp, fmode, cred, td, fp); + error = vn_open_vnode(vp, fmode, cred, curthread, fp); if (first_open) { VI_LOCK(vp); vp->v_iflag &= ~VI_FOPENING; Index: sys/sys/namei.h =================================================================== --- sys/sys/namei.h +++ sys/sys/namei.h @@ -49,7 +49,6 @@ */ u_int64_t cn_origflags; /* flags to namei */ u_int64_t cn_flags; /* flags to namei */ - struct thread *cn_thread;/* thread requesting lookup */ struct ucred *cn_cred; /* credentials */ enum nameiop cn_nameiop; /* namei operation */ int cn_lkflags; /* Lock flags LK_EXCLUSIVE or LK_SHARED */ @@ -262,7 +261,6 @@ _ndp->ni_startdir = startdir; \ _ndp->ni_resflags = 0; \ filecaps_init(&_ndp->ni_filecaps); \ - _ndp->ni_cnd.cn_thread = td; \ _ndp->ni_rightsneeded = _rightsp; \ } while (0) Index: sys/ufs/ffs/ffs_softdep.c =================================================================== --- sys/ufs/ffs/ffs_softdep.c +++ sys/ufs/ffs/ffs_softdep.c @@ -2975,7 +2975,6 @@ bzero(&cnp, sizeof(cnp)); cnp.cn_nameiop = LOOKUP; cnp.cn_flags = ISLASTCN; - cnp.cn_thread = curthread; cnp.cn_cred = curthread->td_ucred; cnp.cn_pnbuf = SUJ_FILE; cnp.cn_nameptr = SUJ_FILE; Index: sys/ufs/ufs/ufs_extattr.c =================================================================== --- sys/ufs/ufs/ufs_extattr.c +++ sys/ufs/ufs/ufs_extattr.c @@ -263,7 +263,6 @@ if (lockparent == UE_GETDIR_LOCKPARENT) cnp.cn_flags |= LOCKPARENT; cnp.cn_lkflags = LK_EXCLUSIVE; - cnp.cn_thread = td; cnp.cn_cred = td->td_ucred; cnp.cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); cnp.cn_nameptr = cnp.cn_pnbuf; Index: sys/ufs/ufs/ufs_lookup.c =================================================================== --- sys/ufs/ufs/ufs_lookup.c +++ sys/ufs/ufs/ufs_lookup.c @@ -230,7 +230,7 @@ * in VFS_VGET but we could end up creating objects * that are never used. */ - vnode_create_vobject(vdp, DIP(dp, i_size), cnp->cn_thread); + vnode_create_vobject(vdp, DIP(dp, i_size), curthread); bmask = VFSTOUFS(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1; @@ -486,9 +486,9 @@ * XXX: Fix the comment above. */ if (flags & WILLBEDIR) - error = VOP_ACCESSX(vdp, VWRITE | VAPPEND, cred, cnp->cn_thread); + error = VOP_ACCESSX(vdp, VWRITE | VAPPEND, cred, curthread); else - error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread); + error = VOP_ACCESS(vdp, VWRITE, cred, curthread); if (error) return (error); /* @@ -601,7 +601,7 @@ if ((error = VFS_VGET(vdp->v_mount, ino, LK_EXCLUSIVE, &tdp)) != 0) return (error); - error = ufs_delete_denied(vdp, tdp, cred, cnp->cn_thread); + error = ufs_delete_denied(vdp, tdp, cred, curthread); if (error) { vput(tdp); return (error); @@ -625,9 +625,9 @@ */ if (nameiop == RENAME && (flags & ISLASTCN)) { if (flags & WILLBEDIR) - error = VOP_ACCESSX(vdp, VWRITE | VAPPEND, cred, cnp->cn_thread); + error = VOP_ACCESSX(vdp, VWRITE | VAPPEND, cred, curthread); else - error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread); + error = VOP_ACCESS(vdp, VWRITE, cred, curthread); if (error) return (error); /* @@ -643,7 +643,7 @@ LK_EXCLUSIVE, &tdp)) != 0) return (error); - error = ufs_delete_denied(vdp, tdp, cred, cnp->cn_thread); + error = ufs_delete_denied(vdp, tdp, cred, curthread); if (error) { vput(tdp); return (error); @@ -660,9 +660,9 @@ * of EACCESS. */ if (tdp->v_type == VDIR) - error = VOP_ACCESSX(vdp, VWRITE | VAPPEND, cred, cnp->cn_thread); + error = VOP_ACCESSX(vdp, VWRITE | VAPPEND, cred, curthread); else - error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread); + error = VOP_ACCESS(vdp, VWRITE, cred, curthread); if (error) { vput(tdp); return (error); Index: sys/ufs/ufs/ufs_vnops.c =================================================================== --- sys/ufs/ufs/ufs_vnops.c +++ sys/ufs/ufs/ufs_vnops.c @@ -1239,7 +1239,7 @@ struct vnode *nvp; struct componentname *tcnp = ap->a_tcnp; struct componentname *fcnp = ap->a_fcnp; - struct thread *td = fcnp->cn_thread; + struct thread *td = curthread; struct inode *fip, *tip, *tdp, *fdp; struct direct newdir; off_t endoff; @@ -1449,7 +1449,7 @@ * as to be able to change "..". */ if (doingdirectory && newparent) { - error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_thread); + error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, curthread); if (error) goto unlockout; @@ -2091,12 +2091,12 @@ #ifdef UFS_ACL if (dvp->v_mount->mnt_flag & MNT_ACLS) { error = ufs_do_posix1e_acl_inheritance_dir(dvp, tvp, dmode, - cnp->cn_cred, cnp->cn_thread); + cnp->cn_cred, curthread); if (error) goto bad; } else if (dvp->v_mount->mnt_flag & MNT_NFS4ACLS) { error = ufs_do_nfs4_acl_inheritance(dvp, tvp, dmode, - cnp->cn_cred, cnp->cn_thread); + cnp->cn_cred, curthread); if (error) goto bad; } @@ -2858,12 +2858,12 @@ #ifdef UFS_ACL if (dvp->v_mount->mnt_flag & MNT_ACLS) { error = ufs_do_posix1e_acl_inheritance_file(dvp, tvp, mode, - cnp->cn_cred, cnp->cn_thread); + cnp->cn_cred, curthread); if (error) goto bad; } else if (dvp->v_mount->mnt_flag & MNT_NFS4ACLS) { error = ufs_do_nfs4_acl_inheritance(dvp, tvp, mode, - cnp->cn_cred, cnp->cn_thread); + cnp->cn_cred, curthread); if (error) goto bad; }