summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_vfs.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2008-12-16 17:04:52 +0000
committertrasz <trasz@FreeBSD.org>2008-12-16 17:04:52 +0000
commit99f3b7b788594678d9c1c7b7f587b70facecb930 (patch)
treeb5d6da0245a3c1e188e1b712b4fbc46f1f446192 /sys/geom/geom_vfs.c
parent1d38ccff9412b97456b3869f294eda87234057c9 (diff)
downloadFreeBSD-src-99f3b7b788594678d9c1c7b7f587b70facecb930.zip
FreeBSD-src-99f3b7b788594678d9c1c7b7f587b70facecb930.tar.gz
Implement g_vfs_orphan(). Without it, the filesystem never closes
the device, which means refcount on periph drivers never drops, which means cam_sim_free() never returns, which results in umass sleeping there ad infinitum. Submitted by: pjd Reviewed by: scottl, pjd Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation
Diffstat (limited to 'sys/geom/geom_vfs.c')
-rw-r--r--sys/geom/geom_vfs.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/sys/geom/geom_vfs.c b/sys/geom/geom_vfs.c
index 0621eff..86c909d 100644
--- a/sys/geom/geom_vfs.c
+++ b/sys/geom/geom_vfs.c
@@ -93,10 +93,23 @@ g_vfs_strategy(struct bufobj *bo, struct buf *bp)
{
struct g_consumer *cp;
struct bio *bip;
+ int vfslocked;
cp = bo->bo_private;
G_VALID_CONSUMER(cp);
+ /*
+ * If the the provider has orphaned us, just return EXIO.
+ */
+ if (cp->provider == NULL) {
+ bp->b_error = ENXIO;
+ bp->b_ioflags |= BIO_ERROR;
+ vfslocked = VFS_LOCK_GIANT(((struct mount *)NULL));
+ bufdone(bp);
+ VFS_UNLOCK_GIANT(vfslocked);
+ return;
+ }
+
bip = g_alloc_bio();
bip->bio_cmd = bp->b_iocmd;
bip->bio_offset = bp->b_iooffset;
@@ -110,18 +123,20 @@ g_vfs_strategy(struct bufobj *bo, struct buf *bp)
static void
g_vfs_orphan(struct g_consumer *cp)
{
+ struct g_geom *gp;
+ struct bufobj *bo;
+
+ g_topology_assert();
+
+ gp = cp->geom;
+ bo = gp->softc;
+ g_trace(G_T_TOPOLOGY, "g_vfs_orphan(%p(%s))", cp, gp->name);
+ if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0)
+ g_access(cp, -cp->acr, -cp->acw, -cp->ace);
+ g_detach(cp);
/*
- * Don't do anything here yet.
- *
- * Ideally we should detach the consumer already now, but that
- * leads to a locking requirement in the I/O path to see if we have
- * a consumer or not. Considering how ugly things are going to get
- * anyway as none of our filesystems are graceful about i/o errors,
- * this is not important right now.
- *
- * Down the road, this is the place where we could give the user
- * a "Abort, Retry or Ignore" option to replace the media again.
+ * Do not destroy the geom. Filesystem will do this during unmount.
*/
}
OpenPOWER on IntegriCloud