From patchwork Fri Apr 13 22:00:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10340813 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 CFF6A60329 for ; Fri, 13 Apr 2018 22:01:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0FB228A07 for ; Fri, 13 Apr 2018 22:01:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5BBD28A09; Fri, 13 Apr 2018 22:01:43 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 56B7828A07 for ; Fri, 13 Apr 2018 22:01:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A91936807; Fri, 13 Apr 2018 22:01:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 556665D9CC; Fri, 13 Apr 2018 22:01:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1AB714CA9F; Fri, 13 Apr 2018 22:01:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3DM1Yj0011469 for ; Fri, 13 Apr 2018 18:01:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 338347CA5B; Fri, 13 Apr 2018 22:01:34 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78C7968D6D; Fri, 13 Apr 2018 22:01:30 +0000 (UTC) Received: from prv3-mh.provo.novell.com (prv3-mh.provo.novell.com [137.65.250.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A92F03136327; Fri, 13 Apr 2018 22:01:29 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (TLS encrypted); Fri, 13 Apr 2018 16:01:23 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Sat, 14 Apr 2018 00:00:04 +0200 Message-Id: <20180413220015.7032-12-mwilck@suse.com> In-Reply-To: <20180413220015.7032-1-mwilck@suse.com> References: <20180413220015.7032-1-mwilck@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 13 Apr 2018 22:01:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 13 Apr 2018 22:01:29 +0000 (UTC) for IP:'137.65.250.26' DOMAIN:'prv3-mh.provo.novell.com' HELO:'prv3-mh.provo.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.26 prv3-mh.provo.novell.com 137.65.250.26 prv3-mh.provo.novell.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v5 11/22] multipath -u: common code path for result message 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 13 Apr 2018 22:01:42 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Print the result message in one place only. This simplifies future changes. multipath -c is also affected. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski Reviewed-by: Hannes Reinecke --- multipath/main.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/multipath/main.c b/multipath/main.c index 2be9b9c2..bf28735f 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -350,6 +350,16 @@ out: return r; } +static int print_cmd_valid(const char *devpath, int k) +{ + if (k < 0 || k > 1) + return 1; + + printf("%s is%s a valid multipath device path\n", + devpath, k ? "" : " not"); + return k == 1; +} + /* * Return value: * -1: Retry @@ -391,10 +401,7 @@ configure (struct config *conf, enum mpath_cmds cmd, cmd != CMD_REMOVE_WWID && (filter_devnode(conf->blist_devnode, conf->elist_devnode, dev) > 0)) { - if (cmd == CMD_VALID_PATH) - printf("%s is not a valid multipath device path\n", - devpath); - goto out; + goto print_valid; } /* @@ -407,7 +414,7 @@ configure (struct config *conf, enum mpath_cmds cmd, if (!refwwid) { 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", devpath); + goto print_valid; else condlog(3, "scope is null"); goto out; @@ -447,9 +454,7 @@ configure (struct config *conf, enum mpath_cmds cmd, if (r == 0 || !find_multipaths_on(conf) || !ignore_wwids_on(conf)) { - printf("%s %s a valid multipath device path\n", - devpath, r == 0 ? "is" : "is not"); - goto out; + goto print_valid; } } } @@ -493,9 +498,7 @@ configure (struct config *conf, enum mpath_cmds cmd, * the refwwid, then the path is valid */ if (VECTOR_SIZE(curmp) != 0 || VECTOR_SIZE(pathvec) > 1) r = 0; - printf("%s %s a valid multipath device path\n", - devpath, r == 0 ? "is" : "is not"); - goto out; + goto print_valid; } if (cmd != CMD_CREATE && cmd != CMD_DRY_RUN) { @@ -509,6 +512,10 @@ configure (struct config *conf, enum mpath_cmds cmd, r = coalesce_paths(&vecs, NULL, refwwid, conf->force_reload, cmd); +print_valid: + if (cmd == CMD_VALID_PATH) + r = print_cmd_valid(devpath, r); + out: if (refwwid) FREE(refwwid); @@ -844,8 +851,7 @@ main (int argc, char *argv[]) if (fd == -1) { condlog(3, "%s: daemon is not running", dev); if (!systemd_service_enabled(dev)) { - printf("%s is not a valid " - "multipath device path\n", dev); + r = print_cmd_valid(dev, 1); goto out; } } else