Do not call VFS_SYNC() before VFS_UNMOUNT() for forced unmount.

Since VFS does not/cannot stop writes, sync might run indefinitely, or
be a wrong thing to do at all.  E. g. NFS ignores VFS_SYNC() for
forced unmounts, since non-responding server does not allow sync to
finish.  On the other hand, filesystems can and do stop writes using
fs-specific facilities, and should already fully flush caches in
VFS_UNMOUNT() due to the race.

Adjust msdosfs tp sync in unmount for forced call, to accomodate the
new behaviour.  Note that it is still racy, since writes are not
stopped.

Discussed with:	avg, bjk, mckusick
Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
This commit is contained in:
Konstantin Belousov 2014-12-09 10:00:47 +00:00
parent a77c72f5ae
commit b2344ab5ff
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=275638
2 changed files with 9 additions and 5 deletions

View file

@ -797,11 +797,15 @@ msdosfs_unmount(struct mount *mp, int mntflags)
int error, flags;
flags = 0;
if (mntflags & MNT_FORCE)
error = msdosfs_sync(mp, MNT_WAIT);
if ((mntflags & MNT_FORCE) != 0) {
flags |= FORCECLOSE;
} else if (error != 0) {
return (error);
}
error = vflush(mp, 0, flags, curthread);
if (error && error != ENXIO)
return error;
if (error != 0 && error != ENXIO)
return (error);
pmp = VFSTOMSDOSFS(mp);
if ((pmp->pm_flags & MSDOSFSMNT_RONLY) == 0) {
error = markvoldirty(pmp, 0);

View file

@ -1305,8 +1305,8 @@ dounmount(mp, flags, td)
}
vput(fsrootvp);
}
if (((mp->mnt_flag & MNT_RDONLY) ||
(error = VFS_SYNC(mp, MNT_WAIT)) == 0) || (flags & MNT_FORCE) != 0)
if ((mp->mnt_flag & MNT_RDONLY) != 0 || (flags & MNT_FORCE) != 0 ||
(error = VFS_SYNC(mp, MNT_WAIT)) == 0)
error = VFS_UNMOUNT(mp, flags);
vn_finished_write(mp);
/*