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
---
...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 000..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
+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
+Reported-by: Marcin Wolcendorf
+Tested-by: Marcin Wolcendorf
+Signed-off-by: Dmitry Monakhov
+---
+ 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 000..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
+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
+Signed-off-by: Dmitry Monakhov
+---
+ 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