fs: push sync_filesystem() down to the file system's remount_fs()
authorTheodore Ts'o <tytso@mit.edu>
Thu, 13 Mar 2014 14:14:33 +0000 (10:14 -0400)
committerMohamad Ayyash <mkayyash@google.com>
Wed, 4 Mar 2015 19:26:46 +0000 (11:26 -0800)
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
42 files changed:
fs/adfs/super.c
fs/affs/super.c
fs/befs/linuxvfs.c
fs/btrfs/super.c
fs/cifs/cifsfs.c
fs/coda/inode.c
fs/cramfs/inode.c
fs/debugfs/inode.c
fs/devpts/inode.c
fs/efs/super.c
fs/ext2/super.c
fs/ext3/super.c
fs/ext4/super.c
fs/f2fs/super.c
fs/fat/inode.c
fs/freevxfs/vxfs_super.c
fs/fuse/inode.c
fs/gfs2/super.c
fs/hfs/super.c
fs/hfsplus/super.c
fs/hpfs/super.c
fs/jffs2/super.c
fs/jfs/super.c
fs/minix/inode.c
fs/ncpfs/inode.c
fs/nfs/super.c
fs/nilfs2/super.c
fs/ntfs/super.c
fs/ocfs2/super.c
fs/openpromfs/inode.c
fs/proc/root.c
fs/pstore/inode.c
fs/qnx4/inode.c
fs/qnx6/inode.c
fs/reiserfs/super.c
fs/romfs/super.c
fs/squashfs/super.c
fs/sysv/inode.c
fs/ubifs/super.c
fs/udf/super.c
fs/ufs/super.c
fs/xfs/xfs_super.c

index 0ff4bae2c2a2c2372a75bc5486a4920672aef0bf..479ef5a9c5d36928dea13d11cc48be8bb8775546 100644 (file)
@@ -213,6 +213,7 @@ static int parse_options(struct super_block *sb, char *options)
 
 static int adfs_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_NODIRATIME;
        return parse_options(sb, data);
 }
index 45161a832bbc9e4aa2d7f6b72a950273e0af7062..01c6e07acbffe63ec4100c511ce888ef343a22a9 100644 (file)
@@ -549,6 +549,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
 
        pr_debug("AFFS: remount(flags=0x%x,opts=\"%s\")\n",*flags,data);
 
+       sync_filesystem(sb);
        *flags |= MS_NODIRATIME;
 
        memcpy(volume, sbi->s_volume, 32);
index f95dddced968f6f4509f1536b80462baa1c4393b..7192a7e9937356c4d61d5a9303cad85fd696262c 100644 (file)
@@ -908,6 +908,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
 static int
 befs_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        if (!(*flags & MS_RDONLY))
                return -EINVAL;
        return 0;
index f0857e092a3cb1af485604850052440579a1bbf1..461731c7fa3a3198c3756c748192521bd3a85c3c 100644 (file)
@@ -1239,6 +1239,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
        unsigned int old_metadata_ratio = fs_info->metadata_ratio;
        int ret;
 
+       sync_filesystem(sb);
        btrfs_remount_prepare(fs_info);
 
        ret = btrfs_parse_options(root, data);
index 3752b9f6d9e46e90876b18f4d14527f9262baff6..0d7daf714c4bf59727edfd79ffbf7388e20cf15f 100644 (file)
@@ -521,6 +521,7 @@ static int cifs_show_stats(struct seq_file *s, struct dentry *root)
 
 static int cifs_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_NODIRATIME;
        return 0;
 }
index 4dcc0d81a7aa511069869141d0d1470800a82e54..0aa4c4d75ec6d78fc8165ef3e7bec1ddf93cefe0 100644 (file)
@@ -96,6 +96,7 @@ void coda_destroy_inodecache(void)
 
 static int coda_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_NOATIME;
        return 0;
 }
index 35b1c7bd18b758a30fc03fd4267151d18fcb2281..c0148585670d29968cace0dd342f05a7feb6660e 100644 (file)
@@ -227,6 +227,7 @@ static void cramfs_put_super(struct super_block *sb)
 
 static int cramfs_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_RDONLY;
        return 0;
 }
index 4888cb3fdef76037b7af5f9db898bdcb82ce48c2..60ef5f96ae3d46696992e87fcabaae74b99975e0 100644 (file)
@@ -218,6 +218,7 @@ static int debugfs_remount(struct super_block *sb, int *flags, char *data)
        int err;
        struct debugfs_fs_info *fsi = sb->s_fs_info;
 
+       sync_filesystem(sb);
        err = debugfs_parse_options(data, &fsi->mount_opts);
        if (err)
                goto fail;
