From owner-freebsd-fs@FreeBSD.ORG Tue Aug 5 16:51:19 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 E48CF106566B for ; Tue, 5 Aug 2008 16:51:19 +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 7BEBD8FC1E for ; Tue, 5 Aug 2008 16:51:19 +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 m75GpFAl089731 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 5 Aug 2008 19:51:15 +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 m75GpFUA071454; Tue, 5 Aug 2008 19:51:15 +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 m75GpFsP071447; Tue, 5 Aug 2008 19:51:15 +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: Tue, 5 Aug 2008 19:51:14 +0300 From: Kostik Belousov To: Rick Macklem Message-ID: <20080805165114.GH97161@deviant.kiev.zoral.com.ua> References: <20080805083229.GB97161@deviant.kiev.zoral.com.ua> <20080805153221.GG97161@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aRuUY7KzmetiZjaI" 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: Tue, 05 Aug 2008 16:51:20 -0000 --aRuUY7KzmetiZjaI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 05, 2008 at 12:54:26PM -0400, Rick Macklem wrote: >=20 >=20 > On Tue, 5 Aug 2008, Kostik Belousov wrote: >=20 > [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"? It means that the vnode memory will not be freed until vrele(). But the VOP_RECLAIM may be called any time, and it requires exclusive lock. After vnode is reclaimed, it is reassigned to the deadfs. In particular, VOP_RECLAIM implementation must clear v_data. For the reclaimed vnode you still hold a reference to, you can reliably obtain the vnode lock. >=20 > I suppose I can test for the lock and grab it, if no other thread already > has it locked. >=20 > >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 =3D=3D 0 under FreeBSD7. >=20 > >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.) I do not know about these systems, esp. whether and how they implement a forced unmount. --aRuUY7KzmetiZjaI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkiYhQIACgkQC3+MBN1Mb4hX1wCgjLV/Tr/QaTG+1hiMbVzDifOA 0bYAn0MDZtboyjCEBXxBU4QTSyJIQU8t =W7MY -----END PGP SIGNATURE----- --aRuUY7KzmetiZjaI--