]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: remove resize inode if both resize_inode and meta_bg are enabled
authorLukas Czerner <lczerner@redhat.com>
Wed, 8 Aug 2018 11:52:56 +0000 (13:52 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 11 Aug 2018 23:04:38 +0000 (19:04 -0400)
Previous e2fsprogs versions allowed to create a file system with both
resize_inode and meta_bg enabled. This was fixed by upstream commit
42e77d5d ("libext2fs: don't create filesystems with meta_bg and resize_inode")

However e2fsck still does not recognize the conflict and will attempt to
clear and recreate resize_inode if it's corrupted due to this incompatible
feature combination, though it will create it in the same wrong layout.

Fix it by teaching e2fsck to recognize resize_inode and meta_bg
conflict and fixing it by disabling and clearing resize inode.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/problem.c
e2fsck/problem.h
e2fsck/super.c

index 47321e0a75d1bf0326e7e4db05a46f3a5a962afd..0f603963c2fd88a9d0dff851ce85ecf4a79a3fbc 100644 (file)
@@ -500,6 +500,12 @@ static struct e2fsck_problem problem_table[] = {
          N_("@S would have too many inodes (%N).\n"),
          PROMPT_NONE, PR_AFTER_CODE, PR_0_SB_CORRUPT },
 
+       /* Meta_bg and resize_inode are not compatible, disable resize_inode*/
+       { PR_0_DISABLE_RESIZE_INODE,
+         N_("Resize_@i and meta_bg features are enabled. Those features are\n"
+            "not compatible. Resize @i should be disabled.  "),
+         PROMPT_FIX, 0 },
+
        /* Pass 1 errors */
 
        /* Pass 1: Checking inodes, blocks, and sizes */
index 7db122abe7b28acaa18a0b8e6c5bf8582f5632ee..2c79169ef33bbd3d8976ca257e069088dd4b2f94 100644 (file)
@@ -285,6 +285,9 @@ struct problem_context {
 /* Inode count in the superblock incorrect */
 #define PR_0_INODE_COUNT_BIG                   0x000050
 
+/* Meta_bg and resize_inode are not compatible, remove resize_inode*/
+#define PR_0_DISABLE_RESIZE_INODE              0x000051
+
 /*
  * Pass 1 errors
  */
index eb7ab0d1bb5f01bdfabfad03fa292cb683e39261..e5932be6067167343faafe4c8943b9e9f28e2b9f 100644 (file)
@@ -436,6 +436,14 @@ void check_resize_inode(e2fsck_t ctx)
 
        clear_problem_context(&pctx);
 
+       if (ext2fs_has_feature_resize_inode(fs->super) &&
+           ext2fs_has_feature_meta_bg(fs->super) &&
+           fix_problem(ctx, PR_0_DISABLE_RESIZE_INODE, &pctx)) {
+               ext2fs_clear_feature_resize_inode(fs->super);
+               fs->super->s_reserved_gdt_blocks = 0;
+               ext2fs_mark_super_dirty(fs);
+       }
+
        /*
         * If the resize inode feature isn't set, then
         * s_reserved_gdt_blocks must be zero.