add patch revert-remove-block_device_ejected
[ext4-patch-queue.git] / ensure-entering-into-panic-after-recording-an-error-in-superblock
blob3785eff4ebcf540ae41728a7898b14d69f5fc604
1 jbd2: ensure entering into panic after recording an error in superblock
3 From: Daeho Jeong <daeho.jeong@samsung.com>
5 If a EXT4 filesystem utilizes JBD2 journaling and an error occurs, the
6 journaling will be aborted first and the error number will be recorded
7 into JBD2 superblock and, finally, the system will enter into the
8 panic state in "errors=panic" option.  But, in the rare case, this
9 sequence is little twisted like the below figure and it will happen
10 that the system enters into panic state, which means the system reset
11 in mobile environment, before completion of recording an error in the
12 journal superblock. In this case, e2fsck cannot recognize that the
13 filesystem failure occured in the previous run and the corruption
14 wouldn't be fixed.
16 Task A                            Task B
17 ext4_handle_error()
18 -> jbd2_journal_abort()
19   -> __journal_abort_soft()
20     -> __jbd2_journal_abort_hard()
21     | -> journal->j_flags |= JBD2_ABORT;
22     |
23     |                           __ext4_abort()
24     |                           -> jbd2_journal_abort()
25     |                           | -> __journal_abort_soft()
26     |                           |   -> if (journal->j_flags & JBD2_ABORT)
27     |                           |           return;
28     |                           -> panic()
29     |
30     -> jbd2_journal_update_sb_errno()    
32 Tested-by: Hobin Woo <hobin.woo@samsung.com>
33 Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
34 Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com>
35 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
37 ---
38  fs/jbd2/journal.c | 4 ++--
39  1 file changed, 2 insertions(+), 2 deletions(-)
41 diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
42 index 8270fe9..84bdb67 100644
43 --- a/fs/jbd2/journal.c
44 +++ b/fs/jbd2/journal.c
45 @@ -2069,10 +2069,10 @@ static void __journal_abort_soft (journal_t *journal, int errno)
46         if (!journal->j_errno)
47                 journal->j_errno = errno;
49 -       __jbd2_journal_abort_hard(journal);
51         if (errno)
52                 jbd2_journal_update_sb_errno(journal);
54 +       __jbd2_journal_abort_hard(journal);
55  }
57  /**