ext4: fix check to prevent initializing reserved inodes
authorTheodore Ts'o <tytso@mit.edu>
Sat, 28 Jul 2018 12:12:04 +0000 (08:12 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 29 Jul 2018 19:34:00 +0000 (15:34 -0400)
commit5012284700775a4e6e3fbe7eac4c543c4874b559
tree5ae733e41b328adc79df258d6339d6c1382416c2
parent8d5a803c6a6ce4ec258e31f76059ea5153ba46ef
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.

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
fs/ext4/super.c