From patchwork Wed Apr 4 16:16:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10322827 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 6BEE660541 for ; Wed, 4 Apr 2018 16:17:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B64D28F0A for ; Wed, 4 Apr 2018 16:17:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FD5C28F0F; Wed, 4 Apr 2018 16:17:47 +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 CEC5428F0A for ; Wed, 4 Apr 2018 16:17:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECD45A4592; Wed, 4 Apr 2018 16:17:45 +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 AFCEF6C322; Wed, 4 Apr 2018 16:17:45 +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 658DD1800CA0; Wed, 4 Apr 2018 16:17:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w34GHh5r011941 for ; Wed, 4 Apr 2018 12:17:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id C00CA8230F; Wed, 4 Apr 2018 16:17:43 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D175A17BB5; Wed, 4 Apr 2018 16:17:38 +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 4934A80471; Wed, 4 Apr 2018 16:17:37 +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); Wed, 04 Apr 2018 10:17:31 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Wed, 4 Apr 2018 18:16:12 +0200 Message-Id: <20180404161627.6244-6-mwilck@suse.com> In-Reply-To: <20180404161627.6244-1-mwilck@suse.com> References: <20180404161627.6244-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.28]); Wed, 04 Apr 2018 16:17:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 04 Apr 2018 16:17:37 +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.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: Julian Andres Klode , dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v4 05/20] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 04 Apr 2018 16:17:46 +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 --- 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 6df8359..088d69f 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 27a7e6f..545cbc2 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 b7392bf..11afe09 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 ba83771..686b037 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 7d3d5b1..644de72 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2324,7 +2324,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); }