From patchwork Fri Apr 13 21:59:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10340809 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 B181A600D0 for ; Fri, 13 Apr 2018 22:01:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A271128A09 for ; Fri, 13 Apr 2018 22:01:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9712428A0B; Fri, 13 Apr 2018 22:01:41 +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 2BDB128A07 for ; Fri, 13 Apr 2018 22:01:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2AB45F798; Fri, 13 Apr 2018 22:01:39 +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 BE4305EDE8; Fri, 13 Apr 2018 22:01:39 +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 95FD5180215F; Fri, 13 Apr 2018 22:01:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3DM1STc011405 for ; Fri, 13 Apr 2018 18:01:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9B9055F7E4; Fri, 13 Apr 2018 22:01:28 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 91955608F0; Fri, 13 Apr 2018 22:01:28 +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 85F4C804E0; Fri, 13 Apr 2018 22:01:27 +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:10 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Fri, 13 Apr 2018 23:59:58 +0200 Message-Id: <20180413220015.7032-6-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.27]); Fri, 13 Apr 2018 22:01:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 13 Apr 2018 22:01:27 +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.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v5 05/22] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 13 Apr 2018 22:01:40 +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 Reviewed-by: Martin Wilck Signed-off-by: Martin Wilck Reviewed-by: Hannes Reinecke --- 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 1cd575e4..c56e972f 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -444,6 +444,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) { @@ -842,8 +864,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 27a7e6f6..545cbc20 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, vector pathvec, char **wwid); int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, int is_daemon); 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 d0256c2c..28063429 100644 --- a/libmultipath/wwids.c +++ b/libmultipath/wwids.c @@ -331,5 +331,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 ba837710..686b0372 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -425,7 +425,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 20b6fe02..10a0ee76 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2323,7 +2323,8 @@ configure (struct vectors * vecs) 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); }