From owner-svn-src-stable-10@freebsd.org Fri Mar 25 08:26:38 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 862D2ADD233; Fri, 25 Mar 2016 08:26:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 62C5510C4; Fri, 25 Mar 2016 08:26:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2P8Qbj5058908; Fri, 25 Mar 2016 08:26:37 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2P8Qb7g058907; Fri, 25 Mar 2016 08:26:37 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201603250826.u2P8Qb7g058907@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 25 Mar 2016 08:26:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r297267 - stable/10/sys/fs/pseudofs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2016 08:26:38 -0000 Author: kib Date: Fri Mar 25 08:26:37 2016 New Revision: 297267 URL: https://svnweb.freebsd.org/changeset/base/297267 Log: MFC r296652: Do not perform unneccessary shared recursion on the allproc_lock in pfs_visible(). Modified: stable/10/sys/fs/pseudofs/pseudofs_vnops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- stable/10/sys/fs/pseudofs/pseudofs_vnops.c Fri Mar 25 04:16:04 2016 (r297266) +++ stable/10/sys/fs/pseudofs/pseudofs_vnops.c Fri Mar 25 08:26:37 2016 (r297267) @@ -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);