aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2012-05-31 19:19:02 -0400
committerKen Sumrall <ksumrall@android.com>2012-06-11 12:46:15 -0700
commitdf5d2e2b942bb263972fe30a4baafd68056e02bd (patch)
treeefd0b7e0d848e0440bfe3232c9416e7177db7eeb
parent97bd1b76758fc5c78b000df9a8bc3840e4f1d31c (diff)
downloadandroid_external_e2fsprogs-df5d2e2b942bb263972fe30a4baafd68056e02bd.tar.gz
android_external_e2fsprogs-df5d2e2b942bb263972fe30a4baafd68056e02bd.tar.bz2
android_external_e2fsprogs-df5d2e2b942bb263972fe30a4baafd68056e02bd.zip
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>
-rw-r--r--e2fsck/journal.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 155857d9..95affda3 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -798,6 +798,19 @@ no_has_journal:
*/
}
+ /*
+ * If we don't need to do replay the journal, check to see if
+ * the journal's errno is set; if so, we need to mark the file
+ * system as being corrupt and clear the journal's s_errno.
+ */
+ if (!(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) &&
+ journal->j_superblock->s_errno) {
+ ctx->fs->super->s_state |= EXT2_ERROR_FS;
+ ext2fs_mark_super_dirty(ctx->fs);
+ journal->j_superblock->s_errno = 0;
+ mark_buffer_dirty(journal->j_sb_buffer);
+ }
+
e2fsck_journal_release(ctx, journal, reset, 0);
return retval;
}