Lines Matching defs: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_nested - 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);
151 * Try-lock for read.
157 if (down_read_trylock(&eb->lock)) {
165 * Try-lock for write.
171 if (down_write_trylock(&eb->lock)) {
180 * Release read lock.
185 up_read(&eb->lock);
191 * @eb: the eb to lock
192 * @nest: the nesting to use for the lock
194 * Returns with the eb->lock write locked.
197 __acquires(&eb->lock)
204 down_write_nested(&eb->lock, nest);
210 * Release the write lock.
216 up_write(&eb->lock);
223 * btrfs_search_slot will keep the lock held on higher nodes in a few corner
247 * we end up with a lock on the root node.
249 * Return: root extent buffer with write lock held
270 * we end up with a lock on the root node.
272 * Return: root extent buffer with read lock held
293 * nowait mode until we end up with a lock on the root node or returning to
296 * Return: root extent buffer with read lock held or -EAGAIN.
320 * DREW stands for double-reader-writer-exclusion lock. It's used in situation
324 * writer both race to acquire their respective sides of the lock the writer
325 * would yield its lock as soon as it detects a concurrent reader. Additionally
327 * acquire the lock.
330 void btrfs_drew_lock_init(struct btrfs_drew_lock *lock)
332 atomic_set(&lock->readers, 0);
333 atomic_set(&lock->writers, 0);
334 init_waitqueue_head(&lock->pending_readers);
335 init_waitqueue_head(&lock->pending_writers);
339 bool btrfs_drew_try_write_lock(struct btrfs_drew_lock *lock)
341 if (atomic_read(&lock->readers))
344 atomic_inc(&lock->writers);
348 if (atomic_read(&lock->readers)) {
349 btrfs_drew_write_unlock(lock);
356 void btrfs_drew_write_lock(struct btrfs_drew_lock *lock)
359 if (btrfs_drew_try_write_lock(lock))
361 wait_event(lock->pending_writers, !atomic_read(&lock->readers));
365 void btrfs_drew_write_unlock(struct btrfs_drew_lock *lock)
371 if (atomic_dec_and_test(&lock->writers))
372 wake_up(&lock->pending_readers);
375 void btrfs_drew_read_lock(struct btrfs_drew_lock *lock)
377 atomic_inc(&lock->readers);
387 wait_event(lock->pending_readers, atomic_read(&lock->writers) == 0);
390 void btrfs_drew_read_unlock(struct btrfs_drew_lock *lock)
396 if (atomic_dec_and_test(&lock->readers))
397 wake_up(&lock->pending_writers);