]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
ChangeLog, journal.c, message.c, problem.c, problem.h, super.c:
authorTheodore Ts'o <tytso@mit.edu>
Sun, 20 Aug 2000 22:06:31 +0000 (22:06 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 20 Aug 2000 22:06:31 +0000 (22:06 +0000)
  journal.c (e2fsck_journal_load): Fix **nasty** bug which caused
   e2fsck_check_ext3_journal to smash the journal because
   journal->j_transaction_sequence wasn't getting initialized.
  journal.c: (recover_ext3_journal, e2fsck_run_ext3_journal): Move call
   to e2fsck_clear_recover from recover_ext3_journal to after the
   filesystem has been closed and reopened.  Otherwise, the superblock in
   the filesystem handle will probably be stale, and will overwrite the
   newer version of the superblock written by the log recovery.
  message.c (expand_inode_expression): Add support for %Iu and %Ig
  problem.h (PR_0_CLEAR_ORPHAN_INODE): Add new problem code.
  super.c (release_orphan_inodes, release_inode_block,
   release_inode_blocks): Update the block group descriptor counts when
   freeing the orphan inode.  Use PR_0_CLEAR_ORPHAN_INODE to report when
   we clear an orphan.
  journal.c (e2fsck_run_ext3_journal): Fix a bug where we attempted to
   reopen the filesystem using the device name instead of the filesystem
   name.

e2fsck/ChangeLog
e2fsck/journal.c
e2fsck/message.c
e2fsck/problem.c
e2fsck/problem.h
e2fsck/super.c

index 797e117f5542fefcf62987a884ffea0f38c48902..86f19398b0b207f51592627d4e713f7ec7f94a45 100644 (file)
@@ -1,3 +1,30 @@
+2000-08-20    <tytso@valinux.com>
+
+       * journal.c (e2fsck_journal_load): Fix **nasty** bug which caused
+               e2fsck_check_ext3_journal to smash the journal because
+               journal->j_transaction_sequence wasn't getting
+               initialized.
+
+       * journal.c: (recover_ext3_journal, e2fsck_run_ext3_journal): Move
+               call to e2fsck_clear_recover from recover_ext3_journal to
+               after the filesystem has been closed and reopened.
+               Otherwise, the superblock in the filesystem handle will
+               probably be stale, and will overwrite the newer version of
+               the superblock written by the log recovery.
+
+       * message.c (expand_inode_expression): Add support for %Iu and %Ig
+
+       * problem.h (PR_0_CLEAR_ORPHAN_INODE): Add new problem code.
+
+       * super.c (release_orphan_inodes, release_inode_block,
+               release_inode_blocks): Update the block group descriptor
+               counts when freeing the orphan inode.  Use
+               PR_0_CLEAR_ORPHAN_INODE to report when we clear an orphan.
+
+       * journal.c (e2fsck_run_ext3_journal): Fix a bug where we
+               attempted to reopen the filesystem using the device name
+               instead of the filesystem name.
+
 2000-08-18    <tytso@valinux.com>
 
        * Makefile.in: Update the make dependencies
index 70869abaa598a55a1668923cead169c9d54fb11c..64c244598c4b950e3ffb4862c8440e10f2e932b2 100644 (file)
@@ -339,6 +339,7 @@ static int e2fsck_journal_load(journal_t *journal)
        }
 
        journal->j_tail_sequence = ntohl(jsb->s_sequence);
+       journal->j_transaction_sequence = journal->j_tail_sequence;
        journal->j_tail = ntohl(jsb->s_start);
        journal->j_first = ntohl(jsb->s_first);
        journal->j_last = ntohl(jsb->s_maxlen);
@@ -474,19 +475,14 @@ static int recover_ext3_journal(e2fsck_t ctx)
 
        retval = e2fsck_get_journal(ctx, &journal);
        if (retval)
-               goto exit;
+               return retval;
+
        retval = e2fsck_journal_load(journal);
        if (retval)
-               goto exit;
+               return retval;
 
        retval = -journal_recover(journal);
-
        e2fsck_journal_release(ctx, journal, 1);
