From owner-freebsd-fs@FreeBSD.ORG Sat Jan 3 18:21:10 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 9E4E11065673 for ; Sat, 3 Jan 2009 18:21:10 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from emh05.mail.saunalahti.fi (emh05.mail.saunalahti.fi [62.142.5.111]) by mx1.freebsd.org (Postfix) with ESMTP id 5B1DF8FC0C for ; Sat, 3 Jan 2009 18:21:10 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from saunalahti-vams (vs3-12.mail.saunalahti.fi [62.142.5.96]) by emh05-2.mail.saunalahti.fi (Postfix) with SMTP id 4B9048C0FB for ; Sat, 3 Jan 2009 20:21:09 +0200 (EET) Received: from emh04.mail.saunalahti.fi ([62.142.5.110]) by vs3-12.mail.saunalahti.fi ([62.142.5.96]) with SMTP (gateway) id A0312D08B57; Sat, 03 Jan 2009 20:21:09 +0200 Received: from a91-153-125-115.elisa-laajakaista.fi (a91-153-125-115.elisa-laajakaista.fi [91.153.125.115]) by emh04.mail.saunalahti.fi (Postfix) with SMTP id 382E941BE5 for ; Sat, 3 Jan 2009 20:21:08 +0200 (EET) Date: Sat, 3 Jan 2009 20:21:08 +0200 From: Jaakko Heinonen To: freebsd-fs@freebsd.org Message-ID: <20090103182107.GA4119@a91-153-125-115.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Antivirus: VAMS Subject: [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: Sat, 03 Jan 2009 18:21:10 -0000 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. -- Jaakko