summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2007-12-27 16:38:28 +0000
committerimp <imp@FreeBSD.org>2007-12-27 16:38:28 +0000
commit430e46303c3bc521da09dfc267d0a5fd64c1d689 (patch)
tree078dcdccc88086fba3a9c673511df9d39c609f7e
parent78bebd3368c125b3a09762078e6ce35dc4e930b0 (diff)
downloadFreeBSD-src-430e46303c3bc521da09dfc267d0a5fd64c1d689.zip
FreeBSD-src-430e46303c3bc521da09dfc267d0a5fd64c1d689.tar.gz
A partial solution to some of the 'pull the umass device with a
mounted FS' problems. These are more along the lines of 'avoiding an avoidable panic' than a complete solution to removable devices. We now close the barn door after the horse has gotten lose and has been hit by a truck, as it were. The barn no longer catches fire in this case, but the horse is still dead :-). The vfs_bio.c fix causes us not to put a failed write back into the dirty pool if the error returned was ENXIO. In that case, the buffer is treated like any other clean buffer that's being retured. ENXIO means the device isn't there anymore and will never be there again in the future, so retrying is futile. The vfs_mount.c fix treats 'ENXIO' as success for unmounting a file system. If the device is gone, retrying later won't help and we'll never be able to unmount the device. These two are part of a larger patch set submitted by the author. The other patches will be forth coming. I added comments to these two patches. Submitted by: Henrik Gulbrandsen Reviewed by: phk@ PR: usb/46176 (partial)
-rw-r--r--sys/kern/vfs_bio.c4
-rw-r--r--sys/kern/vfs_mount.c9
2 files changed, 11 insertions, 2 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 444c2be..b02d65b 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1170,6 +1170,7 @@ brelse(struct buf *bp)
if (bp->b_iocmd == BIO_WRITE &&
(bp->b_ioflags & BIO_ERROR) &&
+ bp->b_error != ENXIO &&
!(bp->b_flags & B_INVAL)) {
/*
* Failed write, redirty. Must clear BIO_ERROR to prevent
@@ -1177,6 +1178,9 @@ brelse(struct buf *bp)
* this case is not run and the next case is run to
* destroy the buffer. B_INVAL can occur if the buffer
* is outside the range supported by the underlying device.
+ * If the error is that the device went away (ENXIO), we
+ * shouldn't redirty the buffer either, but discard the
+ * data too.
*/
bp->b_ioflags &= ~BIO_ERROR;
bdirty(bp);
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index dfb46e2..6a615b1 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1286,8 +1286,13 @@ dounmount(mp, flags, td)
error = VFS_UNMOUNT(mp, flags, td);
}
vn_finished_write(mp);
- if (error) {
- /* Undo cdir/rdir and rootvnode changes made above. */
+ /*
+ * If we failed to flush the dirty blocks for this mount point,
+ * undo all the cdir/rdir and rootvnode changes we made above.
+ * Unless we failed to do so because the device is reporting that
+ * it doesn't exist anymore.
+ */
+ if (error && error != ENXIO) {
if ((flags & MNT_FORCE) &&
VFS_ROOT(mp, LK_EXCLUSIVE, &fsrootvp, td) == 0) {
if (mp->mnt_vnodecovered != NULL)
OpenPOWER on IntegriCloud