Skip to contentSkip to conversation

libmultipath: assign variable to make gcc happy

PATCH Superseded Benjamin Marzinski 2 participants 12 messages Mar 24, 2020 – Jul 3, 2020 Device mapper

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/3 libmultipath: assign variable to make gcc happy

There is nothing wrong with is_queueing not being set at the start of __set_no_path_retry(), it will always get set before it is accessed, but gcc 8.2.1 is failing with

structs_vec.c: In function ‘__set_no_path_retry’:
structs_vec.c:339:7: error: ‘is_queueing’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

  bool is_queueing;
       ^~~~~~~~~~~

so, assign a value to make it happy.

---
 libmultipath/structs_vec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/structs_vec.c +1 -1
index 3dbbaa0f..077f2e42 100644
@@ -336,7 +336,7 @@ static void leave_recovery_mode(struct multipath *mpp)
 
 void __set_no_path_retry(struct multipath *mpp, bool check_features)
 {
-	bool is_queueing;
+	bool is_queueing = false; /* assign a value to make gcc happy */
 
 	check_features = check_features && mpp->features != NULL;
 	if (check_features)
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
author maintainer
#1 lore raw

PATCH 2/3 libmutipath: don't close fd on dm_lib_release

If dm_hold_control_open() isn't set, when dm_lib_release() is called, it will close the control fd. The control fd will get re-opened on the next dm_task_run() call, but if there is a dm_task_run() call already in progress in another thread, it can fail. Since many of the device-mapper callouts happen with the vecs lock held, this wasn't too noticeable, but there is code that calls dm_task_run() without the vecs lock held, notably the dmevent waiter code.

---
 libmultipath/devmapper.c | 1 +
 1 file changed, 1 insertion(+)
libmultipath/devmapper.c +1 -0
index bed8ddc6..d96472fe 100644
@@ -254,6 +254,7 @@ void libmp_dm_init(void)
 	memcpy(conf->version, version, sizeof(version));
 	put_multipath_config(conf);
 	dm_init(verbosity);
+	dm_hold_control_dev(1);
 	dm_udev_set_sync_support(libmp_dm_udev_sync);
 }
 
Signature · 1 line
2.17.2
#2 lore raw

Re: [PATCH 2/3] libmutipath: don't close fd on dm_lib_release

Quoted 21 lines · Benjamin Marzinski

If dm_hold_control_open() isn't set, when dm_lib_release() is called, it
will close the control fd. The control fd will get re-opened on the next
dm_task_run() call, but if there is a dm_task_run() call already in progress in another thread, it can fail. Since many of the device-mapper callouts happen with the vecs lock held, this wasn't too
noticeable, but there is code that calls dm_task_run() without the vecs lock held, notably the dmevent waiter code.

---
 libmultipath/devmapper.c | 1 +
 1 file changed, 1 insertion(+)
libmultipath/devmapper.c +0 -0
index bed8ddc6..d96472fe 100644

libmultipath/devmapper.c void libmp_dm_init(void) · line 259

Quoted 6 lines
libmultipath/devmapper.c +1 -0
@@ -254,6 +254,7 @@ void libmp_dm_init(void)
 	memcpy(conf->version, version, sizeof(version));
 	put_multipath_config(conf);
 	dm_init(verbosity);
+	dm_hold_control_dev(1);
 	dm_udev_set_sync_support(libmp_dm_udev_sync);
 }

AFAICS, this function has been in libdm since 1.02.111. We support 1.02.89 (if all features enabled, otherwise even older). Perhaps we should make this function call conditional on the libdm verson?

But perhaps more importantly, why do we still need to call dm_lib_release()? AFAICS it's only needed for systems that have no udev support for creating device nodes (to call update_devs() via dm_lib_release()), and we don't support that anymore anyway, do we?

Since 26c4bb0, we're always setting the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag, and the cookie, too (we aren't setting it for DM_DEVICE_RELOAD, but it isn't needed for that, either, since no device nodes need to be created or removed); so dm_lib_release() should really have no effect.

