Revert "bcachefs: Add more assertions for locking btree iterators out of order"
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 15 Sep 2021 15:15:18 +0000 (11:15 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:12 +0000 (17:09 -0400)
Figured out the bug we were chasing, and it had nothing to do with
locking btree iterators/paths out of order.

This reverts commit ff08733dd298c969aec7c7828095458f73fd5374.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_key_cache.c
fs/bcachefs/btree_locking.h
fs/bcachefs/btree_types.h

index fbe1a1170df6f6c36669212e2850e91deb70a9c4..4cfd793f85e7abf8d546820698aaf1700f685002 100644 (file)
@@ -157,7 +157,7 @@ bool __bch2_btree_node_relock(struct btree_trans *trans,
        if (six_relock_type(&b->c.lock, want, path->l[level].lock_seq) ||
            (btree_node_lock_seq_matches(path, b, level) &&
             btree_node_lock_increment(trans, b, level, want))) {
-               mark_btree_node_locked(trans, path, level, want);
+               mark_btree_node_locked(path, level, want);
                return true;
        } else {
                return false;
@@ -193,7 +193,7 @@ static bool bch2_btree_node_upgrade(struct btree_trans *trans,
 
        return false;
 success:
-       mark_btree_node_intent_locked(trans, path, level);
+       mark_btree_node_intent_locked(path, level);
        return true;
 }
 
@@ -1045,7 +1045,7 @@ void bch2_trans_node_add(struct btree_trans *trans, struct btree *b)
                            t != BTREE_NODE_UNLOCKED) {
                                btree_node_unlock(path, b->c.level);
                                six_lock_increment(&b->c.lock, (enum six_lock_type) t);
-                               mark_btree_node_locked(trans, path, b->c.level, (enum six_lock_type) t);
+                               mark_btree_node_locked(path, b->c.level, (enum six_lock_type) t);
                        }
 
                        btree_path_level_init(trans, path, b);
@@ -1122,7 +1122,7 @@ static inline int btree_path_lock_root(struct btree_trans *trans,
                        for (i = path->level + 1; i < BTREE_MAX_DEPTH; i++)
                                path->l[i].b = NULL;
 
-                       mark_btree_node_locked(trans, path, path->level, lock_type);
+                       mark_btree_node_locked(path, path->level, lock_type);
                        btree_path_level_init(trans, path, b);
                        return 0;
                }
@@ -1214,7 +1214,7 @@ static __always_inline int btree_path_down(struct btree_trans *trans,
        if (unlikely(ret))
                goto err;
 
-       mark_btree_node_locked(trans, path, level, lock_type);
+       mark_btree_node_locked(path, level, lock_type);
        btree_path_level_init(trans, path, b);
 
        if (tmp.k->k.type == KEY_TYPE_btree_ptr_v2 &&
@@ -1295,9 +1295,6 @@ retry_all:
                path = trans->paths + trans->sorted[i];
 
                EBUG_ON(!(trans->paths_allocated & (1ULL << path->idx)));
-#ifdef CONFIG_BCACHEFS_DEBUG
-               trans->traverse_all_idx = path->idx;
-#endif
 
                ret = btree_path_traverse_one(trans, path, 0, _THIS_IP_);
                if (ret)
@@ -1319,11 +1316,6 @@ retry_all:
 out:
        bch2_btree_cache_cannibalize_unlock(c);
 
-#ifdef CONFIG_BCACHEFS_DEBUG
-       trans->traverse_all_idx = U8_MAX;
-#endif
-       trans->in_traverse_all = false;
-
        trace_trans_traverse_all(trans->ip, trace_ip);
        return ret;
 }
index 9d3a64f37f09af27fb13290b3daa8273fca72ce8..9bdc2c3f21bf4869bf9af0ca45c8080edca6cef2 100644 (file)
@@ -297,7 +297,7 @@ retry:
                if (!ck)
                        goto retry;
 
-               mark_btree_node_locked(trans, path, 0, SIX_LOCK_intent);
+               mark_btree_node_locked(path, 0, SIX_LOCK_intent);
                path->locks_want = 1;
        } else {
                enum six_lock_type lock_want = __btree_lock_want(path, 0);
@@ -319,7 +319,7 @@ retry:
                        goto retry;
                }
 
-               mark_btree_node_locked(trans, path, 0, lock_want);
+               mark_btree_node_locked(path, 0, lock_want);
        }
 
        path->l[0].lock_seq     = ck->c.lock.state.seq;
index ff58870311f3580d7f01ba566a70455d0fe7e50b..d05689180c63e855cbd4d34ae303206cb2194e09 100644 (file)
@@ -57,8 +57,7 @@ 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_trans *trans,
-                                         struct btree_path *path,
+static inline void mark_btree_node_locked(struct btree_path *path,
                                          unsigned level,
                                          enum six_lock_type type)
 {
@@ -68,20 +67,12 @@ static inline void mark_btree_node_locked(struct btree_trans *trans,
 
        path->nodes_locked |= 1 << level;
        path->nodes_intent_locked |= type << level;
-#ifdef CONFIG_BCACHEFS_DEBUG
-       path->ip_locked = _RET_IP_;
-       btree_trans_sort_paths(trans);
-       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_trans *trans,
-                                                struct btree_path *path,
+static inline void mark_btree_node_intent_locked(struct btree_path *path,
                                                 unsigned level)
 {
-       mark_btree_node_locked(trans, path, level, SIX_LOCK_intent);
+       mark_btree_node_locked(path, level, SIX_LOCK_intent);
 }
 
 static inline enum six_lock_type __btree_lock_want(struct btree_path *path, int level)
@@ -120,9 +111,6 @@ 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)
index ce64d3ad768bb59f28f2d2584a48e4f03e6921e5..b7cded2095fffa4069694ee0a0ded9608e4bda48 100644 (file)
@@ -255,7 +255,6 @@ struct btree_path {
        }                       l[BTREE_MAX_DEPTH];
 #ifdef CONFIG_BCACHEFS_DEBUG
        unsigned long           ip_allocated;
-       unsigned long           ip_locked;
 #endif
 };
 
@@ -369,7 +368,6 @@ struct btree_trans {
        struct bpos             locking_pos;
        u8                      locking_btree_id;
        u8                      locking_level;
-       u8                      traverse_all_idx;
        pid_t                   pid;
 #endif
        unsigned long           ip;