Skip to content

Commit 80a160e

Browse files
author
Kent Overstreet
committed
bcachefs: Plumb btree_trans for more locking asserts
Signed-off-by: Kent Overstreet <[email protected]>
1 parent df92f35 commit 80a160e

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

fs/bcachefs/btree_iter.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static void __bch2_btree_path_verify(struct btree_trans *trans,
228228
__bch2_btree_path_verify_level(trans, path, i);
229229
}
230230

231-
bch2_btree_path_verify_locks(path);
231+
bch2_btree_path_verify_locks(trans, path);
232232
}
233233

234234
void __bch2_trans_verify_paths(struct btree_trans *trans)
@@ -991,7 +991,7 @@ static __always_inline int btree_path_down(struct btree_trans *trans,
991991
path->level = level;
992992
bch2_btree_path_level_init(trans, path, b);
993993

994-
bch2_btree_path_verify_locks(path);
994+
bch2_btree_path_verify_locks(trans, path);
995995
err:
996996
bch2_bkey_buf_exit(&tmp, c);
997997
return ret;
@@ -1103,7 +1103,7 @@ static void btree_path_set_level_down(struct btree_trans *trans,
11031103
if (btree_lock_want(path, l) == BTREE_NODE_UNLOCKED)
11041104
btree_node_unlock(trans, path, l);
11051105

1106-
btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
1106+
btree_path_set_dirty(trans, path, BTREE_ITER_NEED_TRAVERSE);
11071107
bch2_btree_path_verify(trans, path);
11081108
}
11091109

@@ -1301,7 +1301,7 @@ __bch2_btree_path_set_pos(struct btree_trans *trans,
13011301
if (unlikely(path->cached)) {
13021302
btree_node_unlock(trans, path, 0);
13031303
path->l[0].b = ERR_PTR(-BCH_ERR_no_btree_node_up);
1304-
btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
1304+
btree_path_set_dirty(trans, path, BTREE_ITER_NEED_TRAVERSE);
13051305
goto out;
13061306
}
13071307

@@ -1330,7 +1330,7 @@ __bch2_btree_path_set_pos(struct btree_trans *trans,
13301330
}
13311331

13321332
if (unlikely(level != path->level)) {
1333-
btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
1333+
btree_path_set_dirty(trans, path, BTREE_ITER_NEED_TRAVERSE);
13341334
__bch2_btree_path_unlock(trans, path);
13351335
}
13361336
out:
@@ -1984,7 +1984,7 @@ struct btree *bch2_btree_iter_next_node(struct btree_trans *trans, struct btree_
19841984
__bch2_btree_path_unlock(trans, path);
19851985
path->l[path->level].b = ERR_PTR(-BCH_ERR_no_btree_node_relock);
19861986
path->l[path->level + 1].b = ERR_PTR(-BCH_ERR_no_btree_node_relock);
1987-
btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
1987+
btree_path_set_dirty(trans, path, BTREE_ITER_NEED_TRAVERSE);
19881988
trace_and_count(trans->c, trans_restart_relock_next_node, trans, _THIS_IP_, path);
19891989
ret = btree_trans_restart(trans, BCH_ERR_transaction_restart_relock);
19901990
goto err;

fs/bcachefs/btree_iter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ static inline bool __btree_path_put(struct btree_trans *trans, struct btree_path
4646
return --path->ref == 0;
4747
}
4848

49-
static inline void btree_path_set_dirty(struct btree_path *path,
49+
static inline void btree_path_set_dirty(struct btree_trans *trans,
50+
struct btree_path *path,
5051
enum btree_path_uptodate u)
5152
{
5253
path->uptodate = max_t(unsigned, path->uptodate, u);

fs/bcachefs/btree_key_cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ void bch2_btree_key_cache_drop(struct btree_trans *trans,
656656
path2->should_be_locked = false;
657657
__bch2_btree_path_unlock(trans, path2);
658658
path2->l[0].b = ERR_PTR(-BCH_ERR_no_btree_node_drop);
659-
btree_path_set_dirty(path2, BTREE_ITER_NEED_TRAVERSE);
659+
btree_path_set_dirty(trans, path2, BTREE_ITER_NEED_TRAVERSE);
660660
}
661661

662662
bch2_trans_verify_locks(trans);

fs/bcachefs/btree_locking.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ static int btree_path_get_locks(struct btree_trans *trans,
494494
}
495495

496496
__bch2_btree_path_unlock(trans, path);
497-
btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
497+
btree_path_set_dirty(trans, path, BTREE_ITER_NEED_TRAVERSE);
498498

499499
/*
500500
* When we fail to get a lock, we have to ensure that any child nodes
@@ -594,7 +594,7 @@ int bch2_btree_path_relock_intent(struct btree_trans *trans,
594594
l++) {
595595
if (!bch2_btree_node_relock(trans, path, l)) {
596596
__bch2_btree_path_unlock(trans, path);
597-
btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
597+
btree_path_set_dirty(trans, path, BTREE_ITER_NEED_TRAVERSE);
598598
trace_and_count(trans->c, trans_restart_relock_path_intent, trans, _RET_IP_, path);
599599
return btree_trans_restart(trans, BCH_ERR_transaction_restart_relock_path_intent);
600600
}
@@ -636,7 +636,7 @@ bool __bch2_btree_path_upgrade_norestart(struct btree_trans *trans,
636636
bool ret = !btree_path_get_locks(trans, path, true, NULL, 0) ||
637637
!path->should_be_locked;
638638

639-
bch2_btree_path_verify_locks(path);
639+
bch2_btree_path_verify_locks(trans, path);
640640
return ret;
641641
}
642642

@@ -739,7 +739,7 @@ void __bch2_btree_path_downgrade(struct btree_trans *trans,
739739
}
740740
}
741741

742-
bch2_btree_path_verify_locks(path);
742+
bch2_btree_path_verify_locks(trans, path);
743743

744744
trace_path_downgrade(trans, _RET_IP_, path, old_locks_want);
745745
}
@@ -880,7 +880,7 @@ int __bch2_trans_mutex_lock(struct btree_trans *trans,
880880

881881
/* Debug */
882882

883-
void __bch2_btree_path_verify_locks(struct btree_path *path)
883+
void __bch2_btree_path_verify_locks(struct btree_trans *trans, struct btree_path *path)
884884
{
885885
/*
886886
* A path may be uptodate and yet have nothing locked if and only if
@@ -929,5 +929,5 @@ void __bch2_trans_verify_locks(struct btree_trans *trans)
929929
unsigned i;
930930

931931
trans_for_each_path(trans, path, i)
932-
__bch2_btree_path_verify_locks(path);
932+
__bch2_btree_path_verify_locks(trans, path);
933933
}

fs/bcachefs/btree_locking.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static inline int btree_path_highest_level_locked(struct btree_path *path)
160160
static inline void __bch2_btree_path_unlock(struct btree_trans *trans,
161161
struct btree_path *path)
162162
{
163-
btree_path_set_dirty(path, BTREE_ITER_NEED_RELOCK);
163+
btree_path_set_dirty(trans, path, BTREE_ITER_NEED_RELOCK);
164164

165165
while (path->nodes_locked)
166166
btree_node_unlock(trans, path, btree_path_lowest_level_locked(path));
@@ -433,7 +433,7 @@ static inline void btree_path_set_level_up(struct btree_trans *trans,
433433
struct btree_path *path)
434434
{
435435
__btree_path_set_level_up(trans, path, path->level++);
436-
btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
436+
btree_path_set_dirty(trans, path, BTREE_ITER_NEED_TRAVERSE);
437437
}
438438

439439
/* debug */
@@ -445,13 +445,14 @@ struct six_lock_count bch2_btree_node_lock_counts(struct btree_trans *,
445445

446446
int bch2_check_for_deadlock(struct btree_trans *, struct printbuf *);
447447

448-
void __bch2_btree_path_verify_locks(struct btree_path *);
448+
void __bch2_btree_path_verify_locks(struct btree_trans *, struct btree_path *);
449449
void __bch2_trans_verify_locks(struct btree_trans *);
450450

451-
static inline void bch2_btree_path_verify_locks(struct btree_path *path)
451+
static inline void bch2_btree_path_verify_locks(struct btree_trans *trans,
452+
struct btree_path *path)
452453
{
453454
if (static_branch_unlikely(&bch2_debug_check_btree_locking))
454-
__bch2_btree_path_verify_locks(path);
455+
__bch2_btree_path_verify_locks(trans, path);
455456
}
456457

457458
static inline void bch2_trans_verify_locks(struct btree_trans *trans)

0 commit comments

Comments
 (0)