summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2013-05-09 16:28:18 +0000
committermarcel <marcel@FreeBSD.org>2013-05-09 16:28:18 +0000
commitbd49099038824e1817f3a5da01c52f82eebe392e (patch)
tree535b854fe8328f0254c6ce52fdd275b2f12140ed
parentce591b770b2ff012762738cb1f1bfeea4003d36c (diff)
downloadFreeBSD-src-bd49099038824e1817f3a5da01c52f82eebe392e.zip
FreeBSD-src-bd49099038824e1817f3a5da01c52f82eebe392e.tar.gz
Add option WITNESS_NO_VNODE to suppress printing LORs between VNODE
locks. To support this, VNODE locks are created with the LK_IS_VNODE flag. This flag is propagated down using the LO_IS_VNODE flag. Note that WITNESS still records the LOR. Only the printing and the optional entering into the kernel debugger is bypassed with the WITNESS_NO_VNODE option.
-rw-r--r--sys/conf/options1
-rw-r--r--sys/kern/kern_lock.c2
-rw-r--r--sys/kern/subr_witness.c14
-rw-r--r--sys/kern/vfs_subr.c2
-rw-r--r--sys/sys/lock.h1
-rw-r--r--sys/sys/lockmgr.h1
6 files changed, 19 insertions, 2 deletions
diff --git a/sys/conf/options b/sys/conf/options
index 3b188b3..e0eda69 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -672,6 +672,7 @@ KTR_ENTRIES opt_global.h
KTR_VERBOSE opt_ktr.h
WITNESS opt_global.h
WITNESS_KDB opt_witness.h
+WITNESS_NO_VNODE opt_witness.h
WITNESS_SKIPSPIN opt_witness.h
# options for ACPI support
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index 7962ae1..849f583 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -393,6 +393,8 @@ lockinit(struct lock *lk, int pri, const char *wmesg, int timo, int flags)
iflags |= LO_WITNESS;
if (flags & LK_QUIET)
iflags |= LO_QUIET;
+ if (flags & LK_IS_VNODE)
+ iflags |= LO_IS_VNODE;
iflags |= flags & (LK_ADAPTIVE | LK_NOSHARE);
lk->lk_lock = LK_UNLOCKED;
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index b30bf08..ac7636ae 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -1289,7 +1289,19 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file,
w->w_reversed = w1->w_reversed = 1;
witness_increment_graph_generation();
mtx_unlock_spin(&w_mtx);
-
+
+#ifdef WITNESS_NO_VNODE
+ /*
+ * There are known LORs between VNODE locks. They are
+ * not an indication of a bug. VNODE locks are flagged
+ * as such (LO_IS_VNODE) and we don't yell if the LOR
+ * is between 2 VNODE locks.
+ */
+ if ((lock->lo_flags & LO_IS_VNODE) != 0 &&
+ (lock1->li_lock->lo_flags & LO_IS_VNODE) != 0)
+ return;
+#endif
+
/*
* Ok, yell about it.
*/
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index de118f7..d9cbde2 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1037,7 +1037,7 @@ alloc:
* By default, don't allow shared locks unless filesystems
* opt-in.
*/
- lockinit(vp->v_vnlock, PVFS, tag, VLKTIMEOUT, LK_NOSHARE);
+ lockinit(vp->v_vnlock, PVFS, tag, VLKTIMEOUT, LK_NOSHARE | LK_IS_VNODE);
/*
* Initialize bufobj.
*/
diff --git a/sys/sys/lock.h b/sys/sys/lock.h
index ab0122d..07651eb 100644
--- a/sys/sys/lock.h
+++ b/sys/sys/lock.h
@@ -79,6 +79,7 @@ struct lock_class {
#define LO_SLEEPABLE 0x00100000 /* Lock may be held while sleeping. */
#define LO_UPGRADABLE 0x00200000 /* Lock may be upgraded/downgraded. */
#define LO_DUPOK 0x00400000 /* Don't check for duplicate acquires */
+#define LO_IS_VNODE 0x00800000 /* Tell WITNESS about a VNODE lock */
#define LO_CLASSMASK 0x0f000000 /* Class index bitmask. */
#define LO_NOPROFILE 0x10000000 /* Don't profile this lock */
diff --git a/sys/sys/lockmgr.h b/sys/sys/lockmgr.h
index 1a2c92c..f525a06 100644
--- a/sys/sys/lockmgr.h
+++ b/sys/sys/lockmgr.h
@@ -146,6 +146,7 @@ _lockmgr_args_rw(struct lock *lk, u_int flags, struct rwlock *ilk,
#define LK_NOWITNESS 0x000010
#define LK_QUIET 0x000020
#define LK_ADAPTIVE 0x000040
+#define LK_IS_VNODE 0x000080 /* Tell WITNESS about a VNODE lock */
/*
* Additional attributes to be used in lockmgr().
OpenPOWER on IntegriCloud