From owner-freebsd-scsi Fri Dec 13 10:54:47 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 E9D6237B404 for ; Fri, 13 Dec 2002 10:54:45 -0800 (PST) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 50A9943ED8 for ; Fri, 13 Dec 2002 10:54:45 -0800 (PST) (envelope-from nate@rootlabs.com) Received: (qmail 36801 invoked by uid 1000); 13 Dec 2002 18:54:46 -0000 Date: Fri, 13 Dec 2002 10:54:45 -0800 (PST) From: Nate Lawson To: Yar Tikhiy Cc: freebsd-scsi@freebsd.org Subject: Re: {da,sa,...}open bug? In-Reply-To: <20021212215655.A92315@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 Thu, 12 Dec 2002, Yar Tikhiy wrote: > On Tue, Dec 10, 2002 at 01:23:59PM -0800, Nate Lawson wrote: > > Here is what would happen with your patch: > > > > open() > > 1. lock -- refcount +1, get lock, refcount -1 > > 2. [open code runs] > > 3. acquire -- refcount +1 > > > > All throughout step 2, periph could disappear if another proc calls > > release. > > I see your point, but your scenario isn't exactly what would happen, to my mind. > If periph weren't currently locked, the refcount would change as follows: > 1. lock -- refcount +1, get lock > 2. [open code runs], refcount >0 > 3. acquire -- refcount +1 > 4. unlock -- refcount -1 > > As you may see, even if cam_periph_acquire() were called lately, > right before cam_periph_unlock(), refcount would never drop below 1. Yes, you are correct. I am still uncomfortable with moving acquire() to the end, depending on the side effect of it staying inside a lock/unlock scope. We may want to push down the locks later to only encapsulate a small portion of shared access routines and that would change this assumption. -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message