summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-08-22 15:29:53 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2022-10-03 23:55:07 -0400
commit88b4843ac3b32e0408f897fa18097478696829dd (patch)
tree95c84065fba82a5873c2c1927d2d2f3e5f21add3
parentbdaeb716c04c4869aee493420abe43fbd5e2cf69 (diff)
bcachefs: Kill normalize_read_intent_locks()
Before we had the deadlock cycle detector, we didn't want to be holding read locks when taking intent locks, because blocking on an intent lock while holding a read lock was a lock ordering violation that could cause a deadlock. With the cycle detector this is no longer an issue, so this code can be deleted. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/btree_update_leaf.c58
1 files changed, 0 insertions, 58 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c
index 260176e0aaf0..07ca146baee0 100644
--- a/fs/bcachefs/btree_update_leaf.c
+++ b/fs/bcachefs/btree_update_leaf.c
@@ -734,62 +734,6 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
return ret;
}
-static inline void path_upgrade_readers(struct btree_trans *trans, struct btree_path *path)
-{
- unsigned l;
-
- for (l = 0; l < BTREE_MAX_DEPTH; l++)
- if (btree_node_read_locked(path, l))
- BUG_ON(!bch2_btree_node_upgrade(trans, path, l));
-}
-
-static inline void upgrade_readers(struct btree_trans *trans, struct btree_path *path)
-{
- struct btree *b = path_l(path)->b;
- unsigned l;
-
- do {
- for (l = 0; l < BTREE_MAX_DEPTH; l++)
- if (btree_node_read_locked(path, l))
- path_upgrade_readers(trans, path);
- } while ((path = prev_btree_path(trans, path)) &&
- path_l(path)->b == b);
-}
-
-/*
- * Check for nodes that we have both read and intent locks on, and upgrade the
- * readers to intent:
- */
-static inline void normalize_read_intent_locks(struct btree_trans *trans)
-{
- struct btree_path *path;
- unsigned i, nr_read = 0, nr_intent = 0;
-
- trans_for_each_path_inorder(trans, path, i) {
- struct btree_path *next = i + 1 < trans->nr_sorted
- ? trans->paths + trans->sorted[i + 1]
- : NULL;
-
- switch (btree_node_locked_type(path, path->level)) {
- case BTREE_NODE_READ_LOCKED:
- nr_read++;
- break;
- case BTREE_NODE_INTENT_LOCKED:
- nr_intent++;
- break;
- }
-
- if (!next || path_l(path)->b != path_l(next)->b) {
- if (nr_read && nr_intent)
- upgrade_readers(trans, path);
-
- nr_read = nr_intent = 0;
- }
- }
-
- bch2_trans_verify_locks(trans);
-}
-
static inline int trans_lock_write(struct btree_trans *trans)
{
struct btree_insert_entry *i;
@@ -893,8 +837,6 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans,
if (unlikely(ret))
return ret;
- normalize_read_intent_locks(trans);
-
ret = trans_lock_write(trans);
if (unlikely(ret))
return ret;