diff options
author | mckusick <mckusick@FreeBSD.org> | 2002-10-25 00:20:37 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2002-10-25 00:20:37 +0000 |
commit | 6b1611bd949afb58a84ad54e4bbcf960b0ef28b1 (patch) | |
tree | 3538f027616418c955bda99415bbb0b81e6d64b5 /sys/kern | |
parent | 776a2129fe77eb14c0d61bf67d393ee4893c4a08 (diff) | |
download | FreeBSD-src-6b1611bd949afb58a84ad54e4bbcf960b0ef28b1.zip FreeBSD-src-6b1611bd949afb58a84ad54e4bbcf960b0ef28b1.tar.gz |
Within ufs, the ffs_sync and ffs_fsync functions did not always
check for and/or report I/O errors. The result is that a VFS_SYNC
or VOP_FSYNC called with MNT_WAIT could loop infinitely on ufs in
the presence of a hard error writing a disk sector or in a filesystem
full condition. This patch ensures that I/O errors will always be
checked and returned. This patch also ensures that every call to
VFS_SYNC or VOP_FSYNC with MNT_WAIT set checks for and takes
appropriate action when an error is returned.
Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_subr.c | 6 | ||||
-rw-r--r-- | sys/kern/vfs_vnops.c | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index e0256ad..8f35ddb 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3425,7 +3425,7 @@ sync_fsync(ap) struct vnode *syncvp = ap->a_vp; struct mount *mp = syncvp->v_mount; struct thread *td = ap->a_td; - int asyncflag; + int error, asyncflag; /* * We only need to do something if this is a lazy evaluation. @@ -3456,12 +3456,12 @@ sync_fsync(ap) asyncflag = mp->mnt_flag & MNT_ASYNC; mp->mnt_flag &= ~MNT_ASYNC; vfs_msync(mp, MNT_NOWAIT); - VFS_SYNC(mp, MNT_LAZY, ap->a_cred, td); + error = VFS_SYNC(mp, MNT_LAZY, ap->a_cred, td); if (asyncflag) mp->mnt_flag |= MNT_ASYNC; vn_finished_write(mp); vfs_unbusy(mp, td); - return (0); + return (error); } /* diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 08f8093..0281a29 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1005,19 +1005,24 @@ vn_finished_write(mp) /* * Request a filesystem to suspend write operations. */ -void +int vfs_write_suspend(mp) struct mount *mp; { struct thread *td = curthread; + int error; if (mp->mnt_kern_flag & MNTK_SUSPEND) - return; + return (0); mp->mnt_kern_flag |= MNTK_SUSPEND; if (mp->mnt_writeopcount > 0) (void) tsleep(&mp->mnt_writeopcount, PUSER - 1, "suspwt", 0); - VFS_SYNC(mp, MNT_WAIT, td->td_ucred, td); + if ((error = VFS_SYNC(mp, MNT_WAIT, td->td_ucred, td)) != 0) { + vfs_write_resume(mp); + return (error); + } mp->mnt_kern_flag |= MNTK_SUSPENDED; + return (0); } /* |