From patchwork Mon Jun 20 08:09:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9186833 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E70DB60756 for ; Mon, 20 Jun 2016 08:13:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D255C24B5B for ; Mon, 20 Jun 2016 08:13:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C763525221; Mon, 20 Jun 2016 08:13:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4D06024B5B for ; Mon, 20 Jun 2016 08:13:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5K89uC4047779; Mon, 20 Jun 2016 04:09:57 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5K89WMX031132 for ; Mon, 20 Jun 2016 04:09:32 -0400 Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5K89WKN015294 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 20 Jun 2016 04:09:32 -0400 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C169FC01AC46; Mon, 20 Jun 2016 08:09:30 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C32D6ACAE; Mon, 20 Jun 2016 08:09:26 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 20 Jun 2016 10:09:00 +0200 Message-Id: <1466410153-23896-14-git-send-email-hare@suse.de> In-Reply-To: <1466410153-23896-1-git-send-email-hare@suse.de> References: <1466410153-23896-1-git-send-email-hare@suse.de> X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 20 Jun 2016 08:09:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 20 Jun 2016 08:09:31 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx2.suse.de' FROM:'hare@suse.de' RCPT:'' X-RedHat-Spam-Score: -3.327 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-loop: dm-devel@redhat.com Cc: Hannes Reinecke , dm-devel@redhat.com Subject: [dm-devel] [PATCH 13/26] multipath: make 'dev' internal to the multipath program X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP Only the multipath program is accessing the config entry 'dev', so we should be making it a local variable. Signed-off-by: Hannes Reinecke --- libmultipath/config.c | 3 --- libmultipath/config.h | 1 - multipath/main.c | 43 +++++++++++++++++++++++-------------------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 88a0f09..137ff6a 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -478,9 +478,6 @@ free_config (struct config * conf) if (!conf) return; - if (conf->dev) - FREE(conf->dev); - if (conf->multipath_dir) FREE(conf->multipath_dir); diff --git a/libmultipath/config.h b/libmultipath/config.h index 06e83dc..d46b9ce 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -141,7 +141,6 @@ struct config { int uev_wait_timeout; unsigned int version[3]; - char * dev; struct udev * udev; char * multipath_dir; char * selector; diff --git a/multipath/main.c b/multipath/main.c index 5b0cb7e..2825c8e 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -239,7 +239,7 @@ get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector pathvec, char * refwwid) * 1: Failure */ static int -configure (enum mpath_cmds cmd, enum devtypes dev_type) +configure (enum mpath_cmds cmd, enum devtypes dev_type, char *devpath) { vector curmp = NULL; vector pathvec = NULL; @@ -262,7 +262,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type) vecs.pathvec = pathvec; vecs.mpvec = curmp; - dev = convert_dev(conf->dev, (dev_type == DEV_DEVNODE)); + dev = convert_dev(devpath, (dev_type == DEV_DEVNODE)); /* * if we have a blacklisted device parameter, exit early @@ -273,20 +273,20 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type) conf->elist_devnode, dev) > 0)) { if (cmd == CMD_VALID_PATH) printf("%s is not a valid multipath device path\n", - conf->dev); + devpath); goto out; } /* * scope limiting must be translated into a wwid * failing the translation is fatal (by policy) */ - if (conf->dev) { - int failed = get_refwwid(cmd, conf->dev, dev_type, + if (devpath) { + int failed = get_refwwid(cmd, devpath, dev_type, pathvec, &refwwid); if (!refwwid) { - condlog(4, "%s: failed to get wwid", conf->dev); + condlog(4, "%s: failed to get wwid", devpath); if (failed == 2 && cmd == CMD_VALID_PATH) - printf("%s is not a valid multipath device path\n", conf->dev); + printf("%s is not a valid multipath device path\n", devpath); else condlog(3, "scope is nul"); goto out; @@ -324,7 +324,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type) r = 0; printf("%s %s a valid multipath device path\n", - conf->dev, r == 0 ? "is" : "is not"); + devpath, r == 0 ? "is" : "is not"); goto out; } } @@ -332,7 +332,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type) /* * get a path list */ - if (conf->dev) + if (devpath) di_flag = DI_WWID; if (cmd == CMD_LIST_LONG) @@ -368,7 +368,7 @@ configure (enum mpath_cmds cmd, enum devtypes dev_type) if (VECTOR_SIZE(curmp) != 0 || VECTOR_SIZE(pathvec) > 1) r = 0; printf("%s %s a valid multipath device path\n", - conf->dev, r == 0 ? "is" : "is not"); + devpath, r == 0 ? "is" : "is not"); goto out; } @@ -481,6 +481,7 @@ main (int argc, char *argv[]) int r = 1; enum mpath_cmds cmd = CMD_CREATE; enum devtypes dev_type; + char *dev = NULL; udev = udev_new(); logsink = 0; @@ -592,16 +593,16 @@ main (int argc, char *argv[]) dm_udev_set_sync_support(1); if (optind < argc) { - conf->dev = MALLOC(FILE_NAME_SIZE); + dev = MALLOC(FILE_NAME_SIZE); - if (!conf->dev) + if (!dev) goto out; - strncpy(conf->dev, argv[optind], FILE_NAME_SIZE); + strncpy(dev, argv[optind], FILE_NAME_SIZE); if (dev_type != DEV_UEVENT) - dev_type = get_dev_type(conf->dev); + dev_type = get_dev_type(dev); if (dev_type == DEV_NONE) { - condlog(0, "'%s' is not a valid argument\n", conf->dev); + condlog(0, "'%s' is not a valid argument\n", dev); goto out; } } @@ -631,7 +632,7 @@ main (int argc, char *argv[]) } if (cmd == CMD_VALID_PATH && - (!conf->dev || dev_type == DEV_DEVMAP)) { + (!dev || dev_type == DEV_DEVMAP)) { condlog(0, "the -c option requires a path to check"); goto out; } @@ -642,12 +643,12 @@ main (int argc, char *argv[]) fd = mpath_connect(); if (fd == -1) { printf("%s is not a valid multipath device path\n", - conf->dev); + dev); goto out; } mpath_disconnect(fd); } - if (cmd == CMD_REMOVE_WWID && !conf->dev) { + if (cmd == CMD_REMOVE_WWID && !dev) { condlog(0, "the -w option requires a device"); goto out; } @@ -674,7 +675,7 @@ main (int argc, char *argv[]) } if (conf->remove == FLUSH_ONE) { if (dev_type == DEV_DEVMAP) { - r = dm_suspend_and_flush_map(conf->dev); + r = dm_suspend_and_flush_map(dev); } else condlog(0, "must provide a map name to remove"); @@ -684,7 +685,7 @@ main (int argc, char *argv[]) r = dm_flush_maps(); goto out; } - while ((r = configure(cmd, dev_type)) < 0) + while ((r = configure(cmd, dev_type, dev)) < 0) condlog(3, "restart multipath configuration process"); out: @@ -706,6 +707,8 @@ out_free_config: free_config(conf); conf = NULL; udev_unref(udev); + if (dev) + FREE(dev); #ifdef _DEBUG_ dbg_free_final(NULL); #endif