[Devel] [PATCH] e2fsprogs: fixup resize issues (PSBM #49322)

Dmitry Monakhov dmonakhov at openvz.org
Fri Jul 8 09:35:48 PDT 2016


Backport mainstream commits:
c82815e resize2fs: disable the meta_bg feature if necessary
7a4352d e2fsck: fix file systems with an overly large s_first_meta_bg

TODO: update changelog
Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
 ...size2fs-disable-the-meta_bg-feature-if-ne.patch | 63 +++++++++++++++++++
 ...file-systems-with-an-overly-large-s_first.patch | 70 ++++++++++++++++++++++
 e2fsprogs.spec                                     |  6 +-
 3 files changed, 138 insertions(+), 1 deletion(-)
 create mode 100644 e2fsprogs-1.42.9-backport-resize2fs-disable-the-meta_bg-feature-if-ne.patch
 create mode 100644 e2fsprogs-1.42.9-e2fsck-fix-file-systems-with-an-overly-large-s_first.patch

diff --git a/e2fsprogs-1.42.9-backport-resize2fs-disable-the-meta_bg-feature-if-ne.patch b/e2fsprogs-1.42.9-backport-resize2fs-disable-the-meta_bg-feature-if-ne.patch
new file mode 100644
index 0000000..e1ef136
--- /dev/null
+++ b/e2fsprogs-1.42.9-backport-resize2fs-disable-the-meta_bg-feature-if-ne.patch
@@ -0,0 +1,63 @@
+From 21045fee7b031db004aba818cc803e92937dbac0 Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso at mit.edu>
+Date: Sat, 9 Aug 2014 12:33:11 -0400
+Subject: [PATCH 2/2] backport resize2fs: disable the meta_bg feature if
+ necessary From c82815e5097f130c8b926b3303a1e063a19dcdd0 Mon Sep 17 00:00:00
+ 2001 [PATCH] resize2fs: disable the meta_bg feature if necessary
+
+When shrinking a file system, if the number block groups drops below
+the point where we started using the meta_bg layout, disable the
+meta_bg feature and set s_first_meta_bg to zero.  This is necessary to
+avoid creating an invalid/corrupted file system after the shrink.
+
+Addresses-Debian-Bug: #756922
+
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+Reported-by: Marcin Wolcendorf <antymat+debian at chelmska.waw.pl>
+Tested-by: Marcin Wolcendorf <antymat+debian at chelmska.waw.pl>
+Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
+---
+ resize/resize2fs.c | 17 +++++++++++++----
+ 1 file changed, 13 insertions(+), 4 deletions(-)
+
+diff --git a/resize/resize2fs.c b/resize/resize2fs.c
+index a8bbd7c..2dc16b8 100644
+--- a/resize/resize2fs.c
++++ b/resize/resize2fs.c
+@@ -462,6 +462,13 @@ retry:
+ 		fs->super->s_reserved_gdt_blocks = new;
+ 	}
+ 
++	if ((fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
++	    (fs->super->s_first_meta_bg > fs->desc_blocks)) {
++		fs->super->s_feature_incompat &=
++			~EXT2_FEATURE_INCOMPAT_META_BG;
++		fs->super->s_first_meta_bg = 0;
++	}
++
+ 	/*
+ 	 * If we are shrinking the number of block groups, we're done
+ 	 * and can exit now.
+@@ -947,13 +954,15 @@ static errcode_t blocks_to_move(ext2_resize_t rfs)
+ 		ext2fs_mark_block_bitmap2(rfs->reserve_blocks, blk);
+ 	}
+ 
+-	if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) {
++	if (old_fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
+ 		old_blocks = old_fs->super->s_first_meta_bg;
+-		new_blocks = fs->super->s_first_meta_bg;
+-	} else {
++	else
+ 		old_blocks = old_fs->desc_blocks + old_fs->super->s_reserved_gdt_blocks;
++
++	if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
++		new_blocks = fs->super->s_first_meta_bg;
++	else
+ 		new_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks;
+-	}
+ 
+ 	if (old_blocks == new_blocks) {
+ 		retval = 0;
+-- 
+1.8.3.1
+
diff --git a/e2fsprogs-1.42.9-e2fsck-fix-file-systems-with-an-overly-large-s_first.patch b/e2fsprogs-1.42.9-e2fsck-fix-file-systems-with-an-overly-large-s_first.patch
new file mode 100644
index 0000000..cdf2524
--- /dev/null
+++ b/e2fsprogs-1.42.9-e2fsck-fix-file-systems-with-an-overly-large-s_first.patch
@@ -0,0 +1,70 @@
+From 26a16ea9c97460711f1cbaf9e0a7333b8b27884d Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso at mit.edu>
+Date: Thu, 7 Jul 2016 19:17:49 +0300
+Subject: [PATCH 1/2] e2fsck: fix file systems with an overly large
+ s_first_meta_bg
+
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
+---
+ e2fsck/problem.c |  5 +++++
+ e2fsck/problem.h |  3 +++
+ e2fsck/super.c   | 12 ++++++++++++
+ 3 files changed, 20 insertions(+)
+
+diff --git a/e2fsck/problem.c b/e2fsck/problem.c
+index 83584a0..431d7e7 100644
+--- a/e2fsck/problem.c
++++ b/e2fsck/problem.c
+@@ -438,6 +438,11 @@ static struct e2fsck_problem problem_table[] = {
+ 	  N_("@S 64bit filesystems needs extents to access the whole disk.  "),
+ 	  PROMPT_FIX, PR_PREEN_OK | PR_NO_OK},
+ 
++	/* The first_meta_bg is too big */
++	{ PR_0_FIRST_META_BG_TOO_BIG,
++	  N_("First_meta_bg is too big.  (%N, max value %g).  "),
++	  PROMPT_CLEAR, 0 },
++
+ 	/* Pass 1 errors */
+ 
+ 	/* Pass 1: Checking inodes, blocks, and sizes */
+diff --git a/e2fsck/problem.h b/e2fsck/problem.h
+index 6cb09cf..4c7ba32 100644
+--- a/e2fsck/problem.h
++++ b/e2fsck/problem.h
+@@ -252,6 +252,9 @@ struct problem_context {
+ /* 64bit is set but extents are not set. */
+ #define PR_0_64BIT_WITHOUT_EXTENTS		0x000048
+ 
++/* The first_meta_bg is too big */
++#define PR_0_FIRST_META_BG_TOO_BIG		0x000049
++
+ /*
+  * Pass 1 errors
+  */
+diff --git a/e2fsck/super.c b/e2fsck/super.c
+index 2fcb315..e6981cf 100644
+--- a/e2fsck/super.c
++++ b/e2fsck/super.c
+@@ -591,6 +591,18 @@ void check_super_block(e2fsck_t ctx)
+ 		ext2fs_mark_super_dirty(fs);
+ 	}
+ 
++	if ((fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
++	    (fs->super->s_first_meta_bg > fs->desc_blocks)) {
++		pctx.group = fs->desc_blocks;
++		pctx.num = fs->super->s_first_meta_bg;
++		if (fix_problem(ctx, PR_0_FIRST_META_BG_TOO_BIG, &pctx)) {
++			fs->super->s_feature_incompat &=
++				~EXT2_FEATURE_INCOMPAT_META_BG;
++			fs->super->s_first_meta_bg = 0;
++			ext2fs_mark_super_dirty(fs);
++		}
++	}
++
+ 	/*
+ 	 * Verify the group descriptors....
+ 	 */
+-- 
+1.8.3.1
+
diff --git a/e2fsprogs.spec b/e2fsprogs.spec
index 56b79c8..64e9bd1 100644
--- a/e2fsprogs.spec
+++ b/e2fsprogs.spec
@@ -1,7 +1,7 @@
 Summary: Utilities for managing ext2, ext3, and ext4 filesystems
 Name: e2fsprogs
 Version: 1.42.9
-Release: 7%{?dist}.8
+Release: 7%{?dist}.9
 
 # License tags based on COPYING file distinctions for various components
 License: GPLv2
@@ -26,6 +26,8 @@ Patch13: e2fsprogs-1.42.9-ext4-manpage-add-mountopts.patch
 Patch14: e2fsprogs-1.42.9-ext4-manpage-add-attrs.patch
 Patch15: e2fsprogs-1.42.9-fix-endian-handling-of-ext3_extent_header.patch
 Patch16: e2fsprogs-1.42.9-dont-require-fsck-for-resize-p.patch
+Patch17: e2fsprogs-1.42.9-e2fsck-fix-file-systems-with-an-overly-large-s_first.patch
+Patch18: e2fsprogs-1.42.9-backport-resize2fs-disable-the-meta_bg-feature-if-ne.patch
 
 # Virtuozzo patches
 Patch100: vl-e2fsprogs-1.42.9-e4defrag2.patch
@@ -210,6 +212,8 @@ It was originally inspired by the Multics SubSystem library.
 %patch14 -p1
 %patch15 -p1
 %patch16 -p1
+%patch17 -p1
+%patch18 -p1
 
 %patch100 -p1
 %patch101 -p1
-- 
1.8.3.1



More information about the Devel mailing list