index 073d30b9d1acdc735eee53cdc26330df46294165..5638ff720f6633cd65a9d566bad25487cc6daaf4 100644 (file)
@@ -313,6 +313,7 @@ static int devpts_remount(struct super_block *sb, int *flags, char *data)
        struct pts_fs_info *fsi = DEVPTS_SB(sb);
        struct pts_mount_opts *opts = &fsi->mount_opts;
 
+       sync_filesystem(sb);
        err = parse_mount_options(data, PARSE_REMOUNT, opts);
 
        /*
index c6f57a74a559da265bc8f062eab06488d8d7c00a..4709692cd7a048684f7f7ee512383445dcc7c01e 100644 (file)
@@ -113,6 +113,7 @@ static void efs_put_super(struct super_block *s)
 
 static int efs_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_RDONLY;
        return 0;
 }
index 288534920fe5cc4960f99ae636777344c5d42db6..bc47f47a99feaa3396633dcfc61dfdd128cafd50 100644 (file)
@@ -1254,6 +1254,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
        unsigned long old_sb_flags;
        int err;
 
+       sync_filesystem(sb);
        spin_lock(&sbi->s_lock);
 
        /* Store the old options */
index 6356665a74bb006a096023399fe8dca5363f1435..246bd04207bf6ff9d6cd488f76052b2e51e6d06a 100644 (file)
@@ -2595,6 +2595,8 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
        int i;
 #endif
 
+       sync_filesystem(sb);
+
        /* Store the original options */
        old_sb_flags = sb->s_flags;
        old_opts.s_mount_opt = sbi->s_mount_opt;
index 94cc84db7c9aae349b44be229e993ec906a0a25a..48c8af5fe91d720c569dd06b67b9bac52f7d7bb7 100644 (file)
@@ -4617,6 +4617,8 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
 #endif
        char *orig_data = kstrdup(data, GFP_KERNEL);
 
+       sync_filesystem(sb);
+
        /* Store the original options */
        old_sb_flags = sb->s_flags;
        old_opts.s_mount_opt = sbi->s_mount_opt;
index 8555f7df82c796720c2c85ce0bd0af6248efa1c2..03ab8b830940b85b51be28eba51adf5621b740be 100644 (file)
@@ -239,7 +239,6 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
        if (test_opt(sbi, DISABLE_EXT_IDENTIFY))
                seq_puts(seq, ",disable_ext_identify");
 
-       seq_printf(seq, ",active_logs=%u", sbi->active_logs);
 
        return 0;
 }
index a14dd4c0528a90a0f9dce633078ecd160113d59a..ebdc6656c067232c523b3a6fd549a47c79a05439 100644 (file)
@@ -632,6 +632,8 @@ static int fat_remount(struct super_block *sb, int *flags, char *data)
        struct msdos_sb_info *sbi = MSDOS_SB(sb);
        *flags |= MS_NODIRATIME | (sbi->options.isvfat ? 0 : MS_NOATIME);
 
+       sync_filesystem(sb);
+
        /* make sure we update state on remount. */
        new_rdonly = *flags & MS_RDONLY;
        if (new_rdonly != (sb->s_flags & MS_RDONLY)) {
index e37eb274e492a9dfd36d4f717d363b6932ae90b5..7ca8c75d50d3fdc5f9079599465e04f99058d45d 100644 (file)
@@ -124,6 +124,7 @@ vxfs_statfs(struct dentry *dentry, struct kstatfs *bufp)
 
 static int vxfs_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_RDONLY;
        return 0;
 }
