Add patches to fix kernel crashes on corrupted file systems
[ext4-patch-queue.git] / fold-ext4_sync_fs_nojournal
blobb08a5162e7678653ad2f8f72753fa456db73d057
1 ext4: fold ext4_sync_fs_nojournal() into ext4_sync_fs()
3 This allows us to eliminate duplicate code, and eventually allow us to
4 also fold ext4_sops and ext4_nojournal_sops together.
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 ---
8  fs/ext4/super.c | 36 +++++++++++++-----------------------
9  1 file changed, 13 insertions(+), 23 deletions(-)
11 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
12 index 115e27d..4770c98 100644
13 --- a/fs/ext4/super.c
14 +++ b/fs/ext4/super.c
15 @@ -70,7 +70,6 @@ static void ext4_mark_recovery_complete(struct super_block *sb,
16  static void ext4_clear_journal_err(struct super_block *sb,
17                                    struct ext4_super_block *es);
18  static int ext4_sync_fs(struct super_block *sb, int wait);
19 -static int ext4_sync_fs_nojournal(struct super_block *sb, int wait);
20  static int ext4_remount(struct super_block *sb, int *flags, char *data);
21  static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf);
22  static int ext4_unfreeze(struct super_block *sb);
23 @@ -1131,7 +1130,7 @@ static const struct super_operations ext4_nojournal_sops = {
24         .dirty_inode    = ext4_dirty_inode,
25         .drop_inode     = ext4_drop_inode,
26         .evict_inode    = ext4_evict_inode,
27 -       .sync_fs        = ext4_sync_fs_nojournal,
28 +       .sync_fs        = ext4_sync_fs,
29         .put_super      = ext4_put_super,
30         .statfs         = ext4_statfs,
31         .remount_fs     = ext4_remount,
32 @@ -4718,15 +4717,19 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
33          * being sent at the end of the function. But we can skip it if
34          * transaction_commit will do it for us.
35          */
36 -       target = jbd2_get_latest_transaction(sbi->s_journal);
37 -       if (wait && sbi->s_journal->j_flags & JBD2_BARRIER &&
38 -           !jbd2_trans_will_send_data_barrier(sbi->s_journal, target))
39 +       if (sbi->s_journal) {
40 +               target = jbd2_get_latest_transaction(sbi->s_journal);
41 +               if (wait && sbi->s_journal->j_flags & JBD2_BARRIER &&
42 +                   !jbd2_trans_will_send_data_barrier(sbi->s_journal, target))
43 +                       needs_barrier = true;
45 +               if (jbd2_journal_start_commit(sbi->s_journal, &target)) {
46 +                       if (wait)
47 +                               ret = jbd2_log_wait_commit(sbi->s_journal,
48 +                                                          target);
49 +               }
50 +       } else if (wait && test_opt(sb, BARRIER))
51                 needs_barrier = true;
53 -       if (jbd2_journal_start_commit(sbi->s_journal, &target)) {
54 -               if (wait)
55 -                       ret = jbd2_log_wait_commit(sbi->s_journal, target);
56 -       }
57         if (needs_barrier) {
58                 int err;
59                 err = blkdev_issue_flush(sb->s_bdev, GFP_KERNEL, NULL);
60 @@ -4737,19 +4740,6 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
61         return ret;
62  }
64 -static int ext4_sync_fs_nojournal(struct super_block *sb, int wait)
66 -       int ret = 0;
68 -       trace_ext4_sync_fs(sb, wait);
69 -       flush_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
70 -       dquot_writeback_dquots(sb, -1);
71 -       if (wait && test_opt(sb, BARRIER))
72 -               ret = blkdev_issue_flush(sb->s_bdev, GFP_KERNEL, NULL);
74 -       return ret;
77  /*
78   * LVM calls this function before a (read-only) snapshot is created.  This
79   * gives us a chance to flush the journal completely and mark the fs clean.