From 8d7f1b40594f5820d8ce7cd3ba26bf6ef2b3b039 Mon Sep 17 00:00:00 2001 From: Andrew Ruder Date: Thu, 30 Jan 2014 09:26:54 -0600 Subject: [PATCH] fs/super.c: sync ro remount after blocking writers 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. CRs-Fixed: 627559 Change-Id: Ib417b59d39210aab2de4e5ae48b18129e8bc3e26 Cc: Artem Bityutskiy Cc: Christoph Hellwig Cc: Alexander Viro CC: Richard Weinberger Co-authored-by: Richard Weinberger Signed-off-by: Andrew Ruder Signed-off-by: Al Viro Git-commit: 807612db2f9940b9fa6deaef054eb16d51bd3e00 Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Signed-off-by: Subhash Jadavani --- fs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/super.c b/fs/super.c index 0cf55bc1d744..5091b3f4764b 100644 --- a/fs/super.c +++ b/fs/super.c @@ -740,7 +740,6 @@ int do_remount_sb2(struct vfsmount *mnt, struct super_block *sb, int flags, void 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); @@ -756,6 +755,8 @@ int do_remount_sb2(struct vfsmount *mnt, struct super_block *sb, int flags, void } } + sync_filesystem(sb); + if (mnt && sb->s_op->remount_fs2) { retval = sb->s_op->remount_fs2(mnt, sb, &flags, data); if (retval) {