Commit 807612db authored by Andrew Ruder's avatar Andrew Ruder Committed by Al Viro

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.

Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
CC: Richard Weinberger <richard@nod.at>
Co-authored-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarAndrew Ruder <andrew.ruder@elecsyscorp.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 9115eac2
...@@ -703,7 +703,6 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force) ...@@ -703,7 +703,6 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
if (flags & MS_RDONLY) if (flags & MS_RDONLY)
acct_auto_close(sb); acct_auto_close(sb);
shrink_dcache_sb(sb); shrink_dcache_sb(sb);
sync_filesystem(sb);
remount_ro = (flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY); 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) ...@@ -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) { if (sb->s_op->remount_fs) {
retval = sb->s_op->remount_fs(sb, &flags, data); retval = sb->s_op->remount_fs(sb, &flags, data);
if (retval) { if (retval) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment