Whamcloud - gitweb
e2fsck: write dir blocks after new inode when reconstructing root/lost+found
authorDarrick J. Wong <darrick.wong@oracle.com>
Sat, 26 Jul 2014 21:14:40 +0000 (17:14 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 26 Jul 2014 21:14:40 +0000 (17:14 -0400)
commiteb89a6287d27d90f10cf7b80da4a5dbd9d1bcd3e
tree5e9a944925178fd3d2466c0bdcafb6fb5727019b
parent17641bf208afc98a59a0a245ecaa06ecb8e081dd
e2fsck: write dir blocks after new inode when reconstructing root/lost+found

If we trash the root directory block, e2fsck will find inode 11 (the
old lost+found) and try to attach it to l+f.  The lost+found checker
also fails to find l+f and tries to add one to the root dir.  The root
dir is not found but is recreated with incorrect checksums, so linking
in the l+f dir fails and the l+f '..' entry isn't set.  Since both
dirs now fail checksum verification, they're both referred to rehash
to have that fixed, but because l+f doesn't have a '..' entry, rehash
crashes because l+f has < 2 entries.

On a checksumming filesystem, the routines in e2fsck that recreate
/lost+found and / must write the new directory block *after* the inode
has been written to disk because the checksum depends on i_generation.
Add a regression test while we're at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass3.c
tests/f_rebuild_csum_rootdir/expect.1 [new file with mode: 0644]
tests/f_rebuild_csum_rootdir/expect.2 [new file with mode: 0644]
tests/f_rebuild_csum_rootdir/image.gz [new file with mode: 0644]
tests/f_rebuild_csum_rootdir/name [new file with mode: 0644]