bcachefs: Dump journal state when the journal deadlocks
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 16 Nov 2020 23:21:55 +0000 (18:21 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:47 +0000 (17:08 -0400)
Currently tracking down one of these bugs.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal.c

index e7b60876d09afbb3ad992a566f2d2f6a3229ec9d..32555ccffc0e9486d38129549371a43f02e17432 100644 (file)
@@ -414,8 +414,17 @@ unlock:
                goto retry;
 
        if (ret == -ENOSPC) {
-               WARN_ONCE(!can_discard && (flags & JOURNAL_RES_GET_RESERVED),
-                         "JOURNAL_RES_GET_RESERVED set but journal full");
+               if (WARN_ONCE(!can_discard && (flags & JOURNAL_RES_GET_RESERVED),
+                             "JOURNAL_RES_GET_RESERVED set but journal full")) {
+                       char *buf;
+
+                       buf = kmalloc(4096, GFP_NOFS);
+                       if (buf) {
+                               bch2_journal_debug_to_text(&_PBUF(buf, 4096), j);
+                               pr_err("\n%s", buf);
+                               kfree(buf);
+                       }
+               }
 
                /*
                 * Journal is full - can't rely on reclaim from work item due to