Regards
Martin

Signature · 4 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer
author maintainer
#3 lore raw

Re: [PATCH 2/3] libmutipath: don't close fd on dm_lib_release

Quoted 38 lines · Martin Wilck
Quoted 21 lines · Benjamin Marzinski

If dm_hold_control_open() isn't set, when dm_lib_release() is called, it
will close the control fd. The control fd will get re-opened on the next
dm_task_run() call, but if there is a dm_task_run() call already in progress in another thread, it can fail. Since many of the device-mapper callouts happen with the vecs lock held, this wasn't too
noticeable, but there is code that calls dm_task_run() without the vecs lock held, notably the dmevent waiter code.

---
 libmultipath/devmapper.c | 1 +
 1 file changed, 1 insertion(+)
libmultipath/devmapper.c +0 -0
index bed8ddc6..d96472fe 100644

libmultipath/devmapper.c void libmp_dm_init(void) · line 259

Quoted 6 lines
libmultipath/devmapper.c +1 -0
@@ -254,6 +254,7 @@ void libmp_dm_init(void)
 	memcpy(conf->version, version, sizeof(version));
 	put_multipath_config(conf);
 	dm_init(verbosity);
+	dm_hold_control_dev(1);
 	dm_udev_set_sync_support(libmp_dm_udev_sync);
 }

AFAICS, this function has been in libdm since 1.02.111. We support 1.02.89 (if all features enabled, otherwise even older). Perhaps we should make this function call conditional on the libdm verson?

But perhaps more importantly, why do we still need to call dm_lib_release()? AFAICS it's only needed for systems that have no udev support for creating device nodes (to call update_devs() via dm_lib_release()), and we don't support that anymore anyway, do we?

Quoted 8 lines

Since 26c4bb0, we're always setting the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag, and the cookie, too (we aren't setting it for DM_DEVICE_RELOAD, but it isn't needed for that, either, since no device nodes need to be created or removed); so dm_lib_release() should really have no effect.

Regards
Martin

Good call. I'll redo this patch.

-Ben

Quoted 7 lines
Signature · 5 lines
-- 
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer
author maintainer
#4 lore raw

Re: [PATCH 2/3] libmutipath: don't close fd on dm_lib_release

Quoted 18 lines · Benjamin Marzinski
Quoted 17 lines · Martin Wilck

On Tue, 2020-03-24 at 16:03 -0500, Benjamin Marzinski wrote:

AFAICS, this function has been in libdm since 1.02.111. We support 1.02.89 (if all features enabled, otherwise even older). Perhaps we should make this function call conditional on the libdm verson?

But perhaps more importantly, why do we still need to call dm_lib_release()? AFAICS it's only needed for systems that have no udev support for creating device nodes (to call update_devs() via dm_lib_release()), and we don't support that anymore anyway, do we?

Since 26c4bb0, we're always setting the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag, and the cookie, too (we aren't setting it for DM_DEVICE_RELOAD, but it isn't needed for that, either, since no device nodes need to be created or removed); so dm_lib_release() should really have no effect.

Quoted 4 lines
Quoted 2 lines

Regards
Martin

Good call. I'll redo this patch.

Actually, I've changed my mind. Calling dm_lib_release() lets us release the memory that device-mapper uses to store all the node ops that it was saving up. Without calling dm_lib_release(), AFAICS, that memory keeps growing until the daemon exits.

-Ben

Quoted 14 lines

-Ben

Quoted 7 lines
Signature · 5 lines
-- 
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#5 lore raw

Re: [PATCH 2/3] libmutipath: don't close fd on dm_lib_release

Quoted 28 lines · Benjamin Marzinski
Quoted 27 lines · Benjamin Marzinski
Quoted 25 lines · Martin Wilck

On Tue, 2020-03-24 at 16:03 -0500, Benjamin Marzinski wrote:

