From owner-freebsd-current@FreeBSD.ORG Sat Nov 22 12:06:25 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A3F61065680 for ; Sat, 22 Nov 2008 12:06:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id B6DB28FC0C for ; Sat, 22 Nov 2008 12:06:24 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1L3r0U-000FBh-Fg; Sat, 22 Nov 2008 13:50:34 +0200 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 mAMBoSU4047771 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 22 Nov 2008 13:50:28 +0200 (EET) (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.3/8.14.3) with ESMTP id mAMBoSM3074161; Sat, 22 Nov 2008 13:50:28 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id mAMBoSOs074160; Sat, 22 Nov 2008 13:50:28 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 22 Nov 2008 13:50:28 +0200 From: Kostik Belousov To: John Baldwin Message-ID: <20081122115028.GB6408@deviant.kiev.zoral.com.ua> References: <200811201627.58289.jhb@freebsd.org> <3a142e750811201532u6e697488w2747242e0a8614a9@mail.gmail.com> <200811211452.02545.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TakKZr9L6Hm6aLOc" Content-Disposition: inline In-Reply-To: <200811211452.02545.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean 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 X-Virus-Scanned: mail.terabit.net.ua 1L3r0U-000FBh-Fg 96d223be7f6f5cfde7235028465312ec X-Terabit: YES Cc: scottl@freebsd.org, current@freebsd.org Subject: Re: [PATCH] Make udf(4) MPSAFE and use shared lookups X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Nov 2008 12:06:25 -0000 --TakKZr9L6Hm6aLOc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 21, 2008 at 02:52:02PM -0500, John Baldwin wrote: > On Thursday 20 November 2008 06:32:25 pm Paul B. Mahol wrote: > > On 11/20/08, John Baldwin wrote: > > > So this patch is fairly minimal since udf(4) is currently read-only. = The > > > changes include: > > > > > > * Set VV_ROOT in udf_vget() if we ever return a vnode instead of doin= g it > > > only > > > in udf_root(). This matches the behavior of other operating system= s and > > > correctly tags the root vnode with VV_ROOT in the unlikely case tha= t we > > > create the vnode during a call to ufs_vget() that does not come from > > > ufs_root(). > > > * If the hash lookup in ufs_vget() fails, ensure an exclusive vnode l= ock=20 > is > > > used while creating the new vnode (same as UFS). > > > * Allow lock recursion (XXX: not really sure this is needed actually). > > > * Allow shared vnode locks on non-fifos. > > > * Honor the requested locking flags (shared vs exclusive) instead of= =20 > always > > > using exclusive vnode locks during a lookup operation. > > > * Handle "." lookups the same way other filesystems do by just bumpin= g the > > > reference on 'dvp' rather than calling udf_vget(). > > > > > > http://www.FreeBSD.org/~jhb/patches/udf_mpsafe.patch > > > > > > I have only verified that this compiles and would appreciate it if so= me > > > folks > > > could test this, preferable with INVARIANTS and DEBUG_VFS_LOCKS enabl= ed. > >=20 > > I lightly tested it with md(4) on 47M size iso created with k3b > > (it contains two files) > >=20 > > I only got this lor related to udf: > >=20 > > lock order reversal: > > 1st 0xc4449270 udf (udf) @ /usr/src/sys/kern/vfs_lookup.c:442 > > 2nd 0xd7d10850 bufwait (bufwait) @ /usr/src/sys/kern/vfs_bio.c:2443 > > 3rd 0xc4399488 udf (udf) @ > > /usr/src/sys/modules/udf/../../fs/udf/udf_vfsops.c:625 >=20 > I've updated the patch at the same URL above to fix this LOR. udf_vget() does insmntque() before vnode is fully initialized, allowing other threads to find the vnode on the mount list. This is typical for !MPSAFE fs, and it seems corresponding call was not marked XXX for udf. udf_lookup for ISDOTDOT case unlocks dvp before vget'ing "..", allowing the same race on forced unmount as ufs (I will finally commit ufs patch today). The race happens for !MPSAFE code too, but it is easier to execute without Giant. --TakKZr9L6Hm6aLOc Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkkn8gMACgkQC3+MBN1Mb4jVOwCcDQGGhm0gQ++oiEAy3KptHUFF sNAAoMDBs3rcsTLN+eS3GJ1jQtGhy3lN =xTI5 -----END PGP SIGNATURE----- --TakKZr9L6Hm6aLOc--