aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2014-03-13 10:14:33 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-03-13 10:14:33 -0400
commit02b9984d640873b7b3809e63f81a0d7e13496886 (patch)
tree0ea70d3084a53d20baf68dd14f4dcb4b66d0666f
parent66a4cb187b92ca8663203fe8fda621e6585a2a00 (diff)
fs: push sync_filesystem() down to the file system's remount_fs()
Previously, the no-op "mount -o mount /dev/xxx" operation when the file system is already mounted read-write causes an implied, unconditional syncfs(). This seems pretty stupid, and it's certainly documented or guaraunteed to do this, nor is it particularly useful, except in the case where the file system was mounted rw and is getting remounted read-only. However, it's possible that there might be some file systems that are actually depending on this behavior. In most file systems, it's probably fine to only call sync_filesystem() when transitioning from read-write to read-only, and there are some file systems where this is not needed at all (for example, for a pseudo-filesystem or something like romfs). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: linux-fsdevel@vger.kernel.org Cc: Christoph Hellwig <hch@infradead.org> Cc: Artem Bityutskiy <dedekind1@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Evgeniy Dushistov <dushistov@mail.ru> Cc: Jan Kara <jack@suse.cz> Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: Anders Larsen <al@alarsen.net> Cc: Phillip Lougher <phillip@squashfs.org.uk> Cc: Kees Cook <keescook@chromium.org> Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> Cc: Petr Vandrovec <petr@vandrovec.name> Cc: xfs@oss.sgi.com Cc: linux-btrfs@vger.kernel.org Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Cc: codalist@coda.cs.cmu.edu Cc: linux-ext4@vger.kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net Cc: fuse-devel@lists.sourceforge.net Cc: cluster-devel@redhat.com Cc: linux-mtd@lists.infradead.org Cc: jfs-discussion@lists.sourceforge.net Cc: linux-nfs@vger.kernel.org Cc: linux-nilfs@vger.kernel.org Cc: linux-ntfs-dev@lists.sourceforge.net Cc: ocfs2-devel@oss.oracle.com Cc: reiserfs-devel@vger.kernel.org
-rw-r--r--fs/adfs/super.c1
-rw-r--r--fs/affs/super.c1
-rw-r--r--fs/befs/linuxvfs.c1
-rw-r--r--fs/btrfs/super.c1
-rw-r--r--fs/cifs/cifsfs.c1
-rw-r--r--fs/coda/inode.c1
-rw-r--r--fs/cramfs/inode.c1
-rw-r--r--fs/debugfs/inode.c1
-rw-r--r--fs/devpts/inode.c1
-rw-r--r--fs/efs/super.c1
-rw-r--r--fs/ext2/super.c1
-rw-r--r--fs/ext3/super.c2
-rw-r--r--fs/ext4/super.c2
-rw-r--r--fs/f2fs/super.c2
-rw-r--r--fs/fat/inode.c2
-rw-r--r--fs/freevxfs/vxfs_super.c1
-rw-r--r--fs/fuse/inode.c1
-rw-r--r--fs/gfs2/super.c2
-rw-r--r--fs/hfs/super.c1
-rw-r--r--fs/hfsplus/super.c1
-rw-r--r--fs/hpfs/super.c2
-rw-r--r--fs/isofs/inode.c1
-rw-r--r--fs/jffs2/super.c1
-rw-r--r--fs/jfs/super.c1
-rw-r--r--fs/minix/inode.c1
-rw-r--r--fs/ncpfs/inode.c1
-rw-r--r--fs/nfs/super.c2
-rw-r--r--fs/nilfs2/super.c1
-rw-r--r--fs/ntfs/super.c2
-rw-r--r--fs/ocfs2/super.c2
-rw-r--r--fs/openpromfs/inode.c1
-rw-r--r--fs/proc/root.c2
-rw-r--r--fs/pstore/inode.c1
-rw-r--r--fs/qnx4/inode.c1
-rw-r--r--fs/qnx6/inode.c1
-rw-r--r--fs/reiserfs/super.c1
-rw-r--r--fs/romfs/super.c1
-rw-r--r--fs/squashfs/super.c1
-rw-r--r--fs/super.c2
-rw-r--r--fs/sysv/inode.c1
-rw-r--r--fs/ubifs/super.c1
-rw-r--r--fs/udf/super.c1
-rw-r--r--fs/ufs/super.c1
-rw-r--r--fs/xfs/xfs_super.c1
44 files changed, 53 insertions, 2 deletions
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 7b3003cb6f1b..952aeb048349 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -212,6 +212,7 @@ static int parse_options(struct super_block *sb, char *options)
212 212
213static int adfs_remount(struct super_block *sb, int *flags, char *data) 213static int adfs_remount(struct super_block *sb, int *flags, char *data)
214{ 214{
215 sync_filesystem(sb);
215 *flags |= MS_NODIRATIME; 216 *flags |= MS_NODIRATIME;
216 return parse_options(sb, data); 217 return parse_options(sb, data);
217} 218}
diff --git a/fs/affs/super.c b/fs/affs/super.c
index d098731b82ff..307453086c3f 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -530,6 +530,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
530 530
531 pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data); 531 pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data);
532 532
533 sync_filesystem(sb);
533 *flags |= MS_NODIRATIME; 534 *flags |= MS_NODIRATIME;
534 535
535 memcpy(volume, sbi->s_volume, 32); 536 memcpy(volume, sbi->s_volume, 32);
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 845d2d690ce2..56d70c8a89b0 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -913,6 +913,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
913static int 913static int
914befs_remount(struct super_block *sb, int *flags, char *data) 914befs_remount(struct super_block *sb, int *flags, char *data)
915{ 915{
916 sync_filesystem(sb);
916 if (!(*flags & MS_RDONLY)) 917 if (!(*flags & MS_RDONLY))
917 return -EINVAL; 918 return -EINVAL;
918 return 0; 919 return 0;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 97cc24198554..00cd0c57b0b3 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1381,6 +1381,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
1381 unsigned int old_metadata_ratio = fs_info->metadata_ratio; 1381 unsigned int old_metadata_ratio = fs_info->metadata_ratio;
1382 int ret; 1382 int ret;
1383 1383
1384 sync_filesystem(sb);
1384 btrfs_remount_prepare(fs_info); 1385 btrfs_remount_prepare(fs_info);
1385 1386
1386 ret = btrfs_parse_options(root, data); 1387 ret = btrfs_parse_options(root, data);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 849f6132b327..4942c94bf7ee 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -541,6 +541,7 @@ static int cifs_show_stats(struct seq_file *s, struct dentry *root)
541 541
542static int cifs_remount(struct super_block *sb, int *flags, char *data) 542static int cifs_remount(struct super_block *sb, int *flags, char *data)
543{ 543{
544 sync_filesystem(sb);
544 *flags |= MS_NODIRATIME; 545 *flags |= MS_NODIRATIME;
545 return 0; 546 return 0;
546} 547}
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 506de34a4ef3..3f48000ef1a5 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -96,6 +96,7 @@ void coda_destroy_inodecache(void)
96 96
97static int coda_remount(struct super_block *sb, int *flags, char *data) 97static int coda_remount(struct super_block *sb, int *flags, char *data)
98{ 98{
99 sync_filesystem(sb);
99 *flags |= MS_NOATIME; 100 *flags |= MS_NOATIME;
100 return 0; 101 return 0;
101} 102}
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 06610cf94d57..a2759112563c 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -244,6 +244,7 @@ static void cramfs_kill_sb(struct super_block *sb)
244 244
245static int cramfs_remount(struct super_block *sb, int *flags, char *data) 245static int cramfs_remount(struct super_block *sb, int *flags, char *data)
246{ 246{
247 sync_filesystem(sb);
247 *flags |= MS_RDONLY; 248 *flags |= MS_RDONLY;
248 return 0; 249 return 0;
249} 250}
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 9c0444cccbe1..02928a9d00a8 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -218,6 +218,7 @@ static int debugfs_remount(struct super_block *sb, int *flags, char *data)
218 int err; 218 int err;
219 struct debugfs_fs_info *fsi = sb->s_fs_info; 219 struct debugfs_fs_info *fsi = sb->s_fs_info;
220 220
221 sync_filesystem(sb);
221 err = debugfs_parse_options(data, &fsi->mount_opts); 222 err = debugfs_parse_options(data, &fsi->mount_opts);
222 if (err) 223 if (err)
223 goto fail; 224 goto fail;
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index a726b9f29cb7..c71038079b47 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -313,6 +313,7 @@ static int devpts_remount(struct super_block *sb, int *flags, char *data)
313 struct pts_fs_info *fsi = DEVPTS_SB(sb); 313 struct pts_fs_info *fsi = DEVPTS_SB(sb);
314 struct pts_mount_opts *opts = &fsi->mount_opts; 314 struct pts_mount_opts *opts = &fsi->mount_opts;
315 315
316 sync_filesystem(sb);
316 err = parse_mount_options(data, PARSE_REMOUNT, opts); 317 err = parse_mount_options(data, PARSE_REMOUNT, opts);
317 318
318 /* 319 /*
diff --git a/fs/efs/super.c b/fs/efs/super.c
index 50215bbd6463..103bbd820b87 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -114,6 +114,7 @@ static void destroy_inodecache(void)
114 114
115static int efs_remount(struct super_block *sb, int *flags, char *data) 115static int efs_remount(struct super_block *sb, int *flags, char *data)
116{ 116{
117 sync_filesystem(sb);
117 *flags |= MS_RDONLY; 118 *flags |= MS_RDONLY;
118 return 0; 119 return 0;
119} 120}
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 20d6697bd638..d260115c0350 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1254,6 +1254,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
1254 unsigned long old_sb_flags; 1254 unsigned long old_sb_flags;
1255 int err; 1255 int err;
1256 1256
1257 sync_filesystem(sb);
1257 spin_lock(&sbi->s_lock); 1258 spin_lock(&sbi->s_lock);
1258 1259
1259 /* Store the old options */ 1260 /* Store the old options */
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 37fd31ed16e7..95c6c5a6d0c5 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2649,6 +2649,8 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2649 int i; 2649 int i;
2650#endif 2650#endif
2651 2651
2652 sync_filesystem(sb);
2653
2652 /* Store the original options */ 2654 /* Store the original options */
2653 old_sb_flags = sb->s_flags; 2655 old_sb_flags = sb->s_flags;
2654 old_opts.s_mount_opt = sbi->s_mount_opt; 2656 old_opts.s_mount_opt = sbi->s_mount_opt;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 7a829f750235..a5f1170048bd 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4765,6 +4765,8 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4765#endif 4765#endif
4766 char *orig_data = kstrdup(data, GFP_KERNEL); 4766 char *orig_data = kstrdup(data, GFP_KERNEL);
4767 4767
4768 sync_filesystem(sb);
4769
4768 /* Store the original options */ 4770 /* Store the original options */
4769 old_sb_flags = sb->s_flags; 4771 old_sb_flags = sb->s_flags;
4770 old_opts.s_mount_opt = sbi->s_mount_opt; 4772 old_opts.s_mount_opt = sbi->s_mount_opt;
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 1a85f83abd53..856bdf994c0a 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -568,6 +568,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
568 struct f2fs_mount_info org_mount_opt; 568 struct f2fs_mount_info org_mount_opt;
569 int err, active_logs; 569 int err, active_logs;
570 570
571 sync_filesystem(sb);
572
571 /* 573 /*
572 * Save the old mount options in case we 574 * Save the old mount options in case we
573 * need to restore them. 575 * need to restore them.
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 854b578f6695..343e477c6dcb 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -635,6 +635,8 @@ static int fat_remount(struct super_block *sb, int *flags, char *data)
635 struct msdos_sb_info *sbi = MSDOS_SB(sb); 635 struct msdos_sb_info *sbi = MSDOS_SB(sb);
636 *flags |= MS_NODIRATIME | (sbi->options.isvfat ? 0 : MS_NOATIME); 636 *flags |= MS_NODIRATIME | (sbi->options.isvfat ? 0 : MS_NOATIME);
637 637
638 sync_filesystem(sb);
639
638 /* make sure we update state on remount. */ 640 /* make sure we update state on remount. */
639 new_rdonly = *flags & MS_RDONLY; 641 new_rdonly = *flags & MS_RDONLY;
640 if (new_rdonly != (sb->s_flags & MS_RDONLY)) { 642 if (new_rdonly != (sb->s_flags & MS_RDONLY)) {
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c
index e37eb274e492..7ca8c75d50d3 100644
--- a/fs/freevxfs/vxfs_super.c
+++ b/fs/freevxfs/vxfs_super.c
@@ -124,6 +124,7 @@ vxfs_statfs(struct dentry *dentry, struct kstatfs *bufp)
124 124
125static int vxfs_remount(struct super_block *sb, int *flags, char *data) 125static int vxfs_remount(struct super_block *sb, int *flags, char *data)
126{ 126{
127 sync_filesystem(sb);
127 *flags |= MS_RDONLY; 128 *flags |= MS_RDONLY;
128 return 0; 129 return 0;
129} 130}
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index d468643a68b2..ecdb255d086d 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -135,6 +135,7 @@ static void fuse_evict_inode(struct inode *inode)
135 135
136static int fuse_remount_fs(struct super_block *sb, int *flags, char *data) 136static int fuse_remount_fs(struct super_block *sb, int *flags, char *data)
137{ 137{
138 sync_filesystem(sb);
138 if (*flags & MS_MANDLOCK) 139 if (*flags & MS_MANDLOCK)
139 return -EINVAL; 140 return -EINVAL;
140 141
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 60f60f6181f3..4c6dd50831ba 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1175,6 +1175,8 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
1175 struct gfs2_tune *gt = &sdp->sd_tune; 1175 struct gfs2_tune *gt = &sdp->sd_tune;
1176 int error; 1176 int error;
1177 1177
1178 sync_filesystem(sb);
1179
1178 spin_lock(&gt->gt_spin); 1180 spin_lock(&gt->gt_spin);
1179 args.ar_commit = gt->gt_logd_secs; 1181 args.ar_commit = gt->gt_logd_secs;
1180 args.ar_quota_quantum = gt->gt_quota_quantum; 1182 args.ar_quota_quantum = gt->gt_quota_quantum;
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 2d2039e754cd..eee7206c38d1 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -112,6 +112,7 @@ static int hfs_statfs(struct dentry *dentry, struct kstatfs *buf)
112 112
113static int hfs_remount(struct super_block *sb, int *flags, char *data) 113static int hfs_remount(struct super_block *sb, int *flags, char *data)
114{ 114{
115 sync_filesystem(sb);
115 *flags |= MS_NODIRATIME; 116 *flags |= MS_NODIRATIME;
116 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) 117 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
117 return 0; 118 return 0;
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 80875aa640ef..8eb787b52c05 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -323,6 +323,7 @@ static int hfsplus_statfs(struct dentry *dentry, struct kstatfs *buf)
323 323
324static int hfsplus_remount(struct super_block *sb, int *flags, char *data) 324static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
325{ 325{
326 sync_filesystem(sb);
326 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) 327 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
327 return 0; 328 return 0;
328 if (!(*flags & MS_RDONLY)) { 329 if (!(*flags & MS_RDONLY)) {
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 4534ff688b76..fe3463a43236 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -421,6 +421,8 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
421 struct hpfs_sb_info *sbi = hpfs_sb(s); 421 struct hpfs_sb_info *sbi = hpfs_sb(s);
422 char *new_opts = kstrdup(data, GFP_KERNEL); 422 char *new_opts = kstrdup(data, GFP_KERNEL);
423 423
424 sync_filesystem(s);
425
424 *flags |= MS_NOATIME; 426 *flags |= MS_NOATIME;
425 427
426 hpfs_lock(s); 428 hpfs_lock(s);
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 4a9e10ea13f2..6af66ee56390 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -117,6 +117,7 @@ static void destroy_inodecache(void)
117 117
118static int isofs_remount(struct super_block *sb, int *flags, char *data) 118static int isofs_remount(struct super_block *sb, int *flags, char *data)
119{ 119{
120 sync_filesystem(sb);
120 if (!(*flags & MS_RDONLY)) 121 if (!(*flags & MS_RDONLY))
121 return -EROFS; 122 return -EROFS;
122 return 0; 123 return 0;
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 0defb1cc2a35..0918f0e2e266 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -243,6 +243,7 @@ static int jffs2_remount_fs(struct super_block *sb, int *flags, char *data)
243 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); 243 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
244 int err; 244 int err;
245 245
246 sync_filesystem(sb);
246 err = jffs2_parse_options(c, data); 247 err = jffs2_parse_options(c, data);
247 if (err) 248 if (err)
248 return -EINVAL; 249 return -EINVAL;
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index e2b7483444fd..97f7fda51890 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -418,6 +418,7 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
418 int flag = JFS_SBI(sb)->flag; 418 int flag = JFS_SBI(sb)->flag;
419 int ret; 419 int ret;
420 420
421 sync_filesystem(sb);
421 if (!parse_options(data, sb, &newLVSize, &flag)) { 422 if (!parse_options(data, sb, &newLVSize, &flag)) {
422 return -EINVAL; 423 return -EINVAL;
423 } 424 }
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 0332109162a5..dcdc2989370d 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -123,6 +123,7 @@ static int minix_remount (struct super_block * sb, int * flags, char * data)
123 struct minix_sb_info * sbi = minix_sb(sb); 123 struct minix_sb_info * sbi = minix_sb(sb);
124 struct minix_super_block * ms; 124 struct minix_super_block * ms;
125 125
126 sync_filesystem(sb);
126 ms = sbi->s_ms; 127 ms = sbi->s_ms;
127 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) 128 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
128 return 0; 129 return 0;
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 2cf2ebecb55f..5f86e8080178 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -99,6 +99,7 @@ static void destroy_inodecache(void)
99 99
100static int ncp_remount(struct super_block *sb, int *flags, char* data) 100static int ncp_remount(struct super_block *sb, int *flags, char* data)
101{ 101{
102 sync_filesystem(sb);
102 *flags |= MS_NODIRATIME; 103 *flags |= MS_NODIRATIME;
103 return 0; 104 return 0;
104} 105}
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 910ed906eb82..2cb56943e232 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2215,6 +2215,8 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
2215 struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data; 2215 struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data;
2216 u32 nfsvers = nfss->nfs_client->rpc_ops->version; 2216 u32 nfsvers = nfss->nfs_client->rpc_ops->version;
2217 2217
2218 sync_filesystem(sb);
2219
2218 /* 2220 /*
2219 * Userspace mount programs that send binary options generally send 2221 * Userspace mount programs that send binary options generally send
2220 * them populated with default values. We have no way to know which 2222 * them populated with default values. We have no way to know which
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 7ac2a122ca1d..8c532b2ca3ab 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1129,6 +1129,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
1129 unsigned long old_mount_opt; 1129 unsigned long old_mount_opt;
1130 int err; 1130 int err;
1131 1131
1132 sync_filesystem(sb);
1132 old_sb_flags = sb->s_flags; 1133 old_sb_flags = sb->s_flags;
1133 old_mount_opt = nilfs->ns_mount_opt; 1134 old_mount_opt = nilfs->ns_mount_opt;
1134 1135
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 82650d52d916..bd5610d48242 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -468,6 +468,8 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
468 468
469 ntfs_debug("Entering with remount options string: %s", opt); 469 ntfs_debug("Entering with remount options string: %s", opt);
470 470
471 sync_filesystem(sb);
472
471#ifndef NTFS_RW 473#ifndef NTFS_RW
472 /* For read-only compiled driver, enforce read-only flag. */ 474 /* For read-only compiled driver, enforce read-only flag. */
473 *flags |= MS_RDONLY; 475 *flags |= MS_RDONLY;
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 49d84f80f36c..5f9bf8f9dfa7 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -631,6 +631,8 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
631 struct ocfs2_super *osb = OCFS2_SB(sb); 631 struct ocfs2_super *osb = OCFS2_SB(sb);
632 u32 tmp; 632 u32 tmp;
633 633
634 sync_filesystem(sb);
635
634 if (!ocfs2_parse_options(sb, data, &parsed_options, 1) || 636 if (!ocfs2_parse_options(sb, data, &parsed_options, 1) ||
635 !ocfs2_check_set_options(sb, &parsed_options)) { 637 !ocfs2_check_set_options(sb, &parsed_options)) {
636 ret = -EINVAL; 638 ret = -EINVAL;
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index 8c0ceb8dd1f7..15e4500cda3e 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -368,6 +368,7 @@ static struct inode *openprom_iget(struct super_block *sb, ino_t ino)
368 368
369static int openprom_remount(struct super_block *sb, int *flags, char *data) 369static int openprom_remount(struct super_block *sb, int *flags, char *data)
370{ 370{
371 sync_filesystem(sb);
371 *flags |= MS_NOATIME; 372 *flags |= MS_NOATIME;
372 return 0; 373 return 0;
373} 374}
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 87dbcbef7fe4..ac823a85cf6e 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -92,6 +92,8 @@ static int proc_parse_options(char *options, struct pid_namespace *pid)
92int proc_remount(struct super_block *sb, int *flags, char *data) 92int proc_remount(struct super_block *sb, int *flags, char *data)
93{ 93{
94 struct pid_namespace *pid = sb->s_fs_info; 94 struct pid_namespace *pid = sb->s_fs_info;
95
96 sync_filesystem(sb);
95 return !proc_parse_options(data, pid); 97 return !proc_parse_options(data, pid);
96} 98}
97 99
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 12823845d324..192297b0090d 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -249,6 +249,7 @@ static void parse_options(char *options)
249 249
250static int pstore_remount(struct super_block *sb, int *flags, char *data) 250static int pstore_remount(struct super_block *sb, int *flags, char *data)
251{ 251{
252 sync_filesystem(sb);
252 parse_options(data); 253 parse_options(data);
253 254
254 return 0; 255 return 0;
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 89558810381c..c4bcb778886e 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -44,6 +44,7 @@ static int qnx4_remount(struct super_block *sb, int *flags, char *data)
44{ 44{
45 struct qnx4_sb_info *qs; 45 struct qnx4_sb_info *qs;
46 46
47 sync_filesystem(sb);
47 qs = qnx4_sb(sb); 48 qs = qnx4_sb(sb);
48 qs->Version = QNX4_VERSION; 49 qs->Version = QNX4_VERSION;
49 *flags |= MS_RDONLY; 50 *flags |= MS_RDONLY;
diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
index 8d941edfefa1..65cdaab3ed49 100644
--- a/fs/qnx6/inode.c
+++ b/fs/qnx6/inode.c
@@ -55,6 +55,7 @@ static int qnx6_show_options(struct seq_file *seq, struct dentry *root)
55 55
56static int qnx6_remount(struct super_block *sb, int *flags, char *data) 56static int qnx6_remount(struct super_block *sb, int *flags, char *data)
57{ 57{
58 sync_filesystem(sb);
58 *flags |= MS_RDONLY; 59 *flags |= MS_RDONLY;
59 return 0; 60 return 0;
60} 61}
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 2c803353f8ac..abf2b76c0d19 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -1319,6 +1319,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1319 int i; 1319 int i;
1320#endif 1320#endif
1321 1321
1322 sync_filesystem(s);
1322 reiserfs_write_lock(s); 1323 reiserfs_write_lock(s);
1323 1324
1324#ifdef CONFIG_QUOTA 1325#ifdef CONFIG_QUOTA
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index d8418782862b..ef90e8bca95a 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -432,6 +432,7 @@ static int romfs_statfs(struct dentry *dentry, struct kstatfs *buf)
432 */ 432 */
433static int romfs_remount(struct super_block *sb, int *flags, char *data) 433static int romfs_remount(struct super_block *sb, int *flags, char *data)
434{ 434{
435 sync_filesystem(sb);
435 *flags |= MS_RDONLY; 436 *flags |= MS_RDONLY;
436 return 0; 437 return 0;
437} 438}
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 202df6312d4e..031c8d67fd51 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -371,6 +371,7 @@ static int squashfs_statfs(struct dentry *dentry, struct kstatfs *buf)
371 371
372static int squashfs_remount(struct super_block *sb, int *flags, char *data) 372static int squashfs_remount(struct super_block *sb, int *flags, char *data)
373{ 373{
374 sync_filesystem(sb);
374 *flags |= MS_RDONLY; 375 *flags |= MS_RDONLY;
375 return 0; 376 return 0;
376} 377}
diff --git a/fs/super.c b/fs/super.c
index 80d5cf2ca765..e9dc3c3fe159 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -719,8 +719,6 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
719 } 719 }
720 } 720 }
721 721
722 sync_filesystem(sb);
723
724 if (sb->s_op->remount_fs) { 722 if (sb->s_op->remount_fs) {
725 retval = sb->s_op->remount_fs(sb, &flags, data); 723 retval = sb->s_op->remount_fs(sb, &flags, data);
726 if (retval) { 724 if (retval) {
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index c327d4ee1235..4742e58f3fc5 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -60,6 +60,7 @@ static int sysv_remount(struct super_block *sb, int *flags, char *data)
60{ 60{
61 struct sysv_sb_info *sbi = SYSV_SB(sb); 61 struct sysv_sb_info *sbi = SYSV_SB(sb);
62 62
63 sync_filesystem(sb);
63 if (sbi->s_forced_ro) 64 if (sbi->s_forced_ro)
64 *flags |= MS_RDONLY; 65 *flags |= MS_RDONLY;
65 return 0; 66 return 0;
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 5ded8490c0c6..e1598abd7475 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1827,6 +1827,7 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
1827 int err; 1827 int err;
1828 struct ubifs_info *c = sb->s_fs_info; 1828 struct ubifs_info *c = sb->s_fs_info;
1829 1829
1830 sync_filesystem(sb);
1830 dbg_gen("old flags %#lx, new flags %#x", sb->s_flags, *flags); 1831 dbg_gen("old flags %#lx, new flags %#x", sb->s_flags, *flags);
1831 1832
1832 err = ubifs_parse_options(c, data, 1); 1833 err = ubifs_parse_options(c, data, 1);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 3306b9f69bed..64f2b7334d08 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -646,6 +646,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
646 int error = 0; 646 int error = 0;
647 struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sb); 647 struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sb);
648 648
649 sync_filesystem(sb);
649 if (lvidiu) { 650 if (lvidiu) {
650 int write_rev = le16_to_cpu(lvidiu->minUDFWriteRev); 651 int write_rev = le16_to_cpu(lvidiu->minUDFWriteRev);
651 if (write_rev > UDF_MAX_WRITE_VERSION && !(*flags & MS_RDONLY)) 652 if (write_rev > UDF_MAX_WRITE_VERSION && !(*flags & MS_RDONLY))
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 329f2f53b7ed..b8c6791f046f 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -1280,6 +1280,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1280 unsigned new_mount_opt, ufstype; 1280 unsigned new_mount_opt, ufstype;
1281 unsigned flags; 1281 unsigned flags;
1282 1282
1283 sync_filesystem(sb);
1283 lock_ufs(sb); 1284 lock_ufs(sb);
1284 mutex_lock(&UFS_SB(sb)->s_lock); 1285 mutex_lock(&UFS_SB(sb)->s_lock);
1285 uspi = UFS_SB(sb)->s_uspi; 1286 uspi = UFS_SB(sb)->s_uspi;
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f317488263dd..aaa3eca3f234 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1197,6 +1197,7 @@ xfs_fs_remount(
1197 char *p; 1197 char *p;
1198 int error; 1198 int error;
1199 1199
1200 sync_filesystem(sb);
1200 while ((p = strsep(&options, ",")) != NULL) { 1201 while ((p = strsep(&options, ",")) != NULL) {
1201 int token; 1202 int token;
1202 1203