fix bug in add-support-collapse-range
[ext4-patch-queue.git] / only-sync-filesystem-when-remounting-ro
blobbb78b66c0d9f39706b7b35ca75a7c1554b419009
1 ext4: only call sync_filesystm() when remounting read-only
3 This is the only time it is required for ext4.
5 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
6 ---
7  fs/ext4/super.c | 5 +++--
8  1 file changed, 3 insertions(+), 2 deletions(-)
10 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
11 index aa3842f..01c5088 100644
12 --- a/fs/ext4/super.c
13 +++ b/fs/ext4/super.c
14 @@ -4767,8 +4767,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
15  #endif
16         char *orig_data = kstrdup(data, GFP_KERNEL);
18 -       sync_filesystem(sb);
20         /* Store the original options */
21         old_sb_flags = sb->s_flags;
22         old_opts.s_mount_opt = sbi->s_mount_opt;
23 @@ -4839,6 +4837,9 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
24                 }
26                 if (*flags & MS_RDONLY) {
27 +                       err = sync_filesystem(sb);
28 +                       if (err < 0)
29 +                               goto restore_opts;
30                         err = dquot_suspend(sb, -1);
31                         if (err < 0)
32                                 goto restore_opts;