-       if (retval)
-               goto exit;
-
-exit:
-       e2fsck_clear_recover(ctx, retval);
        return retval;
 }
 
@@ -597,17 +593,22 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx)
 {
        io_manager io_ptr = ctx->fs->io->manager;
        int blocksize = ctx->fs->blocksize;
-       errcode_t       retval;
+       errcode_t       retval, recover_retval;
        
-       if ((retval = recover_ext3_journal(ctx)))
-               return retval;
+       if (ctx->options & E2F_OPT_READONLY) {
+               printf("%s: won't do journal recovery while read-only\n",
+                      ctx->device_name);
+               return EXT2_ET_FILE_RO;
+       }
+
+       recover_retval = recover_ext3_journal(ctx);
        
        /*
         * Reload the filesystem context to get up-to-date data from disk
         * because journal recovery will change the filesystem under us.
         */
        ext2fs_close(ctx->fs);
-       retval = ext2fs_open(ctx->device_name, EXT2_FLAG_RW,
+       retval = ext2fs_open(ctx->filesystem_name, EXT2_FLAG_RW,
                             ctx->superblock, blocksize, io_ptr,
                             &ctx->fs);
 
@@ -619,5 +620,7 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx)
        }
        ctx->fs->priv_data = ctx;
 
-       return 0;
+       /* Set the superblock flags */
+       e2fsck_clear_recover(ctx, recover_retval);
+       return recover_retval;
 }
index 7622dcbae9d10d85a3bb66d8a6a5205b690cc676..34499997bce93dfd8101714a5f1f58411782b467 100644 (file)
@@ -32,6 +32,8 @@
  *     %IF     <inode> -> i_faddr
  *     %If     <inode> -> i_file_acl
  *     %Id     <inode> -> i_dir_acl
+ *     %Iu     <inode> -> i_uid
+ *     %Ig     <inode> -> i_gid
  *     %j      <ino2>                  inode number
  *     %m      <com_err error message>
  *     %N      <num>
@@ -213,7 +215,7 @@ static _INLINE_ void expand_at_expression(e2fsck_t ctx, char ch,
 }
 
 /*
- * This function expands '%kX' expressions
+ * This function expands '%IX' expressions
  */
 static _INLINE_ void expand_inode_expression(char ch,
                                               struct problem_context *ctx)
