From: Benjamin Marzinski <bmarzins@redhat.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@lists.linux.dev>,
Martin Wilck <Martin.Wilck@suse.com>
Subject: [PATCH v2 5/5] libmultipath: fix deferred_remove function arguments
Date: Thu, 25 Apr 2024 19:35:17 -0400 [thread overview]
Message-ID: <20240425233517.2125142-6-bmarzins@redhat.com> (raw)
In-Reply-To: <20240425233517.2125142-1-bmarzins@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 <bmarzins@redhat.com>
---
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;
--
2.43.0
next prev parent reply other threads:[~2024-04-25 23:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-25 23:35 [PATCH v2 0/5] multipath: fix hang in flush_map_nopaths Benjamin Marzinski
2024-04-25 23:35 ` [PATCH v2 1/5] libmultipath: export partmap_in_use Benjamin Marzinski
2024-04-25 23:35 ` [PATCH v2 2/5] libmultipath: change flush_on_last_del to fix a multipathd hang Benjamin Marzinski
2024-04-30 17:06 ` Martin Wilck
2024-04-30 21:29 ` Benjamin Marzinski
2024-05-02 8:36 ` Martin Wilck
2024-05-02 15:06 ` Martin Wilck
2024-04-25 23:35 ` [PATCH v2 3/5] libmultipath: remove redundant config option from InfiniBox config Benjamin Marzinski
2024-04-25 23:35 ` [PATCH v2 4/5] libmultipath: pad dev_loss_tmo to avoid race with no_path_retry Benjamin Marzinski
2024-05-02 15:14 ` Martin Wilck
2024-05-02 16:05 ` Benjamin Marzinski
2024-05-02 18:44 ` Martin Wilck
2024-04-25 23:35 ` Benjamin Marzinski [this message]
2024-05-02 15:52 ` [PATCH v2 5/5] libmultipath: fix deferred_remove function arguments Martin Wilck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240425233517.2125142-6-bmarzins@redhat.com \
--to=bmarzins@redhat.com \
--cc=Martin.Wilck@suse.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).