[dm-devel] [PATCH v3 86/87] libmultipath: adopt_paths(): set pp->mpp only on success
Benjamin Marzinski
bmarzins at redhat.com
Wed Aug 19 22:15:52 UTC 2020
On Wed, Aug 19, 2020 at 03:18:18PM +0200, mwilck at suse.com wrote:
> From: Martin Wilck <mwilck at suse.com>
>
> Make sure that pp->mpp is only set for paths that have been
> successfully added to mpp->paths.
>
> Suggested-by: Benjamin Marzinki <bmarzins at redhat.com>
Reviewed-by: Benjamin Marzinski <bmarzins at redhat.com>
> Signed-off-by: Martin Wilck <mwilck at suse.com>
> ---
> libmultipath/structs_vec.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
> index 2d85df9..cc2dafa 100644
> --- a/libmultipath/structs_vec.c
> +++ b/libmultipath/structs_vec.c
> @@ -248,14 +248,10 @@ int adopt_paths(vector pathvec, struct multipath *mpp)
> pp->dev, mpp->alias);
> continue;
> }
> - pp->mpp = mpp;
> if (pp->initialized == INIT_REMOVED)
> continue;
> - condlog(3, "%s: ownership set to %s",
> - pp->dev, mpp->alias);
> -
> if (!mpp->paths && !(mpp->paths = vector_alloc()))
> - return 1;
> + goto err;
>
> conf = get_multipath_config();
> pthread_cleanup_push(put_multipath_config, conf);
> @@ -270,10 +266,17 @@ int adopt_paths(vector pathvec, struct multipath *mpp)
>
> if (!find_path_by_devt(mpp->paths, pp->dev_t) &&
> store_path(mpp->paths, pp))
> - return 1;
> + goto err;
> +
> + pp->mpp = mpp;
> + condlog(3, "%s: ownership set to %s",
> + pp->dev, mpp->alias);
> }
> }
> return 0;
> +err:
> + condlog(1, "error setting ownership of %s to %s", pp->dev, mpp->alias);
> + return 1;
> }
>
> void orphan_path(struct path *pp, const char *reason)
> --
> 2.28.0
More information about the dm-devel
mailing list