From eb7bd15fe4e7a4a6cf05d9086722aad49f80c259 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 24 Feb 2022 19:04:11 -0500 Subject: [PATCH] bcachefs: Improve debug assertion We're hitting a strange bug with transaction paths not being sorted correctly - this dumps transaction paths in the order we thought was sorted, which will hopefully shed some light as to what's going on. Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_iter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 8aacaa05fc14..b58219292f34 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1410,7 +1410,7 @@ static int btree_path_traverse_one(struct btree_trans *, struct btree_path *, static int bch2_btree_path_traverse_all(struct btree_trans *trans) { struct bch_fs *c = trans->c; - struct btree_path *path, *prev = NULL; + struct btree_path *path, *prev; unsigned long trace_ip = _RET_IP_; int i, ret = 0; @@ -1419,6 +1419,7 @@ static int bch2_btree_path_traverse_all(struct btree_trans *trans) trans->in_traverse_all = true; retry_all: + prev = NULL; trans->restarted = false; trans_for_each_path(trans, path) @@ -1852,6 +1853,7 @@ struct btree_path *bch2_path_get(struct btree_trans *trans, int i; BUG_ON(trans->restarted); + btree_trans_sort_paths(trans); btree_trans_sort_paths(trans); @@ -2722,7 +2724,10 @@ static void btree_trans_verify_sorted(struct btree_trans *trans) unsigned i; trans_for_each_path_inorder(trans, path, i) { - BUG_ON(prev && btree_path_cmp(prev, path) > 0); + if (prev && btree_path_cmp(prev, path) > 0) { + bch2_dump_trans_paths_updates(trans); + panic("trans paths out of order!\n"); + } prev = path; } } -- 2.25.1