]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Add support for backing up the journal inode location in the
authorTheodore Ts'o <tytso@mit.edu>
Thu, 21 Aug 2003 04:40:26 +0000 (00:40 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 21 Aug 2003 04:40:26 +0000 (00:40 -0400)
superblock.  E2fsck will automatically save the journal information
in the superblock if it is not there already, and will use it if the
journal inode appears to be corrupted.  ext2fs_add_journal_inode()
will also save the backup information, so that new filesystems
created by mke2fs and filesystems that have journals added via
tune2fs will also have journal location written to the superblock as
well.  Debugfs's logdump command has been enhanced so that it can
use the journal information in the superblock.

The debugfs man page has been improved to more fully describe the
logdump command.

Added two new functions, ext2fs_file_open2() and
ext2fs_inode_io_intern2() which take a pointer to an inode structure;
this is needed so that e2fsck and debugfs can synthesize a
fake journal inode and use it to access the journal.

24 files changed:
debugfs/ChangeLog
debugfs/debugfs.8.in
debugfs/logdump.c
e2fsck/ChangeLog
e2fsck/journal.c
e2fsck/problem.c
e2fsck/problem.h
lib/e2p/ChangeLog
lib/e2p/ls.c
lib/ext2fs/ChangeLog
lib/ext2fs/ext2_fs.h
lib/ext2fs/ext2fs.h
lib/ext2fs/fileio.c
lib/ext2fs/inode_io.c
lib/ext2fs/mkjournal.c
tests/ChangeLog
tests/f_bad_local_jnl/expect.1
tests/f_badorphan/expect.1
tests/f_h_badroot/expect.1
tests/f_h_reindex/expect.1
tests/f_journal/expect.1
tests/f_journal/image.gz
tests/f_journal/name
tests/f_special_ea/expect.1

index cdac00ae661cc322d6c1de01cf6a25df24bd56b7..ec0af884c90253227b077ae94bb3037d099c3425 100644 (file)
@@ -1,3 +1,11 @@
+2003-08-21  Theodore Ts'o  <tytso@mit.edu>
+
+       * debugfs.8.in: Fully document the logdump command in the debugfs
+               man page.
+
+       * logdump.c (do_logdump): Add -s option which will use the journal
+               inode information in the superblock.
+
 2003-07-25  Theodore Ts'o  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.34
index f51f8fec9c3acca2311fd985bec60f3a41618df3..fa7e3fbad13ec4cc7618f4f0a9ab6db573cb9371 100644 (file)
@@ -270,8 +270,36 @@ which is a link to
 .IR filespec .
 Note this does not adjust the inode reference counts.
 .TP
-.I logdump [-ac] [-b<block>] [-i<inode>] [-f<journal_file>] [output_file]
-Dump the contents of the ext3 journal.
+.I logdump [-acs] [-b<block>] [-i<filespec>] [-f<journal_file>] [output_file]
+Dump the contents of the ext3 journal.  By default, the journal inode as
+specified in the superblock.  However, this can be overridden with the 
+.I \-i
+option, which uses an inode specifier to specify the journal to be
+used.  A file containing journal data can be specified using the
+.I \-f
+option.   Finally, the 
+.I \-s
+option utilizes the backup information in the superblock to locate the
+journal.
+.IP
+The 
+.I \-a
+option causes the 
+.I logdump
+program to print the contents of all of the descriptor blocks.
+The 
+.I \-b
+option causes 
+.I logdump
+to print all journal records that are refer to the specified block. 
+The 
+.I \-c
+option will print out the contents of all of the data blocks selected by
+the 
+.I \-a
+and 
+.I \-b
+options.
 .TP
 .I ls [-l] [-d] filespec
 Print a listing of the files in the directory
index f3f2e5dcb9887efa3278e3457899e0e7e7272eba..fcc12f0c0b6b28535d205594546e995ee59df8d0 100644 (file)
@@ -79,6 +79,7 @@ void do_logdump(int argc, char **argv)
        char            *inode_spec = NULL;
        char            *journal_fn = NULL;
        int             journal_fd = 0;
+       int             use_sb = 0;
        ext2_ino_t      journal_inum;
        struct ext2_inode journal_inode;
        ext2_file_t     journal_file;
@@ -101,7 +102,7 @@ void do_logdump(int argc, char **argv)
        inode_to_dump = -1;
        
        reset_getopt();
-       while ((c = getopt (argc, argv, "ab:ci:f:")) != EOF) {
+       while ((c = getopt (argc, argv, "ab:ci:f:s")) != EOF) {
                switch (c) {
                case 'a':
                        dump_all++;
@@ -125,6 +126,9 @@ void do_logdump(int argc, char **argv)
                        inode_spec = optarg;
                        dump_descriptors = 0;
                        break;
+               case 's':
+                       use_sb++;
+                       break;
                default:
                        com_err(argv[0], 0, logdump_usage);
                        return;
@@ -199,11 +203,26 @@ void do_logdump(int argc, char **argv)
                journal_source.where = JOURNAL_IS_EXTERNAL;
                journal_source.fd = journal_fd;
        } else if ((journal_inum = es->s_journal_inum)) {
-               if (debugfs_read_inode(journal_inum, &journal_inode, argv[0]))
-                       return;
-
-               retval = ext2fs_file_open(current_fs, journal_inum,
-                                         0, &journal_file);
+               if (use_sb) {
+                       if (es->s_jnl_backup_type != EXT3_JNL_BACKUP_BLOCKS) {
+                               com_err(argv[0], 0,
+                                       "no journal backup in super block\n");
+                               return;
+                       }
+                       memset(&journal_inode, 0, sizeof(struct ext2_inode));
+                       memcpy(&journal_inode.i_block[0], es->s_jnl_blocks, 
+                              EXT2_N_BLOCKS*4);
+                       journal_inode.i_size = es->s_jnl_blocks[16];
+                       journal_inode.i_links_count = 1;
+                       journal_inode.i_mode = LINUX_S_IFREG | 0600;
+               } else {
+                       if (debugfs_read_inode(journal_inum, &journal_inode, 
+                                              argv[0]))
+                               return;
+               }
+               
+               retval = ext2fs_file_open2(current_fs, journal_inum,
+                                          &journal_inode, 0, &journal_file);
                if (retval) {
                        com_err(argv[0], retval, "while opening ext2 file");
                        return;
index e32d0b5b5f3defdc2fb8299ad35dc805dbf81be0..2a8b9c84081bd8fd4981e15b3703865f1123c321 100644 (file)
@@ -1,3 +1,15 @@
+2003-08-20  Theodore Ts'o  <tytso@mit.edu>
+
+       * journal.c (e2fsck_move_ext3_journal): If the superblock's backup
+               journal information is not set, copy the journal inode
+               information to the superblock.
+               (e2fsck_get_journal): If the journal inode is corrupted,
+               synthesize one from the backup information in the
+               superblock.
+
+       * problem.c, problem.h (PR_0_BACKUP_JNL): Add new problem code
+               which is used when we make a backup of the journal inode.
+
 2003-08-19  Theodore Ts'o  <tytso@mit.edu>
 
        * e2fsck.h, unix.c (PRS, e2fsck_clear_progbar, 
index 1ca73663e5faa26f77968d817cee64d72697de3b..8ef4a3665c53f9a7be9b57b5c56ae4461e32bf39 100644 (file)
@@ -188,7 +188,10 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
        errcode_t               retval = 0;
        io_manager              io_ptr = 0;
        unsigned long           start = 0;
+       blk_t                   blk;
        int                     ext_journal = 0;
+       int                     tried_backup_jnl = 0;
+       int                     i;
                
        clear_problem_context(&pctx);
        
@@ -228,24 +231,50 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
                
                if ((retval = ext2fs_read_inode(ctx->fs,
                                                sb->s_journal_inum,
-                                               &j_inode->i_ext2)))
-                       goto errout;
+                                               &j_inode->i_ext2))) {
+               try_backup_journal:
+                       if (sb->s_jnl_backup_type != EXT3_JNL_BACKUP_BLOCKS ||
+                           tried_backup_jnl)
+                               goto errout;
+                       memset(&j_inode->i_ext2, 0, sizeof(struct ext2_inode));
+                       memcpy(&j_inode->i_ext2.i_block[0], sb->s_jnl_blocks, 
+                              EXT2_N_BLOCKS*4);
+                       j_inode->i_ext2.i_size = sb->s_jnl_blocks[16];
+                       j_inode->i_ext2.i_links_count = 1;
+                       j_inode->i_ext2.i_mode = LINUX_S_IFREG | 0600;
+                       tried_backup_jnl++;
+               }
                if (!j_inode->i_ext2.i_links_count ||
                    !LINUX_S_ISREG(j_inode->i_ext2.i_mode)) {
                        retval = EXT2_ET_NO_JOURNAL;
-                       goto errout;
+                       goto try_backup_journal;
                }
                if (j_inode->i_ext2.i_size / journal->j_blocksize <
                    JFS_MIN_JOURNAL_BLOCKS) {
                        retval = EXT2_ET_JOURNAL_TOO_SMALL;
-                       goto errout;
+                       goto try_backup_journal;
+               }
+               for (i=0; i < EXT2_N_BLOCKS; i++) {
+                       blk = j_inode->i_ext2.i_block[i];
+                       if (!blk) {
+                               if (i < EXT2_NDIR_BLOCKS) {
+                                       retval = EXT2_ET_JOURNAL_TOO_SMALL;
+                                       goto try_backup_journal;
+                               }
+                               continue;
+                       }
+                       if (blk < sb->s_first_data_block ||
+                           blk >= sb->s_blocks_count) {
+                               retval = EXT2_ET_BAD_BLOCK_NUM;
+                               goto try_backup_journal;
+                       }
                }
-
                journal->j_maxlen = j_inode->i_ext2.i_size / journal->j_blocksize;
 
 #ifdef USE_INODE_IO
-               retval = ext2fs_inode_io_intern(ctx->fs, sb->s_journal_inum,
-                                               &journal_name);
+               retval = ext2fs_inode_io_intern2(ctx->fs, sb->s_journal_inum,
+                                                &j_inode->i_ext2,
+                                                &journal_name);
                if (retval)
                        goto errout;
 
@@ -439,7 +468,7 @@ static errcode_t e2fsck_journal_load(journal_t *journal)
        case JFS_SUPERBLOCK_V2:
                journal->j_format_version = 2;
                if (ntohl(jsb->s_nr_users) > 1 &&
-                   (ctx->fs->io == ctx->journal_io))
+                   uuid_is_null(ctx->fs->super->s_journal_uuid))
                        clear_v2_journal_fields(journal);
                if (ntohl(jsb->s_nr_users) > 1) {
                        fix_problem(ctx, PR_0_JOURNAL_UNSUPP_MULTIFS, &pctx);
@@ -807,17 +836,50 @@ void e2fsck_move_ext3_journal(e2fsck_t ctx)
        const char * const *    cpp;
        int                     group, mount_flags;
        
+       clear_problem_context(&pctx);
+
        /*
         * If the filesystem is opened read-only, or there is no
-        * journal, or the journal is already in the hidden inode,
-        * then do nothing.
+        * journal, then do nothing.
         */
        if ((ctx->options & E2F_OPT_READONLY) ||
            (sb->s_journal_inum == 0) ||
-           (sb->s_journal_inum == EXT2_JOURNAL_INO) ||
            !(sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL))
                return;
 
+       /*
+        * Read in the journal inode
+        */
+       if (ext2fs_read_inode(fs, sb->s_journal_inum, &inode) != 0)
+               return;
+
+       /*
+        * If it's necessary to backup the journal inode, do so.
+        */
+       if ((sb->s_jnl_backup_type == 0) ||
+           ((sb->s_jnl_backup_type == EXT3_JNL_BACKUP_BLOCKS) &&
+            memcmp(inode.i_block, sb->s_jnl_blocks, EXT2_N_BLOCKS*4))) {
+               if (fix_problem(ctx, PR_0_BACKUP_JNL, &pctx)) {
+                       memcpy(sb->s_jnl_blocks, inode.i_block,
+                              EXT2_N_BLOCKS*4);
+                       sb->s_jnl_blocks[16] = inode.i_size;
+                       sb->s_jnl_backup_type = EXT3_JNL_BACKUP_BLOCKS;
+                       ext2fs_mark_super_dirty(fs);
+               }
+       }
+
+       /*
+        * If the journal is already the hidden inode, then do nothing
+        */
+       if (sb->s_journal_inum == EXT2_JOURNAL_INO)
+               return;
+       
+       /*
+        * The journal inode had better have only one link and not be readable.
+        */
+       if (inode.i_links_count != 1)
+               return;
+
        /*
         * If the filesystem is mounted, or we can't tell whether
         * or not it's mounted, do nothing.
@@ -839,20 +901,11 @@ void e2fsck_move_ext3_journal(e2fsck_t ctx)
        if (*cpp == 0)
                return;
 
-       /*
-        * The inode had better have only one link and not be readable.
-        */
-       if (ext2fs_read_inode(fs, ino, &inode) != 0)
-               return;
-       if (inode.i_links_count != 1)
-               return;
-
        /* We need the inode bitmap to be loaded */
        retval = ext2fs_read_bitmaps(fs);
        if (retval)
                return;
 
-       clear_problem_context(&pctx);
        pctx.str = *cpp;
        if (!fix_problem(ctx, PR_0_MOVE_JOURNAL, &pctx))
                return;
index b8187c9fb91bbb7bdae0210e23540ebda979b379..cc50bf124f45be1d810aa728b2896b58f9cab31e 100644 (file)
@@ -309,6 +309,11 @@ static const struct e2fsck_problem problem_table[] = {
             "Clearing fields beyond the V1 @j @S...\n\n"),
          PROMPT_NONE, 0 },
 
+       /* Backup journal inode blocks */
+       { PR_0_BACKUP_JNL,
+         N_("Backing up @j @i @b information.\n\n"),
+         PROMPT_NONE, 0 },
+
        /* Pass 1 errors */
        
        /* Pass 1: Checking inodes, blocks, and sizes */
index 8626f7fc9cb4735dfad740547e2a31ca347a38a2..b8e6c13271251c0d78aef5f6ad1908c74d803133 100644 (file)
@@ -172,6 +172,9 @@ struct problem_context {
 /* Run journal anyway by default */
 #define PR_0_JOURNAL_RUN_DEFAULT               0x00002C
 
+/* Backup journal inode blocks */
+#define PR_0_BACKUP_JNL                                0x00002D
+
 /*
  * Pass 1 errors
  */
index cf73b71a3cf2f3936c5dd8f2303edcce8177243e..388e4c81df23fed4b1f913e3cfbbf3d7484585ba 100644 (file)
@@ -1,3 +1,7 @@
+2003-08-20  Theodore Ts'o  <tytso@mit.edu>
+
+       * ls.c (list_super2): Display the journal backup type.
+
 2003-07-25  Theodore Ts'o  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.34
index d5a112cc0a77963ae9a74f36a315d594e4e50a2c..3f71eb0088eb11a362acf6b24aa189c6f6cce81a 100644 (file)
@@ -259,6 +259,16 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
        if (!e2p_is_null_uuid(sb->s_hash_seed))
                fprintf(f, "Directory Hash Seed:      %s\n",
                        e2p_uuid2str(sb->s_hash_seed));
+       if (sb->s_jnl_backup_type) {
+               fprintf(f, "Journal backup:           ");
+               switch (sb->s_jnl_backup_type) {
+               case 1:
+                       fprintf(f, "inode blocks\n");
+                       break;
+               default:
+                       fprintf(f, "type %u\n", sb->s_jnl_backup_type);
+               }
+       }
 }
 
 void list_super (struct ext2_super_block * s)
index 7181f98d020accdc07494c5705babcd7391a92f3..52b2944694396fa570e47b3df2457f35e0d5b7bc 100644 (file)
@@ -1,3 +1,18 @@
+2003-08-20  Theodore Ts'o  <tytso@mit.edu>
+
+       * inode_io.c (ext2fs_inode_io_intern2), ext2fs.h: Add new function
+               allows the caller to pass in the inode data structure.
+
+       * fileio.c (ext2fs_file_open2), ext2fs.h: Add new function which
+               allows the caller to pass in the inode to be used in the
+               file I/O.
+
+       * ext2_fs.h: Add a backup of the location of the journal inode
+               blocks to the superblock.
+
+       * mkjournal.c (write_journal_inode): Save the location of the
+               journal inode to the backup location in the superblock.
+
 2003-08-01  Philipp Thomas <pthomas@suse.de>
 
        * alloc.c, badblocks.c, bb_inode.c, bitmaps.c, block.c, bmap.c,
index 6ace0a91d0889d0c36f7c1b6260ede0633314a47..f9f96b555dc9155e87c45f007e4907531efbee1e 100644 (file)
@@ -441,12 +441,13 @@ struct ext2_super_block {
        __u32   s_last_orphan;          /* start of list of inodes to delete */
        __u32   s_hash_seed[4];         /* HTREE hash seed */
        __u8    s_def_hash_version;     /* Default hash version to use */
-       __u8    s_reserved_char_pad;
+       __u8    s_jnl_backup_type;      /* Default type of journal backup */
        __u16   s_reserved_word_pad;
        __u32   s_default_mount_opts;
        __u32   s_first_meta_bg;        /* First metablock group */
        __u32   s_mkfs_time;            /* When the filesystem was created */
-       __u32   s_reserved[189];        /* Padding to the end of the block */
+       __u32   s_jnl_blocks[16];       /* Backup of the journal inode */
+       __u32   s_reserved[173];        /* Padding to the end of the block */
 };
 
 /*
@@ -469,6 +470,11 @@ struct ext2_super_block {
 
 #define EXT2_GOOD_OLD_INODE_SIZE 128
 
+/*
+ * Journal inode backup types
+ */
+#define EXT3_JNL_BACKUP_BLOCKS 1
+
 /*
  * Feature set definitions
  */
index 8087fa226ff85b14ab515117721f211a0766f561..77b2de7d1da444e5170416e9056676fb950d289f 100644 (file)
@@ -686,6 +686,9 @@ extern errcode_t ext2fs_adjust_ea_refcount(ext2_filsys fs, blk_t blk,
                                           int adjust, __u32 *newcount);
 
 /* fileio.c */
+extern errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
+                                  struct ext2_inode *inode,
+                                  int flags, ext2_file_t *ret);
 extern errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino,
                                  int flags, ext2_file_t *ret);
 extern ext2_filsys ext2fs_file_get_fs(ext2_file_t file);
