All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero
@ 2011-09-15  7:09 Robin Dong
  2011-09-15  7:09 ` [PATCH 2/4] ext4: remove unused argument in ext4_mb_generate_from_pa Robin Dong
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Robin Dong @ 2011-09-15  7:09 UTC (permalink / raw)
  To: linux-ext4; +Cc: Robin Dong

From: Robin Dong <sanbai@taobao.com>

The kernel will crash on 

ext4_mb_mark_diskspace_used:
	BUG_ON(ac->ac_b_ex.fe_len <= 0);

after we set /sys/fs/ext4/sda/mb_group_prealloc to zero and create new files in an ext4 filesystem.

The reason is: ac_b_ex.fe_len also set to zero(mb_group_prealloc) in ext4_mb_normalize_group_request
because the ac_flags contains EXT4_MB_HINT_GROUP_ALLOC.

I think when someone set mb_group_prealloc to zero, it means DO NOT USE GROUP PREALLOCATION,
so we should set alloc-strategy to STREAM in this case.

Signed-off-by: Robin Dong <sanbai@taobao.com>
---
 fs/ext4/mballoc.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 17a5a57..6b58247 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3969,6 +3969,11 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac)
 		return;
 	}
 
+	if (sbi->s_mb_group_prealloc <= 0) {
+		ac->ac_flags |= EXT4_MB_STREAM_ALLOC;
+		return;
+	}
+
 	/* don't use group allocation for large files */
 	size = max(size, isize);
 	if (size > sbi->s_mb_stream_request) {
-- 
1.7.4.1


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

* [PATCH 2/4] ext4: remove unused argument in ext4_mb_generate_from_pa
  2011-09-15  7:09 [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero Robin Dong
@ 2011-09-15  7:09 ` Robin Dong
  2011-10-26  9:24   ` Ted Ts'o
  2011-09-15  7:09 ` [PATCH 3/4] ext4: remove unused argument in mb_find_extent Robin Dong
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Robin Dong @ 2011-09-15  7:09 UTC (permalink / raw)
  To: linux-ext4; +Cc: Robin Dong

From: Robin Dong <sanbai@taobao.com>

The argument 'count' in function ext4_mb_generate_from_pa looks useless,
so clean it.

Signed-off-by: Robin Dong <sanbai@taobao.com>
---
 fs/ext4/mballoc.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 6b58247..d0fc76e 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3312,7 +3312,6 @@ void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
 	ext4_group_t groupnr;
 	ext4_grpblk_t start;
 	int preallocated = 0;
-	int count = 0;
 	int len;
 
 	/* all form of preallocation discards first load group,
@@ -3335,7 +3334,6 @@ void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
 		BUG_ON(groupnr != group);
 		ext4_set_bits(bitmap, start, len);
 		preallocated += len;
-		count++;
 	}
 	mb_debug(1, "prellocated %u for group %u\n", preallocated, group);
 }
-- 
1.7.4.1


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

* [PATCH 3/4] ext4: remove unused argument in mb_find_extent
  2011-09-15  7:09 [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero Robin Dong
  2011-09-15  7:09 ` [PATCH 2/4] ext4: remove unused argument in ext4_mb_generate_from_pa Robin Dong
@ 2011-09-15  7:09 ` Robin Dong
  2011-10-26  9:34   ` Ted Ts'o
  2011-09-15  7:09 ` [PATCH 4/4] ext4: fix a wrong comment in __mb_check_buddy Robin Dong
  2011-10-26  9:17 ` [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero Ted Ts'o
  3 siblings, 1 reply; 8+ messages in thread
From: Robin Dong @ 2011-09-15  7:09 UTC (permalink / raw)
  To: linux-ext4; +Cc: Robin Dong

From: Robin Dong <sanbai@taobao.com>

The argument 'ord' in function mb_find_extent is redundant,
so remove it.

Signed-off-by: Robin Dong <sanbai@taobao.com>
---
 fs/ext4/mballoc.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index d0fc76e..99d123a 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1390,7 +1390,6 @@ static int mb_find_extent(struct ext4_buddy *e4b, int order, int block,
 {
 	int next = block;
 	int max;
-	int ord;
 	void *buddy;
 
 	assert_spin_locked(ext4_group_lock_ptr(e4b->bd_sb, e4b->bd_group));
@@ -1432,9 +1431,8 @@ static int mb_find_extent(struct ext4_buddy *e4b, int order, int block,
 		if (mb_test_bit(next, EXT4_MB_BITMAP(e4b)))
 			break;
 
-		ord = mb_find_order_for_block(e4b, next);
+		order = mb_find_order_for_block(e4b, next);
 
-		order = ord;
 		block = next >> order;
 		ex->fe_len += 1 << order;
 	}
-- 
1.7.4.1


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

* [PATCH 4/4] ext4: fix a wrong comment in __mb_check_buddy
  2011-09-15  7:09 [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero Robin Dong
  2011-09-15  7:09 ` [PATCH 2/4] ext4: remove unused argument in ext4_mb_generate_from_pa Robin Dong
  2011-09-15  7:09 ` [PATCH 3/4] ext4: remove unused argument in mb_find_extent Robin Dong
@ 2011-09-15  7:09 ` Robin Dong
  2011-10-26 12:53   ` Ted Ts'o
  2011-10-26  9:17 ` [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero Ted Ts'o
  3 siblings, 1 reply; 8+ messages in thread
From: Robin Dong @ 2011-09-15  7:09 UTC (permalink / raw)
  To: linux-ext4; +Cc: Robin Dong

From: Robin Dong <sanbai@taobao.com>

The comment says the bit should be 0, but the after code assert the bit to be 1.
This makes people confused, so fix it.

Signed-off-by: Robin Dong <sanbai@taobao.com>
---
 fs/ext4/mballoc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 99d123a..0b3d0ee 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -580,7 +580,7 @@ static int __mb_check_buddy(struct ext4_buddy *e4b, char *file,
 				continue;
 			}
 
-			/* both bits in buddy2 must be 0 */
+			/* both bits in buddy2 must be 1 */
 			MB_CHECK_ASSERT(mb_test_bit(i << 1, buddy2));
 			MB_CHECK_ASSERT(mb_test_bit((i << 1) + 1, buddy2));
 
