Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Jan 2009 18:00:43 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Jaakko Heinonen <jh@saunalahti.fi>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: [patch] ext2fs freeze/corruption on amd64
Message-ID:  <20090104160043.GI93900@deviant.kiev.zoral.com.ua>
In-Reply-To: <20090103182107.GA4119@a91-153-125-115.elisa-laajakaista.fi>
References:  <20090103182107.GA4119@a91-153-125-115.elisa-laajakaista.fi>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090104160043.GI93900>