Add Jan Kara's ext4 data corruption bugs for blocksize < pagesize
[ext4-patch-queue.git] / support-freezing-ext2-filesystems
blob1d5832d90c551c65d788f6b4f0283ae41e518643
1 ext4: support freezing ext2 (nojournal) file systems
3 Through an oversight, when we added nojournal support to ext4, we
4 didn't add support to allow file system freezing.  This is relatively
5 easy to add, so let's do it.
7 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 Reported-by: Dexuan Cui <decui@microsoft.com>
9 ---
10  fs/ext4/super.c | 27 ++++++++++++++++-----------
11  1 file changed, 16 insertions(+), 11 deletions(-)
13 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
14 index 4770c98..4db537b 100644
15 --- a/fs/ext4/super.c
16 +++ b/fs/ext4/super.c
17 @@ -1131,6 +1131,8 @@ static const struct super_operations ext4_nojournal_sops = {
18         .drop_inode     = ext4_drop_inode,
19         .evict_inode    = ext4_evict_inode,
20         .sync_fs        = ext4_sync_fs,
21 +       .freeze_fs      = ext4_freeze,
22 +       .unfreeze_fs    = ext4_unfreeze,
23         .put_super      = ext4_put_super,
24         .statfs         = ext4_statfs,
25         .remount_fs     = ext4_remount,
26 @@ -4758,23 +4760,26 @@ static int ext4_freeze(struct super_block *sb)
28         journal = EXT4_SB(sb)->s_journal;
30 -       /* Now we set up the journal barrier. */
31 -       jbd2_journal_lock_updates(journal);
32 +       if (journal) {
33 +               /* Now we set up the journal barrier. */
34 +               jbd2_journal_lock_updates(journal);
36 -       /*
37 -        * Don't clear the needs_recovery flag if we failed to flush
38 -        * the journal.
39 -        */
40 -       error = jbd2_journal_flush(journal);
41 -       if (error < 0)
42 -               goto out;
43 +               /*
44 +                * Don't clear the needs_recovery flag if we failed to
45 +                * flush the journal.
46 +                */
47 +               error = jbd2_journal_flush(journal);
48 +               if (error < 0)
49 +                       goto out;
50 +       }
52         /* Journal blocked and flushed, clear needs_recovery flag. */
53         EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
54         error = ext4_commit_super(sb, 1);
55  out:
56 -       /* we rely on upper layer to stop further updates */
57 -       jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
58 +       if (journal)
59 +               /* we rely on upper layer to stop further updates */
60 +               jbd2_journal_unlock_updates(journal);
61         return error;
62  }