Author: kib
Date: Mon Aug  1 19:07:03 2011
New Revision: 224581
URL: http://svn.freebsd.org/changeset/base/224581

Log:
  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

Modified:
  head/sys/kern/kern_lock.c

Modified: head/sys/kern/kern_lock.c
==============================================================================
--- head/sys/kern/kern_lock.c   Mon Aug  1 15:56:40 2011        (r224580)
+++ head/sys/kern/kern_lock.c   Mon Aug  1 19:07:03 2011        (r224581)
@@ -477,8 +477,18 @@ __lockmgr_args(struct lock *lk, u_int fl
                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) {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to