From 763f7449dc1d3190bc67d34d3c15c7d9702810a1 Mon Sep 17 00:00:00 2001 From: pjd Date: Fri, 21 Sep 2007 10:16:56 +0000 Subject: Fix some locking cases where we ask for exclusively locked vnode, but we get shared locked vnode in instead when vfs.lookup_shared is set to 1. Discussed with: kib, kris Tested by: kris Approved by: re (kensmith) --- sys/kern/vfs_lookup.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sys/kern/vfs_lookup.c') diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index a291a25..6349c36 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -772,6 +772,14 @@ nextname: if ((cnp->cn_flags & LOCKLEAF) == 0) VOP_UNLOCK(dp, 0, td); success: + /* + * Because of lookup_shared we may have the vnode shared locked, but + * the caller may want it to be exclusively locked. + */ + if ((cnp->cn_flags & (ISLASTCN | LOCKSHARED | LOCKLEAF)) == + (ISLASTCN | LOCKLEAF) && VOP_ISLOCKED(dp, td) != LK_EXCLUSIVE) { + vn_lock(dp, LK_UPGRADE | LK_RETRY, td); + } if (vfslocked && dvfslocked) VFS_UNLOCK_GIANT(dvfslocked); /* Only need one */ if (vfslocked || dvfslocked) -- cgit v1.1