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

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