Lines Matching refs:lock
20 static inline void two_state_lock_init(two_state_lock_t *lock) in two_state_lock_init() argument
22 atomic_long_set(&lock->v, 0); in two_state_lock_init()
23 init_waitqueue_head(&lock->wait); in two_state_lock_init()
26 static inline void bch2_two_state_unlock(two_state_lock_t *lock, int s) in bch2_two_state_unlock() argument
30 EBUG_ON(atomic_long_read(&lock->v) == 0); in bch2_two_state_unlock()
32 if (atomic_long_sub_return_release(i, &lock->v) == 0) in bch2_two_state_unlock()
33 wake_up_all(&lock->wait); in bch2_two_state_unlock()
36 static inline bool bch2_two_state_trylock(two_state_lock_t *lock, int s) in bch2_two_state_trylock() argument
41 old = atomic_long_read(&lock->v); in bch2_two_state_trylock()
45 } while (!atomic_long_try_cmpxchg_acquire(&lock->v, &old, old + i)); in bch2_two_state_trylock()
52 static inline void bch2_two_state_lock(two_state_lock_t *lock, int s) in bch2_two_state_lock() argument
54 if (!bch2_two_state_trylock(lock, s)) in bch2_two_state_lock()
55 __bch2_two_state_lock(lock, s); in bch2_two_state_lock()