]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[GFS2] Update debugging code
authorSteven Whitehouse <swhiteho@redhat.com>
Wed, 29 Mar 2006 19:36:49 +0000 (14:36 -0500)
committerSteven Whitehouse <swhiteho@redhat.com>
Wed, 29 Mar 2006 19:36:49 +0000 (14:36 -0500)
Update the debugging code in trans.c and at the same time improve
the debugging code for gfs2_holders. The new code should be pretty
fast during the normal case and provide just as much information
in case of errors (or more).

One small function from glock.c has moved to glock.h as a static inline so
that its return address won't get in the way of the debugging.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/glock.c
fs/gfs2/glock.h
fs/gfs2/incore.h
fs/gfs2/trans.c
fs/gfs2/trans.h

index 81b06812b3296700d3e3fd0a24fa61898944a576..6a1b42cf4df409deabdaef99783011f51a8ae2a5 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/sort.h>
 #include <linux/jhash.h>
 #include <linux/kref.h>
+#include <linux/kallsyms.h>
 #include <linux/gfs2_ondisk.h>
 #include <asm/semaphore.h>
 #include <asm/uaccess.h>
@@ -357,6 +358,7 @@ void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, int flags,
 {
        INIT_LIST_HEAD(&gh->gh_list);
        gh->gh_gl = gl;
+       gh->gh_ip = (unsigned long)__builtin_return_address(0);
        gh->gh_owner = (flags & GL_NEVER_RECURSE) ? NULL : current;
        gh->gh_state = state;
        gh->gh_flags = flags;
@@ -388,6 +390,7 @@ void gfs2_holder_reinit(unsigned int state, int flags, struct gfs2_holder *gh)
                gh->gh_flags |= GL_LOCAL_EXCL;
 
        gh->gh_iflags &= 1 << HIF_ALLOCED;
+       gh->gh_ip = (unsigned long)__builtin_return_address(0);
 }
 
 /**
@@ -400,6 +403,7 @@ void gfs2_holder_uninit(struct gfs2_holder *gh)
 {
        gfs2_glock_put(gh->gh_gl);
        gh->gh_gl = NULL;
+       gh->gh_ip = 0;
 }
 
 /**
@@ -427,7 +431,7 @@ struct gfs2_holder *gfs2_holder_get(struct gfs2_glock *gl, unsigned int state,
 
        gfs2_holder_init(gl, state, flags, gh);
        set_bit(HIF_ALLOCED, &gh->gh_iflags);
-
+       gh->gh_ip = (unsigned long)__builtin_return_address(0);
        return gh;
 }
 
@@ -1238,6 +1242,9 @@ static int recurse_check(struct gfs2_holder *existing, struct gfs2_holder *new,
        return 0;
 
  fail:
+       print_symbol(KERN_WARNING "GFS2: Existing holder from %s\n",
+                    existing->gh_ip);
+       print_symbol(KERN_WARNING "GFS2: New holder from %s\n", new->gh_ip);
        set_bit(HIF_ABORTED, &new->gh_iflags);
        return -EINVAL;
 }
@@ -1543,30 +1550,6 @@ int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time)
        return 0;
 }
 
-/**
- * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock
- * @gl: the glock
- * @state: the state we're requesting
- * @flags: the modifier flags
- * @gh: the holder structure
- *
- * Returns: 0, GLR_*, or errno
- */
-
-int gfs2_glock_nq_init(struct gfs2_glock *gl, unsigned int state, int flags,
-                      struct gfs2_holder *gh)
-{
-       int error;
-
-       gfs2_holder_init(gl, state, flags, gh);
-
-       error = gfs2_glock_nq(gh);
-       if (error)
-               gfs2_holder_uninit(gh);
-
-       return error;
-}
-
 /**
  * gfs2_glock_dq_uninit - dequeue a holder from a glock and initialize it
  * @gh: the holder structure
@@ -2334,6 +2317,7 @@ static int dump_holder(char *str, struct gfs2_holder *gh)
                if (test_bit(x, &gh->gh_iflags))
                        printk(" %u", x);
        printk(" \n");
+       print_symbol(KERN_INFO "    initialized at: %s\n", gh->gh_ip);
 
        error = 0;
 
index 06847ebebdee5ffe869fdf28a397feed35f39f59..560029de8d0782ee1a27f4d25c27d7070972bbd7 100644 (file)
@@ -106,8 +106,6 @@ void gfs2_glock_force_drop(struct gfs2_glock *gl);
 
 int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time);
 
-int gfs2_glock_nq_init(struct gfs2_glock *gl, unsigned int state, int flags,
-                      struct gfs2_holder *gh);
 void gfs2_glock_dq_uninit(struct gfs2_holder *gh);
 int gfs2_glock_nq_num(struct gfs2_sbd *sdp,
                      uint64_t number, struct gfs2_glock_operations *glops,
@@ -121,6 +119,31 @@ void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, uint64_t number,
                             struct gfs2_glock_operations *glops,
                             unsigned int state, int flags);
 
+/**
+ * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock
+ * @gl: the glock
+ * @state: the state we're requesting
+ * @flags: the modifier flags
+ * @gh: the holder structure
+ *
+ * Returns: 0, GLR_*, or errno
+ */
+
+static inline int gfs2_glock_nq_init(struct gfs2_glock *gl,
+                                    unsigned int state, int flags,
+                                    struct gfs2_holder *gh)
+{
+       int error;
+
+       gfs2_holder_init(gl, state, flags, gh);
+
+       error = gfs2_glock_nq(gh);
+       if (error)
+               gfs2_holder_uninit(gh);
+
+       return error;
+}
+
 /*  Lock Value Block functions  */
 
 int gfs2_lvb_hold(struct gfs2_glock *gl);
