2010-11-05 03:09:04

by Joe Perches

[permalink] [raw]
Subject: [PATCH 37/49] fs/ext4: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
fs/ext4/super.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 40131b7..9ed90f4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1909,9 +1909,7 @@ static int ext4_fill_flex_info(struct super_block *sb)
size = flex_group_count * sizeof(struct flex_groups);
sbi->s_flex_groups = kzalloc(size, GFP_KERNEL);
if (sbi->s_flex_groups == NULL) {
- sbi->s_flex_groups = vmalloc(size);
- if (sbi->s_flex_groups)
- memset(sbi->s_flex_groups, 0, size);
+ sbi->s_flex_groups = vzalloc(size);
}
if (sbi->s_flex_groups == NULL) {
ext4_msg(sb, KERN_ERR, "not enough memory for "
--
1.7.3.1.g432b3.dirty



2010-11-05 07:02:15

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH 37/49] fs/ext4: Use vzalloc

On 2010-11-04, at 21:08, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>
> @@ -1909,9 +1909,7 @@ static int ext4_fill_flex_info(struct super_block *sb)
> size = flex_group_count * sizeof(struct flex_groups);
> sbi->s_flex_groups = kzalloc(size, GFP_KERNEL);
> if (sbi->s_flex_groups == NULL) {
> - sbi->s_flex_groups = vmalloc(size);
> - if (sbi->s_flex_groups)
> - memset(sbi->s_flex_groups, 0, size);
> + sbi->s_flex_groups = vzalloc(size);
> }
> if (sbi->s_flex_groups == NULL) {
> ext4_msg(sb, KERN_ERR, "not enough memory for "

You may as well move the second s_flex_groups == NULL check inside the first one:

if (sbi->s_flex_groups == NULL) {
sbi->s_flex_groups = vzalloc(size);
if (sbi->s_flex_groups == NULL) {
ext4_msg(sb, KERN_ERR, "not enough memory for "
"%u flex groups", flex_group_count);
goto failed;
}
}

Cheers, Andreas






2010-11-05 07:18:32

by Joe Perches

[permalink] [raw]
Subject: [PATCH V2 37/49] fs/ext4: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
differences from V1:
Andreas Dilger requested a block be moved so that
sbi->s_flex_groups isn't tested for NULL twice.
Also coalesced a ext4_msg printk format.

fs/ext4/super.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 40131b7..6dbc4379 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1909,14 +1909,13 @@ static int ext4_fill_flex_info(struct
super_block *sb)
size = flex_group_count * sizeof(struct flex_groups);
sbi->s_flex_groups = kzalloc(size, GFP_KERNEL);
if (sbi->s_flex_groups == NULL) {
- sbi->s_flex_groups = vmalloc(size);
- if (sbi->s_flex_groups)
- memset(sbi->s_flex_groups, 0, size);
- }
- if (sbi->s_flex_groups == NULL) {
- ext4_msg(sb, KERN_ERR, "not enough memory for "
- "%u flex groups", flex_group_count);
- goto failed;
+ sbi->s_flex_groups = vzalloc(size);
+ if (sbi->s_flex_groups == NULL) {
+ ext4_msg(sb, KERN_ERR,
+ "not enough memory for %u flex groups",
+ flex_group_count);
+ goto failed;
+ }
}

for (i = 0; i < sbi->s_groups_count; i++) {



2010-12-20 03:22:14

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH V2 37/49] fs/ext4: Use vzalloc

On Fri, Nov 05, 2010 at 12:18:31AM -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>
> ---
> differences from V1:
> Andreas Dilger requested a block be moved so that
> sbi->s_flex_groups isn't tested for NULL twice.
> Also coalesced a ext4_msg printk format.

Thanks, applied to the ext4 tree

- Ted