diff mbox

ext4: fix BUG_ON() in ext4_ext_insert_extent() for .32 longterm

Message ID 20111028123402.GA26003@gmail.com
State Not Applicable, archived
Headers show

Commit Message

Zheng Liu Oct. 28, 2011, 12:34 p.m. UTC
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 .32 longterm kernel. Please try it again.

regards,
Zheng

From bc522003378af679afd227ff87497dfb4fd4d652 Mon Sep 17 00:00:00 2001
From: Zheng Liu <wenqing.lz@taobao.com>
Date: Fri, 28 Oct 2011 19:41:19 +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.32
Cc: Greg Kroah-Hartman <greg@kroah.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Xiaoyun Mao <xiaoyun.maoxy@aliyun-inc.com>
Cc: Yingbin Wang <yingbin.wangyb@aliyun-inc.com>
Cc: Jia Wan <jia.wanj@aliyun-inc.com>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
---
 fs/ext4/extents.c |    1 + 
 1 files changed, 1 insertions(+), 0 deletions(-)
 
        /*

Comments

Greg KH Nov. 2, 2011, 9 p.m. UTC | #1
On Fri, Oct 28, 2011 at 08:34:02PM +0800, Zheng Liu wrote:
> 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 .32 longterm kernel. Please try it again.
> 
> regards,
> Zheng
> 
> >From bc522003378af679afd227ff87497dfb4fd4d652 Mon Sep 17 00:00:00 2001
> From: Zheng Liu <wenqing.lz@taobao.com>
> Date: Fri, 28 Oct 2011 19:41:19 +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.32
> Cc: Greg Kroah-Hartman <greg@kroah.com>
> Cc: "Theodore Ts'o" <tytso@mit.edu>
> Cc: Xiaoyun Mao <xiaoyun.maoxy@aliyun-inc.com>
> Cc: Yingbin Wang <yingbin.wangyb@aliyun-inc.com>
> Cc: Jia Wan <jia.wanj@aliyun-inc.com>
> Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>

Sorry for dragging this out, but what commit id does this correspond to
in Linus's tree?  I can't seem to figure it out.

Or does it not correspond to anything?  If so, I need a sentence that
says why it doesn't for the patch changelog.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zheng Liu Nov. 3, 2011, 3:06 a.m. UTC | #2
On Wed, Nov 02, 2011 at 02:00:24PM -0700, Greg KH wrote:
[snip]
> 
> Sorry for dragging this out, but what commit id does this correspond to
> in Linus's tree?  I can't seem to figure it out.
> 
> Or does it not correspond to anything?  If so, I need a sentence that
> says why it doesn't for the patch changelog.

Hi Greg,

This patch doesn't apply for upstream because the code has been
refactored since 3.0.

Regards,
Zheng

> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Greg KH Nov. 3, 2011, 5:42 p.m. UTC | #3
On Thu, Nov 03, 2011 at 11:06:44AM +0800, Zheng Liu wrote:
> On Wed, Nov 02, 2011 at 02:00:24PM -0700, Greg KH wrote:
> [snip]
> > 
> > Sorry for dragging this out, but what commit id does this correspond to
> > in Linus's tree?  I can't seem to figure it out.
> > 
> > Or does it not correspond to anything?  If so, I need a sentence that
> > says why it doesn't for the patch changelog.
> 
> Hi Greg,
> 
> This patch doesn't apply for upstream because the code has been
> refactored since 3.0.

Thanks for letting me know, I'll go queue this up now.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index f375559..93f7999 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2592,6 +2592,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;
        }