summaryrefslogtreecommitdiff
path: root/fs/jbd2
diff options
context:
space:
mode:
authorDaeho Jeong <daeho.jeong@samsung.com>2015-10-19 00:02:56 +0300
committerSasha Levin <sasha.levin@oracle.com>2016-01-21 19:23:28 +0300
commit8fecc1e2c4b4a71abbbead8afe3098fce2863569 (patch)
treee171743e20417b170e4a2181c084a0e064ac9604 /fs/jbd2
parentebf6b5329105efecf9b9dfc45d486b97cecbf86e (diff)
downloadlinux-8fecc1e2c4b4a71abbbead8afe3098fce2863569.tar.xz
ext4, jbd2: ensure entering into panic after recording an error in superblock
[ Upstream commit 4327ba52afd03fc4b5afa0ee1d774c9c5b0e85c5 ] If a EXT4 filesystem utilizes JBD2 journaling and an error occurs, the journaling will be aborted first and the error number will be recorded into JBD2 superblock and, finally, the system will enter into the panic state in "errors=panic" option. But, in the rare case, this sequence is little twisted like the below figure and it will happen that the system enters into panic state, which means the system reset in mobile environment, before completion of recording an error in the journal superblock. In this case, e2fsck cannot recognize that the filesystem failure occurred in the previous run and the corruption wouldn't be fixed. Task A Task B ext4_handle_error() -> jbd2_journal_abort() -> __journal_abort_soft() -> __jbd2_journal_abort_hard() | -> journal->j_flags |= JBD2_ABORT; | | __ext4_abort() | -> jbd2_journal_abort() | | -> __journal_abort_soft() | | -> if (journal->j_flags & JBD2_ABORT) | | return; | -> panic() | -> jbd2_journal_update_sb_errno() Tested-by: Hobin Woo <hobin.woo@samsung.com> Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'fs/jbd2')
-rw-r--r--fs/jbd2/journal.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 2540324f084b..07e87ec45709 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2087,8 +2087,12 @@ static void __journal_abort_soft (journal_t *journal, int errno)
__jbd2_journal_abort_hard(journal);
- if (errno)
+ if (errno) {
jbd2_journal_update_sb_errno(journal);
+ write_lock(&journal->j_state_lock);
+ journal->j_flags |= JBD2_REC_ERR;
+ write_unlock(&journal->j_state_lock);
+ }
}
/**