1 ext4: preserve the needs_recovery flag when the journal is aborted
3 If the journal is aborted, the needs_recovery feature flag should not
4 be removed. Otherwise, it's the journal might not get replayed and
5 this could lead to more data getting lost.
7 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 Cc: stable@vger.kernel.org
10 fs/ext4/super.c | 6 ++++--
11 1 file changed, 4 insertions(+), 2 deletions(-)
13 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
14 index 829e4a7b59e4..3fef82e79131 100644
17 @@ -825,6 +825,7 @@ static void ext4_put_super(struct super_block *sb)
19 struct ext4_sb_info *sbi = EXT4_SB(sb);
20 struct ext4_super_block *es = sbi->s_es;
24 ext4_unregister_li_request(sb);
25 @@ -834,9 +835,10 @@ static void ext4_put_super(struct super_block *sb)
26 destroy_workqueue(sbi->rsv_conversion_wq);
29 + aborted = is_journal_aborted(sbi->s_journal);
30 err = jbd2_journal_destroy(sbi->s_journal);
31 sbi->s_journal = NULL;
33 + if ((err < 0) && !aborted)
34 ext4_abort(sb, "Couldn't clean up the journal");
37 @@ -847,7 +849,7 @@ static void ext4_put_super(struct super_block *sb)
41 - if (!(sb->s_flags & MS_RDONLY)) {
42 + if (!(sb->s_flags & MS_RDONLY) && !aborted) {
43 ext4_clear_feature_journal_needs_recovery(sb);
44 es->s_state = cpu_to_le16(sbi->s_mount_state);