add patch revert-remove-block_device_ejected
[ext4-patch-queue.git] / dont-manipulate-recovery-flag-when-freezing-no-journal-fs
blob56c732ce8386d76316e596ee6a89613cc58efb42
1 ext4: don't manipulate recovery flag when freezing no-journal fs
3 From: Eric Sandeen <sandeen@redhat.com>
5 At some point along this sequence of changes:
7 f6e63f9 ext4: fold ext4_nojournal_sops into ext4_sops
8 bb04457 ext4: support freezing ext2 (nojournal) file systems
9 9ca9238 ext4: Use separate super_operations structure for no_journal filesystems
11 ext4 started setting needs_recovery on filesystems without journals
12 when they are unfrozen.  This makes no sense, and in fact confuses
13 blkid to the point where it doesn't recognize the filesystem at all.
15 (freeze ext2; unfreeze ext2; run blkid; see no output; run dumpe2fs,
16 see needs_recovery set on fs w/ no journal).
18 To fix this, don't manipulate the INCOMPAT_RECOVER feature on
19 filesystems without journals.
21 Reported-by: Stu Mark <smark@datto.com>
22 Reviewed-by: Jan Kara <jack@suse.com>
23 Signed-off-by: Eric Sandeen <sandeen@redhat.com>
24 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
25 Cc: stable@vger.kernel.org
26 ---
28 Note, is there a reason that in ext4_freeze, if journal_flush
29 fails, we skip the ext4_commit_super call?  I didn't change that
30 here, but it seems odd.
34 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
35 the body of a message to majordomo@vger.kernel.org
36 More majordomo info at  http://vger.kernel.org/majordomo-info.html
38 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
39 index 58987b5..e7b345d 100644
40 --- a/fs/ext4/super.c
41 +++ b/fs/ext4/super.c
42 @@ -4833,10 +4833,11 @@ static int ext4_freeze(struct super_block *sb)
43                 error = jbd2_journal_flush(journal);
44                 if (error < 0)
45                         goto out;
47 +               /* Journal blocked and flushed, clear needs_recovery flag. */
48 +               EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
49         }
51 -       /* Journal blocked and flushed, clear needs_recovery flag. */
52 -       EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
53         error = ext4_commit_super(sb, 1);
54  out:
55         if (journal)
56 @@ -4854,8 +4855,11 @@ static int ext4_unfreeze(struct super_block *sb)
57         if (sb->s_flags & MS_RDONLY)
58                 return 0;
60 -       /* Reset the needs_recovery flag before the fs is unlocked. */
61 -       EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
62 +       if (EXT4_SB(sb)->s_journal) {
63 +               /* Reset the needs_recovery flag before the fs is unlocked. */
64 +               EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
65 +       }
67         ext4_commit_super(sb, 1);
68         return 0;
69  }