linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910!
@ 2008-02-14 16:35 Valerie Clement
  2008-02-14 16:38 ` Eric Sandeen
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Valerie Clement @ 2008-02-14 16:35 UTC (permalink / raw)
  To: linux-ext4; +Cc: Andreas Dilger, Aneesh Kumar, Mingming Cao

Fix kernel BUG at fs/ext4/mballoc.c:910!

From: Valerie Clement <valerie.clement@bull.net>

With the flex_bg feature enabled, a large file creation oopses the
kernel.
The BUG_ON is:
	BUG_ON(len >= EXT4_BLOCKS_PER_GROUP(sb));

As the allocation of the bitmaps and the inode table can be done
outside the block group with flex_bg, this allows to allocate up to
EXT4_BLOCKS_PER_GROUP blocks in a group.
Depending on the group size and the block size, extents might be 
larger than BLOCKS_PER_GROUP(); use EXT_INIT_MAX_LEN instead of 
BLOCKS_PER_GROUP().

This patch fixes the oops.

Signed-off-by: Valerie Clement <valerie.clement@bull.net>
---

 fs/ext4/mballoc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index b0f84b4..ccc33e9 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -34,6 +34,7 @@
 #include <linux/pagemap.h>
 #include <linux/seq_file.h>
 #include <linux/version.h>
+#include <linux/ext4_fs_extents.h>
 #include "group.h"
 
 /*
@@ -907,7 +908,9 @@ static void ext4_mb_mark_free_simple(struct super_block *sb,
 	unsigned short chunk;
 	unsigned short border;
 
-	BUG_ON(len >= EXT4_BLOCKS_PER_GROUP(sb));
+	BUG_ON(len > EXT4_HAS_INCOMPAT_FEATURE(sb,
+			EXT4_FEATURE_INCOMPAT_FLEX_BG) ? EXT_INIT_MAX_LEN :
+			EXT4_BLOCKS_PER_GROUP(sb));
 
 	border = 2 << sb->s_blocksize_bits;
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910!
  2008-02-14 16:35 [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910! Valerie Clement
@ 2008-02-14 16:38 ` Eric Sandeen
  2008-02-15 15:18   ` Valerie Clement
  2008-02-14 17:43 ` Mingming Cao
  2008-02-14 22:13 ` Andreas Dilger
  2 siblings, 1 reply; 7+ messages in thread
From: Eric Sandeen @ 2008-02-14 16:38 UTC (permalink / raw)
  To: Valerie Clement; +Cc: linux-ext4, Andreas Dilger, Aneesh Kumar, Mingming Cao

Valerie Clement wrote:
> Fix kernel BUG at fs/ext4/mballoc.c:910!
> 
> From: Valerie Clement <valerie.clement@bull.net>
> 
> With the flex_bg feature enabled, a large file creation oopses the
> kernel.

Valerie, what's the specific testcase for this?

Thanks,
-Eric

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910!
  2008-02-14 16:35 [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910! Valerie Clement
  2008-02-14 16:38 ` Eric Sandeen
@ 2008-02-14 17:43 ` Mingming Cao
  2008-02-14 22:13 ` Andreas Dilger
  2 siblings, 0 replies; 7+ messages in thread
From: Mingming Cao @ 2008-02-14 17:43 UTC (permalink / raw)
  To: Valerie Clement; +Cc: linux-ext4, Andreas Dilger, Aneesh Kumar

On Thu, 2008-02-14 at 17:35 +0100, Valerie Clement wrote:
> Fix kernel BUG at fs/ext4/mballoc.c:910!
> 
> From: Valerie Clement <valerie.clement@bull.net>
> 
> With the flex_bg feature enabled, a large file creation oopses the
> kernel.
> The BUG_ON is:
> 	BUG_ON(len >= EXT4_BLOCKS_PER_GROUP(sb));
> 
> As the allocation of the bitmaps and the inode table can be done
> outside the block group with flex_bg, this allows to allocate up to
> EXT4_BLOCKS_PER_GROUP blocks in a group.
> Depending on the group size and the block size, extents might be 
> larger than BLOCKS_PER_GROUP(); use EXT_INIT_MAX_LEN instead of 
> BLOCKS_PER_GROUP().
> 

