From owner-freebsd-fs@FreeBSD.ORG Tue Aug 5 16:43:11 2008 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D9811065674 for ; Tue, 5 Aug 2008 16:43:11 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from phoenix.cs.uoguelph.ca (phoenix.cs.uoguelph.ca [131.104.94.216]) by mx1.freebsd.org (Postfix) with ESMTP id 184558FC1C for ; Tue, 5 Aug 2008 16:43:10 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from muncher.cs.uoguelph.ca (muncher.cs.uoguelph.ca [131.104.91.102]) by phoenix.cs.uoguelph.ca (8.13.1/8.13.1) with ESMTP id m75GhAFH009687; Tue, 5 Aug 2008 12:43:10 -0400 Received: from localhost (rmacklem@localhost) by muncher.cs.uoguelph.ca (8.11.7p3+Sun/8.11.6) with ESMTP id m75GsQD28307; Tue, 5 Aug 2008 12:54:26 -0400 (EDT) X-Authentication-Warning: muncher.cs.uoguelph.ca: rmacklem owned process doing -bs Date: Tue, 5 Aug 2008 12:54:26 -0400 (EDT) From: Rick Macklem X-X-Sender: rmacklem@muncher.cs.uoguelph.ca To: Kostik Belousov In-Reply-To: <20080805153221.GG97161@deviant.kiev.zoral.com.ua> Message-ID: References: <20080805083229.GB97161@deviant.kiev.zoral.com.ua> <20080805153221.GG97161@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Scanned-By: MIMEDefang 2.63 on 131.104.94.216 Cc: freebsd-fs@freebsd.org Subject: Re: doing vfs_hash_get when vnode locked X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Aug 2008 16:43:11 -0000 On Tue, 5 Aug 2008, Kostik Belousov wrote: [stuff snipped] >>> >> I need a referenced vnode (v_usecount incremented, which I thought would >> avoid it being recycled) when another blocked thread in the kernel has > No, this is a wrong assumption. Use count does not prevent the vnode > from being reclaimed. > What does v_usecount mean then, if it doesn't say "I have it in use, so you can't recycle it until I vrele() it"? I suppose I can test for the lock and grab it, if no other thread already has it locked. > Unless you held the vnode lock, it may be reclaimed. To set the > VI_DOOMED flag, both exclusive vnode lock and vnode interlock must be > held. > I don't care about VI_DOOMED nor want to set it. It is just what vget() checked for the case of LK_TYPE_MASK == 0 under FreeBSD7. > If you can guarantee that the other thread does not relinquish the vnode > lock while curthread operates on the vnode, you may use vref() and > direct check on VI_DOOMED. I shall admit that this is quite perversive > and fragile. > I'll have to think about it but, yes, I think I can guarantee that if another thread holds the vnode lock then it is blocked waiting for this thread to complete recovery. (The only other way to do this recovery is without the vnode and that means I have to do a lot of coding. I'm pretty sure holding a v_usecount works for OpenBSD and Mac OS X. I've done quite a bit of testing on both and not had a problem.) rick