index 35163b5624607b4341529117733f8c1c25fcf12d..b5a994d1b5f7fd89c4e2a5fa516848bf3816ad88 100644 (file)
@@ -161,6 +161,7 @@ struct gfs2_holder {
        int gh_error;
        unsigned long gh_iflags;
        struct completion gh_wait;
+       unsigned long gh_ip;
 };
 
 enum {
@@ -353,8 +354,7 @@ struct gfs2_log_buf {
 };
 
 struct gfs2_trans {
-       char *tr_file;
-       unsigned int tr_line;
+       unsigned long tr_ip;
 
        unsigned int tr_blocks;
        unsigned int tr_revokes;
index aa1a619f08540559b0a7a13a44005e5c8692f0c4..3fae3d4e9ae4ac96ea787330001bcdd3bd44f46c 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
 #include <linux/gfs2_ondisk.h>
+#include <linux/kallsyms.h>
 #include <asm/semaphore.h>
 
 #include "gfs2.h"
 #include "trans.h"
 #include "util.h"
 
-int gfs2_trans_begin_i(struct gfs2_sbd *sdp, unsigned int blocks,
-                      unsigned int revokes, char *file, unsigned int line)
+int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
+                    unsigned int revokes)
 {
        struct gfs2_trans *tr;
        int error;
 
-       if (gfs2_assert_warn(sdp, !current->journal_info) ||
-           gfs2_assert_warn(sdp, blocks || revokes)) {
-               fs_warn(sdp, "(%s, %u)\n", file, line);
-               return -EINVAL;
-       }
+       BUG_ON(current->journal_info);
+       BUG_ON(blocks == 0 && revokes == 0);
 
        tr = kzalloc(sizeof(struct gfs2_trans), GFP_NOFS);
        if (!tr)
                return -ENOMEM;
 
-       tr->tr_file = file;
-       tr->tr_line = line;
+       tr->tr_ip = (unsigned long)__builtin_return_address(0);
        tr->tr_blocks = blocks;
        tr->tr_revokes = revokes;
        tr->tr_reserved = 1;
@@ -104,16 +101,15 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)
                return;
        }
 
-       if (gfs2_assert_withdraw(sdp, tr->tr_num_buf <= tr->tr_blocks))
-               fs_err(sdp, "tr_num_buf = %u, tr_blocks = %u "
-                      "tr_file = %s, tr_line = %u\n",
-                      tr->tr_num_buf, tr->tr_blocks,
-                      tr->tr_file, tr->tr_line);
+       if (gfs2_assert_withdraw(sdp, tr->tr_num_buf <= tr->tr_blocks)) {
+               fs_err(sdp, "tr_num_buf = %u, tr_blocks = %u ",
+                      tr->tr_num_buf, tr->tr_blocks);
+               print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip);
+       }
        if (gfs2_assert_withdraw(sdp, tr->tr_num_revoke <= tr->tr_revokes))
-               fs_err(sdp, "tr_num_revoke = %u, tr_revokes = %u "
-                      "tr_file = %s, tr_line = %u\n",
-                      tr->tr_num_revoke, tr->tr_revokes,
-                      tr->tr_file, tr->tr_line);
+               fs_err(sdp, "tr_num_revoke = %u, tr_revokes = %u ",
+                      tr->tr_num_revoke, tr->tr_revokes);
+               print_symbol(KERN_WARNING "GFS2: Transaction created at: %s\n", tr->tr_ip);
 
        gfs2_log_commit(sdp, tr);
 
index f7f3e2a3d5905d5c67e0c0653b800e97714f64ad..6b5e9e8bf56192f8fb45279132470aa051d3a210 100644 (file)
 #define RES_STATFS     1
 #define RES_QUOTA      2
 
-#define gfs2_trans_begin(sdp, blocks, revokes) \
-gfs2_trans_begin_i((sdp), (blocks), (revokes), __FILE__, __LINE__)
-
-int gfs2_trans_begin_i(struct gfs2_sbd *sdp,
-                     unsigned int blocks, unsigned int revokes,
-                     char *file, unsigned int line);
+int gfs2_trans_begin(struct gfs2_sbd *sdp,
+                     unsigned int blocks, unsigned int revokes);
 
 void gfs2_trans_end(struct gfs2_sbd *sdp);