add patch dont-wipe-log-on-unmount and dont-wipe-log-on-unmount
[ext4-patch-queue.git] / preserve-needs_recovery-flag-when-journal-is-aborted
blob3abff0f9452154c4426bb0f3a9637804bcf1eb68
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
9 ---
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
15 --- a/fs/ext4/super.c
16 +++ b/fs/ext4/super.c
17 @@ -825,6 +825,7 @@ static void ext4_put_super(struct super_block *sb)
18  {
19         struct ext4_sb_info *sbi = EXT4_SB(sb);
20         struct ext4_super_block *es = sbi->s_es;
21 +       int aborted = 0;
22         int i, err;
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);
28         if (sbi->s_journal) {
29 +               aborted = is_journal_aborted(sbi->s_journal);
30                 err = jbd2_journal_destroy(sbi->s_journal);
31                 sbi->s_journal = NULL;
32 -               if (err < 0)
33 +               if ((err < 0) && !aborted)
34                         ext4_abort(sb, "Couldn't clean up the journal");
35         }
37 @@ -847,7 +849,7 @@ static void ext4_put_super(struct super_block *sb)
38         ext4_mb_release(sb);
39         ext4_ext_release(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);
45         }