From patchwork Thu Apr 25 23:35:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13644017 X-Patchwork-Delegate: christophe.varoqui@free.fr 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.subspace.kernel.org (Postfix) with ESMTPS id 2A492155A5B for ; Thu, 25 Apr 2024 23:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088123; cv=none; b=pr8m4+52hoj1fcJCus8u9d9Cp7FJ5NyqBKMn+BovB6o/mxfBJzKwe6FV4W5sAX1xZdA70w144xycydPVVlZk2YMisN/SggyRjZhkvMEJKrncYBsFPuzEXzC4qh5w4SrAwUF99kmB0iFqHbLWD9nSJx3vh0i/EVurlQb/sW+3m/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088123; c=relaxed/simple; bh=aWfZtY0qBF2iVUOrFIuiK/ahMmitku/p4nz4bWTD9Pw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p73IJctEVvw3ytRVu7TSe1mRHnjTBo360H12HpEGPH+Qhi2Gwnq2dwQ4029UrC1ky21QR1cKTzcBCgiAuhgJOuQSLmQPO68tlq8wS+MIy5t6mHl5BVla48kgTYSiSEdc/U0MdVMaRpMEz9d18/EL+dZ50AyAt/enGK0GZePzvJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Z50g821G; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z50g821G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714088121; h=from:from: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; bh=eAQWk3E3FgkdmNJlFuTiYxSgg2GRX1PCab20XJy7JmU=; b=Z50g821GS5vH2ptOXA+x+yHtmZhx7BI4Mae5yx0pCtWhSM1NY+oDDGea/0C+0Z4qubwhRj mr4xLz0L1kKM2OUULHEEmiSNeCOGJJvIOQ1bDQXqMqNPB2MSlbl3S9Kp2Y6GgASN112d/h CZPHQKFZK7XIU+oIEtpeqrhDJA0EqQY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-_5oDzWjrM2yauCc5FIPv0w-1; Thu, 25 Apr 2024 19:35:18 -0400 X-MC-Unique: _5oDzWjrM2yauCc5FIPv0w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1178A29AA3AC; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B87DAC6C; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1) with ESMTPS id 43PNZHox2125160 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 19:35:17 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1/Submit) id 43PNZHe12125159; Thu, 25 Apr 2024 19:35:17 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 1/5] libmultipath: export partmap_in_use Date: Thu, 25 Apr 2024 19:35:13 -0400 Message-ID: <20240425233517.2125142-2-bmarzins@redhat.com> In-Reply-To: <20240425233517.2125142-1-bmarzins@redhat.com> References: <20240425233517.2125142-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com A future commit will make use of this function Signed-off-by: Benjamin Marzinski --- libmultipath/devmapper.c | 2 +- libmultipath/devmapper.h | 1 + libmultipath/libmultipath.version | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 4ce7e82f..a87abf7e 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -1043,7 +1043,7 @@ has_partmap(const char *name __attribute__((unused)), return 1; } -static int +int partmap_in_use(const char *name, void *data) { int part_count, *ret_count = (int *)data; diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index a7d66604..93caa2aa 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -57,6 +57,7 @@ enum { DM_FLUSH_BUSY, }; +int partmap_in_use(const char *name, void *data); int _dm_flush_map (const char *, int, int, int, int); int dm_flush_map_nopaths(const char * mapname, int deferred_remove); #define dm_flush_map(mapname) _dm_flush_map(mapname, 1, 0, 0, 0) diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index 724786d5..e070f296 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -141,6 +141,7 @@ global: need_io_err_check; orphan_path; parse_prkey_flags; + partmap_in_use; pathcount; path_discovery; path_get_tpgs; From patchwork Thu Apr 25 23:35:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13644020 X-Patchwork-Delegate: christophe.varoqui@free.fr 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.subspace.kernel.org (Postfix) with ESMTPS id 970D7155A5B for ; Thu, 25 Apr 2024 23:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088126; cv=none; b=n3UCS+3ASOSiIfwaa6cL/KTPppKqNr1Zmubz/KwUOs6oNQmE2JqEgtDewPLg7DjHsae9Rwgs1ciPA2dUFyzA/qKyA+C/cAYOuGHfZGUzB9YxipAqieejo7wwpbrj5RtDi4gMUr0eM2PrFpKzJHfg+ef5xL/KmAq+q4AVHy2Z7nk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088126; c=relaxed/simple; bh=+dGy08Snh8BaR/weXFA7+qAfQ/YwWLExY83iegwki3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KKFRKMtk4CIwBtt3FdoZeEQvVAwqY8VhM3qblYrXGZ6do36dnxrYgGViuinVfWmoenJcGfXNBz2ywpQgTzzWG0kziHz1jqv4RqsUpoY34lX+H2wzdJp2r4GbRmJX7Bjrxx33ka9VufwYJ1sBj5H+Kl3xmUdT1bm7xOl/a0ZJdDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=e3N0Ncf4; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="e3N0Ncf4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714088123; h=from:from: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; bh=AYkT8BhTpYheCdc/+tMXwGyViwLsMW4ImmXvP/qRP+M=; b=e3N0Ncf4FRk44Qjhg98DWPU7tYbsJSy2OicSHE90cfVNOhvLYCiSDMbZJxqS6ZSVGEEFoq Y9cnj6RE7XF6fFBbX2zAO4UbgNGYrVWcAoos62uaU2P/iBYoWXHJpBlGACUO+UpeBKJIrK 7PTY6kRzkcxfENKOFTF5zgfqWDQT+sQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-E9Fv1C4YPAuTKzdgpMu8_w-1; Thu, 25 Apr 2024 19:35:18 -0400 X-MC-Unique: E9Fv1C4YPAuTKzdgpMu8_w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3950C385A18C; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32D31730B; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1) with ESMTPS id 43PNZIOm2125164 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 19:35:18 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1/Submit) id 43PNZI2W2125163; Thu, 25 Apr 2024 19:35:18 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 2/5] libmultipath: change flush_on_last_del to fix a multipathd hang Date: Thu, 25 Apr 2024 19:35:14 -0400 Message-ID: <20240425233517.2125142-3-bmarzins@redhat.com> In-Reply-To: <20240425233517.2125142-1-bmarzins@redhat.com> References: <20240425233517.2125142-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Commit 9bd3482e ("multipathd: make flush_map() delete maps like the multipath command") fixed an issue where deleting a queueing multipath device through multipathd could hang because the multipath device had outstanding IO, even though the only openers of it at the time of deletion were the kpartx partition devices. However it is still possible to hang multipathd, because autoremoving the device when all paths have been deleted doesn't disable queueing. To reproduce this hang: 1. create a multipath device with a kpartx partition on top of it and no_path_retry set to either "queue" or something long enough to run all the commands in the reproducer before it disables queueing. 2. disable all the paths to the device with something like: # echo offline > /sys/block//device/state 3. Write directly to the multipath device with something like: # dd if=/dev/zero of=/dev/mapper/ bs=4K count=1 4. delete all the paths to the device with something like: # echo 1 > /sys/block//device/delete Multipathd will hang trying to delete the kpartx device because, as the last opener, it must flush the multipath device before closing it. Because it hangs holding the vecs_lock, multipathd will never disable queueing on the device, so it will hang forever, even if no_path_retry is set to a number. This hang can occur, even if deferred_remove is set. Since nothing has the kpartx device opened, device-mapper does an immediate remove, which will still hang. This means that even if deferred_remove is set, multipathd still cannot delete a map while queueing is enabled. It must either disable queueing or skip the autoremove. Mulitpath can currently be configured to avoid this hang by setting flush_on_last_del yes However there are good reasons why users wouldn't want to set that. They may need to be able to survive having all paths getting temporarily deleted. I should note that this is a pretty rare corner case, since multipath automatically sets dev_loss_tmo so that it should not trigger before queueing is disabled. This commit avoids the hang by changing the possible values for flush_on_last_del to "never", "unused", and "always", and sets the default to "unused". "always" works like "yes" did, "never" will not disable queueing, and "unused" will only disable queueing if nothing has the kpartx devices or the multipath device open. In order to be safe, if the device has queue_if_no_paths set (and in case of "unused", the device is in-use) the autoremove will be skipped. Also, instead of just trusting the lack of "queue_if_no_paths" in the current mpp->features, multipathd will tell the kernel to disable queueing, just to be sure it actually is. I chose "unused" as the default because this should generally only cause multipathd to work differently from the users perspective when nothing has the multipath device open but it is queueing and there is outstanding IO. Without this change, it would have hung instead of failing the outstanding IO. However, I do understand that an argument could be made that "never" makes more sense as default, even though it will cause multipathd to skip autoremoves in cases where it wouldn't before. The change to the behavior of deffered_remove will be noticeable, but skipping an autoremove is much better than hanging. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/defaults.h | 2 +- libmultipath/dict.c | 72 +++++++++++++++++++++++++++++++---- libmultipath/dict.h | 1 + libmultipath/hwtable.c | 6 +-- libmultipath/propsel.c | 4 +- libmultipath/structs.h | 7 ++-- multipath/multipath.conf.5.in | 20 +++++++--- multipathd/main.c | 39 +++++++++++++++---- 8 files changed, 122 insertions(+), 29 deletions(-) diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h index 64b633f2..ed08c251 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h @@ -43,7 +43,7 @@ #define DEFAULT_PRIO PRIO_CONST #define DEFAULT_PRIO_ARGS "" #define DEFAULT_CHECKER TUR -#define DEFAULT_FLUSH FLUSH_DISABLED +#define DEFAULT_FLUSH FLUSH_UNUSED #define DEFAULT_USER_FRIENDLY_NAMES USER_FRIENDLY_NAMES_OFF #define DEFAULT_FORCE_SYNC 0 #define UNSET_PARTITION_DELIM "/UNSET/" diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 5af036b7..546103f2 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -791,14 +791,70 @@ declare_def_snprint(checker_timeout, print_nonzero) declare_def_handler(allow_usb_devices, set_yes_no) declare_def_snprint(allow_usb_devices, print_yes_no) -declare_def_handler(flush_on_last_del, set_yes_no_undef) -declare_def_snprint_defint(flush_on_last_del, print_yes_no_undef, DEFAULT_FLUSH) -declare_ovr_handler(flush_on_last_del, set_yes_no_undef) -declare_ovr_snprint(flush_on_last_del, print_yes_no_undef) -declare_hw_handler(flush_on_last_del, set_yes_no_undef) -declare_hw_snprint(flush_on_last_del, print_yes_no_undef) -declare_mp_handler(flush_on_last_del, set_yes_no_undef) -declare_mp_snprint(flush_on_last_del, print_yes_no_undef) + +static const char * const flush_on_last_del_optvals[] = { + [FLUSH_NEVER] = "never", + [FLUSH_ALWAYS] = "always", + [FLUSH_UNUSED] = "unused", +}; + +static int +set_flush_on_last_del(vector strvec, void *ptr, const char *file, int line_nr) +{ + int i; + int *flush_val_ptr = (int *)ptr; + char *buff; + + buff = set_value(strvec); + if (!buff) + return 1; + + for (i = FLUSH_NEVER; i <= FLUSH_UNUSED; i++) { + if (flush_on_last_del_optvals[i] != NULL && + !strcmp(buff, flush_on_last_del_optvals[i])) { + *flush_val_ptr = i; + break; + } + } + + if (i > FLUSH_UNUSED) { + bool deprecated = true; + if (strcmp(buff, "no") == 0 || strcmp(buff, "0") == 0) + *flush_val_ptr = FLUSH_UNUSED; + else if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0) + *flush_val_ptr = FLUSH_ALWAYS; + else { + deprecated = false; + condlog(1, "%s line %d, invalid value for flush_on_last_del: \"%s\"", + file, line_nr, buff); + } + if (deprecated) + condlog(2, "%s line %d, \"%s\" is a deprecated value for flush_on_last_del and is treated as \"%s\"", + file, line_nr, buff, + flush_on_last_del_optvals[*flush_val_ptr]); + } + + free(buff); + return 0; +} + +int +print_flush_on_last_del(struct strbuf *buff, long v) +{ + if (v == FLUSH_UNDEF) + return 0; + return append_strbuf_quoted(buff, flush_on_last_del_optvals[(int)v]); +} + +declare_def_handler(flush_on_last_del, set_flush_on_last_del) +declare_def_snprint_defint(flush_on_last_del, print_flush_on_last_del, + DEFAULT_FLUSH) +declare_ovr_handler(flush_on_last_del, set_flush_on_last_del) +declare_ovr_snprint(flush_on_last_del, print_flush_on_last_del) +declare_hw_handler(flush_on_last_del, set_flush_on_last_del) +declare_hw_snprint(flush_on_last_del, print_flush_on_last_del) +declare_mp_handler(flush_on_last_del, set_flush_on_last_del) +declare_mp_snprint(flush_on_last_del, print_flush_on_last_del) declare_def_handler(user_friendly_names, set_yes_no_undef) declare_def_snprint_defint(user_friendly_names, print_yes_no_undef, diff --git a/libmultipath/dict.h b/libmultipath/dict.h index 7e2dfbe0..e1794537 100644 --- a/libmultipath/dict.h +++ b/libmultipath/dict.h @@ -18,4 +18,5 @@ int print_undef_off_zero(struct strbuf *buff, long v); int print_dev_loss(struct strbuf *buff, unsigned long v); int print_off_int_undef(struct strbuf *buff, long v); int print_auto_resize(struct strbuf *buff, long v); +int print_flush_on_last_del(struct strbuf *buff, long v); #endif /* _DICT_H */ diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c index 640bf347..ce600030 100644 --- a/libmultipath/hwtable.c +++ b/libmultipath/hwtable.c @@ -60,7 +60,7 @@ .no_path_retry = NO_PATH_RETRY_UNDEF, .minio = 1000, .minio_rq = 1, - .flush_on_last_del = FLUSH_DISABLED, + .flush_on_last_del = FLUSH_UNUSED, .user_friendly_names = USER_FRIENDLY_NAMES_OFF, .fast_io_fail = 5, .dev_loss = 600, @@ -829,7 +829,7 @@ static struct hwentry default_hw[] = { .no_path_retry = NO_PATH_RETRY_QUEUE, .pgpolicy = GROUP_BY_PRIO, .pgfailback = -FAILBACK_IMMEDIATE, - .flush_on_last_del = FLUSH_ENABLED, + .flush_on_last_del = FLUSH_ALWAYS, .dev_loss = MAX_DEV_LOSS_TMO, .prio_name = PRIO_ONTAP, .user_friendly_names = USER_FRIENDLY_NAMES_OFF, @@ -1160,7 +1160,7 @@ static struct hwentry default_hw[] = { .no_path_retry = NO_PATH_RETRY_FAIL, .minio = 1, .minio_rq = 1, - .flush_on_last_del = FLUSH_ENABLED, + .flush_on_last_del = FLUSH_ALWAYS, .fast_io_fail = 15, }, /* diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 44241e2a..e2dcb316 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -963,6 +963,7 @@ out: int select_flush_on_last_del(struct config *conf, struct multipath *mp) { const char *origin; + STRBUF_ON_STACK(buff); mp_set_mpe(flush_on_last_del); mp_set_ovr(flush_on_last_del); @@ -970,8 +971,9 @@ int select_flush_on_last_del(struct config *conf, struct multipath *mp) mp_set_conf(flush_on_last_del); mp_set_default(flush_on_last_del, DEFAULT_FLUSH); out: + print_flush_on_last_del(&buff, mp->flush_on_last_del); condlog(3, "%s: flush_on_last_del = %s %s", mp->alias, - (mp->flush_on_last_del == FLUSH_ENABLED)? "yes" : "no", origin); + get_strbuf_str(&buff), origin); return 0; } diff --git a/libmultipath/structs.h b/libmultipath/structs.h index a25eb9d5..dbaf4d43 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -109,9 +109,10 @@ enum marginal_pathgroups_mode { }; enum flush_states { - FLUSH_UNDEF = YNU_UNDEF, - FLUSH_DISABLED = YNU_NO, - FLUSH_ENABLED = YNU_YES, + FLUSH_UNDEF, + FLUSH_NEVER, + FLUSH_ALWAYS, + FLUSH_UNUSED, }; enum log_checker_err_states { diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in index b29a75fe..8cdb763f 100644 --- a/multipath/multipath.conf.5.in +++ b/multipath/multipath.conf.5.in @@ -707,12 +707,22 @@ The default is: \fBno\fR .TP .B flush_on_last_del If set to -.I yes +.I always , multipathd will disable queueing when the last path to a device has been -deleted. -.RS -.TP -The default is: \fBno\fR +deleted. If set to +.I never +, multipathd will not disable queueing when the last path to a device has +been deleted. Since multipath cannot safely remove a device while queueing +is enabled, setting this to \fInever\fR means that multipathd will not +automatically remove an unused multipath device whose paths are all deleted if +it is currently set to queue_if_no_path. If set to +.I unused +, multipathd will only disable queueing when the last path is removed if +nothing currently has the multipath device or any of the kpartx parition +devices on top of it open. +.RS +.TP +The default is: \fBunused\fR .RE . . diff --git a/multipathd/main.c b/multipathd/main.c index d8518a92..09286dd0 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -584,19 +584,42 @@ int update_multipath (struct vectors *vecs, char *mapname) static bool flush_map_nopaths(struct multipath *mpp, struct vectors *vecs) { int r; + bool is_queueing = true; + if (mpp->features) + is_queueing = strstr(mpp->features, "queue_if_no_path"); + + /* It's not safe to do a remove of a map that has "queue_if_no_path" + * set, since there could be outstanding IO which will cause + * multipathd to hang while attempting the remove */ + if (mpp->flush_on_last_del == FLUSH_NEVER && is_queueing) { + condlog(2, "%s: map is queueing, can't remove", mpp->alias); + return false; + } + if (mpp->flush_on_last_del == FLUSH_UNUSED && + partmap_in_use(mpp->alias, NULL) && is_queueing) { + condlog(2, "%s: map in use and queueing, can't remove", + mpp->alias); + return false; + } /* - * flush_map will fail if the device is open + * This will flush FLUSH_NEVER devices and FLUSH_UNUSED devices + * that are in use, but only if they are already marked as not + * queueing. That is just to make absolutely certain that they + * really are not queueing, like they claim. */ - if (mpp->flush_on_last_del == FLUSH_ENABLED) { - condlog(2, "%s Last path deleted, disabling queueing", + condlog(is_queueing ? 2 : 3, "%s Last path deleted, disabling queueing", + mpp->alias); + mpp->retry_tick = 0; + mpp->no_path_retry = NO_PATH_RETRY_FAIL; + mpp->disable_queueing = 1; + mpp->stat_map_failures++; + if (dm_queue_if_no_path(mpp, 0) != 0) { + condlog(0, "%s: failed to disable queueing. Not removing", mpp->alias); - mpp->retry_tick = 0; - mpp->no_path_retry = NO_PATH_RETRY_FAIL; - mpp->disable_queueing = 1; - mpp->stat_map_failures++; - dm_queue_if_no_path(mpp, 0); + return false; } + r = dm_flush_map_nopaths(mpp->alias, mpp->deferred_remove); if (r != DM_FLUSH_OK) { if (r == DM_FLUSH_DEFERRED) { From patchwork Thu Apr 25 23:35:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13644029 X-Patchwork-Delegate: christophe.varoqui@free.fr 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.subspace.kernel.org (Postfix) with ESMTPS id B7B32156644 for ; Thu, 25 Apr 2024 23:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088527; cv=none; b=ArGdviMXb5ZJfRiWWcMcVm1RzQHlJp8v/nM3hGtDjaXl9xfxDqqX5C9O/7WGRu0jxBdfTAAkUxLYICFuvufQroig2kGozuIUEpo5Kx4oDjryZxSAmlv+ky6ZKIHJFlKbNYazR1Z3FdasvQzr3XJxbHywwgCaF1ZGvlDGd5Hc9II= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088527; c=relaxed/simple; bh=vcWu1ogL4aTCQ5Y1lQbde87ZLW2YuM0ynwL7erz/PHM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P1aVPc7wKosa/oLvq0s7eBNMRRyDkzVj1k2O+KN9wpDUryvlDANk9jyCyTsMoRSOqVKJ1hdpx0KeBJ/399kHG3TAMLO4yOcYVfgxUZFGPEctsXjdulp0t6173glB73BrkoljLNh4zEiI86f8iroPaa2UGzQgps7zzGbaIrt5vNE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IvFKoiuF; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IvFKoiuF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714088524; h=from:from: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; bh=iWvY+fkQ8AcGz852NaJEvn6Dtlhi7RlgHgJnbLiql5c=; b=IvFKoiuFFfuueP13CNZOGMvCM8fMy4pU46GRmZUNwaS4Fnvz56Yh4maeIJK+O7aDQ8d6YW 1D16/DecTTEkjdhA74NVwk7UaVH9Mfs3AmaxX1ue6DiTJms74b/X81Mix6d7crEmUfhlLb VPi59FYpJ2cCzVhJCuTw+icrV9hp4Pc= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-0b8beepTPEqrIzQDVaNQgA-1; Thu, 25 Apr 2024 19:35:18 -0400 X-MC-Unique: 0b8beepTPEqrIzQDVaNQgA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63C5B385A18A; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D99F202450D; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1) with ESMTPS id 43PNZIvI2125168 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 19:35:18 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1/Submit) id 43PNZI402125167; Thu, 25 Apr 2024 19:35:18 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 3/5] libmultipath: remove redundant config option from InfiniBox config Date: Thu, 25 Apr 2024 19:35:15 -0400 Message-ID: <20240425233517.2125142-4-bmarzins@redhat.com> In-Reply-To: <20240425233517.2125142-1-bmarzins@redhat.com> References: <20240425233517.2125142-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com The InfiniBox config already sets no_path_retry to "fail", so it won't ever queue IO. That means setting flush_on_last_del to "always" is redundant, since queueing is always disabled. Remove the flush_on_last_del parameter, to make it easier for users to override the default behavior if desired. Signed-off-by: Benjamin Marzinski --- libmultipath/hwtable.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c index ce600030..51b15eab 100644 --- a/libmultipath/hwtable.c +++ b/libmultipath/hwtable.c @@ -1160,7 +1160,6 @@ static struct hwentry default_hw[] = { .no_path_retry = NO_PATH_RETRY_FAIL, .minio = 1, .minio_rq = 1, - .flush_on_last_del = FLUSH_ALWAYS, .fast_io_fail = 15, }, /* From patchwork Thu Apr 25 23:35:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13644018 X-Patchwork-Delegate: christophe.varoqui@free.fr 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.subspace.kernel.org (Postfix) with ESMTPS id 571B6156880 for ; Thu, 25 Apr 2024 23:35:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088124; cv=none; b=Db5xci8evuHMRoFhcg4r4SuslHK1DIY1q3+z19htRsjUhGpJo1tOALIFSWHjPejxDU/FVjEP6O0XdROBbTnlAfDsqri+C7GmboX2cId/7c64Zza3FsuI159IDVyIjFImS36ZLnF60sMACbZLkM8/Set9vex45S0fqhvFz0MTIUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088124; c=relaxed/simple; bh=gIXjVEdPkB9nUekpb545jMp0pgXNbz4sub5Vw0Zd5w0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DwOAh5p+ahnYJ+LuTa0QZubDJYUCkyn8THhlbKCvbPmcsJZGKEujuluuglV0spuIDfgBteHbfPugybP3PvJLII4XsIt+HdyJb902umjnLOx6xEOLCNyqfwq3MQdxti3SLBcxn5hSTdjFijHdC620CWoXXJjtytXmlUnBDCzWH24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=A13aCWqV; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A13aCWqV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714088122; h=from:from: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; bh=TTmObKnhDAkO7D9oRNftg3SlmH4jF6dOC1JFAV1IEVY=; b=A13aCWqVvdy1SQEzh/NzeVWgrlybW/bZhETWxparsoBTnqWlUT2w55j26I/AYJQO2nMBFu YmmfgwVBYG0Ok1bjelmVGwc0P+R8JjZaa4nS3SlTp+yLffDBjk7ApPsFGqqNemo/PRKKQW 8iLlgaDspaRxCIpmavVxnvX9noAOI1M= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-534-D_jyO-G4OOOGMiOPGr8aRw-1; Thu, 25 Apr 2024 19:35:19 -0400 X-MC-Unique: D_jyO-G4OOOGMiOPGr8aRw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8BC0E29AA385; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85084492BC7; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1) with ESMTPS id 43PNZIwJ2125172 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 19:35:18 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1/Submit) id 43PNZIN72125171; Thu, 25 Apr 2024 19:35:18 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 4/5] libmultipath: pad dev_loss_tmo to avoid race with no_path_retry Date: Thu, 25 Apr 2024 19:35:16 -0400 Message-ID: <20240425233517.2125142-5-bmarzins@redhat.com> In-Reply-To: <20240425233517.2125142-1-bmarzins@redhat.com> References: <20240425233517.2125142-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Currently multipath makes sure that dev_loss_tmo is at least as long as the configured no path queueing time. The goal is to make sure that path devices aren't removed while the multipath device is still queueing in hopes that they will become usable again. This is racy. Multipathd may take longer to check the paths than configured. If strict_timing isn't set, it will definitely take longer. To account for this, pad the minimum dev_loss_tmo value by five seconds (one default checker interval) plus one second per minute of no path queueing time. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/discovery.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 6fd4dabb..e2052422 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -901,6 +901,11 @@ sysfs_set_scsi_tmo (struct config *conf, struct multipath *mpp) uint64_t no_path_retry_tmo = (uint64_t)mpp->no_path_retry * conf->checkint; + /* pad no_path_retry_tmo by one standard check interval + * plus one second per minute to account for timing + * issues with the rechecks */ + no_path_retry_tmo += no_path_retry_tmo / 60 + DEFAULT_CHECKINT; + if (no_path_retry_tmo > MAX_DEV_LOSS_TMO) min_dev_loss = MAX_DEV_LOSS_TMO; else From patchwork Thu Apr 25 23:35:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 13644019 X-Patchwork-Delegate: christophe.varoqui@free.fr 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.subspace.kernel.org (Postfix) with ESMTPS id 4923B15696F for ; Thu, 25 Apr 2024 23:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088126; cv=none; b=Njt2sidjzbS4/Tx776GNv/VNh1D2EwPJ/VuSPgUbzAuFXZ0a6H/j4SnJCOU0rSs1853RgxSU+5kvOK45EPt1eljgmwd8gToChYEBi+tCxgzUCAdBenh2e8c1r16cp5ImIFp8TORf6g05ag1gOM2pqnzaB8M+C8/2pM0OJjBt78w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714088126; c=relaxed/simple; bh=NfmBLwkPLO6O022JwXSyhzIMSiM4O1p5qEZfUzAlEVQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OkoHrB2BaBd7BZrOs46qrMIA371BGFHSicRgnQCjsdG/w9Xx5e6/c8mFqcHtT5mLF7pYJOMV3ufmMTwX5r4+CGIV8/woQVhGBRDPUtfvNIitCmDkLVOsMjZvyaKKvK+eBTd0LIn/NGdVIkr24CBV8xH6YyyEOf8NU46kuZcEnW8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gc6kCrbD; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gc6kCrbD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714088123; h=from:from: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; bh=m+hd0NZRB+CFZQIzTqOQNRFb5OgKc5V4hkQrl2MDUSw=; b=gc6kCrbDfni1CtZkyDPbjkj3XFhOGZ7AhY+GYOV1Ofi8annB49gypr8mNcptzpB9lF1V6F M/tbmFgxle5CZptZGqj/9Qmns4rs4WLTrm5BmIaZ6a1pifw/gY115WHXO2dXk7pZwU79js VaF0yVqq/VJBrNKAk2R2kTMNZa1fxUY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-DQXrqLEGNUq4rRri0syHRg-1; Thu, 25 Apr 2024 19:35:19 -0400 X-MC-Unique: DQXrqLEGNUq4rRri0syHRg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5175804C61; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE912492BC7; Thu, 25 Apr 2024 23:35:18 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1) with ESMTPS id 43PNZIXw2125176 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 25 Apr 2024 19:35:18 -0400 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.17.1/8.17.1/Submit) id 43PNZIaA2125175; Thu, 25 Apr 2024 19:35:18 -0400 From: Benjamin Marzinski To: Christophe Varoqui Cc: device-mapper development , Martin Wilck Subject: [PATCH v2 5/5] libmultipath: fix deferred_remove function arguments Date: Thu, 25 Apr 2024 19:35:17 -0400 Message-ID: <20240425233517.2125142-6-bmarzins@redhat.com> In-Reply-To: <20240425233517.2125142-1-bmarzins@redhat.com> References: <20240425233517.2125142-1-bmarzins@redhat.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Aside from one version of dm_flush_map_nopaths(), all the callers of _dm_flush_map() and dm_simplecmd() set deferred_remove to 0. But these functions, as well as some helper functions they called, all treated the deferred_remove argument as an enum deferred_remove_states, and called do_deferred() to see if the remove should be deferred. To simplify the code, make these functions treat deferred_remove as a boolean value signifying whether a remove is deferred, and make dm_flush_map_nopaths() do the work of checking if the remove should be deferred. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 19 +++++++++---------- libmultipath/libmultipath.version | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index a87abf7e..2e7b2c64 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -386,8 +386,6 @@ libmp_dm_task_create(int task) return dm_task_create(task); } -#define do_deferred(x) ((x) == DEFERRED_REMOVE_ON || (x) == DEFERRED_REMOVE_IN_PROGRESS) - static int dm_simplecmd (int task, const char *name, int no_flush, int need_sync, uint16_t udev_flags, int deferred_remove __DR_UNUSED__) { @@ -411,7 +409,7 @@ dm_simplecmd (int task, const char *name, int no_flush, int need_sync, dm_task_no_flush(dmt); /* for DM_DEVICE_SUSPEND/RESUME */ #endif #ifdef LIBDM_API_DEFERRED - if (do_deferred(deferred_remove)) + if (deferred_remove) dm_task_deferred_remove(dmt); #endif if (udev_wait_flag && @@ -1082,7 +1080,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, /* If you aren't doing a deferred remove, make sure that no * devices are in use */ - if (!do_deferred(deferred_remove) && partmap_in_use(mapname, NULL)) + if (!deferred_remove && partmap_in_use(mapname, NULL)) return DM_FLUSH_BUSY; if (need_suspend && @@ -1100,7 +1098,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, if ((r = dm_remove_partmaps(mapname, need_sync, deferred_remove))) return r; - if (!do_deferred(deferred_remove) && dm_get_opencount(mapname)) { + if (!deferred_remove && dm_get_opencount(mapname)) { condlog(2, "%s: map in use", mapname); return DM_FLUSH_BUSY; } @@ -1112,8 +1110,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, r = dm_device_remove(mapname, need_sync, deferred_remove); if (r) { - if (do_deferred(deferred_remove) - && dm_map_present(mapname)) { + if (deferred_remove && dm_map_present(mapname)) { condlog(4, "multipath map %s remove deferred", mapname); return DM_FLUSH_DEFERRED; @@ -1147,7 +1144,10 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove, int dm_flush_map_nopaths(const char * mapname, int deferred_remove) { - return _dm_flush_map(mapname, 1, deferred_remove, 0, 0); + return _dm_flush_map(mapname, 1, + (deferred_remove == DEFERRED_REMOVE_ON || + deferred_remove == DEFERRED_REMOVE_IN_PROGRESS), + 0, 0); } #else @@ -1539,8 +1539,7 @@ remove_partmap(const char *name, void *data) if (dm_get_opencount(name)) { dm_remove_partmaps(name, rd->need_sync, rd->deferred_remove); - if (!do_deferred(rd->deferred_remove) && - dm_get_opencount(name)) { + if (rd->deferred_remove && dm_get_opencount(name)) { condlog(2, "%s: map in use", name); return DM_FLUSH_BUSY; } diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version index e070f296..eb511749 100644 --- a/libmultipath/libmultipath.version +++ b/libmultipath/libmultipath.version @@ -43,7 +43,7 @@ LIBMPATHCOMMON_1.0.0 { put_multipath_config; }; -LIBMULTIPATH_23.0.0 { +LIBMULTIPATH_24.0.0 { global: /* symbols referenced by multipath and multipathd */ add_foreign;