diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2019-09-15 02:59:53 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2019-09-15 02:59:53 +0000 |
commit | 3155f2f0e29b4650c06a530cffe97d410d58f6f0 (patch) | |
tree | 2eab350b472f52555767d95190a69cec31347684 /sys/kern/kern_rangelock.c | |
parent | 3dffab60f3374c392a72d0bcd3bcee54672152d5 (diff) | |
download | src-test2-3155f2f0e29b4650c06a530cffe97d410d58f6f0.tar.gz src-test2-3155f2f0e29b4650c06a530cffe97d410d58f6f0.zip |
Notes
Diffstat (limited to 'sys/kern/kern_rangelock.c')
-rw-r--r-- | sys/kern/kern_rangelock.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/kern/kern_rangelock.c b/sys/kern/kern_rangelock.c index b434ac4b4c1c..2983abbbdb5a 100644 --- a/sys/kern/kern_rangelock.c +++ b/sys/kern/kern_rangelock.c @@ -299,3 +299,35 @@ rangelock_trywlock(struct rangelock *lock, off_t start, off_t end, 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 */ |