Whamcloud - gitweb
misc: zero s_jnl_blocks when removing internal journal
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Sep 2014 23:12:35 +0000 (16:12 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Sep 2014 16:40:55 +0000 (12:40 -0400)
When we're removing the internal journal (broken journal, turning it
off, or adding an external journal), zero s_jnl_blocks so that they
can't be picked up by accident later.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/journal.c
lib/ext2fs/mkjournal.c
misc/tune2fs.c

index 16bd757..d12e317 100644 (file)
@@ -549,6 +549,7 @@ static errcode_t e2fsck_journal_fix_bad_inode(e2fsck_t ctx,
                                       "filesystem is now ext2 only ***\n\n");
                        sb->s_feature_compat &= ~EXT3_FEATURE_COMPAT_HAS_JOURNAL;
                        sb->s_journal_inum = 0;
+                       memset(sb->s_jnl_blocks, 0, sizeof(sb->s_jnl_blocks));
                        ctx->flags |= E2F_FLAG_JOURNAL_INODE;
                        ctx->fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
                        e2fsck_clear_recover(ctx, 1);
index 85f86bf..0a7cd18 100644 (file)
@@ -490,6 +490,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev)
        fs->super->s_journal_dev = st.st_rdev;
        memcpy(fs->super->s_journal_uuid, jsb->s_uuid,
               sizeof(fs->super->s_journal_uuid));
+       memset(fs->super->s_jnl_blocks, 0, sizeof(fs->super->s_jnl_blocks));
        fs->super->s_feature_compat |= EXT3_FEATURE_COMPAT_HAS_JOURNAL;
        ext2fs_mark_super_dirty(fs);
        return 0;
index c22c8fd..7292ab1 100644 (file)
@@ -377,6 +377,7 @@ static errcode_t remove_journal_inode(ext2_filsys fs)
                return retval;
        }
        fs->super->s_journal_inum = 0;
+       memset(fs->super->s_jnl_blocks, 0, sizeof(fs->super->s_jnl_blocks));
        ext2fs_mark_super_dirty(fs);
 
        return 0;