diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-09 04:29:04 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:42 -0400 |
commit | 1148a97f1fb9b80ef5355021f0c2dfc7b8f003a2 (patch) | |
tree | 6acb14dfff4d86d895e01b67aca7428b6abb7723 /fs/bcachefs/util.c | |
parent | 1be887979bc12a6c88b33b0d53dfdc369bfa9d49 (diff) | |
download | linux-stable-1148a97f1fb9b80ef5355021f0c2dfc7b8f003a2.tar.gz linux-stable-1148a97f1fb9b80ef5355021f0c2dfc7b8f003a2.tar.bz2 linux-stable-1148a97f1fb9b80ef5355021f0c2dfc7b8f003a2.zip |
bcachefs: Print cycle on unrecoverable deadlock
Some lock operations can't fail; a cycle of nofail locks is impossible
to recover from. So we want to get rid of these nofail locking
operations, but as this is tricky it'll be done incrementally.
If such a cycle happens, this patch prints out which codepaths are
involved so we know what to work on next.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/util.c')
-rw-r--r-- | fs/bcachefs/util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index 477c260de50b..bf529bb137ed 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -265,6 +265,26 @@ void bch2_print_string_as_lines(const char *prefix, const char *lines) console_unlock(); } +int bch2_prt_backtrace(struct printbuf *out, struct task_struct *task) +{ + unsigned long entries[32]; + unsigned i, nr_entries; + int ret; + + ret = down_read_killable(&task->signal->exec_update_lock); + if (ret) + return ret; + + nr_entries = stack_trace_save_tsk(task, entries, ARRAY_SIZE(entries), 0); + for (i = 0; i < nr_entries; i++) { + prt_printf(out, "[<0>] %pB", (void *)entries[i]); + prt_newline(out); + } + + up_read(&task->signal->exec_update_lock); + return 0; +} + /* time stats: */ #ifndef CONFIG_BCACHEFS_NO_LATENCY_ACCT |