]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.53/ext4-preserve-the-needs_recovery-flag-when-the-journal-is-aborted.patch
Linux 3.18.140
[thirdparty/kernel/stable-queue.git] / releases / 4.4.53 / ext4-preserve-the-needs_recovery-flag-when-the-journal-is-aborted.patch
1 From 97abd7d4b5d9c48ec15c425485f054e1c15e591b Mon Sep 17 00:00:00 2001
2 From: Theodore Ts'o <tytso@mit.edu>
3 Date: Sat, 4 Feb 2017 23:38:06 -0500
4 Subject: ext4: preserve the needs_recovery flag when the journal is aborted
5
6 From: Theodore Ts'o <tytso@mit.edu>
7
8 commit 97abd7d4b5d9c48ec15c425485f054e1c15e591b upstream.
9
10 If the journal is aborted, the needs_recovery feature flag should not
11 be removed. Otherwise, it's the journal might not get replayed and
12 this could lead to more data getting lost.
13
14 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16
17 ---
18 fs/ext4/super.c | 6 ++++--
19 1 file changed, 4 insertions(+), 2 deletions(-)
20
21 --- a/fs/ext4/super.c
22 +++ b/fs/ext4/super.c
23 @@ -793,6 +793,7 @@ static void ext4_put_super(struct super_
24 {
25 struct ext4_sb_info *sbi = EXT4_SB(sb);
26 struct ext4_super_block *es = sbi->s_es;
27 + int aborted = 0;
28 int i, err;
29
30 ext4_unregister_li_request(sb);
31 @@ -802,9 +803,10 @@ static void ext4_put_super(struct super_
32 destroy_workqueue(sbi->rsv_conversion_wq);
33
34 if (sbi->s_journal) {
35 + aborted = is_journal_aborted(sbi->s_journal);
36 err = jbd2_journal_destroy(sbi->s_journal);
37 sbi->s_journal = NULL;
38 - if (err < 0)
39 + if ((err < 0) && !aborted)
40 ext4_abort(sb, "Couldn't clean up the journal");
41 }
42
43 @@ -816,7 +818,7 @@ static void ext4_put_super(struct super_
44 ext4_ext_release(sb);
45 ext4_xattr_put_super(sb);
46
47 - if (!(sb->s_flags & MS_RDONLY)) {
48 + if (!(sb->s_flags & MS_RDONLY) && !aborted) {
49 ext4_clear_feature_journal_needs_recovery(sb);
50 es->s_state = cpu_to_le16(sbi->s_mount_state);
51 }