multipath-tools: check null path before handle path-failed event
diff mbox

Message ID 1512393350-2956-1-git-send-email-guanjunxiong@huawei.com
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show

Commit Message

Guan Junxiong Dec. 4, 2017, 1:15 p.m. UTC
In the hot-plug storage OS, if we tear down the target storage,
there is a race between the path removing from the path list and
handling the path-failed udev event. Therefore, we need to check
null path before handle path-failed event.

Signed-off-by: Guan Junxiong <guanjunxiong@huawei.com>
---
 multipathd/main.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Christophe Varoqui Jan. 13, 2018, 9:11 a.m. UTC | #1
Merged.
Thanks.

On Mon, Dec 4, 2017 at 2:15 PM, Guan Junxiong <guanjunxiong@huawei.com>
wrote:

> In the hot-plug storage OS, if we tear down the target storage,
> there is a race between the path removing from the path list and
> handling the path-failed udev event. Therefore, we need to check
> null path before handle path-failed event.
>
> Signed-off-by: Guan Junxiong <guanjunxiong@huawei.com>
> ---
>  multipathd/main.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/multipathd/main.c b/multipathd/main.c
> index 31ce923..84bb2c5 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -1073,7 +1073,7 @@ uev_pathfail_check(struct uevent *uev, struct
> vectors *vecs)
>  {
>         char *action = NULL, *devt = NULL;
>         struct path *pp;
> -       int r;
> +       int r = 1;
>
>         action = uevent_get_dm_action(uev);
>         if (!action)
> @@ -1090,15 +1090,17 @@ uev_pathfail_check(struct uevent *uev, struct
> vectors *vecs)
>         lock(&vecs->lock);
>         pthread_testcancel();
>         pp = find_path_by_devt(vecs->pathvec, devt);
> +    if (!pp)
> +        goto out_lock;
>         r = io_err_stat_handle_pathfail(pp);
> -       lock_cleanup_pop(vecs->lock);
> -
>         if (r)
>                 condlog(3, "io_err_stat: %s: cannot handle pathfail
> uevent",
>                                 pp->dev);
> +out_lock:
> +       lock_cleanup_pop(vecs->lock);
>         FREE(devt);
>         FREE(action);
> -       return 0;
> +       return r;
>  out:
>         FREE(action);
>         return 1;
> --
> 2.6.4.windows.1
>
>
>
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

Patch
diff mbox

diff --git a/multipathd/main.c b/multipathd/main.c
index 31ce923..84bb2c5 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1073,7 +1073,7 @@  uev_pathfail_check(struct uevent *uev, struct vectors *vecs)
 {
 	char *action = NULL, *devt = NULL;
 	struct path *pp;
-	int r;
+	int r = 1;
 
 	action = uevent_get_dm_action(uev);
 	if (!action)
@@ -1090,15 +1090,17 @@  uev_pathfail_check(struct uevent *uev, struct vectors *vecs)
 	lock(&vecs->lock);
 	pthread_testcancel();
 	pp = find_path_by_devt(vecs->pathvec, devt);
+    if (!pp)
+        goto out_lock;
 	r = io_err_stat_handle_pathfail(pp);
-	lock_cleanup_pop(vecs->lock);
-
 	if (r)
 		condlog(3, "io_err_stat: %s: cannot handle pathfail uevent",
 				pp->dev);
+out_lock:
+	lock_cleanup_pop(vecs->lock);
 	FREE(devt);
 	FREE(action);
-	return 0;
+	return r;
 out:
 	FREE(action);
 	return 1;