Yep, I think using EXT_INIT_MAX_LEN is better.
Will add to the patch queue shortly.

Thanks,
Mingming
> This patch fixes the oops.
> 
> Signed-off-by: Valerie Clement <valerie.clement@bull.net>
> ---
> 
>  fs/ext4/mballoc.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index b0f84b4..ccc33e9 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -34,6 +34,7 @@
>  #include <linux/pagemap.h>
>  #include <linux/seq_file.h>
>  #include <linux/version.h>
> +#include <linux/ext4_fs_extents.h>
>  #include "group.h"
> 
>  /*
> @@ -907,7 +908,9 @@ static void ext4_mb_mark_free_simple(struct super_block *sb,
>  	unsigned short chunk;
>  	unsigned short border;
> 
> -	BUG_ON(len >= EXT4_BLOCKS_PER_GROUP(sb));
> +	BUG_ON(len > EXT4_HAS_INCOMPAT_FEATURE(sb,
> +			EXT4_FEATURE_INCOMPAT_FLEX_BG) ? EXT_INIT_MAX_LEN :
> +			EXT4_BLOCKS_PER_GROUP(sb));
> 
>  	border = 2 << sb->s_blocksize_bits;
> 
> 
> 
> -
> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910!
  2008-02-14 16:35 [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910! Valerie Clement
  2008-02-14 16:38 ` Eric Sandeen
  2008-02-14 17:43 ` Mingming Cao
@ 2008-02-14 22:13 ` Andreas Dilger
  2008-02-14 23:33   ` Mingming Cao
  2 siblings, 1 reply; 7+ messages in thread
From: Andreas Dilger @ 2008-02-14 22:13 UTC (permalink / raw)
  To: Valerie Clement; +Cc: linux-ext4, Aneesh Kumar, Mingming Cao

On Feb 14, 2008  17:35 +0100, Valerie Clement wrote:
> From: Valerie Clement <valerie.clement@bull.net>
> 
> With the flex_bg feature enabled, a large file creation oopses the
> kernel.
> The BUG_ON is:
> 	BUG_ON(len >= EXT4_BLOCKS_PER_GROUP(sb));
> 
> As the allocation of the bitmaps and the inode table can be done
> outside the block group with flex_bg, this allows to allocate up to
> EXT4_BLOCKS_PER_GROUP blocks in a group.
> Depending on the group size and the block size, extents might be 
> larger than BLOCKS_PER_GROUP(); use EXT_INIT_MAX_LEN instead of 
> BLOCKS_PER_GROUP().

In fact, my earlier review of this patch was incorrect, and Aneesh pointed
out the correct answer.  The ext4_mb_mark_free_simple() function is only
called from ext4_mb_generate_buddy() to generate the buddy bitmap from the
on-disk block bitmap, and in that case the @len parameter should always
be <= EXT4_BLOCKS_PER_GROUP().  I think the original patch was correct.

Sorry about the confusion.  I thought at first glance this was for
freeing the blocks from releasing an extent, but that is incorrect.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910!
  2008-02-14 22:13 ` Andreas Dilger
@ 2008-02-14 23:33   ` Mingming Cao
  0 siblings, 0 replies; 7+ messages in thread
From: Mingming Cao @ 2008-02-14 23:33 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: Valerie Clement, linux-ext4, Aneesh Kumar

On Thu, 2008-02-14 at 15:13 -0700, Andreas Dilger wrote:
> On Feb 14, 2008  17:35 +0100, Valerie Clement wrote:
> > From: Valerie Clement <valerie.clement@bull.net>
> > 
> > With the flex_bg feature enabled, a large file creation oopses the
> > kernel.
> > The BUG_ON is:
> > 	BUG_ON(len >= EXT4_BLOCKS_PER_GROUP(sb));
> > 
> > As the allocation of the bitmaps and the inode table can be done
> > outside the block group with flex_bg, this allows to allocate up to
> > EXT4_BLOCKS_PER_GROUP blocks in a group.
> > Depending on the group size and the block size, extents might be 
> > larger than BLOCKS_PER_GROUP(); use EXT_INIT_MAX_LEN instead of 
> > BLOCKS_PER_GROUP().
> 
> In fact, my earlier review of this patch was incorrect, and Aneesh pointed
> out the correct answer.  The ext4_mb_mark_free_simple() function is only
> called from ext4_mb_generate_buddy() to generate the buddy bitmap from the
> on-disk block bitmap, and in that case the @len parameter should always
> be <= EXT4_BLOCKS_PER_GROUP().  I think the original patch was correct.
> 
> Sorry about the confusion.  I thought at first glance this was for
> freeing the blocks from releasing an extent, but that is incorrect.
> 
Ok, I added the revised first patch
http://repo.or.cz/w/ext4-patch-queue.git?a=blob;f=ext4_fix_BUGON_at_mballoc.patch;h=c2d11bd2ec46c8103d4fad7c62cd792b7daec202;hb=067598f1a058a05342afee9720a0538b871c61f4

Mingming
> Cheers, Andreas
> --
> Andreas Dilger
> Sr. Staff Engineer, Lustre Group
> Sun Microsystems of Canada, Inc.
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910!
  2008-02-14 16:38 ` Eric Sandeen
@ 2008-02-15 15:18   ` Valerie Clement
  2008-02-15 15:51     ` Eric Sandeen
  0 siblings, 1 reply; 7+ messages in thread
From: Valerie Clement @ 2008-02-15 15:18 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-ext4

Eric Sandeen wrote:
> Valerie Clement wrote:
>> Fix kernel BUG at fs/ext4/mballoc.c:910!
>>
>> From: Valerie Clement <valerie.clement@bull.net>
>>
>> With the flex_bg feature enabled, a large file creation oopses the
>> kernel.
> 
> Valerie, what's the specific testcase for this?
> 
> Thanks,
> -Eric
I just did a simple dd,
  dd if=/dev/zero of=/mnt/test/foo bs=1M count=8k
on an ext4 filesystem with the uninit_groups, lazy_bg and flex_bg
features enabled and the default mount options.

The difficulty is to build e2fsprogs programs that integrate all
these new features together.
    Valerie

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910!
  2008-02-15 15:18   ` Valerie Clement
@ 2008-02-15 15:51     ` Eric Sandeen
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Sandeen @ 2008-02-15 15:51 UTC (permalink / raw)
  To: Valerie Clement; +Cc: linux-ext4

Valerie Clement wrote:
> Eric Sandeen wrote:
>> Valerie Clement wrote:
>>> Fix kernel BUG at fs/ext4/mballoc.c:910!
>>>
>>> From: Valerie Clement <valerie.clement@bull.net>
>>>
>>> With the flex_bg feature enabled, a large file creation oopses the
>>> kernel.
>> Valerie, what's the specific testcase for this?
>>
>> Thanks,
>> -Eric
> I just did a simple dd,
>   dd if=/dev/zero of=/mnt/test/foo bs=1M count=8k
> on an ext4 filesystem with the uninit_groups, lazy_bg and flex_bg
> features enabled and the default mount options.

Ok, thanks Valerie.  It's just always nice to know exactly how to
reproduce a problem that a patch fixes, IMHO.

-Eric

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-02-15 15:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-14 16:35 [PATCH RESEND] ext4: Fix kernel BUG at fs/ext4/mballoc.c:910! Valerie Clement
2008-02-14 16:38 ` Eric Sandeen
2008-02-15 15:18   ` Valerie Clement
2008-02-15 15:51     ` Eric Sandeen
2008-02-14 17:43 ` Mingming Cao
2008-02-14 22:13 ` Andreas Dilger
2008-02-14 23:33   ` Mingming Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).