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
6 From: Theodore Ts'o <tytso@mit.edu>
8 commit 97abd7d4b5d9c48ec15c425485f054e1c15e591b upstream.
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.
14 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 fs/ext4/super.c | 6 ++++--
19 1 file changed, 4 insertions(+), 2 deletions(-)
23 @@ -793,6 +793,7 @@ static void ext4_put_super(struct super_
25 struct ext4_sb_info *sbi = EXT4_SB(sb);
26 struct ext4_super_block *es = sbi->s_es;
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);
35 + aborted = is_journal_aborted(sbi->s_journal);
36 err = jbd2_journal_destroy(sbi->s_journal);
37 sbi->s_journal = NULL;
39 + if ((err < 0) && !aborted)
40 ext4_abort(sb, "Couldn't clean up the journal");
43 @@ -816,7 +818,7 @@ static void ext4_put_super(struct super_
45 ext4_xattr_put_super(sb);
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);