summaryrefslogtreecommitdiff
path: root/fs/bcachefs/debug.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-10-02 08:41:08 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:42 +0300
commit40a44873a5ca9843532344d12583e6a3a78ea848 (patch)
treedae065156a658dfa45826f099e7d7eec8dab203d /fs/bcachefs/debug.c
parent943f9946a6cc58e2c15ae39970547cddbe845190 (diff)
downloadlinux-40a44873a5ca9843532344d12583e6a3a78ea848.tar.xz
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 <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/debug.c')
-rw-r--r--fs/bcachefs/debug.c17
1 files changed, 12 insertions, 5 deletions
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)