Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_rangelock.c
Show First 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | |||||
void * | void * | ||||
rangelock_trywlock(struct rangelock *lock, off_t start, off_t end, | rangelock_trywlock(struct rangelock *lock, off_t start, off_t end, | ||||
struct mtx *ilk) | struct mtx *ilk) | ||||
{ | { | ||||
return (rangelock_enqueue(lock, start, end, RL_LOCK_WRITE, ilk, true)); | 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); | |||||
kib: I would suggest to use KASSERT() instead of direct panic(9) call. | |||||
kevansAuthorUnsubmitted Done Inline ActionsHmm... this makes rangelock_cookie_assert useless if kernel is compiled with INVARIANT_SUPPORT but not INVARIANTS and one still wants to do rangelock cookie assertions in a module. Is this intended/desired? kevans: Hmm... this makes rangelock_cookie_assert useless if kernel is compiled with INVARIANT_SUPPORT… | |||||
kibUnsubmitted Done Inline ActionsI am not sure that we need support for rangelocking asserts without INVARIANTs, but I understand your point. In any case I do not insist on this. kib: I am not sure that we need support for rangelocking asserts without INVARIANTs, but I… | |||||
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; | |||||
case RCA_UNLOCKED: | |||||
if ((entry->rl_q_flags & RL_LOCK_GRANTED) != 0) | |||||
kibUnsubmitted Done Inline ActionsWhy rl_q_flags instead of flags ? Also I do not think that RCA_UNLOCKED assert could be made safe. kib: Why rl_q_flags instead of flags ?
Also I do not think that RCA_UNLOCKED assert could be made… | |||||
kevansAuthorUnsubmitted Done Inline ActionsAh, missed converting that one. True- I'll drop RCA_UNLOCKED. kevans: Ah, missed converting that one.
True- I'll drop RCA_UNLOCKED. | |||||
panic("rangelock held @ %s:%d\n", file, line); | |||||
break; | |||||
default: | |||||
panic("Unknown rangelock assertion: %d @ %s:%d", what, file, | |||||
line); | |||||
} | |||||
} | |||||
#endif /* INVARIANT_SUPPORT */ |
I would suggest to use KASSERT() instead of direct panic(9) call.