@@ -784,6 +787,9 @@ extern errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino);
 extern io_manager inode_io_manager;
 extern errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino, 
                                        char **name);
+extern errcode_t ext2fs_inode_io_intern2(ext2_filsys fs, ext2_ino_t ino,
+                                        struct ext2_inode *inode,
+                                        char **name);
        
 /* ismounted.c */
 extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags);
index 39455b9a74efbc5c3f83829968ae6043fd99b908..3e42cbc32e956a1fcbb676ebce6a21912ca10735 100644 (file)
@@ -32,8 +32,9 @@ struct ext2_file {
 
 #define BMAP_BUFFER (file->buf + fs->blocksize)
 
-errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino,
-                          int flags, ext2_file_t *ret)
+errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
+                           struct ext2_inode *inode,
+                           int flags, ext2_file_t *ret)
 {
        ext2_file_t     file;
        errcode_t       retval;
@@ -56,9 +57,13 @@ errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino,
        file->ino = ino;
        file->flags = flags & EXT2_FILE_MASK;
 
-       retval = ext2fs_read_inode(fs, ino, &file->inode);
-       if (retval)
-               goto fail;
+       if (inode) {
+               memcpy(&file->inode, inode, sizeof(struct ext2_inode));
+       } else {
+               retval = ext2fs_read_inode(fs, ino, &file->inode);
+               if (retval)
+                       goto fail;
+       }
        
        retval = ext2fs_get_mem(fs->blocksize * 3, &file->buf);
        if (retval)
@@ -74,6 +79,12 @@ fail:
        return retval;
 }
 
