lkml.org 
[lkml]   [2016]   [Oct]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 3/13] md/multipath: Delete four error messages for a failed memory allocation
    From
    Date
    From: Markus Elfring <elfring@users.sourceforge.net>
    Date: Sat, 1 Oct 2016 21:15:45 +0200

    Omit extra messages for a memory allocation failure in this function.

    Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
    Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
    ---
    drivers/md/multipath.c | 23 ++++-------------------
    1 file changed, 4 insertions(+), 19 deletions(-)

    diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
    index 7fdabb1..be7c0b9 100644
    --- a/drivers/md/multipath.c
    +++ b/drivers/md/multipath.c
    @@ -401,22 +401,14 @@ static int multipath_run (struct mddev *mddev)

    conf = kzalloc(sizeof(*conf), GFP_KERNEL);
    mddev->private = conf;
    - if (!conf) {
    - printk(KERN_ERR
    - "multipath: couldn't allocate memory for %s\n",
    - mdname(mddev));
    + if (!conf)
    goto out;
    - }

    conf->multipaths = kcalloc(mddev->raid_disks,
    sizeof(*conf->multipaths),
    GFP_KERNEL);
    - if (!conf->multipaths) {
    - printk(KERN_ERR
    - "multipath: couldn't allocate memory for %s\n",
    - mdname(mddev));
    + if (!conf->multipaths)
    goto out_free_conf;
    - }

    working_disks = 0;
    rdev_for_each(rdev, mddev) {
    @@ -448,21 +440,14 @@ static int multipath_run (struct mddev *mddev)

    conf->pool = mempool_create_kmalloc_pool(NR_RESERVED_BUFS,
    sizeof(struct multipath_bh));
    - if (conf->pool == NULL) {
    - printk(KERN_ERR
    - "multipath: couldn't allocate memory for %s\n",
    - mdname(mddev));
    + if (!conf->pool)
    goto out_free_conf;
    - }

    {
    mddev->thread = md_register_thread(multipathd, mddev,
    "multipath");
    - if (!mddev->thread) {
    - printk(KERN_ERR "multipath: couldn't allocate thread"
    - " for %s\n", mdname(mddev));
    + if (!mddev->thread)
    goto out_free_conf;
    - }
    }

    printk(KERN_INFO
    --
    2.10.0
    \
     
     \ /
      Last update: 2016-10-02 14:00    [W:4.019 / U:0.140 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site