Lines Matching refs:path
20 static inline bool is_btree_node(struct btree_path *path, unsigned l) in is_btree_node() argument
22 return l < BTREE_MAX_DEPTH && !IS_ERR_OR_NULL(path->l[l].b); in is_btree_node()
40 static inline int btree_node_locked_type(struct btree_path *path, in btree_node_locked_type() argument
43 return BTREE_NODE_UNLOCKED + ((path->nodes_locked >> (level << 1)) & 3); in btree_node_locked_type()
46 static inline bool btree_node_write_locked(struct btree_path *path, unsigned l) in btree_node_write_locked() argument
48 return btree_node_locked_type(path, l) == BTREE_NODE_WRITE_LOCKED; in btree_node_write_locked()
51 static inline bool btree_node_intent_locked(struct btree_path *path, unsigned l) in btree_node_intent_locked() argument
53 return btree_node_locked_type(path, l) == BTREE_NODE_INTENT_LOCKED; in btree_node_intent_locked()
56 static inline bool btree_node_read_locked(struct btree_path *path, unsigned l) in btree_node_read_locked() argument
58 return btree_node_locked_type(path, l) == BTREE_NODE_READ_LOCKED; in btree_node_read_locked()
61 static inline bool btree_node_locked(struct btree_path *path, unsigned level) in btree_node_locked() argument
63 return btree_node_locked_type(path, level) != BTREE_NODE_UNLOCKED; in btree_node_locked()
66 static inline void mark_btree_node_locked_noreset(struct btree_path *path, in mark_btree_node_locked_noreset() argument
74 path->nodes_locked &= ~(3U << (level << 1)); in mark_btree_node_locked_noreset()
75 path->nodes_locked |= (type + 1) << (level << 1); in mark_btree_node_locked_noreset()
78 static inline void mark_btree_node_unlocked(struct btree_path *path, in mark_btree_node_unlocked() argument
81 EBUG_ON(btree_node_write_locked(path, level)); in mark_btree_node_unlocked()
82 mark_btree_node_locked_noreset(path, level, BTREE_NODE_UNLOCKED); in mark_btree_node_unlocked()
86 struct btree_path *path, in mark_btree_node_locked() argument
90 mark_btree_node_locked_noreset(path, level, (enum btree_node_locked_type) type); in mark_btree_node_locked()
92 path->l[level].lock_taken_time = local_clock(); in mark_btree_node_locked()
96 static inline enum six_lock_type __btree_lock_want(struct btree_path *path, int level) in __btree_lock_want() argument
98 return level < path->locks_want in __btree_lock_want()
104 btree_lock_want(struct btree_path *path, int level) in btree_lock_want() argument
106 if (level < path->level) in btree_lock_want()
108 if (level < path->locks_want) in btree_lock_want()
110 if (level == path->level) in btree_lock_want()
116 struct btree_path *path, unsigned level) in btree_trans_lock_hold_time_update() argument
120 path->l[level].lock_taken_time, in btree_trans_lock_hold_time_update()
128 struct btree_path *path, unsigned level) in btree_node_unlock() argument
130 int lock_type = btree_node_locked_type(path, level); in btree_node_unlock()
136 six_unlock_type(&path->l[level].b->c.lock, lock_type); in btree_node_unlock()
137 btree_trans_lock_hold_time_update(trans, path, level); in btree_node_unlock()
139 mark_btree_node_unlocked(path, level); in btree_node_unlock()
142 static inline int btree_path_lowest_level_locked(struct btree_path *path) in btree_path_lowest_level_locked() argument
144 return __ffs(path->nodes_locked) >> 1; in btree_path_lowest_level_locked()
147 static inline int btree_path_highest_level_locked(struct btree_path *path) in btree_path_highest_level_locked() argument
149 return __fls(path->nodes_locked) >> 1; in btree_path_highest_level_locked()
153 struct btree_path *path) in __bch2_btree_path_unlock() argument
155 btree_path_set_dirty(path, BTREE_ITER_NEED_RELOCK); in __bch2_btree_path_unlock()
157 while (path->nodes_locked) in __bch2_btree_path_unlock()
158 btree_node_unlock(trans, path, btree_path_lowest_level_locked(path)); in __bch2_btree_path_unlock()
166 bch2_btree_node_unlock_write_inlined(struct btree_trans *trans, struct btree_path *path, in bch2_btree_node_unlock_write_inlined() argument
172 EBUG_ON(path->l[b->c.level].b != b); in bch2_btree_node_unlock_write_inlined()
173 EBUG_ON(path->l[b->c.level].lock_seq != six_lock_seq(&b->c.lock)); in bch2_btree_node_unlock_write_inlined()
174 EBUG_ON(btree_node_locked_type(path, b->c.level) != SIX_LOCK_write); in bch2_btree_node_unlock_write_inlined()
176 mark_btree_node_locked_noreset(path, b->c.level, BTREE_NODE_INTENT_LOCKED); in bch2_btree_node_unlock_write_inlined()
262 struct btree_path *path; in btree_node_lock_increment() local
265 trans_for_each_path(trans, path, i) in btree_node_lock_increment()
266 if (&path->l[level].b->c == b && in btree_node_lock_increment()
267 btree_node_locked_type(path, level) >= want) { in btree_node_lock_increment()
276 struct btree_path *path, in btree_node_lock() argument
289 !(ret = btree_node_lock_nopath(trans, b, type, btree_path_ip_allocated(path)))) { in btree_node_lock()
291 path->l[b->level].lock_taken_time = local_clock(); in btree_node_lock()
302 struct btree_path *path, in __btree_node_lock_write() argument
306 EBUG_ON(&path->l[b->level].b->c != b); in __btree_node_lock_write()
307 EBUG_ON(path->l[b->level].lock_seq != six_lock_seq(&b->lock)); in __btree_node_lock_write()
308 EBUG_ON(!btree_node_intent_locked(path, b->level)); in __btree_node_lock_write()
315 mark_btree_node_locked_noreset(path, b->level, BTREE_NODE_WRITE_LOCKED); in __btree_node_lock_write()
319 : __bch2_btree_node_lock_write(trans, path, b, lock_may_not_fail); in __btree_node_lock_write()
324 struct btree_path *path, in bch2_btree_node_lock_write() argument
327 return __btree_node_lock_write(trans, path, b, false); in bch2_btree_node_lock_write()
341 struct btree_path *path, unsigned long trace_ip) in bch2_btree_path_relock() argument
343 return btree_node_locked(path, path->level) in bch2_btree_path_relock()
345 : __bch2_btree_path_relock(trans, path, trace_ip); in bch2_btree_path_relock()
351 struct btree_path *path, unsigned level) in bch2_btree_node_relock() argument
353 EBUG_ON(btree_node_locked(path, level) && in bch2_btree_node_relock()
354 !btree_node_write_locked(path, level) && in bch2_btree_node_relock()
355 btree_node_locked_type(path, level) != __btree_lock_want(path, level)); in bch2_btree_node_relock()
357 return likely(btree_node_locked(path, level)) || in bch2_btree_node_relock()
358 (!IS_ERR_OR_NULL(path->l[level].b) && in bch2_btree_node_relock()
359 __bch2_btree_node_relock(trans, path, level, true)); in bch2_btree_node_relock()
363 struct btree_path *path, unsigned level) in bch2_btree_node_relock_notrace() argument
365 EBUG_ON(btree_node_locked(path, level) && in bch2_btree_node_relock_notrace()
366 !btree_node_write_locked(path, level) && in bch2_btree_node_relock_notrace()
367 btree_node_locked_type(path, level) != __btree_lock_want(path, level)); in bch2_btree_node_relock_notrace()
369 return likely(btree_node_locked(path, level)) || in bch2_btree_node_relock_notrace()
370 (!IS_ERR_OR_NULL(path->l[level].b) && in bch2_btree_node_relock_notrace()
371 __bch2_btree_node_relock(trans, path, level, false)); in bch2_btree_node_relock_notrace()
385 struct btree_path *path, in bch2_btree_path_upgrade() argument
389 unsigned old_locks_want = path->locks_want; in bch2_btree_path_upgrade()
393 if (path->locks_want < new_locks_want in bch2_btree_path_upgrade()
394 ? __bch2_btree_path_upgrade(trans, path, new_locks_want, &f) in bch2_btree_path_upgrade()
395 : path->nodes_locked) in bch2_btree_path_upgrade()
398 trace_and_count(trans->c, trans_restart_upgrade, trans, _THIS_IP_, path, in bch2_btree_path_upgrade()
405 …tic inline void btree_path_set_should_be_locked(struct btree_trans *trans, struct btree_path *path) in btree_path_set_should_be_locked() argument
407 EBUG_ON(!btree_node_locked(path, path->level)); in btree_path_set_should_be_locked()
408 EBUG_ON(path->uptodate); in btree_path_set_should_be_locked()
410 path->should_be_locked = true; in btree_path_set_should_be_locked()
411 trace_btree_path_should_be_locked(trans, path); in btree_path_set_should_be_locked()
415 struct btree_path *path, in __btree_path_set_level_up() argument
418 btree_node_unlock(trans, path, l); in __btree_path_set_level_up()
419 path->l[l].b = ERR_PTR(-BCH_ERR_no_btree_node_up); in __btree_path_set_level_up()
423 struct btree_path *path) in btree_path_set_level_up() argument
425 __btree_path_set_level_up(trans, path, path->level++); in btree_path_set_level_up()
426 btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE); in btree_path_set_level_up()
442 static inline void bch2_btree_path_verify_locks(struct btree_path *path) {} in bch2_btree_path_verify_locks() argument