mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 19:34:43 +01:00
rangelock: Reimplement _rangelock_cookie_assert()
After rangelocks were reimplemented, _rangelock_cookie_assert() became a stub. Re-provide an implementation. Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D59222
This commit is contained in:
1 parent
f1f58bdf7b
commit
2e376cca37
2 files changed
+55
-3
No files matched your search
@@ -813,6 +813,58 @@ rangelock_may_recurse(struct rangelock *lock)
|
||||
void
|
||||
_rangelock_cookie_assert(void *cookie, int what, const char *file, int line)
|
||||
{
|
||||
struct rl_q_entry *entry;
|
||||
struct thread *td;
|
||||
uintptr_t c;
|
||||
|
||||
c = (uintptr_t)cookie;
|
||||
switch (what) {
|
||||
case RCA_LOCKED:
|
||||
if (c == RL_RET_CHEAT_RLOCKED || c == RL_RET_CHEAT_WLOCKED)
|
||||
break;
|
||||
entry = cookie;
|
||||
if ((entry->rl_q_flags & RL_LOCK_TYPE_MASK) == 0)
|
||||
panic("rangelock not held (%#x) @ %s:%d\n",
|
||||
entry->rl_q_flags, file, line);
|
||||
td = entry->rl_q_owner;
|
||||
if (td != curthread)
|
||||
panic("rangelock held by thread %d @ %s:%d\n",
|
||||
td != NULL ? td->td_tid : -1, file, line);
|
||||
break;
|
||||
case RCA_RLOCKED:
|
||||
if (c == RL_RET_CHEAT_RLOCKED)
|
||||
break;
|
||||
if (c == RL_RET_CHEAT_WLOCKED)
|
||||
panic("rangelock not rlocked (%#lx) @ %s:%d\n",
|
||||
c, file, line);
|
||||
entry = cookie;
|
||||
if ((entry->rl_q_flags & RL_LOCK_TYPE_MASK) != RL_LOCK_READ)
|
||||
panic("rangelock not rlocked (%#x) @ %s:%d\n",
|
||||
entry->rl_q_flags, file, line);
|
||||
td = entry->rl_q_owner;
|
||||
if (td != curthread)
|
||||
panic("rangelock held by thread %d @ %s:%d\n",
|
||||
td != NULL ? td->td_tid : -1, file, line);
|
||||
break;
|
||||
case RCA_WLOCKED:
|
||||
if (c == RL_RET_CHEAT_WLOCKED)
|
||||
break;
|
||||
if (c == RL_RET_CHEAT_RLOCKED)
|
||||
panic("rangelock not wlocked (%#lx) @ %s:%d\n",
|
||||
c, file, line);
|
||||
entry = cookie;
|
||||
if ((entry->rl_q_flags & RL_LOCK_TYPE_MASK) != RL_LOCK_WRITE)
|
||||
panic("rangelock not wlocked (%#x) @ %s:%d\n",
|
||||
entry->rl_q_flags, file, line);
|
||||
td = entry->rl_q_owner;
|
||||
if (td != curthread)
|
||||
panic("rangelock held by thread %d @ %s:%d\n",
|
||||
td != NULL ? td->td_tid : -1, file, line);
|
||||
break;
|
||||
default:
|
||||
panic("rangelock cookie assert type %d @ %s:%d\n",
|
||||
what, file, line);
|
||||
}
|
||||
}
|
||||
#endif /* INVARIANT_SUPPORT */
|
||||
|
||||
|
||||
+3
-3
@@ -742,7 +742,7 @@ shm_dotruncate_locked(struct shmfd *shmfd, off_t length, void *rl_cookie)
|
||||
KASSERT(length >= 0, ("shm_dotruncate: length < 0"));
|
||||
object = shmfd->shm_object;
|
||||
VM_OBJECT_ASSERT_WLOCKED(object);
|
||||
rangelock_cookie_assert(rl_cookie, RA_WLOCKED);
|
||||
rangelock_cookie_assert(rl_cookie, RCA_WLOCKED);
|
||||
if (length == shmfd->shm_size)
|
||||
return (0);
|
||||
nobjsize = OFF_TO_IDX(length + PAGE_MASK);
|
||||
@@ -807,7 +807,7 @@ shm_dotruncate_largepage(struct shmfd *shmfd, off_t length, void *rl_cookie)
|
||||
KASSERT(length >= 0, ("shm_dotruncate_largepage: length < 0"));
|
||||
object = shmfd->shm_object;
|
||||
VM_OBJECT_ASSERT_WLOCKED(object);
|
||||
rangelock_cookie_assert(rl_cookie, RA_WLOCKED);
|
||||
rangelock_cookie_assert(rl_cookie, RCA_WLOCKED);
|
||||
|
||||
oldobjsz = object->size;
|
||||
newobjsz = OFF_TO_IDX(length);
|
||||
@@ -1584,7 +1584,7 @@ shm_mmap_large(struct shmfd *shmfd, vm_map_t map, vm_offset_t *addr,
|
||||
int docow, error, rv, try;
|
||||
bool curmap;
|
||||
|
||||
rangelock_cookie_assert(rl_cookie, RA_LOCKED);
|
||||
rangelock_cookie_assert(rl_cookie, RCA_LOCKED);
|
||||
|
||||
if (shmfd->shm_lp_psind == 0)
|
||||
return (EINVAL);
|
||||
|
||||
Reference in new issue
Block a user