summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-08-09 22:45:26 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-08-09 23:17:09 +0200
commit0a2c984222d03d940c52c3675849dd6398b34e64 (patch)
tree1750bd4271591755e313a89ae112dd16c56796fd
parent91d209362b97fc1ff2ab931fe854c99f5a5aae73 (diff)
downloadopenwrt-0a2c984222d03d940c52c3675849dd6398b34e64.tar.gz
openwrt-0a2c984222d03d940c52c3675849dd6398b34e64.tar.bz2
openwrt-0a2c984222d03d940c52c3675849dd6398b34e64.zip
kernel: ext4: fix check to prevent initializing reserved inodes
The broken check would detect a newly generated root filesystem as corrupt under certain circumstances, in some cases actually currupting the it while trying to handle the error condition. This is a regression introduced in kernel 4.4.140. The 4.14.y stable series has already received this fix, while it is still pending for 4.4.y and 4.9.y. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
-rw-r--r--target/linux/generic/patches-4.4/005-ext4-fix-check-to-prevent-initializing-reserved-inod.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/target/linux/generic/patches-4.4/005-ext4-fix-check-to-prevent-initializing-reserved-inod.patch b/target/linux/generic/patches-4.4/005-ext4-fix-check-to-prevent-initializing-reserved-inod.patch
new file mode 100644
index 0000000000..4d11892ce9
--- /dev/null
+++ b/target/linux/generic/patches-4.4/005-ext4-fix-check-to-prevent-initializing-reserved-inod.patch
@@ -0,0 +1,68 @@
+From 7cb53d379df849d843cfd658f351b79b41b09051 Mon Sep 17 00:00:00 2001
+Message-Id: <7cb53d379df849d843cfd658f351b79b41b09051.1533837011.git.mschiffer@universe-factory.net>
+From: Theodore Ts'o <tytso@mit.edu>
+Date: Sat, 28 Jul 2018 08:12:04 -0400
+Subject: [PATCH] ext4: fix check to prevent initializing reserved inodes
+
+Commit 5012284700775a4e6e3fbe7eac4c543c4874b559 upstream.
+
+Commit 8844618d8aa7: "ext4: only look at the bg_flags field if it is
+valid" will complain if block group zero does not have the
+EXT4_BG_INODE_ZEROED flag set. Unfortunately, this is not correct,
+since a freshly created file system has this flag cleared. It gets
+almost immediately after the file system is mounted read-write --- but
+the following somewhat unlikely sequence will end up triggering a
+false positive report of a corrupted file system:
+
+ mkfs.ext4 /dev/vdc
+ mount -o ro /dev/vdc /vdc
+ mount -o remount,rw /dev/vdc
+
+Instead, when initializing the inode table for block group zero, test
+to make sure that itable_unused count is not too large, since that is
+the case that will result in some or all of the reserved inodes
+getting cleared.
+
+This fixes the failures reported by Eric Whiteney when running
+generic/230 and generic/231 in the the nojournal test case.
+
+Fixes: 8844618d8aa7 ("ext4: only look at the bg_flags field if it is valid")
+Reported-by: Eric Whitney <enwlinux@gmail.com>
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ fs/ext4/ialloc.c | 5 ++++-
+ fs/ext4/super.c | 8 +-------
+ 2 files changed, 5 insertions(+), 8 deletions(-)
+
+--- a/fs/ext4/ialloc.c
++++ b/fs/ext4/ialloc.c
+@@ -1308,7 +1308,10 @@ int ext4_init_inode_table(struct super_b
+ ext4_itable_unused_count(sb, gdp)),
+ sbi->s_inodes_per_block);
+
+- if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group)) {
++ if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group) ||
++ ((group == 0) && ((EXT4_INODES_PER_GROUP(sb) -
++ ext4_itable_unused_count(sb, gdp)) <
++ EXT4_FIRST_INO(sb)))) {
+ ext4_error(sb, "Something is wrong with group %u: "
+ "used itable blocks: %d; "
+ "itable unused count: %u",
+--- a/fs/ext4/super.c
++++ b/fs/ext4/super.c
+@@ -2875,14 +2875,8 @@ static ext4_group_t ext4_has_uninit_itab
+ if (!gdp)
+ continue;
+
+- if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED))
+- continue;
+- if (group != 0)
++ if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_ZEROED)))
+ break;
+- ext4_error(sb, "Inode table for bg 0 marked as "
+- "needing zeroing");
+- if (sb->s_flags & MS_RDONLY)
+- return ngroups;
+ }
+
+ return group;