Lines Matching +full:1 +full:eb
19 * eb, the lockdep key is determined by the btrfs_root it belongs to and
20 * the level the eb occupies in the tree.
50 DEFINE_LEVEL(stem, 1) \
83 void btrfs_set_buffer_lockdep_class(u64 objectid, struct extent_buffer *eb, int level) in btrfs_set_buffer_lockdep_class() argument
94 lockdep_set_class_and_name(&eb->lock, &ks->keys[level], ks->names[level]); in btrfs_set_buffer_lockdep_class()
97 void btrfs_maybe_reset_lockdep_class(struct btrfs_root *root, struct extent_buffer *eb) in btrfs_maybe_reset_lockdep_class() argument
101 eb, btrfs_header_level(eb)); in btrfs_maybe_reset_lockdep_class()
107 static void btrfs_set_eb_lock_owner(struct extent_buffer *eb, pid_t owner) in btrfs_set_eb_lock_owner() argument
109 eb->lock_owner = owner; in btrfs_set_eb_lock_owner()
112 static void btrfs_set_eb_lock_owner(struct extent_buffer *eb, pid_t owner) { } in btrfs_set_eb_lock_owner() argument
133 * @eb: the eb to be locked
139 void btrfs_tree_read_lock_nested(struct extent_buffer *eb, enum btrfs_lock_nesting nest) in btrfs_tree_read_lock_nested() argument
146 down_read_nested(&eb->lock, nest); in btrfs_tree_read_lock_nested()
147 trace_btrfs_tree_read_lock(eb, start_ns); in btrfs_tree_read_lock_nested()
153 * Return 1 if the rwlock has been taken, 0 otherwise
155 int btrfs_try_tree_read_lock(struct extent_buffer *eb) in btrfs_try_tree_read_lock() argument
157 if (down_read_trylock(&eb->lock)) { in btrfs_try_tree_read_lock()
158 trace_btrfs_try_tree_read_lock(eb); in btrfs_try_tree_read_lock()
159 return 1; in btrfs_try_tree_read_lock()
167 * Return 1 if the rwlock has been taken, 0 otherwise
169 int btrfs_try_tree_write_lock(struct extent_buffer *eb) in btrfs_try_tree_write_lock() argument
171 if (down_write_trylock(&eb->lock)) { in btrfs_try_tree_write_lock()
172 btrfs_set_eb_lock_owner(eb, current->pid); in btrfs_try_tree_write_lock()
173 trace_btrfs_try_tree_write_lock(eb); in btrfs_try_tree_write_lock()
174 return 1; in btrfs_try_tree_write_lock()
182 void btrfs_tree_read_unlock(struct extent_buffer *eb) in btrfs_tree_read_unlock() argument
184 trace_btrfs_tree_read_unlock(eb); in btrfs_tree_read_unlock()
185 up_read(&eb->lock); in btrfs_tree_read_unlock()
189 * Lock eb for write.
191 * @eb: the eb to lock
194 * Returns with the eb->lock write locked.
196 void btrfs_tree_lock_nested(struct extent_buffer *eb, enum btrfs_lock_nesting nest) in btrfs_tree_lock_nested() argument
197 __acquires(&eb->lock) in btrfs_tree_lock_nested()
204 down_write_nested(&eb->lock, nest); in btrfs_tree_lock_nested()
205 btrfs_set_eb_lock_owner(eb, current->pid); in btrfs_tree_lock_nested()
206 trace_btrfs_tree_lock(eb, start_ns); in btrfs_tree_lock_nested()
212 void btrfs_tree_unlock(struct extent_buffer *eb) in btrfs_tree_unlock() argument
214 trace_btrfs_tree_unlock(eb); in btrfs_tree_unlock()
215 btrfs_set_eb_lock_owner(eb, 0); in btrfs_tree_unlock()
216 up_write(&eb->lock); in btrfs_tree_unlock()
253 struct extent_buffer *eb; in btrfs_lock_root_node() local
255 while (1) { in btrfs_lock_root_node()
256 eb = btrfs_root_node(root); in btrfs_lock_root_node()
258 btrfs_maybe_reset_lockdep_class(root, eb); in btrfs_lock_root_node()
259 btrfs_tree_lock(eb); in btrfs_lock_root_node()
260 if (eb == root->node) in btrfs_lock_root_node()
262 btrfs_tree_unlock(eb); in btrfs_lock_root_node()
263 free_extent_buffer(eb); in btrfs_lock_root_node()
265 return eb; in btrfs_lock_root_node()
276 struct extent_buffer *eb; in btrfs_read_lock_root_node() local
278 while (1) { in btrfs_read_lock_root_node()
279 eb = btrfs_root_node(root); in btrfs_read_lock_root_node()
281 btrfs_maybe_reset_lockdep_class(root, eb); in btrfs_read_lock_root_node()
282 btrfs_tree_read_lock(eb); in btrfs_read_lock_root_node()
283 if (eb == root->node) in btrfs_read_lock_root_node()
285 btrfs_tree_read_unlock(eb); in btrfs_read_lock_root_node()
286 free_extent_buffer(eb); in btrfs_read_lock_root_node()
288 return eb; in btrfs_read_lock_root_node()
300 struct extent_buffer *eb; in btrfs_try_read_lock_root_node() local
302 while (1) { in btrfs_try_read_lock_root_node()
303 eb = btrfs_root_node(root); in btrfs_try_read_lock_root_node()
304 if (!btrfs_try_tree_read_lock(eb)) { in btrfs_try_read_lock_root_node()
305 free_extent_buffer(eb); in btrfs_try_read_lock_root_node()
308 if (eb == root->node) in btrfs_try_read_lock_root_node()
310 btrfs_tree_read_unlock(eb); in btrfs_try_read_lock_root_node()
311 free_extent_buffer(eb); in btrfs_try_read_lock_root_node()
313 return eb; in btrfs_try_read_lock_root_node()