From owner-freebsd-fs@FreeBSD.ORG Wed Aug 6 13:39:55 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 8ED6D1065687 for ; Wed, 6 Aug 2008 13:39:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (skuns.zoral.com.ua [91.193.166.194]) by mx1.freebsd.org (Postfix) with ESMTP id 233868FC0C for ; Wed, 6 Aug 2008 13:39:54 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m76DdpSq046188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 6 Aug 2008 16:39:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m76DdpMv099960; Wed, 6 Aug 2008 16:39:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2/Submit) id m76Ddo96099678; Wed, 6 Aug 2008 16:39:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 6 Aug 2008 16:39:50 +0300 From: Kostik Belousov To: Rick Macklem Message-ID: <20080806133950.GN97161@deviant.kiev.zoral.com.ua> 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: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IiH5iyEqjK6f5lUg" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua 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: Wed, 06 Aug 2008 13:39:55 -0000 --IiH5iyEqjK6f5lUg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 05, 2008 at 04:58:30PM -0400, Rick Macklem wrote: >=20 >=20 > On Tue, 5 Aug 2008, Kostik Belousov wrote: >=20 > [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=20 > that will vgonel() it once I have gotten it via vget(). (v_usecount > incremented and not on the vnode freelist) >=20 > 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). You still has the race where the MNTK_UNMOUNTF is set after you check returned false, isn't it ? BTW, is your fs marked as mpsafe ? >=20 > 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. >=20 > 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.) Yes, ATM it should be safe, since only vflush() does reclamation for the vnodes with usecount > 0. On the other hand, I believe our VFS never makes a guarantee that this is the only location of the call. --IiH5iyEqjK6f5lUg Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkiZqaYACgkQC3+MBN1Mb4hdHACdFRKyFhrhmRqHxBWYnk3Ka2id s7MAoNsuFDa+MYMXykCQ8APpEDsrX4A/ =FMcN -----END PGP SIGNATURE----- --IiH5iyEqjK6f5lUg--