From patchwork Thu Jul 9 11:03:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654213 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11E2213B1 for ; Thu, 9 Jul 2020 11:04:10 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B7EB02074B for ; Thu, 9 Jul 2020 11:04:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7EB02074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-53-QYi4ZI44OUaVelx8VXsF2g-1; Thu, 09 Jul 2020 07:04:06 -0400 X-MC-Unique: QYi4ZI44OUaVelx8VXsF2g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D81AB1932488; Thu, 9 Jul 2020 11:04:01 +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 5EC21610F2; Thu, 9 Jul 2020 11:04:01 +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 06DDC1809547; Thu, 9 Jul 2020 11:04:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069B3vIO002104 for ; Thu, 9 Jul 2020 07:03:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 885D7200BD8B; Thu, 9 Jul 2020 11:03:57 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DCC72166B28 for ; Thu, 9 Jul 2020 11:03:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 923C718056A0 for ; Thu, 9 Jul 2020 11:03:53 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-359-cFA1CuYSOuCWKobD5g700A-1; Thu, 09 Jul 2020 07:03:48 -0400 X-MC-Unique: cFA1CuYSOuCWKobD5g700A-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D3D7CAED9; Thu, 9 Jul 2020 11:03:46 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 13:03:25 +0200 Message-Id: <20200709110330.9917-2-mwilck@suse.com> In-Reply-To: <20200709110330.9917-1-mwilck@suse.com> References: <20200709110330.9917-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069B3vIO002104 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 75/80] multipathd: uev_trigger(): handle incomplete ADD events 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Udev may be killed after handling the ADD event for a multipath map, but before handling the subsequent CHANGE event that populates the udev data base with the device properties (e.g. during initrd processing). If this happens, the ADD uevent sent during coldplug will only provide a subset of the device properties. We need another CHANGE event to make the map available to the system. Signed-off-by: Martin Wilck --- multipathd/main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/multipathd/main.c b/multipathd/main.c index 66ca4e3..29227cd 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1508,6 +1508,31 @@ uev_trigger (struct uevent * uev, void * trigger_data) uev_pathfail_check(uev, vecs); } else if (!strncmp(uev->action, "remove", 6)) { r = uev_remove_map(uev, vecs); + } else if (!strncmp(uev->action, "add", 3)) { + const char *ev_name; + char *dm_name; + int major = -1, minor = -1; + + /* + * If DM_NAME is not set for a valid map, trigger a + * change event. This can happen during coldplug + * if udev was killed between handling the 'add' and + * 'change' events before. + */ + ev_name = uevent_get_dm_name(uev); + if (!ev_name) { + major = uevent_get_major(uev); + minor = uevent_get_minor(uev); + dm_name = dm_mapname(major, minor); + if (dm_name && *dm_name) { + condlog(2, "%s: received incomplete 'add' uevent, triggering change", + dm_name); + udev_device_set_sysattr_value(uev->udev, + "uevent", + "change"); + free(dm_name); + } + } } goto out; } From patchwork Thu Jul 9 11:03:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654211 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E257114DD for ; Thu, 9 Jul 2020 11:04:04 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9582F2074B for ; Thu, 9 Jul 2020 11:04:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9582F2074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-207-xlte6zpeN6mAOgV6oEdzJA-1; Thu, 09 Jul 2020 07:04:01 -0400 X-MC-Unique: xlte6zpeN6mAOgV6oEdzJA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A93AF1014E65; Thu, 9 Jul 2020 11:03:56 +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 5DA6590E61; Thu, 9 Jul 2020 11:03:56 +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 EDD6593F81; Thu, 9 Jul 2020 11:03:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069B3rs4002050 for ; Thu, 9 Jul 2020 07:03:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 956BB5F256; Thu, 9 Jul 2020 11:03:53 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 437375F26C for ; Thu, 9 Jul 2020 11:03:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2CA8E8007D2 for ; Thu, 9 Jul 2020 11:03:51 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-qLdbYeR-O0a4r_DDrtrq8w-1; Thu, 09 Jul 2020 07:03:48 -0400 X-MC-Unique: qLdbYeR-O0a4r_DDrtrq8w-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1BABFAEC9; Thu, 9 Jul 2020 11:03:47 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 13:03:26 +0200 Message-Id: <20200709110330.9917-3-mwilck@suse.com> In-Reply-To: <20200709110330.9917-1-mwilck@suse.com> References: <20200709110330.9917-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069B3rs4002050 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 76/80] libmultipath: select_action(): force udev reload for uninitialized maps 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck If we are in the reconfigure() code path, and we encounter maps to be reloaded, we usually set the DM_SUBSYSTEM_UDEV_FLAG0 flag to tell udev not to repeat device detection steps above the multipath layer. However, if the map was previously uninitialized, we have to force udev to reload. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 61 ++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 2509053..efb5808 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -660,6 +660,32 @@ sysfs_set_max_sectors_kb(struct multipath *mpp, int is_reload) return err; } +static void +select_reload_action(struct multipath *mpp, const char *reason) +{ + struct udev_device *mpp_ud; + const char *env; + + /* + * MPATH_DEVICE_READY != 1 can mean two things: + * (a) no usable paths + * (b) device was never fully processed (e.g. udev killed) + * If we are in this code path (startup or forced reconfigure), + * (b) can mean that upper layers like kpartx have never been + * run for this map. Thus force udev reload. + */ + + mpp_ud = get_udev_for_mpp(mpp); + env = udev_device_get_property_value(mpp_ud, "MPATH_DEVICE_READY"); + if (!env || strcmp(env, "1")) + mpp->force_udev_reload = 1; + udev_device_unref(mpp_ud); + mpp->action = ACT_RELOAD; + condlog(3, "%s: set ACT_RELOAD (%s%s)", mpp->alias, + mpp->force_udev_reload ? "forced, " : "", + reason); +} + static void select_action (struct multipath * mpp, vector curmp, int force_reload) { @@ -728,9 +754,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF && !!strstr(mpp->features, "queue_if_no_path") != !!strstr(cmpp->features, "queue_if_no_path")) { - mpp->action = ACT_RELOAD; - condlog(3, "%s: set ACT_RELOAD (no_path_retry change)", - mpp->alias); + select_reload_action(cmpp, "no_path_retry change"); return; } if ((mpp->retain_hwhandler != RETAIN_HWHANDLER_ON || @@ -738,9 +762,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) (strlen(cmpp->hwhandler) != strlen(mpp->hwhandler) || strncmp(cmpp->hwhandler, mpp->hwhandler, strlen(mpp->hwhandler)))) { - mpp->action = ACT_RELOAD; - condlog(3, "%s: set ACT_RELOAD (hwhandler change)", - mpp->alias); + select_reload_action(cmpp, "hwhandler change"); return; } @@ -748,9 +770,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) !!strstr(mpp->features, "retain_attached_hw_handler") != !!strstr(cmpp->features, "retain_attached_hw_handler") && get_linux_version_code() < KERNEL_VERSION(4, 3, 0)) { - mpp->action = ACT_RELOAD; - condlog(3, "%s: set ACT_RELOAD (retain_hwhandler change)", - mpp->alias); + select_reload_action(cmpp, "retain_hwhandler change"); return; } @@ -762,9 +782,10 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) remove_feature(&cmpp_feat, "queue_if_no_path"); remove_feature(&cmpp_feat, "retain_attached_hw_handler"); if (strncmp(mpp_feat, cmpp_feat, PARAMS_SIZE)) { - mpp->action = ACT_RELOAD; - condlog(3, "%s: set ACT_RELOAD (features change)", - mpp->alias); + select_reload_action(cmpp, "features change"); + FREE(cmpp_feat); + FREE(mpp_feat); + return; } } FREE(cmpp_feat); @@ -772,27 +793,19 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) if (!cmpp->selector || strncmp(cmpp->selector, mpp->selector, strlen(mpp->selector))) { - mpp->action = ACT_RELOAD; - condlog(3, "%s: set ACT_RELOAD (selector change)", - mpp->alias); + select_reload_action(cmpp, "selector change"); return; } if (cmpp->minio != mpp->minio) { - mpp->action = ACT_RELOAD; - condlog(3, "%s: set ACT_RELOAD (minio change, %u->%u)", - mpp->alias, cmpp->minio, mpp->minio); + select_reload_action(cmpp, "minio change"); return; } if (!cmpp->pg || VECTOR_SIZE(cmpp->pg) != VECTOR_SIZE(mpp->pg)) { - mpp->action = ACT_RELOAD; - condlog(3, "%s: set ACT_RELOAD (path group number change)", - mpp->alias); + select_reload_action(cmpp, "path group number change"); return; } if (pgcmp(mpp, cmpp)) { - mpp->action = ACT_RELOAD; - condlog(3, "%s: set ACT_RELOAD (path group topology change)", - mpp->alias); + select_reload_action(cmpp, "path group topology change"); return; } if (cmpp->nextpg != mpp->bestpg) { From patchwork Thu Jul 9 11:03:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654217 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C99F914DD for ; Thu, 9 Jul 2020 11:04:41 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F5442074B for ; Thu, 9 Jul 2020 11:04:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F5442074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-IPIOrTBqMVKlR-bSEyh2-Q-1; Thu, 09 Jul 2020 07:04:38 -0400 X-MC-Unique: IPIOrTBqMVKlR-bSEyh2-Q-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B8C50800401; Thu, 9 Jul 2020 11:04:33 +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 85A186FEC6; Thu, 9 Jul 2020 11:04:33 +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 2F610180954D; Thu, 9 Jul 2020 11:04:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069B3sPm002051 for ; Thu, 9 Jul 2020 07:03:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE254217B433; Thu, 9 Jul 2020 11:03:53 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B96882156A59 for ; Thu, 9 Jul 2020 11:03:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C694100E7C4 for ; Thu, 9 Jul 2020 11:03:51 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-492-s53RulUxOiiCGkRsvVVuuw-1; Thu, 09 Jul 2020 07:03:49 -0400 X-MC-Unique: s53RulUxOiiCGkRsvVVuuw-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 59C8BAEE5; Thu, 9 Jul 2020 11:03:47 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 13:03:27 +0200 Message-Id: <20200709110330.9917-4-mwilck@suse.com> In-Reply-To: <20200709110330.9917-1-mwilck@suse.com> References: <20200709110330.9917-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069B3sPm002051 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 77/80] libmultipath: log dm_task_run() errors 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck Log the ioctl error messages from libdm. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 22 ++++++++------- libmultipath/devmapper.c | 61 ++++++++++++++++++++++++++++++++-------- libmultipath/devmapper.h | 4 +++ multipathd/dmevents.c | 4 ++- multipathd/waiter.c | 2 ++ 5 files changed, 70 insertions(+), 23 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index efb5808..faead8c 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -661,7 +661,8 @@ sysfs_set_max_sectors_kb(struct multipath *mpp, int is_reload) } static void -select_reload_action(struct multipath *mpp, const char *reason) +select_reload_action(struct multipath *mpp, const struct multipath *cmpp, + const char *reason) { struct udev_device *mpp_ud; const char *env; @@ -675,8 +676,9 @@ select_reload_action(struct multipath *mpp, const char *reason) * run for this map. Thus force udev reload. */ - mpp_ud = get_udev_for_mpp(mpp); + mpp_ud = get_udev_for_mpp(cmpp); env = udev_device_get_property_value(mpp_ud, "MPATH_DEVICE_READY"); + condlog(3, "%s: %s: \"%s\"\n", __func__, mpp->alias, env); if (!env || strcmp(env, "1")) mpp->force_udev_reload = 1; udev_device_unref(mpp_ud); @@ -754,7 +756,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF && !!strstr(mpp->features, "queue_if_no_path") != !!strstr(cmpp->features, "queue_if_no_path")) { - select_reload_action(cmpp, "no_path_retry change"); + select_reload_action(mpp, cmpp, "no_path_retry change"); return; } if ((mpp->retain_hwhandler != RETAIN_HWHANDLER_ON || @@ -762,7 +764,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) (strlen(cmpp->hwhandler) != strlen(mpp->hwhandler) || strncmp(cmpp->hwhandler, mpp->hwhandler, strlen(mpp->hwhandler)))) { - select_reload_action(cmpp, "hwhandler change"); + select_reload_action(mpp, cmpp, "hwhandler change"); return; } @@ -770,7 +772,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) !!strstr(mpp->features, "retain_attached_hw_handler") != !!strstr(cmpp->features, "retain_attached_hw_handler") && get_linux_version_code() < KERNEL_VERSION(4, 3, 0)) { - select_reload_action(cmpp, "retain_hwhandler change"); + select_reload_action(mpp, cmpp, "retain_hwhandler change"); return; } @@ -782,7 +784,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) remove_feature(&cmpp_feat, "queue_if_no_path"); remove_feature(&cmpp_feat, "retain_attached_hw_handler"); if (strncmp(mpp_feat, cmpp_feat, PARAMS_SIZE)) { - select_reload_action(cmpp, "features change"); + select_reload_action(mpp, cmpp, "features change"); FREE(cmpp_feat); FREE(mpp_feat); return; @@ -793,19 +795,19 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) if (!cmpp->selector || strncmp(cmpp->selector, mpp->selector, strlen(mpp->selector))) { - select_reload_action(cmpp, "selector change"); + select_reload_action(mpp, cmpp, "selector change"); return; } if (cmpp->minio != mpp->minio) { - select_reload_action(cmpp, "minio change"); + select_reload_action(mpp, cmpp, "minio change"); return; } if (!cmpp->pg || VECTOR_SIZE(cmpp->pg) != VECTOR_SIZE(mpp->pg)) { - select_reload_action(cmpp, "path group number change"); + select_reload_action(mpp, cmpp, "path group number change"); return; } if (pgcmp(mpp, cmpp)) { - select_reload_action(cmpp, "path group topology change"); + select_reload_action(mpp, cmpp, "path group topology change"); return; } if (cmpp->nextpg != mpp->bestpg) { diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index fb7675c..46c7ec6 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -182,6 +182,7 @@ dm_tgt_version (unsigned int * version, char * str) dm_task_no_open_count(dmt); if (!dm_task_run(dmt)) { + dm_log_error(2, DM_DEVICE_LIST_VERSIONS, dmt); condlog(0, "Can not communicate with kernel DM"); goto out; } @@ -320,6 +321,8 @@ dm_simplecmd (int task, const char *name, int no_flush, int need_sync, uint16_t goto out; r = dm_task_run (dmt); + if (!r) + dm_log_error(2, task, dmt); if (udev_wait_flag) dm_udev_wait(cookie); @@ -410,6 +413,8 @@ dm_addmap (int task, const char *target, struct multipath *mpp, goto freeout; r = dm_task_run (dmt); + if (!r) + dm_log_error(2, task, dmt); if (task == DM_DEVICE_CREATE) dm_udev_wait(cookie); @@ -521,8 +526,10 @@ do_get_info(const char *name, struct dm_info *info) dm_task_no_open_count(dmt); - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_INFO, dmt); goto out; + } if (!dm_task_get_info(dmt, info)) goto out; @@ -561,6 +568,7 @@ int dm_get_map(const char *name, unsigned long long *size, char *outparams) errno = 0; if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_TABLE, dmt); if (dm_task_get_errno(dmt) == ENXIO) r = DMP_NOT_FOUND; goto out; @@ -601,8 +609,10 @@ dm_get_prefixed_uuid(const char *name, char *uuid, int uuid_len) if (!dm_task_set_name (dmt, name)) goto uuidout; - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_INFO, dmt); goto uuidout; + } uuidtmp = dm_task_get_uuid(dmt); if (uuidtmp) @@ -671,6 +681,7 @@ int dm_get_status(const char *name, char *outstatus) errno = 0; if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_STATUS, dmt); if (dm_task_get_errno(dmt) == ENXIO) r = DMP_NOT_FOUND; goto out; @@ -722,8 +733,10 @@ int dm_type(const char *name, char *type) dm_task_no_open_count(dmt); - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_TABLE, dmt); goto out; + } /* Fetch 1st target */ if (dm_get_next_target(dmt, NULL, &start, &length, @@ -764,8 +777,10 @@ int dm_is_mpath(const char *name) dm_task_no_open_count(dmt); - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_TABLE, dmt); goto out_task; + } if (!dm_task_get_info(dmt, &info)) goto out_task; @@ -826,8 +841,10 @@ dm_map_present_by_uuid(const char *uuid) if (!dm_task_set_uuid(dmt, prefixed_uuid)) goto out_task; - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_INFO, dmt); goto out_task; + } if (!dm_task_get_info(dmt, &info)) goto out_task; @@ -870,8 +887,10 @@ dm_get_opencount (const char * mapname) if (!dm_task_set_name(dmt, mapname)) goto out; - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_INFO, dmt); goto out; + } if (!dm_task_get_info(dmt, &info)) goto out; @@ -1028,8 +1047,10 @@ int dm_flush_maps (int need_suspend, int retries) dm_task_no_open_count(dmt); - if (!dm_task_run (dmt)) + if (!dm_task_run (dmt)) { + dm_log_error(3, DM_DEVICE_LIST, dmt); goto out; + } if (!(names = dm_task_get_names (dmt))) goto out; @@ -1072,8 +1093,10 @@ dm_message(const char * mapname, char * message) dm_task_no_open_count(dmt); - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(2, DM_DEVICE_TARGET_MSG, dmt); goto out; + } r = 0; out: @@ -1190,8 +1213,10 @@ dm_get_maps (vector mp) dm_task_no_open_count(dmt); - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_LIST, dmt); goto out; + } if (!(names = dm_task_get_names(dmt))) goto out; @@ -1280,6 +1305,7 @@ dm_mapname(int major, int minor) } if (!r) { + dm_log_error(2, DM_DEVICE_STATUS, dmt); condlog(0, "%i:%i: timeout fetching map name", major, minor); goto bad; } @@ -1315,8 +1341,10 @@ do_foreach_partmaps (const char * mapname, dm_task_no_open_count(dmt); - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_LIST, dmt); goto out; + } if (!(names = dm_task_get_names(dmt))) goto out; @@ -1550,6 +1578,8 @@ dm_rename (const char * old, char * new, char *delim, int skip_kpartx) if (!dm_task_set_cookie(dmt, &cookie, udev_flags)) goto out; r = dm_task_run(dmt); + if (!r) + dm_log_error(2, DM_DEVICE_RENAME, dmt); dm_udev_wait(cookie); @@ -1593,8 +1623,10 @@ int dm_reassign_table(const char *name, char *old, char *new) dm_task_no_open_count(dmt); - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_TABLE, dmt); goto out; + } if (!(reload_dmt = libmp_dm_task_create(DM_DEVICE_RELOAD))) goto out; if (!dm_task_set_name(reload_dmt, name)) @@ -1625,6 +1657,7 @@ int dm_reassign_table(const char *name, char *old, char *new) dm_task_no_open_count(reload_dmt); if (!dm_task_run(reload_dmt)) { + dm_log_error(3, DM_DEVICE_RELOAD, reload_dmt); condlog(3, "%s: failed to reassign targets", name); goto out_reload; } @@ -1670,8 +1703,10 @@ int dm_reassign(const char *mapname) dm_task_no_open_count(dmt); - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_DEPS, dmt); goto out; + } if (!dm_task_get_info(dmt, &info)) goto out; @@ -1737,6 +1772,8 @@ int dm_setgeometry(struct multipath *mpp) } r = dm_task_run(dmt); + if (!r) + dm_log_error(3, DM_DEVICE_SET_GEOMETRY, dmt); out: dm_task_destroy(dmt); diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 6dd178c..f568ab5 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -85,4 +85,8 @@ struct multipath *dm_get_multipath(const char *name); ((v[0] == minv[0]) && (v[1] == minv[1]) && (v[2] >= minv[2])) \ ) +#define dm_log_error(lvl, cmd, dmt) \ + condlog(lvl, "%s: libdm task=%d error: %s", __func__, \ + cmd, strerror(dm_task_get_errno(dmt))) \ + #endif /* _DEVMAPPER_H */ diff --git a/multipathd/dmevents.c b/multipathd/dmevents.c index b22b47d..b235dd4 100644 --- a/multipathd/dmevents.c +++ b/multipathd/dmevents.c @@ -156,8 +156,10 @@ static int dm_get_events(void) dm_task_no_open_count(dmt); - if (!dm_task_run(dmt)) + if (!dm_task_run(dmt)) { + dm_log_error(3, DM_DEVICE_LIST, dmt); goto fail; + } if (!(names = dm_task_get_names(dmt))) goto fail; diff --git a/multipathd/waiter.c b/multipathd/waiter.c index e645766..16fbdc8 100644 --- a/multipathd/waiter.c +++ b/multipathd/waiter.c @@ -119,6 +119,8 @@ static int waiteventloop (struct event_thread *waiter) pthread_testcancel(); r = dm_task_run(waiter->dmt); + if (!r) + dm_log_error(2, DM_DEVICE_WAITEVENT, waiter->dmt); pthread_testcancel(); pthread_sigmask(SIG_SETMASK, &oldset, NULL); From patchwork Thu Jul 9 11:03:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654221 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3F5D14DD for ; Thu, 9 Jul 2020 11:04:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5A7642074B for ; Thu, 9 Jul 2020 11:04:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A7642074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-NCSJM8xWMY20KcwK9hx98w-1; Thu, 09 Jul 2020 07:04:42 -0400 X-MC-Unique: NCSJM8xWMY20KcwK9hx98w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1DE8A18FF665; Thu, 9 Jul 2020 11:04:38 +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 00F6E1A7CA; Thu, 9 Jul 2020 11:04:37 +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 CFA9693F85; Thu, 9 Jul 2020 11:04:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069B3uoM002077 for ; Thu, 9 Jul 2020 07:03:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id D8E8F2084827; Thu, 9 Jul 2020 11:03:55 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C87EE2084823 for ; Thu, 9 Jul 2020 11:03:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D7C618007CB for ; Thu, 9 Jul 2020 11:03:53 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-358-zLO4BCo4OM20Q4DBRQrdKw-1; Thu, 09 Jul 2020 07:03:49 -0400 X-MC-Unique: zLO4BCo4OM20Q4DBRQrdKw-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 91659AEE9; Thu, 9 Jul 2020 11:03:47 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 13:03:28 +0200 Message-Id: <20200709110330.9917-5-mwilck@suse.com> In-Reply-To: <20200709110330.9917-1-mwilck@suse.com> References: <20200709110330.9917-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069B3uoM002077 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 78/80] libmultipath: move reload_map() to multipathd 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck reload_map() is only used by multipathd. We don't have less exported symbols though, because select_action() now needs to be exported. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 40 +--------------------------------------- libmultipath/configure.h | 2 +- multipathd/main.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index faead8c..b77c2a8 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -688,8 +688,7 @@ select_reload_action(struct multipath *mpp, const struct multipath *cmpp, reason); } -static void -select_action (struct multipath * mpp, vector curmp, int force_reload) +void select_action (struct multipath *mpp, vector curmp, int force_reload) { struct multipath * cmpp; struct multipath * cmpp_by_name; @@ -1478,40 +1477,3 @@ int get_refwwid(enum mpath_cmds cmd, const char *dev, enum devtypes dev_type, pthread_cleanup_pop(1); return ret; } - -int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, - int is_daemon) -{ - char params[PARAMS_SIZE] = {0}; - struct path *pp; - int i, r; - - update_mpp_paths(mpp, vecs->pathvec); - if (refresh) { - vector_foreach_slot (mpp->paths, pp, i) { - struct config *conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); - r = pathinfo(pp, conf, DI_PRIO); - pthread_cleanup_pop(1); - if (r) { - condlog(2, "%s: failed to refresh pathinfo", - mpp->alias); - return 1; - } - } - } - if (setup_map(mpp, params, PARAMS_SIZE, vecs)) { - condlog(0, "%s: failed to setup map", mpp->alias); - return 1; - } - select_action(mpp, vecs->mpvec, 1); - - r = domap(mpp, params, is_daemon); - if (r == DOMAP_FAIL || r == DOMAP_RETRY) { - condlog(3, "%s: domap (%u) failure " - "for reload map", mpp->alias, r); - return 1; - } - - return 0; -} diff --git a/libmultipath/configure.h b/libmultipath/configure.h index d9a7de6..9907775 100644 --- a/libmultipath/configure.h +++ b/libmultipath/configure.h @@ -49,11 +49,11 @@ struct vectors; int setup_map (struct multipath * mpp, char * params, int params_size, struct vectors *vecs ); +void select_action (struct multipath *mpp, vector curmp, int force_reload); 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 (enum mpath_cmds cmd, const 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(struct multipath *mpp, bool is_mpath); diff --git a/multipathd/main.c b/multipathd/main.c index 29227cd..aa08807 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1909,6 +1909,43 @@ int update_prio(struct path *pp, int refresh_all) return 1; } +static int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, + int is_daemon) +{ + char params[PARAMS_SIZE] = {0}; + struct path *pp; + int i, r; + + update_mpp_paths(mpp, vecs->pathvec); + if (refresh) { + vector_foreach_slot (mpp->paths, pp, i) { + struct config *conf = get_multipath_config(); + pthread_cleanup_push(put_multipath_config, conf); + r = pathinfo(pp, conf, DI_PRIO); + pthread_cleanup_pop(1); + if (r) { + condlog(2, "%s: failed to refresh pathinfo", + mpp->alias); + return 1; + } + } + } + if (setup_map(mpp, params, PARAMS_SIZE, vecs)) { + condlog(0, "%s: failed to setup map", mpp->alias); + return 1; + } + select_action(mpp, vecs->mpvec, 1); + + r = domap(mpp, params, is_daemon); + if (r == DOMAP_FAIL || r == DOMAP_RETRY) { + condlog(3, "%s: domap (%u) failure " + "for reload map", mpp->alias, r); + return 1; + } + + return 0; +} + int update_path_groups(struct multipath *mpp, struct vectors *vecs, int refresh) { if (reload_map(vecs, mpp, refresh, 1)) From patchwork Thu Jul 9 11:03:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654223 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED0A914F6 for ; Thu, 9 Jul 2020 11:04:47 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9EE68207DA for ; Thu, 9 Jul 2020 11:04:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EE68207DA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-511-p5onZRoHM2KGn8p5hE2j-w-1; Thu, 09 Jul 2020 07:04:44 -0400 X-MC-Unique: p5onZRoHM2KGn8p5hE2j-w-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4D2C107ACF3; Thu, 9 Jul 2020 11:04: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 C14DB90E6B; Thu, 9 Jul 2020 11:04: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 948BB1809557; Thu, 9 Jul 2020 11:04:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069B3v53002092 for ; Thu, 9 Jul 2020 07:03:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id C5902114B302; Thu, 9 Jul 2020 11:03:56 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D36A114B2F8 for ; Thu, 9 Jul 2020 11:03:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 866BF856A59 for ; Thu, 9 Jul 2020 11:03:53 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-n7icU9VUNhefSThNip8pJQ-1; Thu, 09 Jul 2020 07:03:50 -0400 X-MC-Unique: n7icU9VUNhefSThNip8pJQ-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CC477AEFA; Thu, 9 Jul 2020 11:03:47 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 13:03:29 +0200 Message-Id: <20200709110330.9917-6-mwilck@suse.com> In-Reply-To: <20200709110330.9917-1-mwilck@suse.com> References: <20200709110330.9917-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069B3v53002092 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 79/80] multipathd: rename update_path_groups() -> reload_and_sync_map() 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck This function doesn't just update the path groups. It completely rebuilds the multipath, reloads the kernel map, and syncs path states. That should be reflected in the function name, which should use the term "map", like all other functions that modify kernel state. Todo: there's a large functional overlap between this function and update_map(). Perhaps we should unify the two. Signed-off-by: Martin Wilck --- multipathd/cli_handlers.c | 8 ++++---- multipathd/main.c | 9 +++++---- multipathd/main.h | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 679fd57..d76fe90 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -941,7 +941,7 @@ cli_reload(void *v, char **reply, int *len, void *data) return 1; } - return update_path_groups(mpp, vecs, 0); + return reload_and_sync_map(mpp, vecs, 0); } int resize_map(struct multipath *mpp, unsigned long long size, @@ -1621,7 +1621,7 @@ int cli_set_marginal(void * v, char ** reply, int * len, void * data) } pp->marginal = 1; - return update_path_groups(pp->mpp, vecs, 0); + return reload_and_sync_map(pp->mpp, vecs, 0); } int cli_unset_marginal(void * v, char ** reply, int * len, void * data) @@ -1648,7 +1648,7 @@ int cli_unset_marginal(void * v, char ** reply, int * len, void * data) } pp->marginal = 0; - return update_path_groups(pp->mpp, vecs, 0); + return reload_and_sync_map(pp->mpp, vecs, 0); } int cli_unset_all_marginal(void * v, char ** reply, int * len, void * data) @@ -1685,5 +1685,5 @@ int cli_unset_all_marginal(void * v, char ** reply, int * len, void * data) vector_foreach_slot (pgp->paths, pp, j) pp->marginal = 0; - return update_path_groups(mpp, vecs, 0); + return reload_and_sync_map(mpp, vecs, 0); } diff --git a/multipathd/main.c b/multipathd/main.c index aa08807..e6d4652 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1327,7 +1327,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs) else { if (ro == 1) pp->mpp->force_readonly = 1; - retval = update_path_groups(mpp, vecs, 0); + retval = reload_and_sync_map(mpp, vecs, 0); if (retval == 2) condlog(2, "%s: map removed during reload", pp->dev); else { @@ -1946,7 +1946,8 @@ static int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, return 0; } -int update_path_groups(struct multipath *mpp, struct vectors *vecs, int refresh) +int reload_and_sync_map(struct multipath *mpp, + struct vectors *vecs, int refresh) { if (reload_map(vecs, mpp, refresh, 1)) return 1; @@ -2379,11 +2380,11 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) condlog(4, "path prio refresh"); if (marginal_changed) - update_path_groups(pp->mpp, vecs, 1); + reload_and_sync_map(pp->mpp, vecs, 1); else if (update_prio(pp, new_path_up) && (pp->mpp->pgpolicyfn == (pgpolicyfn *)group_by_prio) && pp->mpp->pgfailback == -FAILBACK_IMMEDIATE) - update_path_groups(pp->mpp, vecs, !new_path_up); + reload_and_sync_map(pp->mpp, vecs, !new_path_up); else if (need_switch_pathgroup(pp->mpp, 0)) { if (pp->mpp->pgfailback > 0 && (new_path_up || pp->mpp->failback_tick <= 0)) diff --git a/multipathd/main.h b/multipathd/main.h index 5dff17e..9aa2a0f 100644 --- a/multipathd/main.h +++ b/multipathd/main.h @@ -46,7 +46,7 @@ int __setup_multipath (struct vectors * vecs, struct multipath * mpp, int reset); #define setup_multipath(vecs, mpp) __setup_multipath(vecs, mpp, 1) int update_multipath (struct vectors *vecs, char *mapname, int reset); -int update_path_groups(struct multipath *mpp, struct vectors *vecs, - int refresh); +int reload_and_sync_map(struct multipath *mpp, struct vectors *vecs, + int refresh); #endif /* MAIN_H */ From patchwork Thu Jul 9 11:03:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 11654219 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 621AE13B1 for ; Thu, 9 Jul 2020 11:04:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 145E52074B for ; Thu, 9 Jul 2020 11:04:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 145E52074B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-503-UkfP_mJXOlSHOUEd5drurA-1; Thu, 09 Jul 2020 07:04:40 -0400 X-MC-Unique: UkfP_mJXOlSHOUEd5drurA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9364D1015ED3; Thu, 9 Jul 2020 11:04:35 +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 7584D610F3; Thu, 9 Jul 2020 11:04:35 +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 4B30F1809557; Thu, 9 Jul 2020 11:04:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 069B3sFL002058 for ; Thu, 9 Jul 2020 07:03:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 466E35F248; Thu, 9 Jul 2020 11:03:54 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A9E55F25C for ; Thu, 9 Jul 2020 11:03:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1304B18056A3 for ; Thu, 9 Jul 2020 11:03:54 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-198-x0-zOBvvNsa-o1V5uoTtLw-1; Thu, 09 Jul 2020 07:03:50 -0400 X-MC-Unique: x0-zOBvvNsa-o1V5uoTtLw-1 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 127AAAEF6; Thu, 9 Jul 2020 11:03:48 +0000 (UTC) From: mwilck@suse.com To: Christophe Varoqui , Benjamin Marzinski Date: Thu, 9 Jul 2020 13:03:30 +0200 Message-Id: <20200709110330.9917-7-mwilck@suse.com> In-Reply-To: <20200709110330.9917-1-mwilck@suse.com> References: <20200709110330.9917-1-mwilck@suse.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 069B3sFL002058 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 80/80] libmultipath: select_action(): don't drop map if alias clashes 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Martin Wilck If for a given map, if we find that the requested alias is already used by a map with different WWID, while the map's own WWID is not used yet, give up the alias and use the WWID instead. This is safer than trying to destroy the existing map, which is likely to fail. This allows us to make use const for the "curmp" parameter. Signed-off-by: Martin Wilck --- libmultipath/configure.c | 13 +++++++------ libmultipath/configure.h | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index b77c2a8..7931045 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -688,7 +688,8 @@ select_reload_action(struct multipath *mpp, const struct multipath *cmpp, reason); } -void select_action (struct multipath *mpp, vector curmp, int force_reload) +void select_action (struct multipath *mpp, const struct _vector *curmp, + int force_reload) { struct multipath * cmpp; struct multipath * cmpp_by_name; @@ -716,12 +717,12 @@ void select_action (struct multipath *mpp, vector curmp, int force_reload) } if (!cmpp) { - condlog(2, "%s: remove (wwid changed)", mpp->alias); - dm_flush_map(mpp->alias); - strlcpy(cmpp_by_name->wwid, mpp->wwid, WWID_SIZE); - drop_multipath(curmp, cmpp_by_name->wwid, KEEP_PATHS); + condlog(1, "%s: can't use alias \"%s\" used by %s, falling back to WWID", + mpp->wwid, mpp->alias, cmpp_by_name->wwid); + /* We can do this because wwid wasn't found */ + strlcpy(mpp->alias, mpp->wwid, sizeof(mpp->alias)); mpp->action = ACT_CREATE; - condlog(3, "%s: set ACT_CREATE (map wwid change)", + condlog(3, "%s: set ACT_CREATE (map does not exist, name changed)", mpp->alias); return; } diff --git a/libmultipath/configure.h b/libmultipath/configure.h index 9907775..6b23ccb 100644 --- a/libmultipath/configure.h +++ b/libmultipath/configure.h @@ -49,7 +49,8 @@ struct vectors; int setup_map (struct multipath * mpp, char * params, int params_size, struct vectors *vecs ); -void select_action (struct multipath *mpp, vector curmp, int force_reload); +void select_action (struct multipath *mpp, const struct _vector *curmp, + int force_reload); 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);