From 40a44873a5ca9843532344d12583e6a3a78ea848 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 2 Oct 2022 01:41:08 -0400 Subject: bcachefs: Improve btree_deadlock debugfs output This changes bch2_check_for_deadlock() to print the longest chains it finds - when we have a deadlock because the cycle detector isn't finding something, this will let us see what it's missing. Signed-off-by: Kent Overstreet --- fs/bcachefs/debug.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'fs/bcachefs/debug.c') diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c index 41b2772afef9..c7d558381388 100644 --- a/fs/bcachefs/debug.c +++ b/fs/bcachefs/debug.c @@ -725,11 +725,18 @@ static ssize_t bch2_btree_deadlock_read(struct file *file, char __user *buf, goto out; mutex_lock(&c->btree_trans_lock); - list_for_each_entry(trans, &c->btree_trans_list, list) - if (bch2_check_for_deadlock(trans, &i->buf)) { - i->iter = 1; - break; - } + list_for_each_entry(trans, &c->btree_trans_list, list) { + if (trans->locking_wait.task->pid <= i->iter) + continue; + + ret = flush_buf(i); + if (ret) + return ret; + + bch2_check_for_deadlock(trans, &i->buf); + + i->iter = trans->locking_wait.task->pid; + } mutex_unlock(&c->btree_trans_lock); out: if (i->buf.allocation_failure) -- cgit v1.2.3