diff options
author | kib <kib@FreeBSD.org> | 2011-08-01 19:07:03 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2011-08-01 19:07:03 +0000 |
commit | 7db6a1f506944de54734420c7d63567ada0461ab (patch) | |
tree | 06c780a2958e783fe88e25345621201e9cd362f8 /sys/kern/kern_lock.c | |
parent | 3eae9025cfec6a4e1c379aa6914479637453484d (diff) | |
download | FreeBSD-src-7db6a1f506944de54734420c7d63567ada0461ab.zip FreeBSD-src-7db6a1f506944de54734420c7d63567ada0461ab.tar.gz |
Fix the LK_NOSHARE lockmgr flag interaction with LK_UPGRADE and
LK_DOWNGRADE lock ops. Namely, the ops should be NOP since LK_NOSHARE
locks are always exclusive.
Reported by: rmacklem
Reviewed by: attilio
Tested by: pho
Approved by: re (kensmith)
MFC after: 1 week
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r-- | sys/kern/kern_lock.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 8e5546e..7311872 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -477,8 +477,18 @@ __lockmgr_args(struct lock *lk, u_int flags, struct lock_object *ilk, return (0); } - if (op == LK_SHARED && (lk->lock_object.lo_flags & LK_NOSHARE)) - op = LK_EXCLUSIVE; + if (lk->lock_object.lo_flags & LK_NOSHARE) { + switch (op) { + case LK_SHARED: + op = LK_EXCLUSIVE; + break; + case LK_UPGRADE: + case LK_DOWNGRADE: + _lockmgr_assert(lk, KA_XLOCKED | KA_NOTRECURSED, + file, line); + return (0); + } + } wakeup_swapper = 0; switch (op) { |