OSDN Git Service

e2fsck: handle an already recovered journal with a non-zero s_error field
authorTheodore Ts'o <tytso@mit.edu>
Thu, 31 May 2012 23:19:02 +0000 (19:19 -0400)
committerKen Sumrall <ksumrall@android.com>
Mon, 11 Jun 2012 19:46:15 +0000 (12:46 -0700)
commitdf5d2e2b942bb263972fe30a4baafd68056e02bd
treeefd0b7e0d848e0440bfe3232c9416e7177db7eeb
parent97bd1b76758fc5c78b000df9a8bc3840e4f1d31c
e2fsck: handle an already recovered journal with a non-zero s_error field

If a file system was remounted read-only after a file system
corruption is detected, and then that file system is mounted and
unmounted by the kernel, the journal would have been recovered, but
the kernel currently leaves the s_errno field still set.  This is
arguably a bug, since it has already propgated the non-zero s_errno
field to the file system superblock, where it will be retained until
e2fsck has been run.

However, e2fsck should handle this case for existing kernel by
checking the journal superblock's s_errno field even if journal
recovery is not required.

Without this commit, e2fsck would not notice anything wrong with the
file system, but a subsequent mount of the file system by the kernel
would mark the file system's superblock as needing checking (since the
journal's s_errno field would still be set), resulting an full e2fsck
run at the next reboot, which would find nothing wrong --- and then
when the file system was mounted, the whole cycle would repeat again.

I had seen reports of this in the past, but it wasn't until recently
that I realized exactly how this had come about, since normally e2fsck
would be run automatically before the file system is mounted again,
thus avoiding this problem.  However, a user using a rescue CD who
didn't run e2fsck before mounting the a file system in this condition
could trigger this situation, and unfortunately, with previous
versions of e2fsprogs and the kernel, there would be no way out no
matter what the user tried to do.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/journal.c