diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 0ec4d2ddf621..6a107ec0d0f6 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c @@ -273,7 +273,13 @@ static int ntfs_reconfigure(struct fs_context *fc) ntfs_debug("Entering with remount"); - sync_filesystem(sb); + err = sync_filesystem(sb); + if (err) { + ntfs_warning(sb, "Failed to sync the filesystem."); + /* A forced remount must still turn the superblock read-only. */ + if (!(fc->sb_flags & SB_FORCE)) + return err; + } /* * For the read-write compiled driver, if we are remounting read-write, @@ -336,11 +342,20 @@ static int ntfs_reconfigure(struct fs_context *fc) * or flush fails the remount, leaving the superblock * read-write so ntfs_put_super() retries at unmount. */ - err = ntfs_sync_volume_dirty_state(vol); - if (err) { - ntfs_warning(sb, - "Failed to update dirty bit in volume information flags. Run chkdsk."); - return err; + /* + * A forced remount does not drain writers in progress, + * so one may still be modifying metadata when the flags + * are committed: never clear the dirty bit then; if + * errors have been recorded, the update preserves or + * sets it; otherwise, skip the update entirely. + */ + if (!(fc->sb_flags & SB_FORCE) || NVolErrors(vol)) { + err = ntfs_sync_volume_dirty_state(vol); + if (err) { + ntfs_warning(sb, + "Failed to update dirty bit in volume information flags. Run chkdsk."); + return err; + } } if (NInoDirty(NTFS_I(vol->vol_ino))) { /* ntfs_commit_inode() would discard the error. */