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

0ef434
From e9d972c483d98b6b6fc9251166a1f5c2ca37ac5e Mon Sep 17 00:00:00 2001
0ef434
From: Lukas Czerner <lczerner@redhat.com>
0ef434
Date: Wed, 8 Aug 2018 13:52:56 +0200
0ef434
Subject: [PATCH 06/16] e2fsck: remove resize inode if both resize_inode and
0ef434
 meta_bg are enabled
0ef434
0ef434
commit 74848259f0dd42bd478f0541c94f31ccd68eac3c
0ef434
0ef434
Previous e2fsprogs versions allowed to create a file system with both
0ef434
resize_inode and meta_bg enabled. This was fixed by upstream commit
0ef434
42e77d5d ("libext2fs: don't create filesystems with meta_bg and resize_inode")
0ef434
0ef434
However e2fsck still does not recognize the conflict and will attempt to
0ef434
clear and recreate resize_inode if it's corrupted due to this incompatible
0ef434
feature combination, though it will create it in the same wrong layout.
0ef434
0ef434
Fix it by teaching e2fsck to recognize resize_inode and meta_bg
0ef434
conflict and fixing it by disabling and clearing resize inode.
0ef434
0ef434
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
0ef434
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
0ef434
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
0ef434
---
0ef434
 e2fsck/problem.c | 6 ++++++
0ef434
 e2fsck/problem.h | 3 +++
0ef434
 e2fsck/super.c   | 8 ++++++++
0ef434
 3 files changed, 17 insertions(+)
0ef434
0ef434
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
0ef434
index 83584a08..a01b2560 100644
0ef434
--- a/e2fsck/problem.c
0ef434
+++ b/e2fsck/problem.c
0ef434
@@ -438,6 +438,12 @@ static struct e2fsck_problem problem_table[] = {
0ef434
 	  N_("@S 64bit filesystems needs extents to access the whole disk.  "),
0ef434
 	  PROMPT_FIX, PR_PREEN_OK | PR_NO_OK},
0ef434
 
0ef434
+	/* Meta_bg and resize_inode are not compatible, disable resize_inode*/
0ef434
+	{ PR_0_DISABLE_RESIZE_INODE,
0ef434
+	  N_("Resize_@i and meta_bg features are enabled. Those features are\n"
0ef434
+	     "not compatible. Resize @i should be disabled.  "),
0ef434
+	  PROMPT_FIX, 0 },
0ef434
+
0ef434
 	/* Pass 1 errors */
0ef434
 
0ef434
 	/* Pass 1: Checking inodes, blocks, and sizes */
0ef434
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
0ef434
index 6cb09cfb..cf2df8ce 100644
0ef434
--- a/e2fsck/problem.h
0ef434
+++ b/e2fsck/problem.h
0ef434
@@ -252,6 +252,9 @@ struct problem_context {
0ef434
 /* 64bit is set but extents are not set. */
0ef434
 #define PR_0_64BIT_WITHOUT_EXTENTS		0x000048
0ef434
 
0ef434
+/* Meta_bg and resize_inode are not compatible, remove resize_inode*/
0ef434
+#define PR_0_DISABLE_RESIZE_INODE		0x000051
0ef434
+
0ef434
 /*
0ef434
  * Pass 1 errors
0ef434
  */
0ef434
diff --git a/e2fsck/super.c b/e2fsck/super.c
0ef434
index a6be3c69..7e2c2e4f 100644
0ef434
--- a/e2fsck/super.c
0ef434
+++ b/e2fsck/super.c
0ef434
@@ -326,6 +326,14 @@ void check_resize_inode(e2fsck_t ctx)
0ef434
 
0ef434
 	clear_problem_context(&pctx);
0ef434
 
0ef434
+	if (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE &&
0ef434
+	    fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG &&
0ef434
+	    fix_problem(ctx, PR_0_DISABLE_RESIZE_INODE, &pctx)) {
0ef434
+		fs->super->s_feature_compat &= ~EXT2_FEATURE_COMPAT_RESIZE_INODE;
0ef434
+		fs->super->s_reserved_gdt_blocks = 0;
0ef434
+		ext2fs_mark_super_dirty(fs);
0ef434
+	}
0ef434
+
0ef434
 	/*
0ef434
 	 * If the resize inode feature isn't set, then
0ef434
 	 * s_reserved_gdt_blocks must be zero.
0ef434
-- 
0ef434
2.20.1
0ef434