From patchwork Fri Jan 19 00:29:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10174381 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 9E51B602B1 for ; Fri, 19 Jan 2018 00:32:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92DC428469 for ; Fri, 19 Jan 2018 00:32:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87D712855C; Fri, 19 Jan 2018 00:32:12 +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 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 2640A28469 for ; Fri, 19 Jan 2018 00:32:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F37E1279A; Fri, 19 Jan 2018 00:32:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48F0360A9D; Fri, 19 Jan 2018 00:32:11 +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 1A60D18033DC; Fri, 19 Jan 2018 00:32:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0J0Trjv013411 for ; Thu, 18 Jan 2018 19:29:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 85BF75D759; Fri, 19 Jan 2018 00:29:53 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CA015D6B2; Fri, 19 Jan 2018 00:29:53 +0000 (UTC) Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (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 CD0C55D687; Fri, 19 Jan 2018 00:29:51 +0000 (UTC) Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Fri, 19 Jan 2018 01:29:50 +0100 Received: from apollon.suse.de.de (nwb-a10-snat.microfocus.com [10.120.13.201]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Fri, 19 Jan 2018 00:29:40 +0000 From: Martin Wilck To: Christophe Varoqui , dm-devel@redhat.com, Benjamin Marzinski Date: Fri, 19 Jan 2018 01:29:15 +0100 Message-Id: <20180119002916.10323-16-mwilck@suse.com> In-Reply-To: <20180119002916.10323-1-mwilck@suse.com> References: <20180119002916.10323-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.39]); Fri, 19 Jan 2018 00:29:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 19 Jan 2018 00:29:52 +0000 (UTC) for IP:'195.135.221.5' DOMAIN:'smtp.nue.novell.com' HELO:'smtp.nue.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 195.135.221.5 smtp.nue.novell.com 195.135.221.5 smtp.nue.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: Xose Vazquez Perez , Martin Wilck Subject: [dm-devel] [RFC PATCH 15/16] libmultipath: trigger change uevent on new device creation 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 19 Jan 2018 00:32:11 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP From: Benjamin Marzinski When multipath first sees a path device with find_multipaths enabled, it can't know if the device should be multipathed. This means that it will not claim the device in udev. If the device is eventually multipathed, multipath should trigger a change uevent to update the udev database to claim the device. Signed-off-by: Benjamin Marzinski --- libmultipath/configure.c | 26 ++++++++++++++++++++++++-- libmultipath/configure.h | 1 + libmultipath/wwids.c | 2 +- multipath/main.c | 2 +- multipathd/main.c | 3 ++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 325018a78b95..c08ea5b8decc 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -433,6 +433,28 @@ trigger_udev_change(const struct multipath *mpp) udev_device_unref(udd); } +void +trigger_paths_udev_change(const struct multipath *mpp) +{ + struct pathgroup * pgp; + struct path * pp; + int i, j; + + if (!mpp || !mpp->pg) + return; + + vector_foreach_slot (mpp->pg, pgp, i) { + if (!pgp->paths) + continue; + vector_foreach_slot(pgp->paths, pp, j) { + if (!pp->udev) + continue; + sysfs_attr_set_value(pp->udev, "uevent", "change", + strlen("change")); + } + } +} + static int is_mpp_known_to_udev(const struct multipath *mpp) { @@ -827,8 +849,8 @@ int domap(struct multipath *mpp, char *params, int is_daemon) * succeeded */ mpp->force_udev_reload = 0; - if (mpp->action == ACT_CREATE) - remember_wwid(mpp->wwid); + if (mpp->action == ACT_CREATE && remember_wwid(mpp->wwid) == 1) + trigger_paths_udev_change(mpp); if (!is_daemon) { /* multipath client mode */ dm_switchgroup(mpp->alias, mpp->bestpg); diff --git a/libmultipath/configure.h b/libmultipath/configure.h index 0ffc28efdaf7..09603ba81733 100644 --- a/libmultipath/configure.h +++ b/libmultipath/configure.h @@ -37,3 +37,4 @@ int get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type, 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); struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type); +void trigger_paths_udev_change(const struct multipath *mpp); diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c index 655ccbe2c94a..098aa6f67b77 100644 --- a/libmultipath/wwids.c +++ b/libmultipath/wwids.c @@ -326,5 +326,5 @@ remember_wwid(char *wwid) condlog(3, "wrote wwid %s to wwids file", wwid); else condlog(4, "wwid %s already in wwids file", wwid); - return 0; + return ret; } diff --git a/multipath/main.c b/multipath/main.c index c65793d5a9e9..528c3fe1f50f 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -419,7 +419,7 @@ configure (struct config *conf, enum mpath_cmds cmd, } if (cmd == CMD_ADD_WWID) { r = remember_wwid(refwwid); - if (r == 0) + if (r >= 0) printf("wwid '%s' added\n", refwwid); else printf("failed adding '%s' to wwids file\n", diff --git a/multipathd/main.c b/multipathd/main.c index 6f612f6d3d2f..5807b42c2b2c 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2048,7 +2048,8 @@ configure (struct vectors * vecs, int start_waiters) sync_maps_state(mpvec); vector_foreach_slot(mpvec, mpp, i){ - remember_wwid(mpp->wwid); + if (remember_wwid(mpp->wwid) == 1) + trigger_paths_udev_change(mpp); update_map_pr(mpp); }