Whamcloud - gitweb
debugfs: force logdump to display (old) journal contents
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 1 May 2014 23:13:02 +0000 (16:13 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 12 May 2014 03:28:57 +0000 (23:28 -0400)
If the user passes the -O option to logdump, try to dump old log
contents.  This can be used to try to track down journal problems even
after the journal has been replayed.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/debugfs.8.in
debugfs/logdump.c

index 7cda819..aacb223 100644 (file)
@@ -389,7 +389,7 @@ which is a hard link to
 .IR filespec .
 Note this does not adjust the inode reference counts.
 .TP
-.BI logdump " [-acs] [-b block] [-i filespec] [-f journal_file] [output_file]"
+.BI logdump " [-acsO] [-b block] [-i filespec] [-f journal_file] [output_file]"
 Dump the contents of the ext3 journal.  By default, dump the journal inode as
 specified in the superblock.  However, this can be overridden with the
 .I \-i
@@ -420,6 +420,12 @@ the
 and
 .I \-b
 options.
+.IP
+The
+.I \-O
+option causes logdump to display old (checkpointed) journal entries.
+This can be used to try to track down journal problems even after the
+journal has been replayed.
 .TP
 .BI ls " [-l] [-c] [-d] [-p] filespec"
 Print a listing of the files in the directory
index 211e11a..9f9594f 100644 (file)
@@ -39,7 +39,7 @@ enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
 
 #define ANY_BLOCK ((blk64_t) -1)
 
-static int             dump_all, dump_contents, dump_descriptors;
+static int             dump_all, dump_old, dump_contents, dump_descriptors;
 static blk64_t         block_to_dump, bitmap_to_dump, inode_block_to_dump;
 static unsigned int    group_to_dump, inode_offset_to_dump;
 static ext2_ino_t      inode_to_dump;
@@ -94,6 +94,7 @@ void do_logdump(int argc, char **argv)
        journal_source.fd = 0;
        journal_source.file = 0;
        dump_all = 0;
+       dump_old = 0;
        dump_contents = 0;
        dump_descriptors = 1;
        block_to_dump = ANY_BLOCK;
@@ -102,7 +103,7 @@ void do_logdump(int argc, char **argv)
        inode_to_dump = -1;
 
        reset_getopt();
-       while ((c = getopt (argc, argv, "ab:ci:f:s")) != EOF) {
+       while ((c = getopt (argc, argv, "ab:ci:f:Os")) != EOF) {
                switch (c) {
                case 'a':
                        dump_all++;
@@ -126,6 +127,9 @@ void do_logdump(int argc, char **argv)
                        inode_spec = optarg;
                        dump_descriptors = 0;
                        break;
+               case 'O':
+                       dump_old++;
+                       break;
                case 's':
                        use_sb++;
                        break;
@@ -267,7 +271,7 @@ errout:
        return;
 
 print_usage:
-       fprintf(stderr, "%s: Usage: logdump [-acs] [-b<block>] [-i<filespec>]\n\t"
+       fprintf(stderr, "%s: Usage: logdump [-acsO] [-b<block>] [-i<filespec>]\n\t"
                "[-f<journal_file>] [output_file]\n", argv[0]);
 }
 
@@ -393,9 +397,13 @@ static void dump_journal(char *cmdname, FILE *out_file,
        fprintf(out_file, "Journal starts at block %u, transaction %u\n",
                blocknr, transaction);
 
-       if (!blocknr)
+       if (!blocknr) {
                /* Empty journal, nothing to do. */
-               return;
+               if (!dump_old)
+                       return;
+               else
+                       blocknr = 1;
+       }
 
        while (1) {
                retval = read_journal_block(cmdname, source,
@@ -420,7 +428,8 @@ static void dump_journal(char *cmdname, FILE *out_file,
                        fprintf (out_file, "Found sequence %u (not %u) at "
                                 "block %u: end of journal.\n",
                                 sequence, transaction, blocknr);
-                       return;
+                       if (!dump_old)
+                               return;
                }
 
                if (dump_descriptors) {