+errcode_t ext2fs_file_open(ext2_filsys fs, ext2_ino_t ino,
+                          int flags, ext2_file_t *ret)
+{
+       return ext2fs_file_open2(fs, ino, NULL, flags, ret);
+}
+
 /*
  * This function returns the filesystem handle of a file from the structure
  */
@@ -106,7 +117,7 @@ errcode_t ext2fs_file_flush(ext2_file_t file)
         */
        if (!file->physblock) {
                retval = ext2fs_bmap(fs, file->ino, &file->inode,
-                                    BMAP_BUFFER, BMAP_ALLOC,
+                                    BMAP_BUFFER, file->ino ? BMAP_ALLOC : 0,
                                     file->blockno, &file->physblock);
                if (retval)
                        return retval;
@@ -353,9 +364,11 @@ errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size)
        
        file->inode.i_size = size;
        file->inode.i_size_high = 0;
-       retval = ext2fs_write_inode(file->fs, file->ino, &file->inode);
-       if (retval)
-               return retval;
+       if (file->ino) {
+               retval = ext2fs_write_inode(file->fs, file->ino, &file->inode);
+               if (retval)
+                       return retval;
+       }
 
        /* 
         * XXX truncate inode if necessary
index 5126bae174319e32e5c3e75dcf85a2c2c7b33114..b5c08b90af8287e528c7da6dee1672bd1e8816ad 100644 (file)
@@ -36,10 +36,13 @@ struct inode_private_data {
        ext2_file_t                     file;
        ext2_filsys                     fs;
        ext2_ino_t                      ino;
+       struct ext2_inode               inode;
        int                             flags;
        struct inode_private_data       *next;
 };
 
+#define CHANNEL_HAS_INODE      0x8000
+
 static struct inode_private_data *top_intern;
 static int ino_unique = 0;
 
@@ -68,8 +71,9 @@ static struct struct_io_manager struct_inode_manager = {
 
 io_manager inode_io_manager = &struct_inode_manager;
 
-errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino,
-                                char **name)
+errcode_t ext2fs_inode_io_intern2(ext2_filsys fs, ext2_ino_t ino,
+                                 struct ext2_inode *inode,
+                                 char **name)
 {
        struct inode_private_data       *data;
        errcode_t                       retval;
@@ -83,12 +87,22 @@ errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino,
        data->fs = fs;
        data->ino = ino;
        data->flags = 0;
+       if (inode) {
+               memcpy(&data->inode, inode, sizeof(struct ext2_inode));
+               data->flags |= CHANNEL_HAS_INODE;
+       }
        data->next = top_intern;
        top_intern = data;
        *name = data->name;
        return 0;
 }
 
+errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino,
+                                char **name)
+{
+       return ext2fs_inode_io_intern2(fs, ino, NULL, name);
+}
+
 
 static errcode_t inode_open(const char *name, int flags, io_channel *channel)
 {
@@ -130,8 +144,10 @@ static errcode_t inode_open(const char *name, int flags, io_channel *channel)
        io->refcount = 1;
 
        open_flags = (flags & IO_FLAG_RW) ? EXT2_FILE_WRITE : 0;
-       retval = ext2fs_file_open(data->fs, data->ino, open_flags,
-                                 &data->file);
+       retval = ext2fs_file_open2(data->fs, data->ino,
+                                  (data->flags & CHANNEL_HAS_INODE) ?
+                                  &data->inode : 0, open_flags,
+                                  &data->file);
        if (retval)
                goto cleanup;
                
index 8a440710e4b3551f9b1474a16bb46c32db06655b..abf162e72c90465fecc59804988c4c6f8796acd8 100644 (file)
@@ -236,6 +236,11 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
                goto errout;
        retval = 0;
 
+       memcpy(fs->super->s_jnl_blocks, inode.i_block, EXT2_N_BLOCKS*4);
+       fs->super->s_jnl_blocks[16] = inode.i_size;
+       fs->super->s_jnl_backup_type = EXT3_JNL_BACKUP_BLOCKS;
+       ext2fs_mark_super_dirty(fs);
+
 errout:
        ext2fs_free_mem(&buf);
        return retval;
index d20b0184ad6f8736d570d8cfccad6271adb91846..455ae133562f96c74226e398d62f49786d72fa2c 100644 (file)
@@ -1,3 +1,14 @@
+2003-08-20  Theodore Ts'o  <tytso@mit.edu>
+
+       * f_bad_local_jnl, f_badorphan, f_h_badroot, f_h_reindex,
+               f_special_ea: Update tests to reflect that e2fsck will
+               backup the journal inode.
+
+       * f_journal: Change test to include a backed up journal location
+               in the superblock, and then corrupt the inode table so the
+               journal inode is trashed.  Make sure e2fsck can recover
+               from it.
+
 2003-08-01  Theodore Ts'o  <tytso@mit.edu>
 
        * f_salveage_dir: Remove HTREE flag from the test image's
index d8f6551c08f22ba68560273ace56c601c2fbecfa..10140b59730c55bc495b119b79b596732728b5ad 100644 (file)
@@ -1,10 +1,14 @@
 Found invalid V2 journal superblock fields (from V1 journal).
 Clearing fields beyond the V1 journal superblock...
 
+Backing up journal inode block information.
+
 Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 11/256 files (0.0% non-contiguous), 1080/8192 blocks
-Exit status is 0
+Exit status is 1
index c75d592b2ba8368f51b2e5edf72b3f6dbaeb6117..ecf0bf7e7735a69bd4668e5cd1955a00e42f8605 100644 (file)
@@ -2,6 +2,8 @@ Clearing orphaned inode 54 (uid=0, gid=0, mode=0100600, size=44610)
 Clearing orphaned inode 32 (uid=0, gid=0, mode=040700, size=1024)
 Clearing orphaned inode 67 (uid=0, gid=0, mode=040700, size=1024)
 Clearing orphaned inode 55 (uid=0, gid=0, mode=040700, size=1024)
+Backing up journal inode block information.
+
 Pass 1: Checking inodes, blocks, and sizes
 Inodes that were part of a corrupted orphan linked list found.  Fix? yes
 
index 398eea2b256bfd0a7ea1e531a30f219e56911883..cd49ccfc85992188027947a875e0bec0905e93d3 100644 (file)
@@ -1,3 +1,5 @@
+Backing up journal inode block information.
+
 Pass 1: Checking inodes, blocks, and sizes
 HTREE directory inode 13345 has an invalid root node.
 Clear HTree index? yes
index 7a315178ed6e62bb40cf8759e281dc920907d64c..1d4eff2858e0328693080803c43356957c6b7572 100644 (file)
@@ -1,3 +1,5 @@
+Backing up journal inode block information.
+
 Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
 Problem in HTREE directory inode 16001: node (1) has bad max hash
index 8859a6d93ac9e980a7e28e4b8d0fe7b91ea0083a..a202c80c77368543125ab0f58d87bff3374947e3 100644 (file)
@@ -47,6 +47,8 @@ Clearing orphaned inode 73 (uid=0, gid=0, mode=040700, size=1024)
 Clearing orphaned inode 55 (uid=0, gid=0, mode=0100600, size=4096)
 Clearing orphaned inode 24 (uid=0, gid=0, mode=0100600, size=4096)
 Clearing orphaned inode 59 (uid=0, gid=0, mode=0100600, size=4096)
+Backing up journal inode block information.
+
 Moving journal from /journal to hidden inode.
 
 Pass 1: Checking inodes, blocks, and sizes
index b4e056f4aed37270af950e1c7375ed10f59c2b82..512d9ec85637d74c482f4c05e4bcfac17c0c30e9 100644 (file)
Binary files a/tests/f_journal/image.gz and b/tests/f_journal/image.gz differ
index ce75ec56565472fd747181b89541d9d489c16584..ece2321e24e08055640e8454b97d912a91774ee0 100644 (file)
@@ -1 +1 @@
-recover journal
+recover journal from corrupted inode table
index 3c775d43d3d5cfe8ad76617bf0eeb89c87a2c7e1..54076fe56d94253875469c49aaf687aca5439005 100644 (file)
@@ -1,7 +1,11 @@
+Backing up journal inode block information.
+
 Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
 test_filesys: 17/1024 files (0.0% non-contiguous), 1180/4096 blocks
 Exit status is 1