Lines Matching full:lock
17 * Lockdep class keys for extent_buffer->lock's in this root. For a given
27 * Lock-nesting across peer nodes is always done with the immediate parent
93 lockdep_set_class_and_name(&eb->lock, &ks->keys[level], ks->names[level]); in btrfs_set_buffer_lockdep_class()
124 * - try-lock semantics for readers and writers
131 * btrfs_tree_read_lock_nested - lock extent buffer for read
135 * This takes the read lock on the extent buffer, using the specified nesting
145 down_read_nested(&eb->lock, nest); in btrfs_tree_read_lock_nested()
150 * Try-lock for read.
156 if (down_read_trylock(&eb->lock)) { in btrfs_try_tree_read_lock()
164 * Release read lock.
169 up_read(&eb->lock); in btrfs_tree_read_unlock()
173 * Lock eb for write.
175 * @eb: the eb to lock
176 * @nest: the nesting to use for the lock
178 * Returns with the eb->lock write locked.
181 __acquires(&eb->lock) in btrfs_tree_lock_nested()
188 down_write_nested(&eb->lock, nest); in btrfs_tree_lock_nested()
194 * Release the write lock.
200 up_write(&eb->lock); in btrfs_tree_unlock()
207 * btrfs_search_slot will keep the lock held on higher nodes in a few corner
231 * we end up with a lock on the root node.
233 * Return: root extent buffer with write lock held
254 * we end up with a lock on the root node.
256 * Return: root extent buffer with read lock held
277 * nowait mode until we end up with a lock on the root node or returning to
280 * Return: root extent buffer with read lock held or -EAGAIN.
304 * DREW stands for double-reader-writer-exclusion lock. It's used in situation
308 * writer both race to acquire their respective sides of the lock the writer
309 * would yield its lock as soon as it detects a concurrent reader. Additionally
311 * acquire the lock.
314 void btrfs_drew_lock_init(struct btrfs_drew_lock *lock) in btrfs_drew_lock_init() argument
316 atomic_set(&lock->readers, 0); in btrfs_drew_lock_init()
317 atomic_set(&lock->writers, 0); in btrfs_drew_lock_init()
318 init_waitqueue_head(&lock->pending_readers); in btrfs_drew_lock_init()
319 init_waitqueue_head(&lock->pending_writers); in btrfs_drew_lock_init()
323 bool btrfs_drew_try_write_lock(struct btrfs_drew_lock *lock) in btrfs_drew_try_write_lock() argument
325 if (atomic_read(&lock->readers)) in btrfs_drew_try_write_lock()
328 atomic_inc(&lock->writers); in btrfs_drew_try_write_lock()
332 if (atomic_read(&lock->readers)) { in btrfs_drew_try_write_lock()
333 btrfs_drew_write_unlock(lock); in btrfs_drew_try_write_lock()
340 void btrfs_drew_write_lock(struct btrfs_drew_lock *lock) in btrfs_drew_write_lock() argument
343 if (btrfs_drew_try_write_lock(lock)) in btrfs_drew_write_lock()
345 wait_event(lock->pending_writers, !atomic_read(&lock->readers)); in btrfs_drew_write_lock()
349 void btrfs_drew_write_unlock(struct btrfs_drew_lock *lock) in btrfs_drew_write_unlock() argument
355 if (atomic_dec_and_test(&lock->writers)) in btrfs_drew_write_unlock()
356 wake_up(&lock->pending_readers); in btrfs_drew_write_unlock()
359 void btrfs_drew_read_lock(struct btrfs_drew_lock *lock) in btrfs_drew_read_lock() argument
361 atomic_inc(&lock->readers); in btrfs_drew_read_lock()
371 wait_event(lock->pending_readers, atomic_read(&lock->writers) == 0); in btrfs_drew_read_lock()
374 void btrfs_drew_read_unlock(struct btrfs_drew_lock *lock) in btrfs_drew_read_unlock() argument
380 if (atomic_dec_and_test(&lock->readers)) in btrfs_drew_read_unlock()
381 wake_up(&lock->pending_writers); in btrfs_drew_read_unlock()