index 9a0cdde14a088c43e12e5d5fc4ba84257ca98b46..a796d1c52a6504c5d1b48d27f87fe65f364f477e 100644 (file)
@@ -135,6 +135,7 @@ static void fuse_evict_inode(struct inode *inode)
 
 static int fuse_remount_fs(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        if (*flags & MS_MANDLOCK)
                return -EINVAL;
 
index e5639dec66c49dc7361ff0ed79828301031b675d..db7fff5a29c15b42de84674578a803bbe863daa7 100644 (file)
@@ -1142,6 +1142,8 @@ static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
        struct gfs2_tune *gt = &sdp->sd_tune;
        int error;
 
+       sync_filesystem(sb);
+
        spin_lock(&gt->gt_spin);
        args.ar_commit = gt->gt_logd_secs;
        args.ar_quota_quantum = gt->gt_quota_quantum;
index 2d2039e754cdb8e7182053ea5666ed64d14ca488..eee7206c38d18e1a3d3b1697fd429763e3fe9f5b 100644 (file)
@@ -112,6 +112,7 @@ static int hfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 static int hfs_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_NODIRATIME;
        if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
                return 0;
index 4c4d142cf890a4cb7949467150d9aeb357fd6942..1b9414f701e666273ffbadf47cbc66dd8b488835 100644 (file)
@@ -323,6 +323,7 @@ static int hfsplus_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
                return 0;
        if (!(*flags & MS_RDONLY)) {
index a0617e7069579c61baed047b3ba2992b294d6082..fc8037639064a5975359a5edacc05f6f81ac77fd 100644 (file)
@@ -395,6 +395,8 @@ static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
        struct hpfs_sb_info *sbi = hpfs_sb(s);
        char *new_opts = kstrdup(data, GFP_KERNEL);
        
+       sync_filesystem(s);
+
        *flags |= MS_NOATIME;
        
        hpfs_lock(s);
index 0defb1cc2a3520d6f5f67cc880f91d0e9fe5b244..0918f0e2e26608467356235c4267c336cccee87c 100644 (file)
@@ -243,6 +243,7 @@ static int jffs2_remount_fs(struct super_block *sb, int *flags, char *data)
        struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
        int err;
 
+       sync_filesystem(sb);
        err = jffs2_parse_options(c, data);
        if (err)
                return -EINVAL;
index 788e0a9c1fb09cfb6d80ee65e1747310c7c840d0..b7486dafa1cda8121016284d9df9eb6d64c6700e 100644 (file)
@@ -413,6 +413,7 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
        int flag = JFS_SBI(sb)->flag;
        int ret;
 
+       sync_filesystem(sb);
        if (!parse_options(data, sb, &newLVSize, &flag)) {
                return -EINVAL;
        }
index df122496f32821bd145490800467d41d02c87f63..a54d08865e598883a00f6eecf6988036e9f2afd9 100644 (file)
@@ -123,6 +123,7 @@ static int minix_remount (struct super_block * sb, int * flags, char * data)
        struct minix_sb_info * sbi = minix_sb(sb);
        struct minix_super_block * ms;
 
+       sync_filesystem(sb);
        ms = sbi->s_ms;
        if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
                return 0;
index 26910c8154da1be65c0318eb088d5d69d3e08baf..3f54348b926b807a343a1514f85d8204d94e7c4c 100644 (file)
@@ -99,6 +99,7 @@ static void destroy_inodecache(void)
 
 static int ncp_remount(struct super_block *sb, int *flags, char* data)
 {
+       sync_filesystem(sb);
        *flags |= MS_NODIRATIME;
        return 0;
 }
index 2d7525fbcf250225981ab521da638fc8f2a204d5..d85c1b8191459874b8e32cb98dfeb05a9a4e2c90 100644 (file)
@@ -2133,6 +2133,8 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
        struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data;
        u32 nfsvers = nfss->nfs_client->rpc_ops->version;
 
+       sync_filesystem(sb);
+
        /*
         * Userspace mount programs that send binary options generally send
         * them populated with default values. We have no way to know which
index c7d1f9f18b094fb1f281fb0dfcb6b53328dc72fe..4b0a8d4a834501bf7cfba69e1ce4d5438807cbe4 100644 (file)
@@ -1114,6 +1114,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
        unsigned long old_mount_opt;
        int err;
 
+       sync_filesystem(sb);
        old_sb_flags = sb->s_flags;
        old_mount_opt = nilfs->ns_mount_opt;
 
index 82650d52d9168ee4f1e1b4282813afdaca5c7ec6..bd5610d482423a0ddf8efaf865f368d66d005e9f 100644 (file)
@@ -468,6 +468,8 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
 
        ntfs_debug("Entering with remount options string: %s", opt);
 
+       sync_filesystem(sb);
+
 #ifndef NTFS_RW
        /* For read-only compiled driver, enforce read-only flag. */
        *flags |= MS_RDONLY;
index 01b85165552b75f1cf2e17893bea1054eb19ff81..616bde667d8d29be41587939366886fa3d5bdaa2 100644 (file)
@@ -632,6 +632,8 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
        struct ocfs2_super *osb = OCFS2_SB(sb);
        u32 tmp;
 
+       sync_filesystem(sb);
+
        if (!ocfs2_parse_options(sb, data, &parsed_options, 1) ||
            !ocfs2_check_set_options(sb, &parsed_options)) {
                ret = -EINVAL;
index 75885ffde44e58a967799d3b461181e74bb8fd9c..f4026aba26f34c8da7251973fcf6a6fa3875d54d 100644 (file)
@@ -375,6 +375,7 @@ static struct inode *openprom_iget(struct super_block *sb, ino_t ino)
 
 static int openprom_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_NOATIME;
        return 0;
 }
index 41a6ea93f486ff81b6b112821339a66f0b020324..85c5018b5b89a0f1c4395fe0381cab4281193336 100644 (file)
@@ -92,6 +92,8 @@ static int proc_parse_options(char *options, struct pid_namespace *pid)
 int proc_remount(struct super_block *sb, int *flags, char *data)
 {
        struct pid_namespace *pid = sb->s_fs_info;
+
+       sync_filesystem(sb);
        return !proc_parse_options(data, pid);
 }
 
index 57bbfeaab66388c288fa8f51e0b0dd0380d9cd2b..0a57f914de2e491d0273f12df9cf7f5ca5054d75 100644 (file)
@@ -247,6 +247,7 @@ static void parse_options(char *options)
 
 static int pstore_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        parse_options(data);
 
        return 0;
index 2e8caa62da78a71cc1ee46ce49634aab9408a779..3410e9f657cadc3072786ebf71e28aa3982b6436 100644 (file)
@@ -46,6 +46,7 @@ static int qnx4_remount(struct super_block *sb, int *flags, char *data)
 {
        struct qnx4_sb_info *qs;
 
+       sync_filesystem(sb);
        qs = qnx4_sb(sb);
        qs->Version = QNX4_VERSION;
        *flags |= MS_RDONLY;
index 8d941edfefa156bedb93a1a074ccda0e9a042fad..65cdaab3ed49d554e4d618202e4d41d11718c714 100644 (file)
@@ -55,6 +55,7 @@ static int qnx6_show_options(struct seq_file *seq, struct dentry *root)
 
 static int qnx6_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_RDONLY;
        return 0;
 }
index f8a23c3078f87d5eda59c30d55cea7ecc94b9273..9fc9d56533fef1c8e8348f56e4b371c643910f55 100644 (file)
@@ -1318,6 +1318,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
        int i;
 #endif
 
+       sync_filesystem(s);
        reiserfs_write_lock(s);
 
 #ifdef CONFIG_QUOTA
index 15cbc41ee3653133c6e7001aec75e754582362e6..ae839482c34159d4bd6ad2cd18536760c9a55dd2 100644 (file)
@@ -435,6 +435,7 @@ static int romfs_statfs(struct dentry *dentry, struct kstatfs *buf)
  */
 static int romfs_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_RDONLY;
        return 0;
 }
index 202df6312d4e8517a63bb9ff10b385738e54ab6e..031c8d67fd5178bb5afca2b04c71637254b46873 100644 (file)
@@ -371,6 +371,7 @@ static int squashfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 static int squashfs_remount(struct super_block *sb, int *flags, char *data)
 {
+       sync_filesystem(sb);
        *flags |= MS_RDONLY;
        return 0;
 }
index c327d4ee1235494e05ae1587b86ca357577b2292..4742e58f3fc520328a965b7a512fbcb3d0ec02a9 100644 (file)
@@ -60,6 +60,7 @@ static int sysv_remount(struct super_block *sb, int *flags, char *data)
 {
        struct sysv_sb_info *sbi = SYSV_SB(sb);
 
+       sync_filesystem(sb);
        if (sbi->s_forced_ro)
                *flags |= MS_RDONLY;
        return 0;
index f21acf0ef01f9535b7d3a576361c387593414747..0d0036750c7140f8c78c01435802a2b7347665d5 100644 (file)
@@ -1840,6 +1840,7 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
        int err;
        struct ubifs_info *c = sb->s_fs_info;
 
+       sync_filesystem(sb);
        dbg_gen("old flags %#lx, new flags %#x", sb->s_flags, *flags);
 
        err = ubifs_parse_options(c, data, 1);
index 9ac4057a86c90f64a84ea2cee0b92e4f549ac01a..3b1a4bea332dc55b51d06808f8c318e1e9573e73 100644 (file)
@@ -629,6 +629,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
        struct udf_options uopt;
        struct udf_sb_info *sbi = UDF_SB(sb);
        int error = 0;
+       sync_filesystem(sb);
 
        uopt.flags = sbi->s_flags;
        uopt.uid   = sbi->s_uid;
index 329f2f53b7ed655b2ef525331f7c75a714d58de9..b8c6791f046fbe4195d97697bbe8a6ba29be03a0 100644 (file)
@@ -1280,6 +1280,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
        unsigned new_mount_opt, ufstype;
        unsigned flags;
 
+       sync_filesystem(sb);
        lock_ufs(sb);
        mutex_lock(&UFS_SB(sb)->s_lock);
        uspi = UFS_SB(sb)->s_uspi;
index 3033ba5e9762f19609a7f86d5117f64eb70f7bd4..478c0ad5e36fcd20d0cc077d6f49b8b44fe2b402 100644 (file)
@@ -1218,6 +1218,7 @@ xfs_fs_remount(
        char                    *p;
        int                     error;
 
+       sync_filesystem(sb);
        while ((p = strsep(&options, ",")) != NULL) {
                int token;