Blame SOURCES/e2fsprogs-1.44.4-e2fsck-remove-resize-inode-if-both-resize_inode-and-.patch

5ce3dc
From b3105cb666a7a8447e08cf3ab49b8e60426b21cc Mon Sep 17 00:00:00 2001
5ce3dc
From: Lukas Czerner <lczerner@redhat.com>
5ce3dc
Date: Wed, 8 Aug 2018 13:52:56 +0200
5ce3dc
Subject: [PATCH 03/10] e2fsck: remove resize inode if both resize_inode and
5ce3dc
 meta_bg are enabled
5ce3dc
5ce3dc
Previous e2fsprogs versions allowed to create a file system with both
5ce3dc
resize_inode and meta_bg enabled. This was fixed by upstream commit
5ce3dc
42e77d5d ("libext2fs: don't create filesystems with meta_bg and resize_inode")
5ce3dc
5ce3dc
However e2fsck still does not recognize the conflict and will attempt to
5ce3dc
clear and recreate resize_inode if it's corrupted due to this incompatible
5ce3dc
feature combination, though it will create it in the same wrong layout.
5ce3dc
5ce3dc
Fix it by teaching e2fsck to recognize resize_inode and meta_bg
5ce3dc
conflict and fixing it by disabling and clearing resize inode.
5ce3dc
5ce3dc
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
5ce3dc
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
5ce3dc
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
5ce3dc
---
5ce3dc
 e2fsck/problem.c | 6 ++++++
5ce3dc
 e2fsck/problem.h | 3 +++
5ce3dc
 e2fsck/super.c   | 8 ++++++++
5ce3dc
 3 files changed, 17 insertions(+)
5ce3dc
5ce3dc
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
5ce3dc
index a0a3cfec..ddd8c1c4 100644
5ce3dc
--- a/e2fsck/problem.c
5ce3dc
+++ b/e2fsck/problem.c
5ce3dc
@@ -498,6 +498,12 @@ static struct e2fsck_problem problem_table[] = {
5ce3dc
 	  N_("@S would have too many inodes (%N).\n"),
5ce3dc
 	  PROMPT_NONE, PR_AFTER_CODE, PR_0_SB_CORRUPT },
5ce3dc
 
5ce3dc
+	/* Meta_bg and resize_inode are not compatible, disable resize_inode*/
5ce3dc
+	{ PR_0_DISABLE_RESIZE_INODE,
5ce3dc
+	  N_("Resize_@i and meta_bg features are enabled. Those features are\n"
5ce3dc
+	     "not compatible. Resize @i should be disabled.  "),
5ce3dc
+	  PROMPT_FIX, 0 },
5ce3dc
+
5ce3dc
 	/* Pass 1 errors */
5ce3dc
 
5ce3dc
 	/* Pass 1: Checking inodes, blocks, and sizes */
5ce3dc
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
5ce3dc
index 7db122ab..2c79169e 100644
5ce3dc
--- a/e2fsck/problem.h
5ce3dc
+++ b/e2fsck/problem.h
5ce3dc
@@ -285,6 +285,9 @@ struct problem_context {
5ce3dc
 /* Inode count in the superblock incorrect */
5ce3dc
 #define PR_0_INODE_COUNT_BIG			0x000050
5ce3dc
 
5ce3dc
+/* Meta_bg and resize_inode are not compatible, remove resize_inode*/
5ce3dc
+#define PR_0_DISABLE_RESIZE_INODE		0x000051
5ce3dc
+
5ce3dc
 /*
5ce3dc
  * Pass 1 errors
5ce3dc
  */
5ce3dc
diff --git a/e2fsck/super.c b/e2fsck/super.c
5ce3dc
index eb7ab0d1..e5932be6 100644
5ce3dc
--- a/e2fsck/super.c
5ce3dc
+++ b/e2fsck/super.c
5ce3dc
@@ -436,6 +436,14 @@ void check_resize_inode(e2fsck_t ctx)
5ce3dc
 
5ce3dc
 	clear_problem_context(&pctx);
5ce3dc
 
5ce3dc
+	if (ext2fs_has_feature_resize_inode(fs->super) &&
5ce3dc
+	    ext2fs_has_feature_meta_bg(fs->super) &&
5ce3dc
+	    fix_problem(ctx, PR_0_DISABLE_RESIZE_INODE, &pctx)) {
5ce3dc
+		ext2fs_clear_feature_resize_inode(fs->super);
5ce3dc
+		fs->super->s_reserved_gdt_blocks = 0;
5ce3dc
+		ext2fs_mark_super_dirty(fs);
5ce3dc
+	}
5ce3dc
+
5ce3dc
 	/*
5ce3dc
 	 * If the resize inode feature isn't set, then
5ce3dc
 	 * s_reserved_gdt_blocks must be zero.
5ce3dc
-- 
5ce3dc
2.17.2
5ce3dc