@@ -268,6 +270,14 @@ static _INLINE_ void expand_inode_expression(char ch,
                printf("%u", (LINUX_S_ISDIR(inode->i_mode) ?
                              inode->i_dir_acl : 0));
                break;
+       case 'u':
+               printf("%d", (inode->i_uid |
+                             (inode->osd2.linux2.l_i_uid_high << 16)));
+               break;
+       case 'g':
+               printf("%d", (inode->i_gid |
+                             (inode->osd2.linux2.l_i_gid_high << 16)));
+               break;
        default:
        no_inode:
                printf("%%I%c", ch);
index 52b0014995400ccc8e32ae46fb2c5a8cebdfc51e..bbfbb2593a24d364f5a8485e7a6f5b1e02190726 100644 (file)
@@ -229,6 +229,11 @@ static const struct e2fsck_problem problem_table[] = {
          N_("ext3 recovery flag clear, but journal has data.\n"),
          PROMPT_CLEAR, PR_PREEN_OK|PR_PREEN_NOMSG },
 
+       /* Clearing orphan inode */
+       { PR_0_CLEAR_ORPHAN_INODE,
+         N_("Clearing @o @i %i (uid=%Iu, gid=%Ig, mode=%Im, size=%Is)\n"),
+         PROMPT_NONE, 0 },
+
        /* Illegal block found in orphaned inode */
        { PR_0_ORPHAN_ILLEGAL_BLOCK_NUM,
           N_("@I @b #%B (%b) found in @o @i %i.\n"),
index 9a0cff962c96041e66b35c7a5334704796173b83..60ca1d266e40995e5dad97138fce89fd53d357d4 100644 (file)
@@ -127,22 +127,24 @@ struct problem_context {
 /* Superblock recovery flag clear - journal needs to be reset */
 #define PR_0_JOURNAL_RESET_PROMPT 0x000019
 
+/* Clearing orphan inode */
+#define PR_0_CLEAR_ORPHAN_INODE                        0x000020
+       
 /* Illegal block found in orphaned inode */
-#define PR_0_ORPHAN_ILLEGAL_BLOCK_NUM          0x000020
+#define PR_0_ORPHAN_ILLEGAL_BLOCK_NUM          0x000021
 
 /* Already cleared block found in orphaned inode */
-#define PR_0_ORPHAN_ALREADY_CLEARED_BLOCK      0x000021
+#define PR_0_ORPHAN_ALREADY_CLEARED_BLOCK      0x000022
        
 /* Illegal orphan inode in superblock */
-#define PR_0_ORPHAN_ILLEGAL_HEAD_INODE         0x000022
+#define PR_0_ORPHAN_ILLEGAL_HEAD_INODE         0x000023
 
 /* Illegal inode in orphaned inode list */
-#define PR_0_ORPHAN_ILLEGAL_INODE              0x000023
+#define PR_0_ORPHAN_ILLEGAL_INODE              0x000024
 
 /* Orphan inode has a non-zero link count */
-#define PR_0_ORPHAN_INODE_INUSE                        0x000024
+#define PR_0_ORPHAN_INODE_INUSE                        0x000025
 
-       
 /*
  * Pass 1 errors
  */
index 3d41e81c73f58e0a45d4dadd13d9f179ec9ec758..8e8c8aaefd2e3449d146ce4416a45611541db8ce 100644 (file)
@@ -95,6 +95,8 @@ static int release_inode_block(ext2_filsys fs,
        }
        
        ext2fs_unmark_block_bitmap(fs->block_map, blk);
+       fs->group_desc[ext2fs_group_of_blk(fs, blk)].bg_free_blocks_count++;
+       fs->super->s_free_blocks_count++;
        
        return 0;
 }
@@ -125,8 +127,6 @@ static int release_inode_blocks(e2fsck_t ctx, ino_t ino, char* block_buf,
        if (pb.abort)
                return 1;
 
-       ext2fs_unmark_inode_bitmap(fs->inode_map, ino);
-       ext2fs_mark_ib_dirty(fs);
        ext2fs_mark_bb_dirty(fs);
        return 0;
 }
@@ -138,6 +138,7 @@ static int release_inode_blocks(e2fsck_t ctx, ino_t ino, char* block_buf,
 static int release_orphan_inodes(e2fsck_t ctx)
 {
        ext2_filsys fs = ctx->fs;
+       int group;
        ino_t   ino, next_ino;
        struct ext2_inode inode;
        struct problem_context pctx;
@@ -166,15 +167,13 @@ static int release_orphan_inodes(e2fsck_t ctx)
        e2fsck_read_bitmaps(ctx);
        
        while (ino) {
-#ifdef JFS_DEBUG
-               printf("Clearing orphan inode %d\n", ino);
-#endif
-
                e2fsck_read_inode(ctx, ino, &inode, "delete_file");
                clear_problem_context(&pctx);
-               pctx.ino;
+               pctx.ino = ino;
                pctx.inode = &inode;
 
+               fix_problem(ctx, PR_0_CLEAR_ORPHAN_INODE, &pctx);
+
                if (inode.i_links_count) {
                        fix_problem(ctx, PR_0_ORPHAN_INODE_INUSE, &pctx);
                        goto abort;
@@ -192,6 +191,15 @@ static int release_orphan_inodes(e2fsck_t ctx)
                
                inode.i_dtime = time(0);
                e2fsck_write_inode(ctx, ino, &inode, "delete_file");
+
+               ext2fs_unmark_inode_bitmap(fs->inode_map, ino);
+               ext2fs_mark_ib_dirty(fs);
+               group = ext2fs_group_of_ino(fs, ino);
+               fs->group_desc[group].bg_free_inodes_count++;
+               fs->super->s_free_inodes_count++;
+               if (LINUX_S_ISDIR(inode.i_mode))
+                       fs->group_desc[group].bg_used_dirs_count--;
+               
                ino = next_ino;
        }
        return 0;