Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Aug 2011 19:07:03 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r224581 - head/sys/kern
Message-ID:  <201108011907.p71J73qB009100@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108011907.p71J73qB009100>