Browse files

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 <>
Cc: Christoph Hellwig <>
Cc: Alexander Viro <>
CC: Richard Weinberger <>
Co-authored-by: Richard Weinberger <>
Signed-off-by: Andrew Ruder <>
Signed-off-by: Al Viro <>
  • Loading branch information...
1 parent 9115eac commit 807612db2f9940b9fa6deaef054eb16d51bd3e00 @aeruder aeruder committed with Al Viro Jan 30, 2014
Showing with 2 additions and 1 deletion.
  1. +2 −1 fs/super.c
@@ -703,7 +703,6 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
if (flags & MS_RDONLY)
- 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) {

0 comments on commit 807612d

Please sign in to comment.