fs/super.c: sync ro remount after blocking writers
authorAndrew Ruder <[email protected]>
Thu, 30 Jan 2014 15:26:54 +0000 (09:26 -0600)
committerAl Viro <[email protected]>
Fri, 31 Jan 2014 19:29:36 +0000 (14:29 -0500)
Move sync_filesystem() after sb_prepare_remount_readonly().  If writers
sneak in anywhere from sync_filesystem() to sb_prepare_remount_readonly()
it can cause inodes to be dirtied and writeback to occur well after
sys_mount() has completely successfully.

This was spotted by corrupted ubifs filesystems on reboot, but appears
that it can cause issues with any filesystem using writeback.

Cc: Artem Bityutskiy <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Alexander Viro <[email protected]>
CC: Richard Weinberger <[email protected]>
Co-authored-by: Richard Weinberger <[email protected]>
Signed-off-by: Andrew Ruder <[email protected]>
Signed-off-by: Al Viro <[email protected]>
fs/super.c

index cecd780e0f44ffed45f9b6ff9b540fadc34d5a3a..80d5cf2ca76518a450a31cb7cad340794a525ed8 100644 (file)
@@ -703,7 +703,6 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
        if (flags & MS_RDONLY)
                acct_auto_close(sb);
        shrink_dcache_sb(sb);
-       sync_filesystem(sb);
 
        remount_ro = (flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY);
 
@@ -720,6 +719,8 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
                }
        }
 
+       sync_filesystem(sb);
+
        if (sb->s_op->remount_fs) {
                retval = sb->s_op->remount_fs(sb, &flags, data);
                if (retval) {