diff options
author | John Baldwin <jhb@FreeBSD.org> | 2008-11-04 19:04:01 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2008-11-04 19:04:01 +0000 |
commit | 2ff47c5f181b6ccf2ad64d3552687e28781eab5a (patch) | |
tree | b47a8cae4ebd0444298548735180256fabe8a0d6 /sys/fs | |
parent | 2ef42c06d66bc2811c37c7041142338efcab4b73 (diff) |
Remove unnecessary locking around vn_fullpath(). The vnode lock for the
vnode in question does not need to be held. All the data structures used
during the name lookup are protected by the global name cache lock.
Instead, the caller merely needs to ensure a reference is held on the
vnode (such as vhold()) to keep it from being freed.
In the case of procfs' <pid>/file entry, grab the process lock while we
gain a new reference (via vhold()) on p_textvp to fully close races with
execve(2).
For the kern.proc.vmmap sysctl handler, use a shared vnode lock around
the call to VOP_GETATTR() rather than an exclusive lock.
MFC after: 1 month
Notes
Notes:
svn path=/head/; revision=184652
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/procfs/procfs.c | 12 | ||||
-rw-r--r-- | sys/fs/procfs/procfs_map.c | 5 |
2 files changed, 6 insertions, 11 deletions
diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c index bc0efdaa2f61..26bd18532f8e 100644 --- a/sys/fs/procfs/procfs.c +++ b/sys/fs/procfs/procfs.c @@ -70,17 +70,13 @@ procfs_doprocfile(PFS_FILL_ARGS) char *fullpath = "unknown"; char *freepath = NULL; struct vnode *textvp; - int err; + PROC_LOCK(p); textvp = p->p_textvp; - VI_LOCK(textvp); - vholdl(textvp); - err = vn_lock(textvp, LK_EXCLUSIVE | LK_INTERLOCK); - vdrop(textvp); - if (err) - return (err); + vhold(textvp); + PROC_UNLOCK(p); vn_fullpath(td, textvp, &fullpath, &freepath); - VOP_UNLOCK(textvp, 0); + vdrop(textvp); sbuf_printf(sb, "%s", fullpath); if (freepath) free(freepath, M_TEMP); diff --git a/sys/fs/procfs/procfs_map.c b/sys/fs/procfs/procfs_map.c index 1a9e4aaa8b80..0c671b4c286c 100644 --- a/sys/fs/procfs/procfs_map.c +++ b/sys/fs/procfs/procfs_map.c @@ -175,10 +175,9 @@ procfs_doprocmap(PFS_FILL_ARGS) shadow_count = obj->shadow_count; VM_OBJECT_UNLOCK(obj); if (vp != NULL) { - vfslocked = VFS_LOCK_GIANT(vp->v_mount); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); vn_fullpath(td, vp, &fullpath, &freepath); - vput(vp); + vfslocked = VFS_LOCK_GIANT(vp->v_mount); + vrele(vp); VFS_UNLOCK_GIANT(vfslocked); } } else { |