From owner-freebsd-scsi Mon Nov 25 12:10:17 2002 Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C590937B404 for ; Mon, 25 Nov 2002 12:10:15 -0800 (PST) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id B5CD643E88 for ; Mon, 25 Nov 2002 12:10:13 -0800 (PST) (envelope-from nate@rootlabs.com) Received: (qmail 83352 invoked by uid 1000); 25 Nov 2002 20:10:14 -0000 Date: Mon, 25 Nov 2002 12:10:14 -0800 (PST) From: Nate Lawson To: Yar Tikhiy Cc: freebsd-scsi@freebsd.org Subject: Re: {da,sa,...}open bug? In-Reply-To: <20021125134302.D14452@comp.chem.msu.su> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-scsi@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Mon, 25 Nov 2002, Yar Tikhiy wrote: > On Fri, Nov 22, 2002 at 11:14:47AM -0800, Nate Lawson wrote: > > On Fri, 22 Nov 2002, Yar Tikhiy wrote: > > > The XXopen() methods of the da, sa etc drivers get a reference to > > > the peripheral ("periph") through cam_periph_acquire() and don't > > > release it on error exit. I suspect this leads to CAM wedge if the > > > device is removed when its driver is in XXopen(). That is because > > > the "periph" stays acquired (refcount > 0), but the XXopen() caller > > > wouldn't invoke XXclose() subsequently since it sees XXopen() having > > > failed. Thus CAM won't ever "forget" the device removed. > > > > > > Moreover, after I had patched daopen() to release the peripheral > > > if returning non-zero error code, the CAM wedge has gone. > > > > Your approach sounds correct to me. open should call cam_periph_release > > if it errors out after cam_periph_acquire. Care to submit a patch? > > Certainly! The patch is at the end of this message. I can commit > it if it looks right to you. Thanks. I have emailed a patch to re@ and will commit it upon approval. > While preparing the fix, I noticed an additional couple of oddities. > First, files under sys/cam/scsi are inconsistent as to the order of > calling cam_periph_release() and cam_periph_unlock(): Some of them > will call cam_periph_release() first, and the others will call it second. > Then, there's a number of places in the code where cam_periph_unlock() > won't be called before return on a cam_periph_acquire() error, though > the "periph" has been locked. I think this should be fixed. Please submit a patch for this. -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message