Commit fada3660 authored by Theodore Ts'o's avatar Theodore Ts'o Committed by Ken Sumrall
Browse files

e2fsck: correctly propagate error from journal to superblock


If the file system is mounted read-only after a file system error has
been detected, the fact that an error occurred is written to the
journal.  This is important because while the journal is getting
replayed, the error indication in the superblock may very well get
overwritten.

Unfortunately, the code to propagate the error indication from the
journal to superblock was broken because this was being done before
the old file system handle is thrown away and the file system is
re-opened to ensure that no stale data is in the file system handle.
As a result, the error indication in the superblock was never written
out.

To fix this, we need to move the check if the journal's error
indicator has been set after the file system has been freed and
re-open.
Reported-by: default avatarKen Sumrall <ksumrall@google.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent df5d2e2b
......@@ -843,15 +843,7 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx)
if (journal->j_failed_commit) {
pctx.ino = journal->j_failed_commit;
fix_problem(ctx, PR_0_JNL_TXN_CORRUPT, &pctx);
ctx->fs->super->s_state |= EXT2_ERROR_FS;
ext2fs_mark_super_dirty(ctx->fs);
}
if (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;
journal->j_superblock->s_errno = -EINVAL;
mark_buffer_dirty(journal->j_sb_buffer);
}
......@@ -908,7 +900,13 @@ int e2fsck_run_ext3_journal(e2fsck_t ctx)
/* Set the superblock flags */
e2fsck_clear_recover(ctx, recover_retval);
return recover_retval;
/*
* Do one last sanity check, and propagate journal->s_errno to
* the EXT2_ERROR_FS flag in the fs superblock if needed.
*/
retval = e2fsck_check_ext3_journal(ctx);
return retval ? retval : recover_retval;
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment