lkml.org 
[lkml]   [2020]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] btrfs: Replace kmalloc with kzalloc in the error message
From
Date
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...


\
 
 \ /
  Last update: 2020-05-29 04:04    [W:0.061 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site