summaryrefslogtreecommitdiff
authorTheodore Ts'o <tytso@mit.edu>2018-07-28 12:12:04 (GMT)
committer Tellen Yu <tellen.yu@amlogic.com>2018-08-11 03:48:54 (GMT)
commit7ac5a0503ee83b258f89a57c4baab34cdcd58a8f (patch)
treea3200d8f3a1d82715afe37fe37536c0e2330f92f
parent39169ed5d09e6bced2938c9e9462f94c16454a26 (diff)
downloadcommon-7ac5a0503ee83b258f89a57c4baab34cdcd58a8f.zip
common-7ac5a0503ee83b258f89a57c4baab34cdcd58a8f.tar.gz
common-7ac5a0503ee83b258f89a57c4baab34cdcd58a8f.tar.bz2
ext4: fix check to prevent initializing reserved inodes
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. Change-Id: I3967036c1d84cc69798b7c948420735c623c9ae8 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>
Diffstat
-rw-r--r--fs/ext4/ialloc.c5
-rw-r--r--fs/ext4/super.c8
2 files changed, 5 insertions, 8 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index fec1eaa..3c80c89 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1317,7 +1317,10 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,
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",
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2f892f2..ab72207 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3041,14 +3041,8 @@ static ext4_group_t ext4_has_uninit_itable(struct super_block *sb)
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;