From patchwork Mon Jul 4 07:08:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9211733 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 B08946088F for ; Mon, 4 Jul 2016 07:12:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95F3328603 for ; Mon, 4 Jul 2016 07:12:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 849B428411; Mon, 4 Jul 2016 07:12:56 +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 EF45F28470 for ; Mon, 4 Jul 2016 07:12:55 +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 u6479ajT005495; Mon, 4 Jul 2016 03:09:36 -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 u6479A4w017687 for ; Mon, 4 Jul 2016 03:09:10 -0400 Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6479Apk004391 (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 614643B709; Mon, 4 Jul 2016 07:09:09 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5D422ACBD; Mon, 4 Jul 2016 07:09:05 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 4 Jul 2016 09:08:28 +0200 Message-Id: <1467616126-10036-9-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.30]); Mon, 04 Jul 2016 07:09:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); 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.30 X-loop: dm-devel@redhat.com Cc: Hannes Reinecke , dm-devel@redhat.com Subject: [dm-devel] [PATCH 08/26] libmultipath: Do not access 'conf->cmd' in domap() 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 'conf->cmd' is only ever set if we're called from multipath, so we can combine the 'is_daemon' argument and the 'conf->cmd' check in domap() and avoid accessing 'conf->cmd' in domap(). Signed-off-by: Hannes Reinecke --- libmultipath/config.h | 1 + libmultipath/configure.c | 7 +++++-- libmultipath/configure.h | 3 ++- multipath/main.c | 5 +++-- multipathd/main.c | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libmultipath/config.h b/libmultipath/config.h index bd31037..e0ace8c 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -24,6 +24,7 @@ enum devtypes { }; enum mpath_cmds { + CMD_NONE, CMD_CREATE, CMD_DRY_RUN, CMD_LIST_SHORT, diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 6ae780f..a111f6e 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -586,7 +586,7 @@ domap (struct multipath * mpp, char * params, int is_daemon) /* * last chance to quit before touching the devmaps */ - if (conf->cmd == CMD_DRY_RUN && mpp->action != ACT_NOTHING) { + if (mpp->action == ACT_DRY_RUN) { print_multipath_topology(mpp, conf->verbosity); return DOMAP_DRY; } @@ -731,10 +731,11 @@ out: } extern int -coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_reload, int is_daemon) +coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_reload, enum mpath_cmds cmd) { int r = 1; int k, i; + int is_daemon = (cmd == CMD_NONE) ? 1 : 0; char params[PARAMS_SIZE]; struct multipath * mpp; struct path * pp1; @@ -827,6 +828,8 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r continue; } + if (cmd == CMD_DRY_RUN) + mpp->action = ACT_DRY_RUN; if (mpp->action == ACT_UNDEF) select_action(mpp, curmp, force_reload); diff --git a/libmultipath/configure.h b/libmultipath/configure.h index c0338bf..8d474ea 100644 --- a/libmultipath/configure.h +++ b/libmultipath/configure.h @@ -19,6 +19,7 @@ enum actions { ACT_CREATE, ACT_RESIZE, ACT_FORCERENAME, + ACT_DRY_RUN, }; #define FLUSH_ONE 1 @@ -27,7 +28,7 @@ enum actions { int setup_map (struct multipath * mpp, char * params, int params_size ); int domap (struct multipath * mpp, char * params, int is_daemon); int reinstate_paths (struct multipath *mpp); -int coalesce_paths (struct vectors *vecs, vector curmp, char * refwwid, int force_reload, int is_daemon); +int coalesce_paths (struct vectors *vecs, vector curmp, char * refwwid, int force_reload, enum mpath_cmds cmd); int get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid); int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, int is_daemon); int sysfs_get_host_adapter_name(struct path *pp, char *adapter_name); diff --git a/multipath/main.c b/multipath/main.c index 7c35ce1..e16c6cc 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -381,7 +381,7 @@ configure (void) * core logic entry point */ r = coalesce_paths(&vecs, NULL, refwwid, - conf->force_reload, 0); + conf->force_reload, conf->cmd); out: if (refwwid) @@ -484,7 +484,8 @@ main (int argc, char *argv[]) logsink = 0; if (load_config(DEFAULT_CONFIGFILE, udev)) exit(1); - + /* Default to CMD_CREATE */ + conf->cmd = CMD_CREATE; while ((arg = getopt(argc, argv, ":adchl::FfM:v:p:b:BritquwW")) != EOF ) { switch(arg) { case 1: printf("optarg : %s\n",optarg); diff --git a/multipathd/main.c b/multipathd/main.c index 9568ae9..036872c 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -487,7 +487,7 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs) r = get_refwwid(dev, DEV_DEVMAP, vecs->pathvec, &refwwid); if (refwwid) { - r = coalesce_paths(vecs, NULL, refwwid, 0, 1); + r = coalesce_paths(vecs, NULL, refwwid, 0, CMD_NONE); dm_lib_release(); } @@ -1798,7 +1798,7 @@ configure (struct vectors * vecs, int start_waiters) /* * create new set of maps & push changed ones into dm */ - if (coalesce_paths(vecs, mpvec, NULL, 1, 1)) + if (coalesce_paths(vecs, mpvec, NULL, 1, CMD_NONE)) return 1; /*