Lines Matching defs:lock

32 #include <sys/lock.h>
72 rangelock_init(struct rangelock *lock)
75 TAILQ_INIT(&lock->rl_waiters);
76 lock->rl_currdep = NULL;
80 rangelock_destroy(struct rangelock *lock)
83 KASSERT(TAILQ_EMPTY(&lock->rl_waiters), ("Dangling waiters"));
107 * Recalculate the lock->rl_currdep after an unlock.
110 rangelock_calc_block(struct rangelock *lock)
114 if (lock->rl_currdep == TAILQ_FIRST(&lock->rl_waiters) &&
115 lock->rl_currdep != NULL)
116 lock->rl_currdep = TAILQ_NEXT(lock->rl_currdep, rl_q_link);
117 for (entry = lock->rl_currdep; entry != NULL;
119 TAILQ_FOREACH(entry1, &lock->rl_waiters, rl_q_link) {
127 lock->rl_currdep = entry;
128 TAILQ_FOREACH(whead, &lock->rl_waiters, rl_q_link) {
129 if (whead == lock->rl_currdep)
139 rangelock_unlock_locked(struct rangelock *lock, struct rl_q_entry *entry,
143 MPASS(lock != NULL && entry != NULL && ilk != NULL);
145 KASSERT(entry != lock->rl_currdep, ("stuck currdep"));
147 TAILQ_REMOVE(&lock->rl_waiters, entry, rl_q_link);
148 rangelock_calc_block(lock);
157 rangelock_unlock(struct rangelock *lock, void *cookie, struct mtx *ilk)
160 MPASS(lock != NULL && cookie != NULL && ilk != NULL);
163 rangelock_unlock_locked(lock, cookie, ilk);
167 * Unlock the sub-range of granted lock.
170 rangelock_unlock_range(struct rangelock *lock, void *cookie, off_t start,
175 MPASS(lock != NULL && cookie != NULL && ilk != NULL);
178 ("Unlocking non-granted lock"));
184 rangelock_unlock_locked(lock, cookie, ilk);
188 rangelock_calc_block(lock);
194 * Add the lock request to the queue of the pending requests for
198 rangelock_enqueue(struct rangelock *lock, off_t start, off_t end, int mode,
204 MPASS(lock != NULL && ilk != NULL);
220 * lock that is incompatible with another request from the same
224 TAILQ_INSERT_TAIL(&lock->rl_waiters, entry, rl_q_link);
225 if (lock->rl_currdep == NULL)
226 lock->rl_currdep = entry;
227 rangelock_calc_block(lock);
235 rangelock_rlock(struct rangelock *lock, off_t start, off_t end, struct mtx *ilk)
238 return (rangelock_enqueue(lock, start, end, RL_LOCK_READ, ilk));
242 rangelock_wlock(struct rangelock *lock, off_t start, off_t end, struct mtx *ilk)
245 return (rangelock_enqueue(lock, start, end, RL_LOCK_WRITE, ilk));