From owner-freebsd-fs@FreeBSD.ORG Tue Aug 5 20:47:14 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 979AF106566C for ; Tue, 5 Aug 2008 20:47:14 +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 5099E8FC15 for ; Tue, 5 Aug 2008 20:47:14 +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 m75KlDf3001479; Tue, 5 Aug 2008 16:47:13 -0400 Received: from localhost (rmacklem@localhost) by muncher.cs.uoguelph.ca (8.11.7p3+Sun/8.11.6) with ESMTP id m75KwUP03929; Tue, 5 Aug 2008 16:58:30 -0400 (EDT) X-Authentication-Warning: muncher.cs.uoguelph.ca: rmacklem owned process doing -bs Date: Tue, 5 Aug 2008 16:58:30 -0400 (EDT) From: Rick Macklem X-X-Sender: rmacklem@muncher.cs.uoguelph.ca To: Kostik Belousov In-Reply-To: <20080805194341.GI97161@deviant.kiev.zoral.com.ua> Message-ID: References: <20080805083229.GB97161@deviant.kiev.zoral.com.ua> <20080805153221.GG97161@deviant.kiev.zoral.com.ua> <20080805165114.GH97161@deviant.kiev.zoral.com.ua> <20080805194341.GI97161@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 20:47:14 -0000 On Tue, 5 Aug 2008, Kostik Belousov wrote: [stuff snipped] >> Ok, I just spent a few minutes snooping around in vfs_subr.c and I think >> I see the problem. vget() has called vholdl() and then >> v_upgrade_usecount(), which has incremented the usecount and taken the >> vnode off the free list. This appears to prevent vgonel() from being >> called on it for most cases, but there is still the case in vflush() >> where the FORCECLOSE flag is set. > Yes, exactly. > [more stuff snipped] > > But, what guarantees that the vnode would not be reclaimed before/under > your vref() it ? For instance, what if the vnode is locked due to reclaim > being in progress ? > So long as I never do a vflush() with FORCECLOSE, I can't see anywhere that will vgonel() it once I have gotten it via vget(). (v_usecount incremented and not on the vnode freelist) The way I just coded it is: - the function that does the vfs_hash_get() without LK_EXCLUSIVE just fails if MNTK_UNMOUNTF is set. - my nfs_close just returns when MNTK_UNMOUNTF is set. - my nfs_unmount() doesn't set FORCECLOSE on the vflush() but instead sleeps and retries a bunch of times if vflush() fails for MNT_FORCE. - my nfs_unmount() and other code (mostly based on the vanilla FreeBSD client makes requests all fail with EINTR when MNTK_UNMOUNTF is set). I think this should work for a forced unmount, since once requests all fail and the recovery also fails, I think vflush() will work without the FORCECLOSE flag. As far as I can see, since I'm not vflush()'ng with FORCECLOSE, then nothing will vgonel() the vnode until it has been vrele()'d. (If there is a case other than vflush() with FORCECLOSE that will vgone() it when it is not on the freelist and has a v_usecount > 0, then I'll need to handle that as well, but I can't see one.) rick