AFAICS, this function has been in libdm since 1.02.111. We support
1.02.89 (if all features enabled, otherwise even older). Perhaps we
should make this function call conditional on the libdm verson?

But perhaps more importantly, why do we still need to call dm_lib_release()? AFAICS it's only needed for systems that have no udev
support for creating device nodes (to call update_devs() via dm_lib_release()), and we don't support that anymore anyway, do we?

Since 26c4bb0, we're always setting the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag, and the cookie, too (we aren't setting it for DM_DEVICE_RELOAD, but it isn't needed for
that, either, since no device nodes need to be created or removed); so
dm_lib_release() should really have no effect.

Regards
Martin

Quoted 7 lines
Quoted 1 line

Good call. I'll redo this patch.

Actually, I've changed my mind. Calling dm_lib_release() lets us release
the memory that device-mapper uses to store all the node ops that it was saving up. Without calling dm_lib_release(), AFAICS, that memory keeps growing until the daemon exits.

Ok, I see. libdm stacks the node ops, even if it's told to rely on udev. The question is, what for, as it will discard the stacked nodes later on anyway.

Fine, then. But please add a check for the libdm version.

Thanks,
Martin

Signature · 4 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer
#6 lore raw

Re: [PATCH 2/3] libmutipath: don't close fd on dm_lib_release

In reply to Benjamin Marzinski
Quoted 28 lines · Benjamin Marzinski
Quoted 27 lines · Benjamin Marzinski
Quoted 25 lines · Martin Wilck

On Tue, 2020-03-24 at 16:03 -0500, Benjamin Marzinski wrote:

AFAICS, this function has been in libdm since 1.02.111. We support
1.02.89 (if all features enabled, otherwise even older). Perhaps we
should make this function call conditional on the libdm verson?

But perhaps more importantly, why do we still need to call dm_lib_release()? AFAICS it's only needed for systems that have no udev
support for creating device nodes (to call update_devs() via dm_lib_release()), and we don't support that anymore anyway, do we?

Since 26c4bb0, we're always setting the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag, and the cookie, too (we aren't setting it for DM_DEVICE_RELOAD, but it isn't needed for
that, either, since no device nodes need to be created or removed); so
dm_lib_release() should really have no effect.

Regards
Martin

Quoted 7 lines
Quoted 1 line

Good call. I'll redo this patch.

Actually, I've changed my mind. Calling dm_lib_release() lets us release
the memory that device-mapper uses to store all the node ops that it was saving up. Without calling dm_lib_release(), AFAICS, that memory keeps growing until the daemon exits.

Sorry for coming back to this so late. I've just stared at the libdm code again.

We always set DM_UDEV_DISABLE_LIBRARY_FALLBACK. In the standard CREATE and REMOVE cases, libdm doesn't stack any operations if this flag is set. The only exceptions are

a) RESUME operations with DM_ADD_NODE_ON_RESUME set. This happens
implicity when we create new maps
b) RENAME operations

In both cases, we call dm_udev_wait() after the libdm operation, which calls update_devs() and should thus have the same effect as dm_lib_release(). IOW, I still believe we don't need to call dm_lib_release() any more.

Regards,
Martin

Signature · 4 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer
author maintainer
#7 lore raw

Re: [PATCH 2/3] libmutipath: don't close fd on dm_lib_release

Quoted 44 lines · Martin Wilck
Quoted 28 lines · Benjamin Marzinski
Quoted 27 lines · Benjamin Marzinski
Quoted 25 lines · Martin Wilck

On Tue, 2020-03-24 at 16:03 -0500, Benjamin Marzinski wrote:

AFAICS, this function has been in libdm since 1.02.111. We support
1.02.89 (if all features enabled, otherwise even older). Perhaps we
should make this function call conditional on the libdm verson?

But perhaps more importantly, why do we still need to call dm_lib_release()? AFAICS it's only needed for systems that have no udev
support for creating device nodes (to call update_devs() via dm_lib_release()), and we don't support that anymore anyway, do we?

