* [PATCH] btrfs: Replace kmalloc with kzalloc in the error message
@ 2020-05-29 1:00 Yi Wang
2020-05-29 2:03 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Yi Wang @ 2020-05-29 1:00 UTC (permalink / raw)
To: clm
Cc: josef, dsterba, linux-btrfs, linux-kernel, xue.zhihong,
wang.yi59, wang.liang82, Liao Pingfang
From: Liao Pingfang <liao.pingfang@zte.com.cn>
Use kzalloc instead of kmalloc in the error message according to
the previous kzalloc() call.
Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
---
fs/btrfs/check-integrity.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 32e11a2..4847509 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -632,7 +632,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
if (NULL == selected_super) {
- pr_info("btrfsic: error, kmalloc failed!\n");
+ pr_info("btrfsic: error, kzalloc failed!\n");
return -ENOMEM;
}
@@ -795,7 +795,7 @@ static int btrfsic_process_superblock_dev_mirror(
if (NULL == superblock_tmp) {
superblock_tmp = btrfsic_block_alloc();
if (NULL == superblock_tmp) {
- pr_info("btrfsic: error, kmalloc failed!\n");
+ pr_info("btrfsic: error, kzalloc failed!\n");
ret = -1;
goto out;
}
@@ -1313,7 +1313,7 @@ static int btrfsic_create_link_to_next_block(
if (NULL == l) {
l = btrfsic_block_link_alloc();
if (NULL == l) {
- pr_info("btrfsic: error, kmalloc failed!\n");
+ pr_info("btrfsic: error, kzalloc failed!\n");
btrfsic_release_block_ctx(next_block_ctx);
*next_blockp = NULL;
return -1;
@@ -1470,7 +1470,7 @@ static int btrfsic_handle_extent_data(
mirror_num,
&block_was_created);
if (NULL == next_block) {
- pr_info("btrfsic: error, kmalloc failed!\n");
+ pr_info("btrfsic: error, kzalloc failed!\n");
btrfsic_release_block_ctx(&next_block_ctx);
return -1;
}
@@ -2013,7 +2013,7 @@ static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state,
block = btrfsic_block_alloc();
if (NULL == block) {
- pr_info("btrfsic: error, kmalloc failed!\n");
+ pr_info("btrfsic: error, kzalloc failed!\n");
btrfsic_release_block_ctx(&block_ctx);
goto continue_loop;
}
@@ -2234,7 +2234,7 @@ static int btrfsic_process_written_superblock(
mirror_num,
&was_created);
if (NULL == next_block) {
- pr_info("btrfsic: error, kmalloc failed!\n");
+ pr_info("btrfsic: error, kzalloc failed!\n");
btrfsic_release_block_ctx(&tmp_next_block_ctx);
return -1;
}
@@ -2543,7 +2543,7 @@ static struct btrfsic_block_link *btrfsic_block_link_lookup_or_add(
if (NULL == l) {
l = btrfsic_block_link_alloc();
if (NULL == l) {
- pr_info("btrfsic: error, kmalloc failed!\n");
+ pr_info("btrfsic: error, kzalloc failed!\n");
return NULL;
}
@@ -2590,7 +2590,7 @@ static struct btrfsic_block *btrfsic_block_lookup_or_add(
block = btrfsic_block_alloc();
if (NULL == block) {
- pr_info("btrfsic: error, kmalloc failed!\n");
+ pr_info("btrfsic: error, kzalloc failed!\n");
return NULL;
}
dev_state = btrfsic_dev_state_lookup(block_ctx->dev->bdev->bd_dev);
@@ -2829,7 +2829,7 @@ int btrfsic_mount(struct btrfs_fs_info *fs_info,
ds = btrfsic_dev_state_alloc();
if (NULL == ds) {
- pr_info("btrfs check-integrity: kmalloc() failed!\n");
+ pr_info("btrfs check-integrity: kzalloc() failed!\n");
mutex_unlock(&btrfsic_mutex);
return -ENOMEM;
}
--
2.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs: Replace kmalloc with kzalloc in the error message
2020-05-29 1:00 [PATCH] btrfs: Replace kmalloc with kzalloc in the error message Yi Wang
@ 2020-05-29 2:03 ` Joe Perches
2020-05-29 13:05 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2020-05-29 2:03 UTC (permalink / raw)
To: Yi Wang, clm
Cc: josef, dsterba, linux-btrfs, linux-kernel, xue.zhihong,
wang.liang82, Liao Pingfang
On Fri, 2020-05-29 at 09:00 +0800, Yi Wang wrote:
> From: Liao Pingfang <liao.pingfang@zte.com.cn>
>
> Use kzalloc instead of kmalloc in the error message according to
> the previous kzalloc() call.
[]
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
[]
> @@ -632,7 +632,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
>
> selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
> if (NULL == selected_super) {
> - pr_info("btrfsic: error, kmalloc failed!\n");
> + pr_info("btrfsic: error, kzalloc failed!\n");
As there is a dump_stack() done on memory allocation
failures, these messages might as well be deleted instead.
> return -ENOMEM;
> }
>
> @@ -795,7 +795,7 @@ static int btrfsic_process_superblock_dev_mirror(
> if (NULL == superblock_tmp) {
> superblock_tmp = btrfsic_block_alloc();
> if (NULL == superblock_tmp) {
> - pr_info("btrfsic: error, kmalloc failed!\n");
> + pr_info("btrfsic: error, kzalloc failed!\n");
If these are really desired, it'd be likely be better
to describe the function that failed instead of whatever
internal memory allocation the function used.
Another option would be to add __GFP_NOWARN to the
allocation internal to btrfsic_block_alloc and then
change this to something like
pr_info("btrfsic: error, btrfsic_block_alloc failed!\n"); }
or move this reporting into the btrfsic_block_alloc
function and remove the messages after each failure.
etc...
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs: Replace kmalloc with kzalloc in the error message
2020-05-29 2:03 ` Joe Perches
@ 2020-05-29 13:05 ` David Sterba
0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2020-05-29 13:05 UTC (permalink / raw)
To: Joe Perches
Cc: Yi Wang, clm, josef, dsterba, linux-btrfs, linux-kernel,
xue.zhihong, wang.liang82, Liao Pingfang
On Thu, May 28, 2020 at 07:03:45PM -0700, Joe Perches wrote:
> On Fri, 2020-05-29 at 09:00 +0800, Yi Wang wrote:
> > From: Liao Pingfang <liao.pingfang@zte.com.cn>
> >
> > Use kzalloc instead of kmalloc in the error message according to
> > the previous kzalloc() call.
> []
> > diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> []
> > @@ -632,7 +632,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
> >
> > selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
> > if (NULL == selected_super) {
> > - pr_info("btrfsic: error, kmalloc failed!\n");
> > + pr_info("btrfsic: error, kzalloc failed!\n");
>
> As there is a dump_stack() done on memory allocation
> failures, these messages might as well be deleted instead.
I wouldn't bother changing the strings, removing them entirely sounds
like a better idea to me.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-29 13:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29 1:00 [PATCH] btrfs: Replace kmalloc with kzalloc in the error message Yi Wang
2020-05-29 2:03 ` Joe Perches
2020-05-29 13:05 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®