Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146040398
D21628.id62117.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D21628.id62117.diff
View Options
Index: head/sys/kern/kern_rangelock.c
===================================================================
--- head/sys/kern/kern_rangelock.c
+++ head/sys/kern/kern_rangelock.c
@@ -299,3 +299,35 @@
return (rangelock_enqueue(lock, start, end, RL_LOCK_WRITE, ilk, true));
}
+
+#ifdef INVARIANT_SUPPORT
+void
+_rangelock_cookie_assert(void *cookie, int what, const char *file, int line)
+{
+ struct rl_q_entry *entry;
+ int flags;
+
+ MPASS(cookie != NULL);
+ entry = cookie;
+ flags = entry->rl_q_flags;
+ switch (what) {
+ case RCA_LOCKED:
+ if ((flags & RL_LOCK_GRANTED) == 0)
+ panic("rangelock not held @ %s:%d\n", file, line);
+ break;
+ case RCA_RLOCKED:
+ if ((flags & (RL_LOCK_GRANTED | RL_LOCK_READ)) !=
+ (RL_LOCK_GRANTED | RL_LOCK_READ))
+ panic("rangelock not rlocked @ %s:%d\n", file, line);
+ break;
+ case RCA_WLOCKED:
+ if ((flags & (RL_LOCK_GRANTED | RL_LOCK_WRITE)) !=
+ (RL_LOCK_GRANTED | RL_LOCK_WRITE))
+ panic("rangelock not wlocked @ %s:%d\n", file, line);
+ break;
+ default:
+ panic("Unknown rangelock assertion: %d @ %s:%d", what, file,
+ line);
+ }
+}
+#endif /* INVARIANT_SUPPORT */
Index: head/sys/sys/rangelock.h
===================================================================
--- head/sys/sys/rangelock.h
+++ head/sys/sys/rangelock.h
@@ -82,6 +82,29 @@
void *rangelock_trywlock(struct rangelock *lock, off_t start, off_t end,
struct mtx *ilk);
void rlqentry_free(struct rl_q_entry *rlqe);
+#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
+void _rangelock_cookie_assert(void *cookie, int what, const char *file,
+ int line);
+#endif
+
+#ifdef INVARIANTS
+#define rangelock_cookie_assert_(cookie, what, file, line) \
+ _rangelock_cookie_assert((cookie), (what), (file), (line))
+#else
+#define rangelock_cookie_assert_(cookie, what, file, line) (void)0
+#endif
+
+#define rangelock_cookie_assert(cookie, what) \
+ rangelock_cookie_assert_((cookie), (what), __FILE__, __LINE__)
+
+/*
+ * Assertion flags.
+ */
+#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
+#define RCA_LOCKED 0x0001
+#define RCA_RLOCKED 0x0002
+#define RCA_WLOCKED 0x0004
+#endif
#endif /* _KERNEL */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 28, 7:10 AM (18 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29058067
Default Alt Text
D21628.id62117.diff (2 KB)
Attached To
Mode
D21628: rangelock: add rangelock_cookie_assert
Attached
Detach File
Event Timeline
Log In to Comment