Since 26c4bb0, we're always setting the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag, and the cookie, too (we aren't setting it for DM_DEVICE_RELOAD, but it isn't needed for
that, either, since no device nodes need to be created or removed); so
dm_lib_release() should really have no effect.

Regards
Martin

Quoted 7 lines
Quoted 1 line

Good call. I'll redo this patch.

Actually, I've changed my mind. Calling dm_lib_release() lets us release
the memory that device-mapper uses to store all the node ops that it was saving up. Without calling dm_lib_release(), AFAICS, that memory keeps growing until the daemon exits.

Sorry for coming back to this so late. I've just stared at the libdm code again.

We always set DM_UDEV_DISABLE_LIBRARY_FALLBACK. In the standard CREATE and REMOVE cases, libdm doesn't stack any operations if this flag is set. The only exceptions are

Quoted 8 lines

a) RESUME operations with DM_ADD_NODE_ON_RESUME set. This happens
implicity when we create new maps
b) RENAME operations

In both cases, we call dm_udev_wait() after the libdm operation, which calls update_devs() and should thus have the same effect as dm_lib_release(). IOW, I still believe we don't need to call dm_lib_release() any more.

Sure. But can we leave this patch as is, and remove those calls in a different patch?

-Ben

Quoted 9 lines

Regards,
Martin

Signature · 4 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer
#8 lore raw

Re: [PATCH 2/3] libmutipath: don't close fd on dm_lib_release

Quoted 60 lines · Benjamin Marzinski
Quoted 59 lines · Martin Wilck
Quoted 36 lines · Benjamin Marzinski
Quoted 29 lines · Benjamin Marzinski
Quoted 28 lines · Martin Wilck

On Tue, 2020-03-24 at 16:03 -0500, Benjamin Marzinski wrote:

AFAICS, this function has been in libdm since 1.02.111. We support
1.02.89 (if all features enabled, otherwise even older). Perhaps
we
should make this function call conditional on the libdm verson?

But perhaps more importantly, why do we still need to call dm_lib_release()? AFAICS it's only needed for systems that have
no udev
support for creating device nodes (to call update_devs() via dm_lib_release()), and we don't support that anymore anyway, do
we?

Since 26c4bb0, we're always setting the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag, and the cookie, too (we aren't setting it for DM_DEVICE_RELOAD, but it isn't needed
for
that, either, since no device nodes need to be created or removed); so
dm_lib_release() should really have no effect.

Quoted 4 lines
Quoted 2 lines

Regards
Martin

Good call. I'll redo this patch.

Quoted 7 lines

Actually, I've changed my mind. Calling dm_lib_release() lets us release
the memory that device-mapper uses to store all the node ops that it
was saving up. Without calling dm_lib_release(), AFAICS, that memory
keeps growing until the daemon exits.

Sorry for coming back to this so late. I've just stared at the libdm
code again.

We always set DM_UDEV_DISABLE_LIBRARY_FALLBACK. In the standard CREATE
and REMOVE cases, libdm doesn't stack any operations if this flag is
set. The only exceptions are

a) RESUME operations with DM_ADD_NODE_ON_RESUME set. This happens
implicity when we create new maps
b) RENAME operations

Quoted 8 lines
Quoted 5 lines

In both cases, we call dm_udev_wait() after the libdm operation, which
calls update_devs() and should thus have the same effect as dm_lib_release(). IOW, I still believe we don't need to call dm_lib_release() any more.

Sure. But can we leave this patch as is, and remove those calls in a different patch?

Of course. It's not important, either. I just wanted to make sure we agree on the technical side.

Regards
Martin

Signature · 4 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer
author maintainer
#9 lore raw

PATCH 3/3 libmultipath: allow force reload with no active paths

In reply to Benjamin Marzinski

If the partition information has changed on multipath devices (say, because it was updated on another node that has access to the same storage), users expect that running "multipathd reconfigure" will update that. However, if the checkers for the multipath device are pending for too long when the the device is reconfigured, multipathd will give up waiting for them, and refuse to reload the device, since there are no active paths. This means that no kpartx update will be triggered.

