drop ensure-entering-into-panic-after-recording-an-error-in-superblock
[ext4-patch-queue.git] / add-REQ_FUQ-flag-when-recording-an-error
blob88b521209f3c630e85730b957d75878f6190e9a0
1 ext4, jbd2: add REQ_FUA flag when recording an error in the superblock
3 From: Daeho Jeong <daeho.jeong@samsung.com>
5 When an error condition is detected, an error status should be recorded into
6 superblocks of EXT4 or JBD2. However, the write request is submitted now
7 without REQ_FUA flag, even in "barrier=1" mode, which is followed by
8 panic() function in "errors=panic" mode. On mobile devices which make
9 whole system reset as soon as kernel panic occurs, this write request
10 containing an error flag will disappear just from storage cache without
11 written to the physical cells. Therefore, when next start, even forever,
12 the error flag cannot be shown in both superblocks, and e2fsck cannot fix
13 the filesystem problems automatically, unless e2fsck is executed in
14 force checking mode.
16 [ Changed use test_opt(sb, BARRIER) of checking the journal flags -- TYT ]
18 Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
19 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
20 ---
21  fs/ext4/super.c   | 3 ++-
22  fs/jbd2/journal.c | 2 +-
23  2 files changed, 3 insertions(+), 2 deletions(-)
25 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
26 index 14909cd..a51db9c 100644
27 --- a/fs/ext4/super.c
28 +++ b/fs/ext4/super.c
29 @@ -4667,7 +4667,8 @@ static int ext4_commit_super(struct super_block *sb, int sync)
30         ext4_superblock_csum_set(sb);
31         mark_buffer_dirty(sbh);
32         if (sync) {
33 -               error = sync_dirty_buffer(sbh);
34 +               error = __sync_dirty_buffer(sbh,
35 +                       test_opt(sb, BARRIER) ? WRITE_FUA : WRITE_SYNC);
36                 if (error)
37                         return error;
39 diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
40 index 4ff3fad..fe1b4bd 100644
41 --- a/fs/jbd2/journal.c
42 +++ b/fs/jbd2/journal.c
43 @@ -1456,7 +1456,7 @@ void jbd2_journal_update_sb_errno(journal_t *journal)
44         sb->s_errno    = cpu_to_be32(journal->j_errno);
45         read_unlock(&journal->j_state_lock);
47 -       jbd2_write_superblock(journal, WRITE_SYNC);
48 +       jbd2_write_superblock(journal, WRITE_FUA);
49  }
50  EXPORT_SYMBOL(jbd2_journal_update_sb_errno);