From patchwork Mon Jun 20 08:08:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9186807 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 A767260756 for ; Mon, 20 Jun 2016 08:13:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9262F24B5B for ; Mon, 20 Jun 2016 08:13:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 872F624B5E; Mon, 20 Jun 2016 08:13:02 +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 mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (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 BD8B725221 for ; Mon, 20 Jun 2016 08: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 mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5K89lMX057777; Mon, 20 Jun 2016 04:09:47 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5K89T4H031076 for ; Mon, 20 Jun 2016 04:09:29 -0400 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5K89TQr014286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 20 Jun 2016 04:09:29 -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 1229C80E47; Mon, 20 Jun 2016 08:09:28 +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 A1B71AC79; Mon, 20 Jun 2016 08:09:26 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 20 Jun 2016 10:08:56 +0200 Message-Id: <1466410153-23896-10-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.25]); Mon, 20 Jun 2016 08:09:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 20 Jun 2016 08:09:28 +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.22 X-Scanned-By: MIMEDefang 2.75 on 10.5.110.25 X-loop: dm-devel@redhat.com Cc: Hannes Reinecke , dm-devel@redhat.com Subject: [dm-devel] [PATCH 09/26] libmultipath: add 'cmd' as argument for get_refwwid() 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 This patch adds an 'cmd' argument to get_refwwid(). This allows store_pathvec() to be simplified and avoids accesses to conf->cmd. Signed-off-by: Hannes Reinecke --- libmultipath/configure.c | 13 +++++++++---- libmultipath/configure.h | 3 ++- libmultipath/discovery.c | 4 +--- multipath/main.c | 4 ++-- multipathd/cli_handlers.c | 4 ++-- multipathd/main.c | 2 +- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 44b2d2b..8c16e23 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -925,12 +925,14 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r * 2 - blacklist */ extern int -get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid) +get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type, + vector pathvec, char **wwid) { int ret = 1; struct path * pp; char buff[FILE_NAME_SIZE]; char * refwwid = NULL, tmpwwid[WWID_SIZE]; + int flags = DI_SYSFS | DI_WWID; if (!wwid) return 1; @@ -939,6 +941,9 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid) if (dev_type == DEV_NONE) return 1; + if (cmd != CMD_REMOVE_WWID) + flags |= DI_BLACKLIST; + if (dev_type == DEV_DEVNODE) { if (basenamecpy(dev, buff, FILE_NAME_SIZE) == 0) { condlog(1, "basename failed for '%s' (%s)", @@ -955,7 +960,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid) return 1; } ret = store_pathinfo(pathvec, conf->hwtable, udevice, - DI_SYSFS | DI_WWID, &pp); + flags, &pp); udev_device_unref(udevice); if (!pp) { if (ret == 1) @@ -987,7 +992,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid) return 1; } ret = store_pathinfo(pathvec, conf->hwtable, udevice, - DI_SYSFS | DI_WWID, &pp); + flags, &pp); udev_device_unref(udevice); if (!pp) { if (ret == 1) @@ -1012,7 +1017,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid) return 1; } ret = store_pathinfo(pathvec, conf->hwtable, udevice, - DI_SYSFS | DI_WWID, &pp); + flags, &pp); udev_device_unref(udevice); if (!pp) { if (ret == 1) diff --git a/libmultipath/configure.h b/libmultipath/configure.h index 8d474ea..442c956 100644 --- a/libmultipath/configure.h +++ b/libmultipath/configure.h @@ -29,6 +29,7 @@ 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, enum mpath_cmds cmd); -int get_refwwid (char * dev, enum devtypes dev_type, vector pathvec, char **wwid); +int get_refwwid (enum mpath_cmds cmd, 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/libmultipath/discovery.c b/libmultipath/discovery.c index 126a54f..6fc2e8f 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -90,9 +90,7 @@ store_pathinfo (vector pathvec, vector hwtable, struct udev_device *udevice, goto out; } pp->udev = udev_device_ref(udevice); - err = pathinfo(pp, hwtable, - (conf->cmd == CMD_REMOVE_WWID)? flag : - (flag | DI_BLACKLIST)); + err = pathinfo(pp, hwtable, flag); if (err) goto out; diff --git a/multipath/main.c b/multipath/main.c index e16c6cc..bf2fd31 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -281,8 +281,8 @@ configure (void) * failing the translation is fatal (by policy) */ if (conf->dev) { - int failed = get_refwwid(conf->dev, conf->dev_type, pathvec, - &refwwid); + int failed = get_refwwid(conf->cmd, conf->dev, conf->dev_type, + pathvec, &refwwid); if (!refwwid) { condlog(4, "%s: failed to get wwid", conf->dev); if (failed == 2 && conf->cmd == CMD_VALID_PATH) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index eaeaa74..05dcb41 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -708,8 +708,8 @@ cli_add_map (void * v, char ** reply, int * len, void * data) if (!alias && !count) { condlog(2, "%s: mapname not found for %d:%d", param, major, minor); - rc = get_refwwid(param, DEV_DEVMAP, vecs->pathvec, - &refwwid); + rc = get_refwwid(CMD_NONE, param, DEV_DEVMAP, + vecs->pathvec, &refwwid); if (refwwid) { if (coalesce_paths(vecs, NULL, refwwid, 0, 1)) condlog(2, "%s: coalesce_paths failed", diff --git a/multipathd/main.c b/multipathd/main.c index 036872c..6230798 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -484,7 +484,7 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs) return 1; } } - r = get_refwwid(dev, DEV_DEVMAP, vecs->pathvec, &refwwid); + r = get_refwwid(CMD_NONE, dev, DEV_DEVMAP, vecs->pathvec, &refwwid); if (refwwid) { r = coalesce_paths(vecs, NULL, refwwid, 0, CMD_NONE);