From owner-cvs-all@FreeBSD.ORG Fri Nov 18 05:47:01 2005 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6767B16A41F; Fri, 18 Nov 2005 05:47:01 +0000 (GMT) (envelope-from nate@root.org) Received: from www.cryptography.com (li-22.members.linode.com [64.5.53.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0E2F943D46; Fri, 18 Nov 2005 05:47:00 +0000 (GMT) (envelope-from nate@root.org) Received: from [10.0.5.50] (ppp-71-139-0-107.dsl.snfc21.pacbell.net [71.139.0.107]) by www.cryptography.com (8.12.8/8.12.8) with ESMTP id jAI5l1De027603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 17 Nov 2005 21:47:02 -0800 Message-ID: <437D6AB5.7020306@root.org> Date: Thu, 17 Nov 2005 21:46:29 -0800 From: Nate Lawson User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: John Polstra References: <20051118024411.AD37516A455@hub.freebsd.org> In-Reply-To: <20051118024411.AD37516A455@hub.freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/cam/scsi scsi_cd.c scsi_da.c src/sys/geom geom_disk.c geom_disk.h geom_subr.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Nov 2005 05:47:01 -0000 John Polstra wrote: > jdp 2005-11-18 02:43:49 UTC > > FreeBSD src repository > > Modified files: > sys/cam/scsi scsi_cd.c scsi_da.c > sys/geom geom_disk.c geom_disk.h geom_subr.c > Log: > Fix a bug that caused some /dev entries to continue to exist after > the underlying drive had been hot-unplugged from the system. Here > is a specific example. Filesystem code had opened /dev/da1s1e. > Subsequently, the drive was hot-unplugged. This (correctly) caused > all of the associated /dev/da1* entries to be deleted. When the > filesystem later realized that the drive was gone it closed the > device, reducing the write-access counts to 0 on the geom providers > for da1s1e, da1s1, and da1. This caused geom to re-taste the > providers, resulting in the devices being created again. When the > drive was hot-plugged back in, it resulted in duplicate /dev entries > for da1s1e, da1s1, and da1. > > This fix adds a new disk_gone() function which is called by CAM when a > drive goes away. It orphans all of the providers associated with the > drive, setting an error condition of ENXIO in each one. In addition, > we prevent a re-taste on last close for writing if an error condition > has been set in the provider. > > Sponsored by: Isilon Systems > Reviewed by: phk > MFC after: 1 week > > Revision Changes Path > 1.94 +1 -0 src/sys/cam/scsi/scsi_cd.c > 1.181 +1 -0 src/sys/cam/scsi/scsi_da.c > 1.98 +12 -0 src/sys/geom/geom_disk.c > 1.5 +1 -0 src/sys/geom/geom_disk.h > 1.88 +3 -2 src/sys/geom/geom_subr.c > > > Index: src/sys/geom/geom_disk.c > diff -u src/sys/geom/geom_disk.c:1.97 src/sys/geom/geom_disk.c:1.98 > --- src/sys/geom/geom_disk.c:1.97 Fri Sep 30 17:32:08 2005 > +++ src/sys/geom/geom_disk.c Fri Nov 18 02:43:49 2005 > @@ -419,6 +419,18 @@ > g_post_event(g_disk_destroy, dp, M_WAITOK, NULL); > } > > +void > +disk_gone(struct disk *dp) > +{ > + struct g_geom *gp; > + struct g_provider *pp; > + > + gp = dp->d_geom; > + if (gp != NULL) > + LIST_FOREACH(pp, &gp->provider, provider) > + g_orphan_provider(pp, ENXIO); > +} > + Does there need to be locking for this list traversal? Couldn't disk_gone() race in parallel with a taste event if someone plugs/unplugs quickly, especially for a slow device (i.e. floppy)? -- Nate