From patchwork Mon Jul 4 07:08:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9211737 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 12A6A60572 for ; Mon, 4 Jul 2016 07:13:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F166727C2C for ; Mon, 4 Jul 2016 07:13:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E571028411; Mon, 4 Jul 2016 07:13:01 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7117B27C2C for ; Mon, 4 Jul 2016 07:13:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u6479bxO005510; Mon, 4 Jul 2016 03:09:37 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u6479AvF017702 for ; Mon, 4 Jul 2016 03:09:10 -0400 Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6479Ami004394 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 4 Jul 2016 03:09:10 -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 4822264386; Mon, 4 Jul 2016 07:09:09 +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 717AFACCC; Mon, 4 Jul 2016 07:09:05 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 4 Jul 2016 09:08:32 +0200 Message-Id: <1467616126-10036-13-git-send-email-hare@suse.de> In-Reply-To: <1467616126-10036-1-git-send-email-hare@suse.de> References: <1467616126-10036-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.39]); Mon, 04 Jul 2016 07:09:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 04 Jul 2016 07:09:09 +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.188 (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.26 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-loop: dm-devel@redhat.com Cc: Hannes Reinecke , dm-devel@redhat.com Subject: [dm-devel] [PATCH 12/26] multipath: make 'dev_type' 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 uses the 'dev_type' config entry, so we should be dropping it from the main configuration and make it a local variable to the multipath program. Signed-off-by: Hannes Reinecke --- libmultipath/config.c | 1 - libmultipath/config.h | 1 - multipath/main.c | 29 +++++++++++++++-------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 6f3c4e8..88a0f09 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -595,7 +595,6 @@ load_config (char * file, struct udev *udev) conf->verbosity = DEFAULT_VERBOSITY; conf->udev = udev; - conf->dev_type = DEV_NONE; conf->minio = DEFAULT_MINIO; conf->minio_rq = DEFAULT_MINIO_RQ; get_sys_max_fds(&conf->max_fds); diff --git a/libmultipath/config.h b/libmultipath/config.h index 3ed550c..f28508f 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -99,7 +99,6 @@ struct config { int verbosity; int pgpolicy_flag; int pgpolicy; - enum devtypes dev_type; int minio; int minio_rq; int checkint; diff --git a/multipath/main.c b/multipath/main.c index bd7da58..5b0cb7e 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) +configure (enum mpath_cmds cmd, enum devtypes dev_type) { vector curmp = NULL; vector pathvec = NULL; @@ -262,12 +262,12 @@ configure (enum mpath_cmds cmd) vecs.pathvec = pathvec; vecs.mpvec = curmp; - dev = convert_dev(conf->dev, (conf->dev_type == DEV_DEVNODE)); + dev = convert_dev(conf->dev, (dev_type == DEV_DEVNODE)); /* * if we have a blacklisted device parameter, exit early */ - if (dev && conf->dev_type == DEV_DEVNODE && + if (dev && dev_type == DEV_DEVNODE && cmd != CMD_REMOVE_WWID && (filter_devnode(conf->blist_devnode, conf->elist_devnode, dev) > 0)) { @@ -281,7 +281,7 @@ configure (enum mpath_cmds cmd) * failing the translation is fatal (by policy) */ if (conf->dev) { - int failed = get_refwwid(cmd, conf->dev, conf->dev_type, + int failed = get_refwwid(cmd, conf->dev, dev_type, pathvec, &refwwid); if (!refwwid) { condlog(4, "%s: failed to get wwid", conf->dev); @@ -480,6 +480,7 @@ main (int argc, char *argv[]) extern int optind; int r = 1; enum mpath_cmds cmd = CMD_CREATE; + enum devtypes dev_type; udev = udev_new(); logsink = 0; @@ -554,7 +555,7 @@ main (int argc, char *argv[]) exit(0); case 'u': cmd = CMD_VALID_PATH; - conf->dev_type = DEV_UEVENT; + dev_type = DEV_UEVENT; break; case 'w': cmd = CMD_REMOVE_WWID; @@ -597,14 +598,14 @@ main (int argc, char *argv[]) goto out; strncpy(conf->dev, argv[optind], FILE_NAME_SIZE); - if (conf->dev_type != DEV_UEVENT) - conf->dev_type = get_dev_type(conf->dev); - if (conf->dev_type == DEV_NONE) { + if (dev_type != DEV_UEVENT) + dev_type = get_dev_type(conf->dev); + if (dev_type == DEV_NONE) { condlog(0, "'%s' is not a valid argument\n", conf->dev); goto out; } } - if (conf->dev_type == DEV_UEVENT) { + if (dev_type == DEV_UEVENT) { openlog("multipath", 0, LOG_DAEMON); setlogmask(LOG_UPTO(conf->verbosity + 3)); logsink = 1; @@ -630,12 +631,12 @@ main (int argc, char *argv[]) } if (cmd == CMD_VALID_PATH && - (!conf->dev || conf->dev_type == DEV_DEVMAP)) { + (!conf->dev || dev_type == DEV_DEVMAP)) { condlog(0, "the -c option requires a path to check"); goto out; } if (cmd == CMD_VALID_PATH && - conf->dev_type == DEV_UEVENT) { + dev_type == DEV_UEVENT) { int fd; fd = mpath_connect(); @@ -672,7 +673,7 @@ main (int argc, char *argv[]) goto out; } if (conf->remove == FLUSH_ONE) { - if (conf->dev_type == DEV_DEVMAP) { + if (dev_type == DEV_DEVMAP) { r = dm_suspend_and_flush_map(conf->dev); } else condlog(0, "must provide a map name to remove"); @@ -683,7 +684,7 @@ main (int argc, char *argv[]) r = dm_flush_maps(); goto out; } - while ((r = configure(cmd)) < 0) + while ((r = configure(cmd, dev_type)) < 0) condlog(3, "restart multipath configuration process"); out: @@ -693,7 +694,7 @@ out: cleanup_prio(); cleanup_checkers(); - if (conf->dev_type == DEV_UEVENT) + if (dev_type == DEV_UEVENT) closelog(); out_free_config: