All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Marzinski <bmarzins@redhat.com>
To: Martin Wilck <martin.wilck@suse.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>,
	dm-devel@lists.linux.dev, Martin Wilck <mwilck@suse.com>,
	Benjamin Marzinski <bmarzins@suse.com>
Subject: Re: [PATCH v2 14/26] multipathd: add_map_without_path(): orphan paths instead of freeing them
Date: Fri, 19 Dec 2025 23:23:23 -0500	[thread overview]
Message-ID: <aUYkuzmyuntUhEvk@redhat.com> (raw)
In-Reply-To: <20251219144108.237928-15-mwilck@suse.com>

On Fri, Dec 19, 2025 at 03:40:56PM +0100, Martin Wilck wrote:
> If add_map_without_path() fails to set up the multipath data structures,
> don't free the paths associated with the map as
> cleanup_multipath_and_paths() would; just orphan the paths.
> update_pathvec_from_dm() will handle the paths and see if they
> need to be removed.
> 
> Suggested-by: Benjamin Marzinski <bmarzins@suse.com>
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  multipathd/main.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/multipathd/main.c b/multipathd/main.c
> index c03546b..7b522e8 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -771,8 +771,8 @@ fail:
>  
>  static int add_map_without_path (struct vectors *vecs, const char *alias)
>  {
> -	struct multipath __attribute__((cleanup(cleanup_multipath_and_paths)))
> -		*mpp = alloc_multipath();
> +	struct multipath __attribute__((cleanup(cleanup_multipath))) *mpp =
> +		alloc_multipath();
>  	char __attribute__((cleanup(cleanup_charp))) *params = NULL;
>  	char __attribute__((cleanup(cleanup_charp))) *status = NULL;
>  	struct config *conf;
> @@ -802,11 +802,13 @@ static int add_map_without_path (struct vectors *vecs, const char *alias)
>  	mpp->mpe = find_mpe(conf->mptable, mpp->wwid);
>  	put_multipath_config(conf);
>  
> -	if ((rc = update_multipath_table__(mpp, vecs->pathvec, 0, params, status)) != DMP_OK)
> +	if (update_multipath_table__(mpp, vecs->pathvec, 0, params, status) != DMP_OK ||
> +	    !vector_alloc_slot(vecs->mpvec)) {
> +		orphan_paths(vecs->pathvec, mpp, "failed to add map");
>  		return DMP_ERR;

I'm not sure we should just call orphan_paths() after we call
update_multipath_table__(). If we hit a cancellation point in the middle
of update_multipath_table__(), we want to fully orphan any paths that
got added to the device before we cancelled.  Perhaps the easiest way to
solve this is to make cleanup_multipath_and_paths() loop through all the
path in mpp->pg and orphan them before calling free_multipath(). We
shouldn't need to search through the entire pathvec here. Since this
multipath device was just created, the only paths that could have
pp->mpp set to this device will be in mpp->pg.

-Ben

> +	}
>  
> -	if (!vector_alloc_slot(vecs->mpvec))
> -		return DMP_ERR;
> +	/* Make sure mpp is not cleaned up on return */
>  	vector_set_slot(vecs->mpvec, steal_ptr(mpp));
>  
>  	/*
> -- 
> 2.52.0


  parent reply	other threads:[~2025-12-20  4:23 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-19 14:40 [PATCH v2 00/26] Multipath-tools: various bug fixes Martin Wilck
2025-12-19 14:40 ` [PATCH v2 01/26] libmultipath: drop drop_multipath Martin Wilck
2025-12-19 14:40 ` [PATCH v2 02/26] libmultipath: don't access path members in free_pgvec() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 03/26] libmpathutil: constify find_slot() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 04/26] libmultipath: don't touch mpvec in remove_map() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 05/26] libmultipath: export orphan_paths() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 06/26] libmultipath: export cleanup_multipath() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 07/26] libmultipath: add cleanup_pathvec_and_free_paths() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 08/26] libmultipath: don't free paths in orphan_paths() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 09/26] multipathd: free orphaned paths in checker_finished() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 10/26] libmultipath: remove free_paths argument from free_pathgroup() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 11/26] libmultipath: remove free_paths argument from free_pgvec() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 12/26] libmultipath: remove free_paths argument from free_multipathvec() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 13/26] multipath: free paths through pathvec in check_usable_paths() Martin Wilck
2025-12-20  4:19   ` Benjamin Marzinski
2026-01-05 14:38     ` Martin Wilck
2025-12-19 14:40 ` [PATCH v2 14/26] multipathd: add_map_without_path(): orphan paths instead of freeing them Martin Wilck
2025-12-19 14:46   ` Martin Wilck
2025-12-20  4:23   ` Benjamin Marzinski [this message]
2026-01-05 15:15     ` Martin Wilck
2026-01-05 23:17       ` Benjamin Marzinski
2026-01-06 10:31         ` Martin Wilck
2025-12-19 14:40 ` [PATCH v2 15/26] libmultipath: remove free_paths argument from free_multipath() Martin Wilck
2025-12-19 14:40 ` [PATCH v2 16/26] libmultipath: remove cleanup_multipath_and_paths() Martin Wilck
2025-12-20  4:26   ` Benjamin Marzinski
2025-12-19 14:40 ` [PATCH v2 17/26] libmultipaths: annotate functions that may free paths Martin Wilck
2025-12-20  4:35   ` Benjamin Marzinski
2025-12-19 14:41 ` [PATCH v2 18/26] multipath-tools: Fix ISO C23 errors with strchr() Martin Wilck
2025-12-19 14:41 ` [PATCH v2 19/26] libmultipath: simplify sysfs_get_target_nodename() Martin Wilck
2025-12-19 14:41 ` [PATCH v2 20/26] multipathd: join the init_unwinder dummy thread Martin Wilck
2025-12-19 14:41 ` [PATCH v2 21/26] kpartx: fix some memory leaks Martin Wilck
2025-12-19 14:41 ` [PATCH v2 22/26] libmpathutil: use union for bitfield Martin Wilck
2025-12-19 14:41 ` [PATCH v2 23/26] libmpathutil: add wrapper code for libudev Martin Wilck
2025-12-19 14:41 ` [PATCH v2 24/26] multipath-tools: use the libudev wrapper functions Martin Wilck
2025-12-19 14:41 ` [PATCH v2 25/26] Makefile: add functionality to determine cmocka version Martin Wilck
2025-12-19 14:41 ` [PATCH v2 26/26] multipath-tools tests: adaptations for cmocka 2.0 Martin Wilck
2025-12-20  4:41 ` [PATCH v2 00/26] Multipath-tools: various bug fixes Benjamin Marzinski

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=aUYkuzmyuntUhEvk@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=bmarzins@suse.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=martin.wilck@suse.com \
    --cc=mwilck@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.