gfs2: print details on transactions that aren't properly ended
authorBob Peterson <rpeterso@redhat.com>
Thu, 23 Jul 2020 18:14:07 +0000 (13:14 -0500)
committerAndreas Gruenbacher <agruenba@redhat.com>
Fri, 7 Aug 2020 10:19:13 +0000 (12:19 +0200)
If function gfs2_trans_begin is called with another transaction active
it BUGs out, but it doesn't give any details about the duplicate.
This patch moves function gfs2_print_trans and calls it when this
situation arises for better debugging.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/trans.c

index a3dfa3a..e1c7eb6 100644 (file)
 #include "util.h"
 #include "trace_gfs2.h"
 
+static void gfs2_print_trans(struct gfs2_sbd *sdp, const struct gfs2_trans *tr)
+{
+       fs_warn(sdp, "Transaction created at: %pSR\n", (void *)tr->tr_ip);
+       fs_warn(sdp, "blocks=%u revokes=%u reserved=%u touched=%u\n",
+               tr->tr_blocks, tr->tr_revokes, tr->tr_reserved,
+               test_bit(TR_TOUCHED, &tr->tr_flags));
+       fs_warn(sdp, "Buf %u/%u Databuf %u/%u Revoke %u/%u\n",
+               tr->tr_num_buf_new, tr->tr_num_buf_rm,
+               tr->tr_num_databuf_new, tr->tr_num_databuf_rm,
+               tr->tr_num_revoke, tr->tr_num_revoke_rm);
+}
+
 int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
                     unsigned int revokes)
 {
        struct gfs2_trans *tr;
        int error;
 
-       BUG_ON(current->journal_info);
+       if (current->journal_info) {
+               gfs2_print_trans(sdp, current->journal_info);
+               BUG();
+       }
        BUG_ON(blocks == 0 && revokes == 0);
 
        if (!test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags))
@@ -72,18 +87,6 @@ fail:
        return error;
 }
 
-static void gfs2_print_trans(struct gfs2_sbd *sdp, const struct gfs2_trans *tr)
-{
-       fs_warn(sdp, "Transaction created at: %pSR\n", (void *)tr->tr_ip);
-       fs_warn(sdp, "blocks=%u revokes=%u reserved=%u touched=%u\n",
-               tr->tr_blocks, tr->tr_revokes, tr->tr_reserved,
-               test_bit(TR_TOUCHED, &tr->tr_flags));
-       fs_warn(sdp, "Buf %u/%u Databuf %u/%u Revoke %u/%u\n",
-               tr->tr_num_buf_new, tr->tr_num_buf_rm,
-               tr->tr_num_databuf_new, tr->tr_num_databuf_rm,
-               tr->tr_num_revoke, tr->tr_num_revoke_rm);
-}
-
 void gfs2_trans_end(struct gfs2_sbd *sdp)
 {
        struct gfs2_trans *tr = current->journal_info;