Lines Matching refs:lock

18  * Lockdep class keys for extent_buffer->lock's in this root.  For a given
94 lockdep_set_class_and_name(&eb->lock, &ks->keys[level], ks->names[level]);
125 * - try-lock semantics for readers and writers
132 * __btrfs_tree_read_lock - lock extent buffer for read
136 * This takes the read lock on the extent buffer, using the specified nesting
146 down_read_nested(&eb->lock, nest);
156 * Try-lock for read.
162 if (down_read_trylock(&eb->lock)) {
170 * Try-lock for write.
176 if (down_write_trylock(&eb->lock)) {
185 * Release read lock.
190 up_read(&eb->lock);
196 * @eb: the eb to lock
197 * @nest: the nesting to use for the lock
199 * Returns with the eb->lock write locked.
202 __acquires(&eb->lock)
209 down_write_nested(&eb->lock, nest);
220 * Release the write lock.
226 up_write(&eb->lock);
233 * btrfs_search_slot will keep the lock held on higher nodes in a few corner
257 * we end up with a lock on the root node.
259 * Return: root extent buffer with write lock held
280 * we end up with a lock on the root node.
282 * Return: root extent buffer with read lock held
303 * nowait mode until we end up with a lock on the root node or returning to
306 * Return: root extent buffer with read lock held or -EAGAIN.
330 * DREW stands for double-reader-writer-exclusion lock. It's used in situation
334 * writer both race to acquire their respective sides of the lock the writer
335 * would yield its lock as soon as it detects a concurrent reader. Additionally
337 * acquire the lock.
340 void btrfs_drew_lock_init(struct btrfs_drew_lock *lock)
342 atomic_set(&lock->readers, 0);
343 atomic_set(&lock->writers, 0);
344 init_waitqueue_head(&lock->pending_readers);
345 init_waitqueue_head(&lock->pending_writers);
349 bool btrfs_drew_try_write_lock(struct btrfs_drew_lock *lock)
351 if (atomic_read(&lock->readers))
354 atomic_inc(&lock->writers);
358 if (atomic_read(&lock->readers)) {
359 btrfs_drew_write_unlock(lock);
366 void btrfs_drew_write_lock(struct btrfs_drew_lock *lock)
369 if (btrfs_drew_try_write_lock(lock))
371 wait_event(lock->pending_writers, !atomic_read(&lock->readers));
375 void btrfs_drew_write_unlock(struct btrfs_drew_lock *lock)
377 atomic_dec(&lock->writers);
378 cond_wake_up(&lock->pending_readers);
381 void btrfs_drew_read_lock(struct btrfs_drew_lock *lock)
383 atomic_inc(&lock->readers);
393 wait_event(lock->pending_readers, atomic_read(&lock->writers) == 0);
396 void btrfs_drew_read_unlock(struct btrfs_drew_lock *lock)
402 if (atomic_dec_and_test(&lock->readers))
403 wake_up(&lock->pending_writers);