From patchwork Tue Dec 20 23:41:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13078259 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D0C5C4332F for ; Tue, 20 Dec 2022 23:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671579735; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2GpfyEn4SKaouFUqi0XTZSbgGoXpskct++5Fbi0IcAw=; b=eQH7wir9mlG3DjZ+R4KtNuDWcTv92JbdBM7btE9HvYEmcjNaTx0ozPhIAdZMy3hwyzYaYF VZkxuV/DniMRFwPmgggjNXMMkP4vh/qJADccLe5V+EjmxG1I1ZFhck24m9NkmODWLX919K RezegYX181xQBYbRVpxo2tROqohG7JI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-119-CxvMjkSUMGyl215sQdLBFQ-1; Tue, 20 Dec 2022 18:41:34 -0500 X-MC-Unique: CxvMjkSUMGyl215sQdLBFQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5AEC03C025CE; Tue, 20 Dec 2022 23:41:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC7EF2026D4B; Tue, 20 Dec 2022 23:41:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F1F5F19465A3; Tue, 20 Dec 2022 23:41:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E4B9F19465A3 for ; Tue, 20 Dec 2022 23:41:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6F022492B02; Tue, 20 Dec 2022 23:41:19 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C75FB492B00; Tue, 20 Dec 2022 23:41:18 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 2BKNfHMI023700; Tue, 20 Dec 2022 17:41:17 -0600 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 2BKNfHN9023699; Tue, 20 Dec 2022 17:41:17 -0600 From: Benjamin Marzinski To: Christophe Varoqui Date: Tue, 20 Dec 2022 17:41:10 -0600 Message-Id: <1671579675-23658-2-git-send-email-bmarzins@redhat.com> In-Reply-To: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> References: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Subject: [dm-devel] [PATCH 1/6] multipathd: make pr registration consistent X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: device-mapper development , Martin Wilck MIME-Version: 1.0 Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com multipathd was inconsistent on what it did with persistent reservations when a multipath device was created. If a multipath device with a configured reservation key was created during configure(), multipathd would try to read the registered keys using an active path. If it saw a matching key, it would set the prflag, but not attempt to register the key on any of the other paths. This means that if a new path had appeared while multipathd was not running, it wouldn't register the key on this path. If the multipath device was created during ev_add_path(), multipathd would used the added path to check if there was a matching key and if there was, register the key only on the added path and then set the prflag. This could be problematic if the device was created with multiple paths, for instance because find_mutipaths was set to "yes" and a second path just appeared. In this case, if the device happened to be only registered on the second path, it would not get registered on the first path. If the multipath device was added to multipathd during a call to ev_add_map(), multipathd wouldn't set the prflag or register the key on any paths. After a device was created with the prflag set, if a new path appeared before the creation uevent, and multipathd was forced to delay adding it, when it finally updated the multipath device, the key would be registered on all paths, fixing any paths missed during creation. However, if a new path appeared after the creation uevent, the key would only be registered on that new path. Any paths that were missed on creation would stay missed. persistent key registration needs to be handled consistently. This patch does so by making sure that however a multipath device is added to multipathd, it will check to see if the configured key is registered. If it is, multipathd will set the prflag and register the key on all the currently active paths. When a new path is added, multipathd will use it to check for active keys, as before. But if it finds a matching key and prflag isn't currently set, it will register the key on all paths. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 1e1b254f..f7212d7b 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -586,13 +586,26 @@ flush_map_nopaths(struct multipath *mpp, struct vectors *vecs) { return false; } +static void +pr_register_active_paths(struct multipath *mpp) +{ + unsigned int i, j; + struct path *pp; + struct pathgroup *pgp; + + vector_foreach_slot (mpp->pg, pgp, i) { + vector_foreach_slot (pgp->paths, pp, j) { + if ((pp->state == PATH_UP) || (pp->state == PATH_GHOST)) + mpath_pr_event_handle(pp); + } + } +} + static int update_map (struct multipath *mpp, struct vectors *vecs, int new_map) { int retries = 3; char *params __attribute__((cleanup(cleanup_charp))) = NULL; - struct path *pp; - int i; retry: condlog(4, "%s: updating new map", mpp->alias); @@ -609,15 +622,6 @@ retry: mpp->action = ACT_RELOAD; - if (mpp->prflag) { - vector_foreach_slot(mpp->paths, pp, i) { - if ((pp->state == PATH_UP) || (pp->state == PATH_GHOST)) { - /* persistent reservation check*/ - mpath_pr_event_handle(pp); - } - } - } - if (setup_map(mpp, ¶ms, vecs)) { condlog(0, "%s: failed to setup new map in update", mpp->alias); retries = -1; @@ -643,6 +647,11 @@ fail: sync_map_state(mpp); + if (!mpp->prflag) + update_map_pr(mpp); + if (mpp->prflag) + pr_register_active_paths(mpp); + if (retries < 0) condlog(0, "%s: failed reload in new map update", mpp->alias); return 0; @@ -1191,6 +1200,7 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map) int start_waiter = 0; int ret; int ro; + unsigned char prflag = 0; /* * need path UID to go any further @@ -1234,6 +1244,8 @@ rescan: verify_paths(mpp); mpp->action = ACT_RELOAD; + prflag = mpp->prflag; + mpath_pr_event_handle(pp); } else { if (!should_multipath(pp, vecs->pathvec, vecs->mpvec)) { orphan_path(pp, "only one path"); @@ -1252,9 +1264,6 @@ rescan: goto fail; /* leave path added to pathvec */ } - /* persistent reservation check*/ - mpath_pr_event_handle(pp); - /* ro check - if new path is ro, force map to be ro as well */ ro = sysfs_get_ro(pp); if (ro == 1) @@ -1319,6 +1328,10 @@ rescan: sync_map_state(mpp); if (retries >= 0) { + if (start_waiter) + update_map_pr(mpp); + if (mpp->prflag && !prflag) + pr_register_active_paths(mpp); condlog(2, "%s [%s]: path added to devmap %s", pp->dev, pp->dev_t, mpp->alias); return 0; @@ -2852,6 +2865,8 @@ configure (struct vectors * vecs, enum force_reload_types reload_type) if (remember_wwid(mpp->wwid) == 1) trigger_paths_udev_change(mpp, true); update_map_pr(mpp); + if (mpp->prflag) + pr_register_active_paths(mpp); } /* From patchwork Tue Dec 20 23:41:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13078256 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4CF2C41535 for ; Tue, 20 Dec 2022 23:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671579697; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gfD2H/DaV0OloEA/0Ux3OwyYWOMVl4c8iTpgvciyYm4=; b=fsQNTRcm9gdRaagWNiYpNTUUUVpgD305jSuBSkCOO63MTisZxu3yfB+kGak/kpFIoOdA80 Z03+/RGIlDrsB/gogm3I8S/m8bxPY3elXKZxiXzfFgdNFkfXTNhYdkj9716r05teCpVr0B NABvV9q5ST+SXEbExM364tbYQgqdJg0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-PCqaxNIkO66jBtlmPpXZyg-1; Tue, 20 Dec 2022 18:41:34 -0500 X-MC-Unique: PCqaxNIkO66jBtlmPpXZyg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5B03A85C6E6; Tue, 20 Dec 2022 23:41:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E867C16028; Tue, 20 Dec 2022 23:41:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4AE7F1946A6F; Tue, 20 Dec 2022 23:41:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E20B919465A0 for ; Tue, 20 Dec 2022 23:41:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 48B292166B26; Tue, 20 Dec 2022 23:41:20 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 223462166B2B; Tue, 20 Dec 2022 23:41:20 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 2BKNfIF5023704; Tue, 20 Dec 2022 17:41:18 -0600 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 2BKNfIEC023703; Tue, 20 Dec 2022 17:41:18 -0600 From: Benjamin Marzinski To: Christophe Varoqui Date: Tue, 20 Dec 2022 17:41:11 -0600 Message-Id: <1671579675-23658-3-git-send-email-bmarzins@redhat.com> In-Reply-To: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> References: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Subject: [dm-devel] [PATCH 2/6] libmultipath: make prflag an enum X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: device-mapper development , Martin Wilck MIME-Version: 1.0 Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com In preparation for a future patch, make prflag an enum, and change the reply of cli_getprstatus() to a string. Signed-off-by: Benjamin Marzinski --- libmpathpersist/mpath_persist_int.c | 2 +- libmultipath/structs.h | 8 +++++++- multipathd/cli_handlers.c | 17 +++++++++-------- multipathd/main.c | 14 +++++++------- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/libmpathpersist/mpath_persist_int.c b/libmpathpersist/mpath_persist_int.c index 6924b379..a84d9474 100644 --- a/libmpathpersist/mpath_persist_int.c +++ b/libmpathpersist/mpath_persist_int.c @@ -783,7 +783,7 @@ int update_map_pr(struct multipath *mpp) if (isFound) { - mpp->prflag = 1; + mpp->prflag = PRFLAG_SET; condlog(2, "%s: prflag flag set.", mpp->alias ); } diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 9e2c1ab0..f2265300 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -375,6 +375,12 @@ struct path { typedef int (pgpolicyfn) (struct multipath *, vector); + +enum prflag_value { + PRFLAG_UNSET, + PRFLAG_SET, +}; + struct multipath { char wwid[WWID_SIZE]; char alias_old[WWID_SIZE]; @@ -449,7 +455,7 @@ struct multipath { int prkey_source; struct be64 reservation_key; uint8_t sa_flags; - unsigned char prflag; + int prflag; int all_tg_pt; struct gen_multipath generic_mp; bool fpin_must_reload; diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index e65fb75c..7ee2729f 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -1277,6 +1277,10 @@ cli_shutdown (void * v, struct strbuf *reply, void * data) static int cli_getprstatus (void * v, struct strbuf *reply, void * data) { + static const char * const prflag_str[] = { + [PRFLAG_UNSET] = "unset\n", + [PRFLAG_SET] = "set\n", + }; struct multipath * mpp; struct vectors * vecs = (struct vectors *)data; char * param = get_keyparam(v, KEY_MAP); @@ -1287,10 +1291,7 @@ cli_getprstatus (void * v, struct strbuf *reply, void * data) if (!mpp) return 1; - condlog(3, "%s: prflag = %u", param, (unsigned int)mpp->prflag); - - if (print_strbuf(reply, "%d", mpp->prflag) < 0) - return 1; + append_strbuf_str(reply, prflag_str[mpp->prflag]); condlog(3, "%s: reply = %s", param, get_strbuf_str(reply)); @@ -1310,8 +1311,8 @@ cli_setprstatus(void * v, struct strbuf *reply, void * data) if (!mpp) return 1; - if (!mpp->prflag) { - mpp->prflag = 1; + if (mpp->prflag != PRFLAG_SET) { + mpp->prflag = PRFLAG_SET; condlog(2, "%s: prflag set", param); } @@ -1332,8 +1333,8 @@ cli_unsetprstatus(void * v, struct strbuf *reply, void * data) if (!mpp) return 1; - if (mpp->prflag) { - mpp->prflag = 0; + if (mpp->prflag != PRFLAG_UNSET) { + mpp->prflag = PRFLAG_UNSET; condlog(2, "%s: prflag unset", param); } diff --git a/multipathd/main.c b/multipathd/main.c index f7212d7b..722235c7 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -647,9 +647,9 @@ fail: sync_map_state(mpp); - if (!mpp->prflag) + if (mpp->prflag == PRFLAG_UNSET) update_map_pr(mpp); - if (mpp->prflag) + if (mpp->prflag == PRFLAG_SET) pr_register_active_paths(mpp); if (retries < 0) @@ -1200,7 +1200,7 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map) int start_waiter = 0; int ret; int ro; - unsigned char prflag = 0; + unsigned char prflag = PRFLAG_UNSET; /* * need path UID to go any further @@ -1330,7 +1330,7 @@ rescan: if (retries >= 0) { if (start_waiter) update_map_pr(mpp); - if (mpp->prflag && !prflag) + if (mpp->prflag == PRFLAG_SET && prflag == PRFLAG_UNSET) pr_register_active_paths(mpp); condlog(2, "%s [%s]: path added to devmap %s", pp->dev, pp->dev_t, mpp->alias); @@ -2492,7 +2492,7 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) } if (newstate == PATH_UP || newstate == PATH_GHOST) { - if (pp->mpp->prflag) { + if (pp->mpp->prflag == PRFLAG_SET) { /* * Check Persistent Reservation. */ @@ -2865,7 +2865,7 @@ configure (struct vectors * vecs, enum force_reload_types reload_type) if (remember_wwid(mpp->wwid) == 1) trigger_paths_udev_change(mpp, true); update_map_pr(mpp); - if (mpp->prflag) + if (mpp->prflag == PRFLAG_SET) pr_register_active_paths(mpp); } @@ -3840,7 +3840,7 @@ void * mpath_pr_event_handler_fn (void * pathp ) { condlog(0,"%s: Reservation registration failed. Error: %d", pp->dev, ret); } - mpp->prflag = 1; + mpp->prflag = PRFLAG_SET; free(param); out: From patchwork Tue Dec 20 23:41:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13078258 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBD44C4332F for ; Tue, 20 Dec 2022 23:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671579730; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UWaECTxWgyngqa9oQp7RgnHaqocsVtRWkhTEnM8WRco=; b=B/RQoxURJNQ4Cv2EUVqDSFy+PRotXKiAwIbIh9yPSbE3OK4sbwNnhVqTKjKObNO+aBDIeC nUh4MDJC8rUFAbEE/ZqAnVylfUEICxzz3MJVoUbcbkddkKqxw/9582lbMe/SUkjVlHQ5vi T19lQuco93g96DnTsemtVvehBMGEz6U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-221-qfYeo1HZMduh10hnu5UW2A-1; Tue, 20 Dec 2022 18:41:34 -0500 X-MC-Unique: qfYeo1HZMduh10hnu5UW2A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5AF31183B3CB; Tue, 20 Dec 2022 23:41:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A10DD2166B2B; Tue, 20 Dec 2022 23:41:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 796931946A78; Tue, 20 Dec 2022 23:41:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BA42B19465A0 for ; Tue, 20 Dec 2022 23:41:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 91649492C1B; Tue, 20 Dec 2022 23:41:21 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 72389492C18; Tue, 20 Dec 2022 23:41:21 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 2BKNfKkq023708; Tue, 20 Dec 2022 17:41:20 -0600 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 2BKNfJwU023707; Tue, 20 Dec 2022 17:41:19 -0600 From: Benjamin Marzinski To: Christophe Varoqui Date: Tue, 20 Dec 2022 17:41:12 -0600 Message-Id: <1671579675-23658-4-git-send-email-bmarzins@redhat.com> In-Reply-To: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> References: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Subject: [dm-devel] [PATCH 3/6] multipathd: handle no active paths in update_map_pr X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: device-mapper development , Martin Wilck MIME-Version: 1.0 Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com When a multipath device is first created, if it has a reservation key configured, update_map_pr() will check for a matching key on the active paths. If there were no active paths to check with, multipathd was leaving mpp->prflag in PRFLAG_UNSET, as if there were no matching keys. It's possible that when update_map_pr() is called, all the paths will be in the PATH_PENDING state because the checkers haven't completed yet. In this case, multipathd was treating the device as having no registered keys without ever checking. To solve this, multipath devices now start with prflag = PRFLAG_UNKNOWN. It will remain in this state until multipathd actually tries to get the registered keys down a path. If the map is in this state, it will check newly active paths, and if it finds a matching key, it will register the key down all active paths. Signed-off-by: Benjamin Marzinski --- libmpathpersist/mpath_persist_int.c | 8 ++++++++ libmultipath/structs.h | 1 + multipathd/cli_handlers.c | 1 + multipathd/main.c | 19 ++++++++++++++----- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/libmpathpersist/mpath_persist_int.c b/libmpathpersist/mpath_persist_int.c index a84d9474..8b52b746 100644 --- a/libmpathpersist/mpath_persist_int.c +++ b/libmpathpersist/mpath_persist_int.c @@ -738,6 +738,7 @@ int update_map_pr(struct multipath *mpp) if (!get_be64(mpp->reservation_key)) { /* Nothing to do. Assuming pr mgmt feature is disabled*/ + mpp->prflag = PRFLAG_UNSET; condlog(4, "%s: reservation_key not set in multipath.conf", mpp->alias); return MPATH_PR_SUCCESS; @@ -749,6 +750,13 @@ int update_map_pr(struct multipath *mpp) condlog(0,"%s : failed to alloc resp in update_map_pr", mpp->alias); return MPATH_PR_OTHER; } + if (count_active_paths(mpp) == 0) + { + condlog(0,"%s: No available paths to check pr status", + mpp->alias); + return MPATH_PR_OTHER; + } + mpp->prflag = PRFLAG_UNSET; ret = mpath_prin_activepath(mpp, MPATH_PRIN_RKEY_SA, resp, noisy); if (ret != MPATH_PR_SUCCESS ) diff --git a/libmultipath/structs.h b/libmultipath/structs.h index f2265300..e2294323 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -377,6 +377,7 @@ typedef int (pgpolicyfn) (struct multipath *, vector); enum prflag_value { + PRFLAG_UNKNOWN, PRFLAG_UNSET, PRFLAG_SET, }; diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 7ee2729f..ec5db1b8 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -1278,6 +1278,7 @@ static int cli_getprstatus (void * v, struct strbuf *reply, void * data) { static const char * const prflag_str[] = { + [PRFLAG_UNKNOWN] = "unknown\n", [PRFLAG_UNSET] = "unset\n", [PRFLAG_SET] = "set\n", }; diff --git a/multipathd/main.c b/multipathd/main.c index 722235c7..bdeffe76 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -647,7 +647,7 @@ fail: sync_map_state(mpp); - if (mpp->prflag == PRFLAG_UNSET) + if (mpp->prflag != PRFLAG_SET) update_map_pr(mpp); if (mpp->prflag == PRFLAG_SET) pr_register_active_paths(mpp); @@ -1330,7 +1330,7 @@ rescan: if (retries >= 0) { if (start_waiter) update_map_pr(mpp); - if (mpp->prflag == PRFLAG_SET && prflag == PRFLAG_UNSET) + if (mpp->prflag == PRFLAG_SET && prflag != PRFLAG_SET) pr_register_active_paths(mpp); condlog(2, "%s [%s]: path added to devmap %s", pp->dev, pp->dev_t, mpp->alias); @@ -2492,13 +2492,17 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) } if (newstate == PATH_UP || newstate == PATH_GHOST) { - if (pp->mpp->prflag == PRFLAG_SET) { + if (pp->mpp->prflag != PRFLAG_UNSET) { + int prflag = pp->mpp->prflag; /* * Check Persistent Reservation. */ condlog(2, "%s: checking persistent " "reservation registration", pp->dev); mpath_pr_event_handle(pp); + if (pp->mpp->prflag == PRFLAG_SET && + prflag != PRFLAG_SET) + pr_register_active_paths(pp->mpp); } } @@ -3788,6 +3792,7 @@ void * mpath_pr_event_handler_fn (void * pathp ) goto out; } + mpp->prflag = PRFLAG_UNSET; ret = prin_do_scsi_ioctl(pp->dev, MPATH_PRIN_RKEY_SA, resp, 0); if (ret != MPATH_PR_SUCCESS ) { @@ -3858,12 +3863,12 @@ int mpath_pr_event_handle(struct path *pp) struct multipath * mpp; if (pp->bus != SYSFS_BUS_SCSI) - return 0; + goto no_pr; mpp = pp->mpp; if (!get_be64(mpp->reservation_key)) - return -1; + goto no_pr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); @@ -3876,4 +3881,8 @@ int mpath_pr_event_handle(struct path *pp) pthread_attr_destroy(&attr); rc = pthread_join(thread, NULL); return 0; + +no_pr: + pp->mpp->prflag = PRFLAG_UNSET; + return 0; } From patchwork Tue Dec 20 23:41:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13078254 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A72A3C3DA6E for ; Tue, 20 Dec 2022 23:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671579697; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Qq/47iRTHaPIESwRL8+7tRWdRfMWFIcK2CRXqJyra7I=; b=STk9rNeGnE8x2k4nk5yBwQbQmypLeHwOMLk5vImhfIF9Z+315RJf9xARu2VwakSFe9aXMs pIqaHTwtbkDPpgHLbe2gQkr8dJOrdZisexpIzjgWGc4avxvlXfOTxjDHIdOAC6triWahYs xL9ZZuc9LQtNTke0rDIzGs3wrteWuI0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-Jft2sAijM4KbUZiiHCYIpw-1; Tue, 20 Dec 2022 18:41:34 -0500 X-MC-Unique: Jft2sAijM4KbUZiiHCYIpw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5AA441C068E0; Tue, 20 Dec 2022 23:41:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 067E514152F4; Tue, 20 Dec 2022 23:41:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9F26F1947041; Tue, 20 Dec 2022 23:41:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 186A71946A6D for ; Tue, 20 Dec 2022 23:41:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E31A6112132D; Tue, 20 Dec 2022 23:41:22 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2D44112132C; Tue, 20 Dec 2022 23:41:22 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 2BKNfLsx023712; Tue, 20 Dec 2022 17:41:21 -0600 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 2BKNfLkG023711; Tue, 20 Dec 2022 17:41:21 -0600 From: Benjamin Marzinski To: Christophe Varoqui Date: Tue, 20 Dec 2022 17:41:13 -0600 Message-Id: <1671579675-23658-5-git-send-email-bmarzins@redhat.com> In-Reply-To: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> References: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Subject: [dm-devel] [PATCH 4/6] multipathd: add missing newline to cli_del_map reply X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: device-mapper development , Martin Wilck MIME-Version: 1.0 Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Signed-off-by: Benjamin Marzinski --- multipathd/cli_handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index ec5db1b8..44bf43df 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -760,7 +760,7 @@ cli_del_map (void * v, struct strbuf *reply, void * data) } rc = ev_remove_map(param, alias, minor, vecs); if (rc == 2) - append_strbuf_str(reply, "delayed"); + append_strbuf_str(reply, "delayed\n"); free(alias); return rc; From patchwork Tue Dec 20 23:41:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13078255 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3014FC4167B for ; Tue, 20 Dec 2022 23:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671579698; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tzqBtAIe5ylq8MobLXPdIQnggjNqQPeXMpxusXeecHA=; b=Gzcu5E6ZDkBj9W/DbxKvblwkZLzt4uccNvRAYZH1GF9lMmj8LmDl5xBTAirQFxKe0eHpOF ZwT+1lvev+oiYJvI6zLD5wwO2KnNjwnjOgbWF1C6yEugkvatcCFuRh3Chlyi1hnGlnY6EY zjg2GiabHfQIj+nEgRd6IXfwCLqnBls= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-cMs23T-BMUyZUTY9iWsf-Q-1; Tue, 20 Dec 2022 18:41:34 -0500 X-MC-Unique: cMs23T-BMUyZUTY9iWsf-Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5AE2E857A85; Tue, 20 Dec 2022 23:41:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6969E40C2004; Tue, 20 Dec 2022 23:41:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C508E194704B; Tue, 20 Dec 2022 23:41:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 28026194704A for ; Tue, 20 Dec 2022 23:41:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1A8062166B2B; Tue, 20 Dec 2022 23:41:24 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06D942166B26; Tue, 20 Dec 2022 23:41:23 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 2BKNfMp9023716; Tue, 20 Dec 2022 17:41:22 -0600 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 2BKNfM0R023715; Tue, 20 Dec 2022 17:41:22 -0600 From: Benjamin Marzinski To: Christophe Varoqui Date: Tue, 20 Dec 2022 17:41:14 -0600 Message-Id: <1671579675-23658-6-git-send-email-bmarzins@redhat.com> In-Reply-To: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> References: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Subject: [dm-devel] [PATCH 5/6] libmultipath: skip extra vector work in remove_maps X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: device-mapper development , Martin Wilck MIME-Version: 1.0 Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Instead of repeatedly removing the first vector element, and shifting the rest to fill in, call remove_map() without a vector, so it just frees the devices. The vector will be completely cleaned up by vector_free() immediately afterwards. Signed-off-by: Benjamin Marzinski --- libmultipath/structs_vec.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 5a618767..f3fdc5a6 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -392,10 +392,8 @@ remove_maps(struct vectors * vecs) if (!vecs) return; - vector_foreach_slot (vecs->mpvec, mpp, i) { - remove_map(mpp, vecs->pathvec, vecs->mpvec); - i--; - } + vector_foreach_slot (vecs->mpvec, mpp, i) + remove_map(mpp, vecs->pathvec, NULL); vector_free(vecs->mpvec); vecs->mpvec = NULL; From patchwork Tue Dec 20 23:41:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13078257 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57ABDC4332F for ; Tue, 20 Dec 2022 23:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671579726; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YMYRWeuOEk73siD+EVzs2CZva+XXz2KJ2ic8NlnfqS0=; b=EJFQz1jsTywTuIyu/T9SNOT6SEOODu/W3ZNu0Eh085uePfUPvIaDtl7tOlSj1ggpKFL/h1 K6hTx3VWq4QE9uF4/VEpMnmPxPQTw0VoiN5AzmYLYTHwf3UqMjSVaYmVWXTOf0sV2C89uI EXj2VNtUALWw1x0cfxTLZXm1XT6Ey0M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-3e0YBd_hPM2lG2IpqcPKuA-1; Tue, 20 Dec 2022 18:41:34 -0500 X-MC-Unique: 3e0YBd_hPM2lG2IpqcPKuA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5ADBE85C6E4; Tue, 20 Dec 2022 23:41:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B77B9492C14; Tue, 20 Dec 2022 23:41:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 90B5D1947054; Tue, 20 Dec 2022 23:41:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7BB5A1947053 for ; Tue, 20 Dec 2022 23:41:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5FB5E492B02; Tue, 20 Dec 2022 23:41:25 +0000 (UTC) Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B920492B00; Tue, 20 Dec 2022 23:41:25 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 2BKNfOJT023720; Tue, 20 Dec 2022 17:41:24 -0600 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 2BKNfNsJ023719; Tue, 20 Dec 2022 17:41:23 -0600 From: Benjamin Marzinski To: Christophe Varoqui Date: Tue, 20 Dec 2022 17:41:15 -0600 Message-Id: <1671579675-23658-7-git-send-email-bmarzins@redhat.com> In-Reply-To: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> References: <1671579675-23658-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Subject: [dm-devel] [PATCH 6/6] libmultipath: orphan paths if coalesce_paths frees newmp X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: device-mapper development , Martin Wilck MIME-Version: 1.0 Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com If coalesce_paths() is called without a mpvec, it will free all the multipath devices on newmp at the end. This will clear pp->mpp from the path, but it doesn't completely unitialize them. cli_add_map() can call coalsce_paths() this way, when adding a device that doesn't currently exist. cli_add_map() first creates the device in the kernel, and then calls ev_add_map() to add it to multipathd. If something goes wrong in ev_add_map(), the paths will still be initialized, even though they're orphans. Fix this by calling remove_map() to orphan the paths that belong to the multipath devices being deleted by coalesce_paths(). Signed-off-by: Benjamin Marzinski --- libmultipath/configure.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index e551047a..e689f8a7 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -1273,8 +1273,11 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid, ret = CP_OK; out: free(size_mismatch_seen); - if (!mpvec) - free_multipathvec(newmp, KEEP_PATHS); + if (!mpvec) { + vector_foreach_slot (newmp, mpp, i) + remove_map(mpp, vecs->pathvec, NULL); + vector_free(newmp); + } return ret; }