From patchwork Fri Oct 28 12:36:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 122400 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 63C8F1007DB for ; Fri, 28 Oct 2011 23:35:21 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755578Ab1J1MfT (ORCPT ); Fri, 28 Oct 2011 08:35:19 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:35666 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753137Ab1J1MfS (ORCPT ); Fri, 28 Oct 2011 08:35:18 -0400 Received: by iaby12 with SMTP id y12so4014031iab.19 for ; Fri, 28 Oct 2011 05:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=XdxICwwt9N23/ZZAYcEzp2h9q60c392b3AhiT/rlDnE=; b=c306f9jgdDaj28VwHdBVVn0tXffdQUEyiC/sdUesi9Jl0IKexgMa7vslhrmgLF/vbI 6+txcYwST2ygk2IzGVWgXP0OHeJtgsEjUDa6veGA0sGmYw2e0inlCyYocj4Pa8FKH7jd VMWgIDKZHRZkwVdcayvTO2Y78xKH6KogoK+FU= Received: by 10.42.151.4 with SMTP id c4mr3939124icw.39.1319805318207; Fri, 28 Oct 2011 05:35:18 -0700 (PDT) Received: from gmail.com ([182.92.247.2]) by mx.google.com with ESMTPS id pa4sm4034608igc.1.2011.10.28.05.35.13 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Oct 2011 05:35:17 -0700 (PDT) Date: Fri, 28 Oct 2011 20:36:22 +0800 From: Zheng Liu To: Greg KH Cc: Ted Ts'o , Tao Ma , linux-ext4@vger.kernel.org, Xiaoyun Mao , Yingbin Wang , Jia Wan Subject: [PATCH] ext4: fix BUG_ON() in ext4_ext_insert_extent() for .33 longterm Message-ID: <20111028123622.GB26003@gmail.com> Mail-Followup-To: Greg KH , Ted Ts'o , Tao Ma , linux-ext4@vger.kernel.org, Xiaoyun Mao , Yingbin Wang , Jia Wan References: <20110927193523.GB3309@thunk.org> <1317206703-5604-1-git-send-email-tm@tao.ma> <20111027094329.GB31921@thunk.org> <20111027115322.GB6379@kroah.com> <20111028023607.GA23772@gmail.com> <20111028052406.GA21306@kroah.com> <20111028084652.GA25104@gmail.com> <20111028090759.GA22822@kroah.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20111028090759.GA22822@kroah.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Oct 28, 2011 at 11:07:59AM +0200, Greg KH wrote: > On Fri, Oct 28, 2011 at 04:46:52PM +0800, Zheng Liu wrote: > > On Fri, Oct 28, 2011 at 07:24:06AM +0200, Greg KH wrote: > > > On Fri, Oct 28, 2011 at 10:36:08AM +0800, Zheng Liu wrote: > > > > On Thu, Oct 27, 2011 at 01:53:22PM +0200, Greg KH wrote: > > > > > On Thu, Oct 27, 2011 at 05:43:29AM -0400, Ted Ts'o wrote: > > > > > > On Wed, Sep 28, 2011 at 06:45:03PM +0800, Tao Ma wrote: > > > > > > > actually this bug does show up in 2.6.39 and I think stable tree still > > > > > > > needs this fix. After some careful test, my colleague has generated > > > > > > > the patch. Please considering ack it so that Greg can add it into the > > > > > > > stable tree. > > > > > > > > > > > > Sorry for the delay, but yes. This patch would be good for the stable > > > > > > tree for 2.6.39 (if Greg is still accepting patches for > > > > > > 2.6.39-stable). It doesn't apply for upstream ext4 since the code has > > > > > > been changed/refactored since then, but it's a good fix. > > > > > > > > > > No, .39 has not been maintained for quite some time now, sorry. > > > > Hi Greg, > > > > > > > > Thank you for your attention. Actually this bug is between from .32 to > > > > .39. Please considering to apply this patch to other stable or longterm > > > > trees. > > > > > > Ah, ok, that makes sense, can you provide me a patch that will apply to > > > the .32 and .33-longterm kernels? > > Hi Greg, > > > > I couldn't download the .32 and .33-longterm kernels from kernel.org > > because the full sources were not found on that server. Thus this patch > > is generated from the .32-mainline kernel and can be applied to the .32 > > and .33 kernels. > > The .32 and .33 longterm kernels are part of the linux-stable tree on > git.kernel.org, they are in their own branch. Please redo this against > those trees, as I'm pretty sure that there will be conflicts, due to all > of the different changes since the .0 releases. Hi Greg, This patch is for .33 longterm kernel. Please apply it. regards, Zheng From 86c78ef9cd861146a48e8a643601c165b0e80849 Mon Sep 17 00:00:00 2001 From: Zheng Liu Date: Fri, 28 Oct 2011 19:45:31 +0800 Subject: [PATCH] ext4: fix BUG_ON() in ext4_ext_insert_extent() We will meet with a BUG_ON() if following script is run. mkfs.ext4 -b 4096 /dev/sdb1 1000000 mount -t ext4 /dev/sdb1 /mnt/sdb1 fallocate -l 100M /mnt/sdb1/test sync for((i=0;i<170;i++)) do dd if=/dev/zero of=/mnt/sdb1/test conv=notrunc bs=256k count=1 seek=`expr $i \* 2` done umount /mnt/sdb1 mount -t ext4 /dev/sdb1 /mnt/sdb1 dd if=/dev/zero of=/mnt/sdb1/test conv=notrunc bs=256k count=1 seek=341 umount /mnt/sdb1 mount /dev/sdb1 /mnt/sdb1 dd if=/dev/zero of=/mnt/sdb1/test conv=notrunc bs=256k count=1 seek=340 sync The reason is that it forgot to mark dirty when splitting two extents in ext4_ext_convert_to_initialized(). Althrough ex has been updated in memory, it is not dirtied both in ext4_ext_convert_to_initialized() and ext4_ext_insert_extent(). The disk layout is corrupted. Then it will meet with a BUG_ON() when writting at the start of that extent again. Cc: stable@kernel.org #for 2.6.33 Cc: Greg Kroah-Hartman Cc: "Theodore Ts'o" Cc: Xiaoyun Mao Cc: Yingbin Wang Cc: Jia Wan Signed-off-by: Zheng Liu --- fs/ext4/extents.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) /* diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 505a281..6cb1bbd 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2566,6 +2566,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, ex1 = ex; ex1->ee_len = cpu_to_le16(iblock - ee_block); ext4_ext_mark_uninitialized(ex1); + ext4_ext_dirty(handle, inode, path + depth); ex2 = &newex; }