Multipath is fully capable of reloading a multipath device that has no active paths. This has been possible for years. If multipath is supposed to reload the device, it should do so, even if there are no active paths.

Generally, when multipath is force reloaded, kpartx will be updated. However when a device is reloaded with no paths, the udev rules won't run kpartx. But they also weren't running kpartx when the first valid path appeared, even though the dm activation rules get run in this case. This changes 11-dm-mpath.rules to run kpartx when a device goes from no usable paths to having usable paths.

---
 libmultipath/configure.c    | 6 ------
 multipath/11-dm-mpath.rules | 2 +-
 2 files changed, 1 insertion(+), 7 deletions(-)
libmultipath/configure.c +0 -6
index c95848a0..96c79610 100644
@@ -710,12 +710,6 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
 		return;
 	}
 
-	if (pathcount(mpp, PATH_UP) == 0) {
-		mpp->action = ACT_IMPOSSIBLE;
-		condlog(3, "%s: set ACT_IMPOSSIBLE (no usable path)",
-			mpp->alias);
-		return;
-	}
 	if (force_reload) {
 		mpp->force_udev_reload = 1;
 		mpp->action = ACT_RELOAD;
multipath/11-dm-mpath.rules +1 -1
index 07320a14..cd522e8c 100644
@@ -75,7 +75,7 @@ ENV{MPATH_DEVICE_READY}=="0", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
 ENV{MPATH_DEVICE_READY}!="0", ENV{.MPATH_DEVICE_READY_OLD}=="0",\
 	ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}",\
 	ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="",\
-	ENV{DM_ACTIVATION}="1"
+	ENV{DM_ACTIVATION}="1", ENV{MPATH_UNCHANGED}="0"
 
 # The code to check multipath state ends here. We need to set
 # properties and symlinks regardless whether the map is usable or
Signature · 1 line
2.17.2
Reviewed-by on v1 3/3
#10 lore raw

Re: [PATCH 3/3] libmultipath: allow force reload with no active paths

Quoted 27 lines · Benjamin Marzinski

If the partition information has changed on multipath devices (say, because it was updated on another node that has access to the same storage), users expect that running "multipathd reconfigure" will update
that. However, if the checkers for the multipath device are pending for
too long when the the device is reconfigured, multipathd will give up waiting for them, and refuse to reload the device, since there are no active paths. This means that no kpartx update will be triggered.

Multipath is fully capable of reloading a multipath device that has no
active paths. This has been possible for years. If multipath is supposed
to reload the device, it should do so, even if there are no active paths.

Generally, when multipath is force reloaded, kpartx will be updated. However when a device is reloaded with no paths, the udev rules won't run kpartx. But they also weren't running kpartx when the first valid
path appeared, even though the dm activation rules get run in this case.
This changes 11-dm-mpath.rules to run kpartx when a device goes from no
usable paths to having usable paths.

Quoted 5 lines
---
 libmultipath/configure.c    | 6 ------
 multipath/11-dm-mpath.rules | 2 +-
 2 files changed, 1 insertion(+), 7 deletions(-)
Signature · 4 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer
Reviewed-by on v1 1/3
#11 lore raw
In reply to Benjamin Marzinski
Quoted 12 lines · Benjamin Marzinski

There is nothing wrong with is_queueing not being set at the start of __set_no_path_retry(), it will always get set before it is accessed,
but gcc 8.2.1 is failing with

structs_vec.c: In function ‘__set_no_path_retry’:
structs_vec.c:339:7: error: ‘is_queueing’ may be used uninitialized in
this function [-Werror=maybe-uninitialized]

  bool is_queueing;
       ^~~~~~~~~~~
Quoted 6 lines

so, assign a value to make it happy.

---
 libmultipath/structs_vec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

That actually looks like a gcc bug to me. Anyway:

Signature · 11 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107
SUSE  Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer



--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel