From owner-freebsd-fs@FreeBSD.ORG Sun Jan 4 16:00:48 2009 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 4BA551065672 for ; Sun, 4 Jan 2009 16:00:48 +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 E5C638FC18 for ; Sun, 4 Jan 2009 16:00:47 +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 1LJVPC-0002Xj-Bt; Sun, 04 Jan 2009 18:00:46 +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 n04G0h1W092457 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 4 Jan 2009 18:00:43 +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 n04G0hNs062148; Sun, 4 Jan 2009 18:00:43 +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 n04G0hPX062146; Sun, 4 Jan 2009 18:00:43 +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: Sun, 4 Jan 2009 18:00:43 +0200 From: Kostik Belousov To: Jaakko Heinonen Message-ID: <20090104160043.GI93900@deviant.kiev.zoral.com.ua> References: <20090103182107.GA4119@a91-153-125-115.elisa-laajakaista.fi> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wZdghQXYJzyo6AGC" Content-Disposition: inline In-Reply-To: <20090103182107.GA4119@a91-153-125-115.elisa-laajakaista.fi> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 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 1LJVPC-0002Xj-Bt 3af7db5cff8db4364b6c701704f3747b X-Terabit: YES Cc: freebsd-fs@freebsd.org Subject: Re: [patch] ext2fs freeze/corruption on amd64 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: Sun, 04 Jan 2009 16:00:48 -0000 --wZdghQXYJzyo6AGC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jan 03, 2009 at 08:21:08PM +0200, Jaakko Heinonen wrote: >=20 > Hi, >=20 > I can quite easily reproduce a hard freeze while writing to an ext2fs > filesystem on amd64. I can reliably reproduce it by building a kernel > with "make -j2" on ext2fs. >=20 > This has been reported by other people too: >=20 > http://lists.freebsd.org/pipermail/freebsd-fs/2008-March/004504.html > http://lists.freebsd.org/pipermail/freebsd-bugs/2008-January/027555.html > http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dkern/119529 > http://www.freebsd.org/cgi/query-pr.cgi?pr=3Damd64/99561 >=20 > I tracked the problem down to find_next_zero_bit() in ext2_bitops.h. > The bug doesn't affect i386 because it uses asm bitops from > i386-bitops.h. (There's also sparc64-bitops.h file but it's not used > anywhere.) >=20 > The problem is that if the offset (ofs) has one or more of it's five low > bits set those bits are incorrectly re-added to the result. With > following patch applied I can't reproduce the problem. >=20 > %%% > Index: sys/gnu/fs/ext2fs/ext2_bitops.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- sys/gnu/fs/ext2fs/ext2_bitops.h (revision 186639) > +++ sys/gnu/fs/ext2fs/ext2_bitops.h (working copy) > @@ -84,7 +84,7 @@ find_next_zero_bit(void *data, size_t sz > mask =3D ~0U << (ofs & 31); > bit =3D *p | ~mask; > if (bit !=3D ~0U) > - return (ffs(~bit) + ofs - 1); > + return (ffs(~bit) + (ofs & ~31U) - 1); > p++; > ofs =3D (ofs + 31U) & ~31U; > } > %%% >=20 > I hope that someone would commit this or similar fix. It might be also > reasonable to delete the unused sparc64-bitops.h file. Please note that find_next_zero_bit() uses gcc extension to perform void-pointer arithmetic. Also, at the +2 line, it performs unaligned access to the uint32_t entities. --wZdghQXYJzyo6AGC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAklg3SoACgkQC3+MBN1Mb4jasACgnVBp7ehnPSciZTa4jT3R771M NfEAn2bUN458Uav6daqeGf5NOEjrTXPg =3Dqp -----END PGP SIGNATURE----- --wZdghQXYJzyo6AGC--