summaryrefslogtreecommitdiffstats
path: root/sys/fs/specfs
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2002-10-25 00:20:37 +0000
committermckusick <mckusick@FreeBSD.org>2002-10-25 00:20:37 +0000
commit6b1611bd949afb58a84ad54e4bbcf960b0ef28b1 (patch)
tree3538f027616418c955bda99415bbb0b81e6d64b5 /sys/fs/specfs
parent776a2129fe77eb14c0d61bf67d393ee4893c4a08 (diff)
downloadFreeBSD-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/fs/specfs')
-rw-r--r--sys/fs/specfs/spec_vnops.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c
index 9ae87c0..ed5c2bc 100644
--- a/sys/fs/specfs/spec_vnops.c
+++ b/sys/fs/specfs/spec_vnops.c
@@ -421,8 +421,8 @@ spec_fsync(ap)
struct vnode *vp = ap->a_vp;
struct buf *bp;
struct buf *nbp;
- int s;
- int maxretry = 10000; /* large, arbitrarily chosen */
+ int s, error = 0;
+ int maxretry = 100; /* large, arbitrarily chosen */
if (!vn_isdisk(vp, NULL))
return (0);
@@ -435,6 +435,7 @@ loop1:
s = splbio();
TAILQ_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs) {
bp->b_flags &= ~B_SCANNED;
+ bp->b_error = 0;
}
splx(s);
@@ -481,16 +482,25 @@ loop2:
PRIBIO + 1, "spfsyn", 0);
}
if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
- if (--maxretry != 0) {
+ /*
+ * If we are unable to write any of these buffers
+ * then we fail now rather than trying endlessly
+ * to write them out.
+ */
+ TAILQ_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs)
+ if ((error = bp->b_error) == 0)
+ continue;
+ if (error == 0 && --maxretry >= 0) {
splx(s);
goto loop1;
}
vprint("spec_fsync: giving up on dirty", vp);
+ error = EAGAIN;
}
}
VI_UNLOCK(vp);
splx(s);
- return (0);
+ return (error);
}
/*
OpenPOWER on IntegriCloud