[patch] ext2fs freeze/corruption on amd64
Kostik Belousov
kostikbel at gmail.com
Sun Jan 4 08:00:48 PST 2009
On Sat, Jan 03, 2009 at 08:21:08PM +0200, Jaakko Heinonen wrote:
>
> Hi,
>
> 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.
>
> This has been reported by other people too:
>
> 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=kern/119529
> http://www.freebsd.org/cgi/query-pr.cgi?pr=amd64/99561
>
> 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.)
>
> 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.
>
> %%%
> Index: sys/gnu/fs/ext2fs/ext2_bitops.h
> ===================================================================
> --- 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 = ~0U << (ofs & 31);
> bit = *p | ~mask;
> if (bit != ~0U)
> - return (ffs(~bit) + ofs - 1);
> + return (ffs(~bit) + (ofs & ~31U) - 1);
> p++;
> ofs = (ofs + 31U) & ~31U;
> }
> %%%
>
> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20090104/33428f73/attachment.pgp
More information about the freebsd-fs
mailing list