Date: Mon, 24 Aug 2020 08:57:02 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364633 - in head/sys: compat/linprocfs compat/linux dev/filemon dev/hwpmc fs/fdescfs fs/procfs kern security/audit sys vm Message-ID: <202008240857.07O8v2v3090692@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Mon Aug 24 08:57:02 2020 New Revision: 364633 URL: https://svnweb.freebsd.org/changeset/base/364633 Log: cache: drop the always curthread argument from reverse lookup routines Note VOP_VPTOCNP keeps getting it as temporary compatibility for zfs. Tested by: pho Modified: head/sys/compat/linprocfs/linprocfs.c head/sys/compat/linux/linux_getcwd.c head/sys/dev/filemon/filemon_wrapper.c head/sys/dev/hwpmc/hwpmc_mod.c head/sys/fs/fdescfs/fdesc_vnops.c head/sys/fs/procfs/procfs.c head/sys/fs/procfs/procfs_map.c head/sys/kern/kern_exec.c head/sys/kern/kern_proc.c head/sys/kern/kern_sig.c head/sys/kern/sys_process.c head/sys/kern/vfs_cache.c head/sys/kern/vfs_vnops.c head/sys/security/audit/audit_bsm_klib.c head/sys/sys/vnode.h head/sys/vm/vm_object.c Modified: head/sys/compat/linprocfs/linprocfs.c ============================================================================== --- head/sys/compat/linprocfs/linprocfs.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/compat/linprocfs/linprocfs.c Mon Aug 24 08:57:02 2020 (r364633) @@ -426,7 +426,7 @@ linprocfs_domtab(PFS_FILL_ARGS) error = namei(&nd); lep = linux_emul_path; if (error == 0) { - if (vn_fullpath(td, nd.ni_vp, &dlep, &flep) == 0) + if (vn_fullpath(nd.ni_vp, &dlep, &flep) == 0) lep = dlep; vrele(nd.ni_vp); } @@ -1053,7 +1053,7 @@ linprocfs_doproccwd(PFS_FILL_ARGS) char *freepath = NULL; pwd = pwd_hold(td); - vn_fullpath(td, pwd->pwd_cdir, &fullpath, &freepath); + vn_fullpath(pwd->pwd_cdir, &fullpath, &freepath); sbuf_printf(sb, "%s", fullpath); if (freepath) free(freepath, M_TEMP); @@ -1074,7 +1074,7 @@ linprocfs_doprocroot(PFS_FILL_ARGS) pwd = pwd_hold(td); vp = jailed(p->p_ucred) ? pwd->pwd_jdir : pwd->pwd_rdir; - vn_fullpath(td, vp, &fullpath, &freepath); + vn_fullpath(vp, &fullpath, &freepath); sbuf_printf(sb, "%s", fullpath); if (freepath) free(freepath, M_TEMP); @@ -1219,7 +1219,7 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) shadow_count = obj->shadow_count; VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(td, vp, &name, &freename); + vn_fullpath(vp, &name, &freename); vn_lock(vp, LK_SHARED | LK_RETRY); VOP_GETATTR(vp, &vat, td->td_ucred); ino = vat.va_fileid; Modified: head/sys/compat/linux/linux_getcwd.c ============================================================================== --- head/sys/compat/linux/linux_getcwd.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/compat/linux/linux_getcwd.c Mon Aug 24 08:57:02 2020 (r364633) @@ -73,7 +73,7 @@ linux_getcwd(struct thread *td, struct linux_getcwd_ar buflen = LINUX_PATH_MAX; buf = malloc(buflen, M_TEMP, M_WAITOK); - error = vn_getcwd(td, buf, &retbuf, &buflen); + error = vn_getcwd(buf, &retbuf, &buflen); if (error == 0) { error = copyout(retbuf, uap->buf, buflen); if (error == 0) Modified: head/sys/dev/filemon/filemon_wrapper.c ============================================================================== --- head/sys/dev/filemon/filemon_wrapper.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/dev/filemon/filemon_wrapper.c Mon Aug 24 08:57:02 2020 (r364633) @@ -186,8 +186,7 @@ _filemon_wrapper_openat(struct thread *td, const char */ if (getvnode(td, fd, cap_rights_init(&rights, CAP_LOOKUP), &fp) == 0) { - vn_fullpath(td, fp->f_vnode, &atpath, - &freepath); + vn_fullpath(fp->f_vnode, &atpath, &freepath); } } if (flags & O_RDWR) { Modified: head/sys/dev/hwpmc/hwpmc_mod.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_mod.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/dev/hwpmc/hwpmc_mod.c Mon Aug 24 08:57:02 2020 (r364633) @@ -832,7 +832,7 @@ pmc_getfilename(struct vnode *v, char **fullpath, char *fullpath = "unknown"; *freepath = NULL; - vn_fullpath(curthread, v, fullpath, freepath); + vn_fullpath(v, fullpath, freepath); } /* Modified: head/sys/fs/fdescfs/fdesc_vnops.c ============================================================================== --- head/sys/fs/fdescfs/fdesc_vnops.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/fs/fdescfs/fdesc_vnops.c Mon Aug 24 08:57:02 2020 (r364633) @@ -640,7 +640,7 @@ fdesc_readlink(struct vop_readlink_args *va) switch (fp->f_type) { case DTYPE_VNODE: vp = fp->f_vnode; - error = vn_fullpath(td, vp, &fullpath, &freepath); + error = vn_fullpath(vp, &fullpath, &freepath); break; default: fullpath = "anon_inode:[unknown]"; Modified: head/sys/fs/procfs/procfs.c ============================================================================== --- head/sys/fs/procfs/procfs.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/fs/procfs/procfs.c Mon Aug 24 08:57:02 2020 (r364633) @@ -79,7 +79,7 @@ procfs_doprocfile(PFS_FILL_ARGS) textvp = p->p_textvp; vhold(textvp); PROC_UNLOCK(p); - error = vn_fullpath(td, textvp, &fullpath, &freepath); + error = vn_fullpath(textvp, &fullpath, &freepath); vdrop(textvp); if (error == 0) sbuf_printf(sb, "%s", fullpath); Modified: head/sys/fs/procfs/procfs_map.c ============================================================================== --- head/sys/fs/procfs/procfs_map.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/fs/procfs/procfs_map.c Mon Aug 24 08:57:02 2020 (r364633) @@ -189,7 +189,7 @@ procfs_doprocmap(PFS_FILL_ARGS) shadow_count = obj->shadow_count; VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(td, vp, &fullpath, &freepath); + vn_fullpath(vp, &fullpath, &freepath); vrele(vp); } } else { Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/kern/kern_exec.c Mon Aug 24 08:57:02 2020 (r364633) @@ -575,8 +575,7 @@ interpret: imgp->execpath = args->fname; else { VOP_UNLOCK(imgp->vp); - if (vn_fullpath(td, imgp->vp, &imgp->execpath, - &imgp->freepath) != 0) + if (vn_fullpath(imgp->vp, &imgp->execpath, &imgp->freepath) != 0) imgp->execpath = args->fname; vn_lock(imgp->vp, LK_SHARED | LK_RETRY); } Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/kern/kern_proc.c Mon Aug 24 08:57:02 2020 (r364633) @@ -2237,7 +2237,7 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER_ARGS) vref(vp); if (*pidp != -1) PROC_UNLOCK(p); - error = vn_fullpath(req->td, vp, &retbuf, &freebuf); + error = vn_fullpath(vp, &retbuf, &freebuf); vrele(vp); if (error) return (error); @@ -2375,8 +2375,7 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS) kve->kve_shadow_count = obj->shadow_count; VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(curthread, vp, &fullpath, - &freepath); + vn_fullpath(vp, &fullpath, &freepath); cred = curthread->td_ucred; vn_lock(vp, LK_SHARED | LK_RETRY); if (VOP_GETATTR(vp, &va, cred) == 0) { @@ -2584,8 +2583,7 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, s kve->kve_shadow_count = obj->shadow_count; VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(curthread, vp, &fullpath, - &freepath); + vn_fullpath(vp, &fullpath, &freepath); kve->kve_vn_type = vntype_to_kinfo(vp->v_type); cred = curthread->td_ucred; vn_lock(vp, LK_SHARED | LK_RETRY); Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/kern/kern_sig.c Mon Aug 24 08:57:02 2020 (r364633) @@ -3731,7 +3731,7 @@ coredump(struct thread *td) if (error != 0 || coredump_devctl == 0) goto out; sb = sbuf_new_auto(); - if (vn_fullpath_global(td, p->p_textvp, &fullpath, &freepath) != 0) + if (vn_fullpath_global(p->p_textvp, &fullpath, &freepath) != 0) goto out2; sbuf_printf(sb, "comm=\""); devctl_safe_quote_sb(sb, fullpath); @@ -3746,7 +3746,7 @@ coredump(struct thread *td) if (name[0] != '/') { fullpathsize = MAXPATHLEN; freepath = malloc(fullpathsize, M_TEMP, M_WAITOK); - if (vn_getcwd(td, freepath, &fullpath, &fullpathsize) != 0) { + if (vn_getcwd(freepath, &fullpath, &fullpathsize) != 0) { free(freepath, M_TEMP); goto out2; } Modified: head/sys/kern/sys_process.c ============================================================================== --- head/sys/kern/sys_process.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/kern/sys_process.c Mon Aug 24 08:57:02 2020 (r364633) @@ -418,7 +418,7 @@ ptrace_vm_entry(struct thread *td, struct proc *p, str if (vp != NULL) { freepath = NULL; fullpath = NULL; - vn_fullpath(td, vp, &fullpath, &freepath); + vn_fullpath(vp, &fullpath, &freepath); vn_lock(vp, LK_SHARED | LK_RETRY); if (VOP_GETATTR(vp, &vattr, td->td_ucred) == 0) { pve->pve_fileid = vattr.va_fileid; Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/kern/vfs_cache.c Mon Aug 24 08:57:02 2020 (r364633) @@ -475,12 +475,12 @@ STATNODE_COUNTER(shrinking_skipped, "Number of times shrinking was already in progress"); static void cache_zap_locked(struct namecache *ncp); -static int vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf, +static int vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, size_t *buflen); -static int vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *buflen); -static int vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *len, bool slash_prefixed, size_t addend); +static int vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, + char **retbuf, size_t *buflen); +static int vn_fullpath_dir(struct vnode *vp, struct vnode *rdir, char *buf, + char **retbuf, size_t *len, bool slash_prefixed, size_t addend); static MALLOC_DEFINE(M_VFSCACHE, "vfscache", "VFS name cache entries"); @@ -2463,7 +2463,7 @@ sys___getcwd(struct thread *td, struct __getcwd_args * buflen = MAXPATHLEN; buf = uma_zalloc(namei_zone, M_WAITOK); - error = vn_getcwd(td, buf, &retbuf, &buflen); + error = vn_getcwd(buf, &retbuf, &buflen); if (error == 0) error = copyout(retbuf, uap->buf, buflen); uma_zfree(namei_zone, buf); @@ -2471,13 +2471,13 @@ sys___getcwd(struct thread *td, struct __getcwd_args * } int -vn_getcwd(struct thread *td, char *buf, char **retbuf, size_t *buflen) +vn_getcwd(char *buf, char **retbuf, size_t *buflen) { struct pwd *pwd; int error; - pwd = pwd_hold(td); - error = vn_fullpath_any(td, pwd->pwd_cdir, pwd->pwd_rdir, buf, retbuf, buflen); + pwd = pwd_hold(curthread); + error = vn_fullpath_any(pwd->pwd_cdir, pwd->pwd_rdir, buf, retbuf, buflen); pwd_drop(pwd); #ifdef KTRACE @@ -2501,7 +2501,7 @@ kern___realpathat(struct thread *td, int fd, const cha pathseg, path, fd, &cap_fstat_rights, td); if ((error = namei(&nd)) != 0) return (error); - error = vn_fullpath_hardlink(td, &nd, &retbuf, &freebuf, &size); + error = vn_fullpath_hardlink(&nd, &retbuf, &freebuf, &size); if (error == 0) { error = copyout(retbuf, buf, size); free(freebuf, M_TEMP); @@ -2523,23 +2523,22 @@ sys___realpathat(struct thread *td, struct __realpatha * cache (if available) */ int -vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf) +vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf) { struct pwd *pwd; char *buf; size_t buflen; int error; - if (__predict_false(vn == NULL)) + if (__predict_false(vp == NULL)) return (EINVAL); buflen = MAXPATHLEN; buf = malloc(buflen, M_TEMP, M_WAITOK); - pwd = pwd_hold(td); - error = vn_fullpath_any(td, vn, pwd->pwd_rdir, buf, retbuf, &buflen); + pwd = pwd_hold(curthread); + error = vn_fullpath_any(vp, pwd->pwd_rdir, buf, retbuf, &buflen); pwd_drop(pwd); - - if (!error) + if (error == 0) *freebuf = buf; else free(buf, M_TEMP); @@ -2553,19 +2552,18 @@ vn_fullpath(struct thread *td, struct vnode *vn, char * global root mount point. */ int -vn_fullpath_global(struct thread *td, struct vnode *vn, - char **retbuf, char **freebuf) +vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf) { char *buf; size_t buflen; int error; - if (__predict_false(vn == NULL)) + if (__predict_false(vp == NULL)) return (EINVAL); buflen = MAXPATHLEN; buf = malloc(buflen, M_TEMP, M_WAITOK); - error = vn_fullpath_any(td, vn, rootvnode, buf, retbuf, &buflen); - if (!error) + error = vn_fullpath_any(vp, rootvnode, buf, retbuf, &buflen); + if (error == 0) *freebuf = buf; else free(buf, M_TEMP); @@ -2661,8 +2659,8 @@ vn_vptocnp(struct vnode **vp, struct ucred *cred, char * The vnode must be referenced. */ static int -vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *len, bool slash_prefixed, size_t addend) +vn_fullpath_dir(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, + size_t *len, bool slash_prefixed, size_t addend) { #ifdef KDTRACE_HOOKS struct vnode *startvp = vp; @@ -2727,7 +2725,7 @@ vn_fullpath_dir(struct thread *td, struct vnode *vp, s error, vp, NULL); break; } - error = vn_vptocnp(&vp, td->td_ucred, buf, &buflen); + error = vn_vptocnp(&vp, curthread->td_ucred, buf, &buflen); if (error) break; if (buflen == 0) { @@ -2772,8 +2770,8 @@ vn_fullpath_dir(struct thread *td, struct vnode *vp, s * (in which case resolving fails) */ static int -vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *buflen) +vn_fullpath_any(struct vnode *vp, struct vnode *rdir, char *buf, char **retbuf, + size_t *buflen) { size_t orig_buflen; bool slash_prefixed; @@ -2789,7 +2787,7 @@ vn_fullpath_any(struct thread *td, struct vnode *vp, s if (vp->v_type != VDIR) { *buflen -= 1; buf[*buflen] = '\0'; - error = vn_vptocnp(&vp, td->td_ucred, buf, buflen); + error = vn_vptocnp(&vp, curthread->td_ucred, buf, buflen); if (error) return (error); if (*buflen == 0) { @@ -2801,7 +2799,7 @@ vn_fullpath_any(struct thread *td, struct vnode *vp, s slash_prefixed = true; } - return (vn_fullpath_dir(td, vp, rdir, buf, retbuf, buflen, slash_prefixed, + return (vn_fullpath_dir(vp, rdir, buf, retbuf, buflen, slash_prefixed, orig_buflen - *buflen)); } @@ -2818,8 +2816,8 @@ vn_fullpath_any(struct thread *td, struct vnode *vp, s * from the parent */ static int -vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf, - char **freebuf, size_t *buflen) +vn_fullpath_hardlink(struct nameidata *ndp, char **retbuf, char **freebuf, + size_t *buflen) { char *buf, *tmpbuf; struct pwd *pwd; @@ -2838,7 +2836,7 @@ vn_fullpath_hardlink(struct thread *td, struct nameida slash_prefixed = false; buf = malloc(*buflen, M_TEMP, M_WAITOK); - pwd = pwd_hold(td); + pwd = pwd_hold(curthread); addend = 0; vp = ndp->ni_vp; @@ -2883,7 +2881,7 @@ vn_fullpath_hardlink(struct thread *td, struct nameida } vref(vp); - error = vn_fullpath_dir(td, vp, pwd->pwd_rdir, buf, retbuf, buflen, + error = vn_fullpath_dir(vp, pwd->pwd_rdir, buf, retbuf, buflen, slash_prefixed, addend); if (error != 0) goto out_bad; @@ -2969,7 +2967,7 @@ vn_path_to_global_path(struct thread *td, struct vnode /* Construct global filesystem path from vp. */ VOP_UNLOCK(vp); - error = vn_fullpath_global(td, vp, &rpath, &fbuf); + error = vn_fullpath_global(vp, &rpath, &fbuf); if (error != 0) { vrele(vp); Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/kern/vfs_vnops.c Mon Aug 24 08:57:02 2020 (r364633) @@ -2513,7 +2513,7 @@ vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_fil kif->kf_un.kf_file.kf_file_type = vntype_to_kinfo(vp->v_type); freepath = NULL; fullpath = "-"; - error = vn_fullpath(curthread, vp, &fullpath, &freepath); + error = vn_fullpath(vp, &fullpath, &freepath); if (error == 0) { strlcpy(kif->kf_path, fullpath, sizeof(kif->kf_path)); } Modified: head/sys/security/audit/audit_bsm_klib.c ============================================================================== --- head/sys/security/audit/audit_bsm_klib.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/security/audit/audit_bsm_klib.c Mon Aug 24 08:57:02 2020 (r364633) @@ -463,7 +463,7 @@ audit_canon_path_vp(struct thread *td, struct vnode *r * on Darwin. As a result, this may need some additional attention * in the future. */ - error = vn_fullpath_global(td, vp, &rbuf, &fbuf); + error = vn_fullpath_global(vp, &rbuf, &fbuf); if (error) { cpath[0] = '\0'; return; Modified: head/sys/sys/vnode.h ============================================================================== --- head/sys/sys/vnode.h Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/sys/vnode.h Mon Aug 24 08:57:02 2020 (r364633) @@ -660,11 +660,9 @@ u_quad_t init_va_filerev(void); int speedup_syncer(void); int vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf, size_t *buflen); -int vn_getcwd(struct thread *td, char *buf, char **retbuf, size_t *buflen); -int vn_fullpath(struct thread *td, struct vnode *vn, - char **retbuf, char **freebuf); -int vn_fullpath_global(struct thread *td, struct vnode *vn, - char **retbuf, char **freebuf); +int vn_getcwd(char *buf, char **retbuf, size_t *buflen); +int vn_fullpath(struct vnode *vp, char **retbuf, char **freebuf); +int vn_fullpath_global(struct vnode *vp, char **retbuf, char **freebuf); struct vnode * vn_dir_dd_ino(struct vnode *vp); int vn_commname(struct vnode *vn, char *buf, u_int buflen); Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Mon Aug 24 08:55:55 2020 (r364632) +++ head/sys/vm/vm_object.c Mon Aug 24 08:57:02 2020 (r364633) @@ -2582,7 +2582,7 @@ sysctl_vm_object_list(SYSCTL_HANDLER_ARGS) vref(vp); VM_OBJECT_RUNLOCK(obj); if (vp != NULL) { - vn_fullpath(curthread, vp, &fullpath, &freepath); + vn_fullpath(vp, &fullpath, &freepath); vn_lock(vp, LK_SHARED | LK_RETRY); if (VOP_GETATTR(vp, &va, curthread->td_ucred) == 0) { kvo->kvo_vn_fileid = va.va_fileid;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008240857.07O8v2v3090692>