add patch fix-block_validity-documentation
[ext4-patch-queue.git] / fix-checks-for-data-ordered-and-journal_async_commit-options
bloba81016aba8d880feaff591201019220fdb888fb2
1 ext4: fix checks for data=ordered and journal_async_commit options
3 From: Jan Kara <jack@suse.cz>
5 Combination of data=ordered mode and journal_async_commit mount option
6 is invalid. However the check in parse_options() fails to detect the
7 case where we simply end up defaulting to data=ordered mode and we
8 detect the problem only on remount which triggers hard to understand
9 failure to remount the filesystem.
11 Fix the checking of mount options to take into account also the default
12 mode by moving the check somewhat later in the mount sequence.
14 Reported-by: Wolfgang Walter <linux@stwm.de>
15 Signed-off-by: Jan Kara <jack@suse.cz>
16 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
17 ---
18  fs/ext4/super.c | 21 +++++++++++++++------
19  1 file changed, 15 insertions(+), 6 deletions(-)
21 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
22 index 52b0530c5d65..58017f54a016 100644
23 --- a/fs/ext4/super.c
24 +++ b/fs/ext4/super.c
25 @@ -1883,12 +1883,6 @@ static int parse_options(char *options, struct super_block *sb,
26                         return 0;
27                 }
28         }
29 -       if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA &&
30 -           test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
31 -               ext4_msg(sb, KERN_ERR, "can't mount with journal_async_commit "
32 -                        "in data=ordered mode");
33 -               return 0;
34 -       }
35         return 1;
36  }
38 @@ -3967,6 +3961,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
39         default:
40                 break;
41         }
43 +       if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA &&
44 +           test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
45 +               ext4_msg(sb, KERN_ERR, "can't mount with "
46 +                       "journal_async_commit in data=ordered mode");
47 +               goto failed_mount_wq;
48 +       }
50         set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
52         sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
53 @@ -4857,6 +4859,13 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
54                         err = -EINVAL;
55                         goto restore_opts;
56                 }
57 +       } else if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA) {
58 +               if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) {
59 +                       ext4_msg(sb, KERN_ERR, "can't mount with "
60 +                               "journal_async_commit in data=ordered mode");
61 +                       err = -EINVAL;
62 +                       goto restore_opts;
63 +               }
64         }
66         if ((sbi->s_mount_opt ^ old_opts.s_mount_opt) & EXT4_MOUNT_DAX) {
67 -- 
68 2.6.6