Author: kib Date: Fri Mar 11 11:51:38 2016 New Revision: 296652 URL: https://svnweb.freebsd.org/changeset/base/296652
Log: Do not perform unneccessary shared recursion on the allproc_lock in pfs_visible(). The recursion does not cause deadlock because the sx implementation does not prefer exclusive waiters over the shared, but this is an implementation detail. Reported by: pho, Matthew Bryan <matthew.br...@isilon.com> Reviewed by: jhb Tested by: pho Approved by: des (pseudofs maintainer) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Modified: head/sys/fs/pseudofs/pseudofs_vnops.c Modified: head/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- head/sys/fs/pseudofs/pseudofs_vnops.c Fri Mar 11 11:38:31 2016 (r296651) +++ head/sys/fs/pseudofs/pseudofs_vnops.c Fri Mar 11 11:51:38 2016 (r296652) @@ -104,7 +104,8 @@ pfs_visible_proc(struct thread *td, stru } static int -pfs_visible(struct thread *td, struct pfs_node *pn, pid_t pid, struct proc **p) +pfs_visible(struct thread *td, struct pfs_node *pn, pid_t pid, + bool allproc_locked, struct proc **p) { struct proc *proc; @@ -115,7 +116,8 @@ pfs_visible(struct thread *td, struct pf *p = NULL; if (pid == NO_PID) PFS_RETURN (1); - if ((proc = pfind(pid)) == NULL) + proc = allproc_locked ? pfind_locked(pid) : pfind(pid); + if (proc == NULL) PFS_RETURN (0); if (pfs_visible_proc(td, pn, proc)) { if (p) @@ -202,7 +204,7 @@ pfs_getattr(struct vop_getattr_args *va) PFS_TRACE(("%s", pn->pn_name)); pfs_assert_not_owned(pn); - if (!pfs_visible(curthread, pn, pvd->pvd_pid, &proc)) + if (!pfs_visible(curthread, pn, pvd->pvd_pid, false, &proc)) PFS_RETURN (ENOENT); vap->va_type = vn->v_type; @@ -293,7 +295,7 @@ pfs_ioctl(struct vop_ioctl_args *va) * This is necessary because process' privileges may * have changed since the open() call. */ - if (!pfs_visible(curthread, pn, pvd->pvd_pid, &proc)) { + if (!pfs_visible(curthread, pn, pvd->pvd_pid, false, &proc)) { VOP_UNLOCK(vn, 0); PFS_RETURN (EIO); } @@ -326,7 +328,7 @@ pfs_getextattr(struct vop_getextattr_arg * This is necessary because either process' privileges may * have changed since the open() call. */ - if (!pfs_visible(curthread, pn, pvd->pvd_pid, &proc)) + if (!pfs_visible(curthread, pn, pvd->pvd_pid, false, &proc)) PFS_RETURN (EIO); if (pn->pn_getextattr == NULL) @@ -462,7 +464,7 @@ pfs_lookup(struct vop_cachedlookup_args PFS_RETURN (ENOENT); /* check that parent directory is visible... */ - if (!pfs_visible(curthread, pd, pvd->pvd_pid, NULL)) + if (!pfs_visible(curthread, pd, pvd->pvd_pid, false, NULL)) PFS_RETURN (ENOENT); /* self */ @@ -546,7 +548,7 @@ pfs_lookup(struct vop_cachedlookup_args got_pnode: pfs_assert_not_owned(pd); pfs_assert_not_owned(pn); - visible = pfs_visible(curthread, pn, pid, NULL); + visible = pfs_visible(curthread, pn, pid, false, NULL); if (!visible) { error = ENOENT; goto failed; @@ -635,7 +637,7 @@ pfs_read(struct vop_read_args *va) * This is necessary because either process' privileges may * have changed since the open() call. */ - if (!pfs_visible(curthread, pn, pvd->pvd_pid, &proc)) + if (!pfs_visible(curthread, pn, pvd->pvd_pid, false, &proc)) PFS_RETURN (EIO); if (proc != NULL) { _PHOLD(proc); @@ -791,7 +793,7 @@ pfs_readdir(struct vop_readdir_args *va) pfs_lock(pd); /* check if the directory is visible to the caller */ - if (!pfs_visible(curthread, pd, pid, &proc)) { + if (!pfs_visible(curthread, pd, pid, true, &proc)) { sx_sunlock(&allproc_lock); pfs_unlock(pd); PFS_RETURN (ENOENT); @@ -995,7 +997,7 @@ pfs_write(struct vop_write_args *va) * This is necessary because either process' privileges may * have changed since the open() call. */ - if (!pfs_visible(curthread, pn, pvd->pvd_pid, &proc)) + if (!pfs_visible(curthread, pn, pvd->pvd_pid, false, &proc)) PFS_RETURN (EIO); if (proc != NULL) { _PHOLD(proc); _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"