From owner-svn-src-head@FreeBSD.ORG Tue Dec 16 17:04:52 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83AB31065675; Tue, 16 Dec 2008 17:04:52 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7175F8FC14; Tue, 16 Dec 2008 17:04:52 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBGH4qts043023; Tue, 16 Dec 2008 17:04:52 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBGH4qK8043022; Tue, 16 Dec 2008 17:04:52 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <200812161704.mBGH4qK8043022@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 16 Dec 2008 17:04:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186188 - head/sys/geom X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2008 17:04:52 -0000 Author: trasz Date: Tue Dec 16 17:04:52 2008 New Revision: 186188 URL: http://svn.freebsd.org/changeset/base/186188 Log: 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 Modified: head/sys/geom/geom_vfs.c Modified: head/sys/geom/geom_vfs.c ============================================================================== --- head/sys/geom/geom_vfs.c Tue Dec 16 17:03:22 2008 (r186187) +++ head/sys/geom/geom_vfs.c Tue Dec 16 17:04:52 2008 (r186188) @@ -93,10 +93,23 @@ g_vfs_strategy(struct bufobj *bo, struct { 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 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. */ }