update atomically-set-inode-flags
[ext4-patch-queue.git] / fs-push-sync_filesystem-down-to-remount_fs
blob0b593aa4cce6ad5af32c10f4b2d6b247f24463fb
1 fs: push sync_filesystem() down to the file system's remount_fs()
3 Previously, the no-op "mount -o mount /dev/xxx" operation when the
4 file system is already mounted read-write causes an implied,
5 unconditional syncfs().  This seems pretty stupid, and it's certainly
6 documented or guaraunteed to do this, nor is it particularly useful,
7 except in the case where the file system was mounted rw and is getting
8 remounted read-only.
10 However, it's possible that there might be some file systems that are
11 actually depending on this behavior.  In most file systems, it's
12 probably fine to only call sync_filesystem() when transitioning from
13 read-write to read-only, and there are some file systems where this is
14 not needed at all (for example, for a pseudo-filesystem or something
15 like romfs).
17 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
18 Cc: linux-fsdevel@vger.kernel.org
19 Cc: Christoph Hellwig <hch@infradead.org>
20 Cc: Artem Bityutskiy <dedekind1@gmail.com>
21 Cc: Adrian Hunter <adrian.hunter@intel.com>
22 Cc: Evgeniy Dushistov <dushistov@mail.ru>
23 Cc: Jan Kara <jack@suse.cz>
24 Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
25 Cc: Anders Larsen <al@alarsen.net>
26 Cc: Phillip Lougher <phillip@squashfs.org.uk>
27 Cc: Kees Cook <keescook@chromium.org>
28 Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
29 Cc: Petr Vandrovec <petr@vandrovec.name>
30 Cc: xfs@oss.sgi.com
31 Cc: linux-btrfs@vger.kernel.org
32 Cc: linux-cifs@vger.kernel.org
33 Cc: samba-technical@lists.samba.org
34 Cc: codalist@coda.cs.cmu.edu
35 Cc: linux-ext4@vger.kernel.org
36 Cc: linux-f2fs-devel@lists.sourceforge.net
37 Cc: fuse-devel@lists.sourceforge.net
38 Cc: cluster-devel@redhat.com
39 Cc: linux-mtd@lists.infradead.org
40 Cc: jfs-discussion@lists.sourceforge.net
41 Cc: linux-nfs@vger.kernel.org
42 Cc: linux-nilfs@vger.kernel.org
43 Cc: linux-ntfs-dev@lists.sourceforge.net
44 Cc: ocfs2-devel@oss.oracle.com
45 Cc: reiserfs-devel@vger.kernel.org
46 ---
47  fs/adfs/super.c          | 1 +
48  fs/affs/super.c          | 1 +
49  fs/befs/linuxvfs.c       | 1 +
50  fs/btrfs/super.c         | 1 +
51  fs/cifs/cifsfs.c         | 1 +
52  fs/coda/inode.c          | 1 +
53  fs/cramfs/inode.c        | 1 +
54  fs/debugfs/inode.c       | 1 +
55  fs/devpts/inode.c        | 1 +
56  fs/efs/super.c           | 1 +
57  fs/ext2/super.c          | 1 +
58  fs/ext3/super.c          | 2 ++
59  fs/ext4/super.c          | 2 ++
60  fs/f2fs/super.c          | 2 ++
61  fs/fat/inode.c           | 2 ++
62  fs/freevxfs/vxfs_super.c | 1 +
63  fs/fuse/inode.c          | 1 +
64  fs/gfs2/super.c          | 2 ++
65  fs/hfs/super.c           | 1 +
66  fs/hfsplus/super.c       | 1 +
67  fs/hpfs/super.c          | 2 ++
68  fs/isofs/inode.c         | 1 +
69  fs/jffs2/super.c         | 1 +
70  fs/jfs/super.c           | 1 +
71  fs/minix/inode.c         | 1 +
72  fs/ncpfs/inode.c         | 1 +
73  fs/nfs/super.c           | 2 ++
74  fs/nilfs2/super.c        | 1 +
75  fs/ntfs/super.c          | 2 ++
76  fs/ocfs2/super.c         | 2 ++
77  fs/openpromfs/inode.c    | 1 +
78  fs/proc/root.c           | 2 ++
79  fs/pstore/inode.c        | 1 +
80  fs/qnx4/inode.c          | 1 +
81  fs/qnx6/inode.c          | 1 +
82  fs/reiserfs/super.c      | 1 +
83  fs/romfs/super.c         | 1 +
84  fs/squashfs/super.c      | 1 +
85  fs/super.c               | 2 --
86  fs/sysv/inode.c          | 1 +
87  fs/ubifs/super.c         | 1 +
88  fs/udf/super.c           | 1 +
89  fs/ufs/super.c           | 1 +
90  fs/xfs/xfs_super.c       | 1 +
91  44 files changed, 53 insertions(+), 2 deletions(-)
93 diff --git a/fs/adfs/super.c b/fs/adfs/super.c
94 index 7b3003c..952aeb0 100644
95 --- a/fs/adfs/super.c
96 +++ b/fs/adfs/super.c
97 @@ -212,6 +212,7 @@ static int parse_options(struct super_block *sb, char *options)
99  static int adfs_remount(struct super_block *sb, int *flags, char *data)
101 +       sync_filesystem(sb);
102         *flags |= MS_NODIRATIME;
103         return parse_options(sb, data);
105 diff --git a/fs/affs/super.c b/fs/affs/super.c
106 index d098731..3074530 100644
107 --- a/fs/affs/super.c
108 +++ b/fs/affs/super.c
109 @@ -530,6 +530,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
111         pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data);
113 +       sync_filesystem(sb);
114         *flags |= MS_NODIRATIME;
116         memcpy(volume, sbi->s_volume, 32);
117 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
118 index 845d2d6..56d70c8 100644
119 --- a/fs/befs/linuxvfs.c
120 +++ b/fs/befs/linuxvfs.c
121 @@ -913,6 +913,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
122  static int
123  befs_remount(struct super_block *sb, int *flags, char *data)
125 +       sync_filesystem(sb);
126         if (!(*flags & MS_RDONLY))
127                 return -EINVAL;
128         return 0;
129 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
130 index 97cc241..00cd0c5 100644
131 --- a/fs/btrfs/super.c
132 +++ b/fs/btrfs/super.c
133 @@ -1381,6 +1381,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
134         unsigned int old_metadata_ratio = fs_info->metadata_ratio;
135         int ret;
137 +       sync_filesystem(sb);
138         btrfs_remount_prepare(fs_info);
140         ret = btrfs_parse_options(root, data);
141 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
142 index 849f613..4942c94 100644
143 --- a/fs/cifs/cifsfs.c
144 +++ b/fs/cifs/cifsfs.c
145 @@ -541,6 +541,7 @@ static int cifs_show_stats(struct seq_file *s, struct dentry *root)
147  static int cifs_remount(struct super_block *sb, int *flags, char *data)
149 +       sync_filesystem(sb);
150         *flags |= MS_NODIRATIME;
151         return 0;
153 diff --git a/fs/coda/inode.c b/fs/coda/inode.c
154 index 506de34..3f48000 100644
155 --- a/fs/coda/inode.c
156 +++ b/fs/coda/inode.c
157 @@ -96,6 +96,7 @@ void coda_destroy_inodecache(void)
159  static int coda_remount(struct super_block *sb, int *flags, char *data)
161 +       sync_filesystem(sb);
162         *flags |= MS_NOATIME;
163         return 0;
165 diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
166 index 06610cf..a275911 100644
167 --- a/fs/cramfs/inode.c
168 +++ b/fs/cramfs/inode.c
169 @@ -244,6 +244,7 @@ static void cramfs_kill_sb(struct super_block *sb)
171  static int cramfs_remount(struct super_block *sb, int *flags, char *data)
173 +       sync_filesystem(sb);
174         *flags |= MS_RDONLY;
175         return 0;
177 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
178 index 9c0444c..02928a9 100644
179 --- a/fs/debugfs/inode.c
180 +++ b/fs/debugfs/inode.c
181 @@ -218,6 +218,7 @@ static int debugfs_remount(struct super_block *sb, int *flags, char *data)
182         int err;
183         struct debugfs_fs_info *fsi = sb->s_fs_info;
185 +       sync_filesystem(sb);
186         err = debugfs_parse_options(data, &fsi->mount_opts);
187         if (err)
188                 goto fail;
189 diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
190 index a726b9f..c710380 100644
191 --- a/fs/devpts/inode.c
192 +++ b/fs/devpts/inode.c
193 @@ -313,6 +313,7 @@ static int devpts_remount(struct super_block *sb, int *flags, char *data)
194         struct pts_fs_info *fsi = DEVPTS_SB(sb);
195         struct pts_mount_opts *opts = &fsi->mount_opts;
197 +       sync_filesystem(sb);
198         err = parse_mount_options(data, PARSE_REMOUNT, opts);
200         /*
201 diff --git a/fs/efs/super.c b/fs/efs/super.c
202 index 50215bb..103bbd8 100644
203 --- a/fs/efs/super.c
204 +++ b/fs/efs/super.c
205 @@ -114,6 +114,7 @@ static void destroy_inodecache(void)
207  static int efs_remount(struct super_block *sb, int *flags, char *data)
209 +       sync_filesystem(sb);
210         *flags |= MS_RDONLY;
211         return 0;
213 diff --git a/fs/ext2/super.c b/fs/ext2/super.c
214 index 20d6697..d260115 100644
215 --- a/fs/ext2/super.c
216 +++ b/fs/ext2/super.c
217 @@ -1254,6 +1254,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
218         unsigned long old_sb_flags;
219         int err;
221 +       sync_filesystem(sb);
222         spin_lock(&sbi->s_lock);
224         /* Store the old options */
225 diff --git a/fs/ext3/super.c b/fs/ext3/super.c
226 index 37fd31e..95c6c5a 100644
227 --- a/fs/ext3/super.c
228 +++ b/fs/ext3/super.c
229 @@ -2649,6 +2649,8 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
230         int i;
231  #endif
233 +       sync_filesystem(sb);
235         /* Store the original options */
236         old_sb_flags = sb->s_flags;
237         old_opts.s_mount_opt = sbi->s_mount_opt;
238 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
239 index f5c13b8..aa3842f 100644
240 --- a/fs/ext4/super.c
241 +++ b/fs/ext4/super.c
242 @@ -4767,6 +4767,8 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
243  #endif
244         char *orig_data = kstrdup(data, GFP_KERNEL);
246 +       sync_filesystem(sb);
248         /* Store the original options */
249         old_sb_flags = sb->s_flags;
250         old_opts.s_mount_opt = sbi->s_mount_opt;
251 diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
252 index 1a85f83..856bdf9 100644
253 --- a/fs/f2fs/super.c
254 +++ b/fs/f2fs/super.c
255 @@ -568,6 +568,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
256         struct f2fs_mount_info org_mount_opt;
257         int err, active_logs;
259 +       sync_filesystem(sb);
261         /*
262          * Save the old mount options in case we
263          * need to restore them.
264 diff --git a/fs/fat/inode.c b/fs/fat/inode.c
265 index 854b578..343e477 100644
266 --- a/fs/fat/inode.c
267 +++ b/fs/fat/inode.c
268 @@ -635,6 +635,8 @@ static int fat_remount(struct super_block *sb, int *flags, char *data)
269         struct msdos_sb_info *sbi = MSDOS_SB(sb);
270         *flags |= MS_NODIRATIME | (sbi->options.isvfat ? 0 : MS_NOATIME);
272 +       sync_filesystem(sb);
274         /* make sure we update state on remount. */
275         new_rdonly = *flags & MS_RDONLY;
276         if (new_rdonly != (sb->s_flags & MS_RDONLY)) {
277 diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c
278 index e37eb27..7ca8c75 100644
279 --- a/fs/freevxfs/vxfs_super.c
280 +++ b/fs/freevxfs/vxfs_super.c
281 @@ -124,6 +124,7 @@ vxfs_statfs(struct dentry *dentry, struct kstatfs *bufp)
283  static int vxfs_remount(struct super_block *sb, int *flags, char *data)
285 +       sync_filesystem(sb);
286         *flags |= MS_RDONLY;
287         return 0;
289 diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
290 index d468643..ecdb255d 100644
291 --- a/fs/fuse/inode.c
292 +++ b/fs/fuse/inode.c
293 @@ -135,6 +135,7 @@ static void fuse_evict_inode(struct inode *inode)
295  static int fuse_remount_fs(struct super_block *sb, int *flags, char *data)
297 +       sync_filesystem(sb);
298         if (*flags & MS_MANDLOCK)
299                 return -EINVAL;
301 diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
302 index 60f60f6..4c6dd50 100644
303 --- a/fs/gfs2/super.c
304 +++ b/fs/gfs2/super.c
305 @@ -1175,6 +1175,8 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
306         struct gfs2_tune *gt = &sdp->sd_tune;
307         int error;
309 +       sync_filesystem(sb);
311         spin_lock(&gt->gt_spin);
312         args.ar_commit = gt->gt_logd_secs;
313         args.ar_quota_quantum = gt->gt_quota_quantum;
314 diff --git a/fs/hfs/super.c b/fs/hfs/super.c
315 index 2d2039e..eee7206 100644
316 --- a/fs/hfs/super.c
317 +++ b/fs/hfs/super.c
318 @@ -112,6 +112,7 @@ static int hfs_statfs(struct dentry *dentry, struct kstatfs *buf)
320  static int hfs_remount(struct super_block *sb, int *flags, char *data)
322 +       sync_filesystem(sb);
323         *flags |= MS_NODIRATIME;
324         if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
325                 return 0;
326 diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
327 index 80875aa..8eb787b 100644
328 --- a/fs/hfsplus/super.c
329 +++ b/fs/hfsplus/super.c
330 @@ -323,6 +323,7 @@ static int hfsplus_statfs(struct dentry *dentry, struct kstatfs *buf)
332  static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
334 +       sync_filesystem(sb);
335         if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
336                 return 0;
337         if (!(*flags & MS_RDONLY)) {
338 diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
339 index 4534ff6..fe3463a 100644
340 --- a/fs/hpfs/super.c
341 +++ b/fs/hpfs/super.c
342 @@ -421,6 +421,8 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
343         struct hpfs_sb_info *sbi = hpfs_sb(s);
344         char *new_opts = kstrdup(data, GFP_KERNEL);
345         
346 +       sync_filesystem(s);
348         *flags |= MS_NOATIME;
349         
350         hpfs_lock(s);
351 diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
352 index 4a9e10e..6af66ee 100644
353 --- a/fs/isofs/inode.c
354 +++ b/fs/isofs/inode.c
355 @@ -117,6 +117,7 @@ static void destroy_inodecache(void)
357  static int isofs_remount(struct super_block *sb, int *flags, char *data)
359 +       sync_filesystem(sb);
360         if (!(*flags & MS_RDONLY))
361                 return -EROFS;
362         return 0;
363 diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
364 index 0defb1c..0918f0e 100644
365 --- a/fs/jffs2/super.c
366 +++ b/fs/jffs2/super.c
367 @@ -243,6 +243,7 @@ static int jffs2_remount_fs(struct super_block *sb, int *flags, char *data)
368         struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
369         int err;
371 +       sync_filesystem(sb);
372         err = jffs2_parse_options(c, data);
373         if (err)
374                 return -EINVAL;
375 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
376 index e2b7483..97f7fda 100644
377 --- a/fs/jfs/super.c
378 +++ b/fs/jfs/super.c
379 @@ -418,6 +418,7 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
380         int flag = JFS_SBI(sb)->flag;
381         int ret;
383 +       sync_filesystem(sb);
384         if (!parse_options(data, sb, &newLVSize, &flag)) {
385                 return -EINVAL;
386         }
387 diff --git a/fs/minix/inode.c b/fs/minix/inode.c
388 index 0332109..dcdc298 100644
389 --- a/fs/minix/inode.c
390 +++ b/fs/minix/inode.c
391 @@ -123,6 +123,7 @@ static int minix_remount (struct super_block * sb, int * flags, char * data)
392         struct minix_sb_info * sbi = minix_sb(sb);
393         struct minix_super_block * ms;
395 +       sync_filesystem(sb);
396         ms = sbi->s_ms;
397         if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
398                 return 0;
399 diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
400 index 2cf2ebe..5f86e80 100644
401 --- a/fs/ncpfs/inode.c
402 +++ b/fs/ncpfs/inode.c
403 @@ -99,6 +99,7 @@ static void destroy_inodecache(void)
405  static int ncp_remount(struct super_block *sb, int *flags, char* data)
407 +       sync_filesystem(sb);
408         *flags |= MS_NODIRATIME;
409         return 0;
411 diff --git a/fs/nfs/super.c b/fs/nfs/super.c
412 index 910ed90..2cb5694 100644
413 --- a/fs/nfs/super.c
414 +++ b/fs/nfs/super.c
415 @@ -2215,6 +2215,8 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
416         struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data;
417         u32 nfsvers = nfss->nfs_client->rpc_ops->version;
419 +       sync_filesystem(sb);
421         /*
422          * Userspace mount programs that send binary options generally send
423          * them populated with default values. We have no way to know which
424 diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
425 index 7ac2a12..8c532b2 100644
426 --- a/fs/nilfs2/super.c
427 +++ b/fs/nilfs2/super.c
428 @@ -1129,6 +1129,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
429         unsigned long old_mount_opt;
430         int err;
432 +       sync_filesystem(sb);
433         old_sb_flags = sb->s_flags;
434         old_mount_opt = nilfs->ns_mount_opt;
436 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
437 index 82650d5..bd5610d 100644
438 --- a/fs/ntfs/super.c
439 +++ b/fs/ntfs/super.c
440 @@ -468,6 +468,8 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
442         ntfs_debug("Entering with remount options string: %s", opt);
444 +       sync_filesystem(sb);
446  #ifndef NTFS_RW
447         /* For read-only compiled driver, enforce read-only flag. */
448         *flags |= MS_RDONLY;
449 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
450 index 49d84f8..5f9bf8f 100644
451 --- a/fs/ocfs2/super.c
452 +++ b/fs/ocfs2/super.c
453 @@ -631,6 +631,8 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
454         struct ocfs2_super *osb = OCFS2_SB(sb);
455         u32 tmp;
457 +       sync_filesystem(sb);
459         if (!ocfs2_parse_options(sb, data, &parsed_options, 1) ||
460             !ocfs2_check_set_options(sb, &parsed_options)) {
461                 ret = -EINVAL;
462 diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
463 index 8c0ceb8..15e4500 100644
464 --- a/fs/openpromfs/inode.c
465 +++ b/fs/openpromfs/inode.c
466 @@ -368,6 +368,7 @@ static struct inode *openprom_iget(struct super_block *sb, ino_t ino)
468  static int openprom_remount(struct super_block *sb, int *flags, char *data)
470 +       sync_filesystem(sb);
471         *flags |= MS_NOATIME;
472         return 0;
474 diff --git a/fs/proc/root.c b/fs/proc/root.c
475 index 87dbcbe..ac823a8 100644
476 --- a/fs/proc/root.c
477 +++ b/fs/proc/root.c
478 @@ -92,6 +92,8 @@ static int proc_parse_options(char *options, struct pid_namespace *pid)
479  int proc_remount(struct super_block *sb, int *flags, char *data)
481         struct pid_namespace *pid = sb->s_fs_info;
483 +       sync_filesystem(sb);
484         return !proc_parse_options(data, pid);
487 diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
488 index 1282384..192297b 100644
489 --- a/fs/pstore/inode.c
490 +++ b/fs/pstore/inode.c
491 @@ -249,6 +249,7 @@ static void parse_options(char *options)
493  static int pstore_remount(struct super_block *sb, int *flags, char *data)
495 +       sync_filesystem(sb);
496         parse_options(data);
498         return 0;
499 diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
500 index 8955881..c4bcb77 100644
501 --- a/fs/qnx4/inode.c
502 +++ b/fs/qnx4/inode.c
503 @@ -44,6 +44,7 @@ static int qnx4_remount(struct super_block *sb, int *flags, char *data)
505         struct qnx4_sb_info *qs;
507 +       sync_filesystem(sb);
508         qs = qnx4_sb(sb);
509         qs->Version = QNX4_VERSION;
510         *flags |= MS_RDONLY;
511 diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
512 index 8d941ed..65cdaab 100644
513 --- a/fs/qnx6/inode.c
514 +++ b/fs/qnx6/inode.c
515 @@ -55,6 +55,7 @@ static int qnx6_show_options(struct seq_file *seq, struct dentry *root)
517  static int qnx6_remount(struct super_block *sb, int *flags, char *data)
519 +       sync_filesystem(sb);
520         *flags |= MS_RDONLY;
521         return 0;
523 diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
524 index 2c80335..abf2b76 100644
525 --- a/fs/reiserfs/super.c
526 +++ b/fs/reiserfs/super.c
527 @@ -1319,6 +1319,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
528         int i;
529  #endif
531 +       sync_filesystem(s);
532         reiserfs_write_lock(s);
534  #ifdef CONFIG_QUOTA
535 diff --git a/fs/romfs/super.c b/fs/romfs/super.c
536 index d841878..ef90e8b 100644
537 --- a/fs/romfs/super.c
538 +++ b/fs/romfs/super.c
539 @@ -432,6 +432,7 @@ static int romfs_statfs(struct dentry *dentry, struct kstatfs *buf)
540   */
541  static int romfs_remount(struct super_block *sb, int *flags, char *data)
543 +       sync_filesystem(sb);
544         *flags |= MS_RDONLY;
545         return 0;
547 diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
548 index 202df63..031c8d67 100644
549 --- a/fs/squashfs/super.c
550 +++ b/fs/squashfs/super.c
551 @@ -371,6 +371,7 @@ static int squashfs_statfs(struct dentry *dentry, struct kstatfs *buf)
553  static int squashfs_remount(struct super_block *sb, int *flags, char *data)
555 +       sync_filesystem(sb);
556         *flags |= MS_RDONLY;
557         return 0;
559 diff --git a/fs/super.c b/fs/super.c
560 index 80d5cf2..e9dc3c3 100644
561 --- a/fs/super.c
562 +++ b/fs/super.c
563 @@ -719,8 +719,6 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
564                 }
565         }
567 -       sync_filesystem(sb);
569         if (sb->s_op->remount_fs) {
570                 retval = sb->s_op->remount_fs(sb, &flags, data);
571                 if (retval) {
572 diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
573 index c327d4e..4742e58 100644
574 --- a/fs/sysv/inode.c
575 +++ b/fs/sysv/inode.c
576 @@ -60,6 +60,7 @@ static int sysv_remount(struct super_block *sb, int *flags, char *data)
578         struct sysv_sb_info *sbi = SYSV_SB(sb);
580 +       sync_filesystem(sb);
581         if (sbi->s_forced_ro)
582                 *flags |= MS_RDONLY;
583         return 0;
584 diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
585 index 5ded849..e1598ab 100644
586 --- a/fs/ubifs/super.c
587 +++ b/fs/ubifs/super.c
588 @@ -1827,6 +1827,7 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
589         int err;
590         struct ubifs_info *c = sb->s_fs_info;
592 +       sync_filesystem(sb);
593         dbg_gen("old flags %#lx, new flags %#x", sb->s_flags, *flags);
595         err = ubifs_parse_options(c, data, 1);
596 diff --git a/fs/udf/super.c b/fs/udf/super.c
597 index 3306b9f..64f2b73 100644
598 --- a/fs/udf/super.c
599 +++ b/fs/udf/super.c
600 @@ -646,6 +646,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
601         int error = 0;
602         struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sb);
604 +       sync_filesystem(sb);
605         if (lvidiu) {
606                 int write_rev = le16_to_cpu(lvidiu->minUDFWriteRev);
607                 if (write_rev > UDF_MAX_WRITE_VERSION && !(*flags & MS_RDONLY))
608 diff --git a/fs/ufs/super.c b/fs/ufs/super.c
609 index 329f2f5..b8c6791 100644
610 --- a/fs/ufs/super.c
611 +++ b/fs/ufs/super.c
612 @@ -1280,6 +1280,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
613         unsigned new_mount_opt, ufstype;
614         unsigned flags;
616 +       sync_filesystem(sb);
617         lock_ufs(sb);
618         mutex_lock(&UFS_SB(sb)->s_lock);
619         uspi = UFS_SB(sb)->s_uspi;
620 diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
621 index f317488..aaa3eca 100644
622 --- a/fs/xfs/xfs_super.c
623 +++ b/fs/xfs/xfs_super.c
624 @@ -1197,6 +1197,7 @@ xfs_fs_remount(
625         char                    *p;
626         int                     error;
628 +       sync_filesystem(sb);
629         while ((p = strsep(&options, ",")) != NULL) {
630                 int token;