diff mbox

[6/9] multipathd: drop lock before calling uev_add_path

Message ID 1491545798-22183-7-git-send-email-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show

Commit Message

Benjamin Marzinski April 7, 2017, 6:16 a.m. UTC
commit c6a18f4541d0a161e2f5fed8c67d9732bf512b37 made uev_update_path
call uev_add_path while holding the vecs lock, which is deadlocks, since
uev_add_path grabs the vecs lock itself.

Cc: Alban Browaeys <prahal@yahoo.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 multipathd/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Alban Browaeys April 7, 2017, 1:23 p.m. UTC | #1
Le vendredi 07 avril 2017 à 01:16 -0500, Benjamin Marzinski a écrit :
> commit c6a18f4541d0a161e2f5fed8c67d9732bf512b37 made uev_update_path
> call uev_add_path while holding the vecs lock, which is deadlocks,
> since
> uev_add_path grabs the vecs lock itself.
> 
> Cc: Alban Browaeys <prahal@yahoo.com>
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>  multipathd/main.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/multipathd/main.c b/multipathd/main.c
> index f671d58..f4ff13e 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -974,6 +974,7 @@ uev_update_path (struct uevent *uev, struct
> vectors * vecs)
>  	struct path * pp;
>  	struct config *conf;
>  	int disable_changed_wwids;
> +	int needs_reinit = 0;
>  
>  	conf = get_multipath_config();
>  	disable_changed_wwids = conf->disable_changed_wwids;
> @@ -1009,7 +1010,7 @@ uev_update_path (struct uevent *uev, struct
> vectors * vecs)
>  		}
>  
>  		if (pp->initialized == INIT_REQUESTED_UDEV)
> -			retval = uev_add_path(uev, vecs, 1);
> +			needs_reinit = 1;
>  		else if (mpp && ro >= 0) {
>  			condlog(2, "%s: update path write_protect to
> '%d' (uevent)", uev->kernel, ro);
>  
> @@ -1041,7 +1042,8 @@ out:
>  
>  		condlog(0, "%s: spurious uevent, path not found",
> uev->kernel);
>  	}
> -
> +	if (needs_reinit)
> +		retval = uev_add_path(uev, vecs, 1);
>  	return retval;
>  }


Thanks a lot. 
The patch fixes the hang in multipathd.
I made a minor modification for the test as I test above multipath-
tools 0.6.4. 
I stripped the need_do_map parameter from uev_add_path.

Thanks
Alban

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

diff --git a/multipathd/main.c b/multipathd/main.c
index f671d58..f4ff13e 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -974,6 +974,7 @@  uev_update_path (struct uevent *uev, struct vectors * vecs)
 	struct path * pp;
 	struct config *conf;
 	int disable_changed_wwids;
+	int needs_reinit = 0;
 
 	conf = get_multipath_config();
 	disable_changed_wwids = conf->disable_changed_wwids;
@@ -1009,7 +1010,7 @@  uev_update_path (struct uevent *uev, struct vectors * vecs)
 		}
 
 		if (pp->initialized == INIT_REQUESTED_UDEV)
-			retval = uev_add_path(uev, vecs, 1);
+			needs_reinit = 1;
 		else if (mpp && ro >= 0) {
 			condlog(2, "%s: update path write_protect to '%d' (uevent)", uev->kernel, ro);
 
@@ -1041,7 +1042,8 @@  out:
 
 		condlog(0, "%s: spurious uevent, path not found", uev->kernel);
 	}
-
+	if (needs_reinit)
+		retval = uev_add_path(uev, vecs, 1);
 	return retval;
 }