-- 
1.7.4.1


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

* Re: [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero
  2011-09-15  7:09 [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero Robin Dong
                   ` (2 preceding siblings ...)
  2011-09-15  7:09 ` [PATCH 4/4] ext4: fix a wrong comment in __mb_check_buddy Robin Dong
@ 2011-10-26  9:17 ` Ted Ts'o
  3 siblings, 0 replies; 8+ messages in thread
From: Ted Ts'o @ 2011-10-26  9:17 UTC (permalink / raw)
  To: Robin Dong; +Cc: linux-ext4, Robin Dong

On Thu, Sep 15, 2011 at 03:09:37PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai@taobao.com>
> 
> The kernel will crash on 
> 
> ext4_mb_mark_diskspace_used:
> 	BUG_ON(ac->ac_b_ex.fe_len <= 0);
> 
> after we set /sys/fs/ext4/sda/mb_group_prealloc to zero and create new files in an ext4 filesystem.
> 
> The reason is: ac_b_ex.fe_len also set to zero(mb_group_prealloc) in ext4_mb_normalize_group_request
> because the ac_flags contains EXT4_MB_HINT_GROUP_ALLOC.
> 
> I think when someone set mb_group_prealloc to zero, it means DO NOT USE GROUP PREALLOCATION,
> so we should set alloc-strategy to STREAM in this case.
> 
> Signed-off-by: Robin Dong <sanbai@taobao.com>

Thanks, applied.

						- Ted

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

* Re: [PATCH 2/4] ext4: remove unused argument in ext4_mb_generate_from_pa
  2011-09-15  7:09 ` [PATCH 2/4] ext4: remove unused argument in ext4_mb_generate_from_pa Robin Dong
@ 2011-10-26  9:24   ` Ted Ts'o
  0 siblings, 0 replies; 8+ messages in thread
From: Ted Ts'o @ 2011-10-26  9:24 UTC (permalink / raw)
  To: Robin Dong; +Cc: linux-ext4, Robin Dong

On Thu, Sep 15, 2011 at 03:09:38PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai@taobao.com>
> 
> The argument 'count' in function ext4_mb_generate_from_pa looks useless,
> so clean it.
> 
> Signed-off-by: Robin Dong <sanbai@taobao.com>

Thanks, applied.

					- Ted

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

* Re: [PATCH 3/4] ext4: remove unused argument in mb_find_extent
  2011-09-15  7:09 ` [PATCH 3/4] ext4: remove unused argument in mb_find_extent Robin Dong
@ 2011-10-26  9:34   ` Ted Ts'o
  0 siblings, 0 replies; 8+ messages in thread
From: Ted Ts'o @ 2011-10-26  9:34 UTC (permalink / raw)
  To: Robin Dong; +Cc: linux-ext4, Robin Dong

On Thu, Sep 15, 2011 at 03:09:39PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai@taobao.com>
> 
> The argument 'ord' in function mb_find_extent is redundant,
> so remove it.
> 
> Signed-off-by: Robin Dong <sanbai@taobao.com>

Thanks, applied.

In both this and the previous patch, I changed "argument" to
"variable" for clarity/correctness in the git commit log.

	       			      	  - Ted

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

* Re: [PATCH 4/4] ext4: fix a wrong comment in __mb_check_buddy
  2011-09-15  7:09 ` [PATCH 4/4] ext4: fix a wrong comment in __mb_check_buddy Robin Dong
@ 2011-10-26 12:53   ` Ted Ts'o
  0 siblings, 0 replies; 8+ messages in thread
From: Ted Ts'o @ 2011-10-26 12:53 UTC (permalink / raw)
  To: Robin Dong; +Cc: linux-ext4, Robin Dong

On Thu, Sep 15, 2011 at 03:09:40PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai@taobao.com>
> 
> The comment says the bit should be 0, but the after code assert the bit to be 1.
> This makes people confused, so fix it.
> 
> Signed-off-by: Robin Dong <sanbai@taobao.com>

Thanks, applied.

						- Ted

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

end of thread, other threads:[~2011-10-26 12:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-15  7:09 [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero Robin Dong
2011-09-15  7:09 ` [PATCH 2/4] ext4: remove unused argument in ext4_mb_generate_from_pa Robin Dong
2011-10-26  9:24   ` Ted Ts'o
2011-09-15  7:09 ` [PATCH 3/4] ext4: remove unused argument in mb_find_extent Robin Dong
2011-10-26  9:34   ` Ted Ts'o
2011-09-15  7:09 ` [PATCH 4/4] ext4: fix a wrong comment in __mb_check_buddy Robin Dong
2011-10-26 12:53   ` Ted Ts'o
2011-10-26  9:17 ` [PATCH 1/4] ext4: use stream-alloc when mb_group_prealloc set to zero Ted Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.