summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_locking.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-09-03 17:18:57 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2021-09-04 22:28:57 -0400
commitff08733dd298c969aec7c7828095458f73fd5374 (patch)
tree6a2b9fdfa0e617a31aafd823e32e6f00c1dc0b51 /fs/bcachefs/btree_locking.h
parent2c95e5357eaf9d786b8894f9fd1d1df9926caec8 (diff)
bcachefs: Add more assertions for locking btree iterators out of orderbtree_path
btree_path_traverse_all() traverses btree iterators in sorted order, and thus shouldn't see transaction restarts due to potential deadlocks - but sometimes we do. This patch adds some more assertions and tracks some more state to help track this down. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_locking.h')
-rw-r--r--fs/bcachefs/btree_locking.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/bcachefs/btree_locking.h b/fs/bcachefs/btree_locking.h
index d599008c5fc1..5c6b758070e1 100644
--- a/fs/bcachefs/btree_locking.h
+++ b/fs/bcachefs/btree_locking.h
@@ -58,7 +58,8 @@ static inline void mark_btree_node_unlocked(struct btree_path *path,
path->nodes_intent_locked &= ~(1 << level);
}
-static inline void mark_btree_node_locked(struct btree_path *path,
+static inline void mark_btree_node_locked(struct btree_trans *trans,
+ struct btree_path *path,
unsigned level,
enum six_lock_type type)
{
@@ -68,12 +69,19 @@ static inline void mark_btree_node_locked(struct btree_path *path,
path->nodes_locked |= 1 << level;
path->nodes_intent_locked |= type << level;
+#ifdef CONFIG_BCACHEFS_DEBUG
+ path->ip_locked = _RET_IP_;
+ BUG_ON(trans->in_traverse_all &&
+ trans->traverse_all_idx != U8_MAX &&
+ path->sorted_idx > trans->paths[trans->traverse_all_idx].sorted_idx);
+#endif
}
-static inline void mark_btree_node_intent_locked(struct btree_path *path,
+static inline void mark_btree_node_intent_locked(struct btree_trans *trans,
+ struct btree_path *path,
unsigned level)
{
- mark_btree_node_locked(path, level, SIX_LOCK_intent);
+ mark_btree_node_locked(trans, path, level, SIX_LOCK_intent);
}
static inline enum six_lock_type __btree_lock_want(struct btree_path *path, int level)
@@ -112,6 +120,9 @@ static inline void __bch2_btree_path_unlock(struct btree_path *path)
while (path->nodes_locked)
btree_node_unlock(path, __ffs(path->nodes_locked));
+#ifdef CONFIG_BCACHEFS_DEBUG
+ path->ip_locked = 0;
+#endif
}
static inline enum bch_time_stats lock_to_time_stat(enum six_lock_type type)