public inbox for dm-devel@redhat.com
 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>
Subject: Re: [PATCH 03/21] multipathd: free paths in checker_finished()
Date: Thu, 18 Dec 2025 18:34:10 -0500	[thread overview]
Message-ID: <aUSPcsNAzvD5rj4M@redhat.com> (raw)
In-Reply-To: <20251217212113.234959-4-mwilck@suse.com>

On Wed, Dec 17, 2025 at 10:20:55PM +0100, Martin Wilck wrote:
> Modifying the pathvec in a deep call stack is unexpected and
> error-prone. Free paths in the checkerloop instead, after
> having synced all maps.

I'm not fond of the fact that this leaves paths around, when callers
expect that the path will be removed. For instance, right now
cli_add_path() and uev_add_path() can call ev_remove_path to handle
INIT_REMOVED paths, and expect that success means the path is removed.
They can end up storing duplicate paths with this code.

What do you think about having calls to ev_remove_path() actually remove
the path if multipath device successfully orphans it. All the callers
of that function already expect that it likely will remove the path, and
that means that whenever multipathd is explicitly told to remove a path,
it will, if it can. If it can't, then the path was always going to get
removed later, and delaying that later incidental remove till the next
path check shouldn't make much difference.

-Ben
 
> Suggested-by: Benjamin Marzinski <bmarzins@redhat.com>
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  libmultipath/libmultipath.version | 1 +
>  libmultipath/structs_vec.c        | 7 +++----
>  libmultipath/structs_vec.h        | 1 +
>  multipathd/main.c                 | 1 +
>  4 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version
> index 89ae2a3..e5b7b83 100644
> --- a/libmultipath/libmultipath.version
> +++ b/libmultipath/libmultipath.version
> @@ -58,6 +58,7 @@ global:
>  	change_foreign;
>  	check_alias_settings;
>  	check_daemon;
> +	check_removed_paths;
>  	checker_clear_message;
>  	checker_disable;
>  	checker_enable;
> diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
> index f651b29..3a9ab58 100644
> --- a/libmultipath/structs_vec.c
> +++ b/libmultipath/structs_vec.c
> @@ -573,16 +573,16 @@ static struct path *find_devt_in_pathgroups(const struct multipath *mpp,
>  	return NULL;
>  }
>  
> -static void check_removed_paths(const struct multipath *mpp, vector pathvec)
> +void check_removed_paths(vector pathvec)
>  {
>  	struct path *pp;
>  	int i;
>  
>  	vector_foreach_slot(pathvec, pp, i) {
> -		if (pp->mpp == mpp &&
> +		if (pp->mpp &&
>  		    (pp->initialized == INIT_REMOVED ||
>  		     pp->initialized == INIT_PARTIAL) &&
> -		    !find_devt_in_pathgroups(mpp, pp->dev_t)) {
> +		    !find_devt_in_pathgroups(pp->mpp, pp->dev_t)) {
>  			condlog(2, "%s: %s: freeing path in %s state",
>  				__func__, pp->dev,
>  				pp->initialized == INIT_REMOVED ?
> @@ -615,7 +615,6 @@ void sync_paths(struct multipath *mpp, vector pathvec)
>  			orphan_path(pp, "path removed externally");
>  		}
>  	}
> -	check_removed_paths(mpp, pathvec);
>  	update_mpp_paths(mpp, pathvec);
>  	vector_foreach_slot (mpp->paths, pp, i)
>  		pp->mpp = mpp;
> diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h
> index 1188ada..cb02d75 100644
> --- a/libmultipath/structs_vec.h
> +++ b/libmultipath/structs_vec.h
> @@ -18,6 +18,7 @@ int adopt_paths (vector pathvec, struct multipath *mpp,
>  void orphan_path (struct path * pp, const char *reason);
>  void set_path_removed(struct path *pp);
>  
> +void check_removed_paths(vector pathvec);
>  int verify_paths(struct multipath *mpp);
>  int update_mpp_paths(struct multipath * mpp, vector pathvec);
>  int update_multipath_strings (struct multipath *mpp, vector pathvec);
> diff --git a/multipathd/main.c b/multipathd/main.c
> index d3bf4d0..49a1f25 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -3127,6 +3127,7 @@ static void checker_finished(struct vectors *vecs, unsigned int ticks)
>  	}
>  	if (uev_timed_out && !need_to_delay_reconfig(vecs))
>  		unblock_reconfigure();
> +	check_removed_paths(vecs->pathvec);
>  	partial_retrigger_tick(vecs->pathvec);
>  }
>  
> -- 
> 2.52.0


  reply	other threads:[~2025-12-18 23:34 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17 21:20 [PATCH 00/21] Multipath-tools: various bug fixes Martin Wilck
2025-12-17 21:20 ` [PATCH 01/21] libmultipath: drop drop_multipath Martin Wilck
2025-12-17 21:20 ` [PATCH 02/21] libmultipath: don't access path members in free_pgvec() Martin Wilck
2025-12-17 21:20 ` [PATCH 03/21] multipathd: free paths in checker_finished() Martin Wilck
2025-12-18 23:34   ` Benjamin Marzinski [this message]
2025-12-18 23:40     ` Martin Wilck
2025-12-19 10:38       ` Martin Wilck
2025-12-17 21:20 ` [PATCH 04/21] libmultipath: don't touch mpvec in remove_map() Martin Wilck
2025-12-17 21:20 ` [PATCH 05/21] libmpathutil: constify find_slot() Martin Wilck
2025-12-17 21:20 ` [PATCH 06/21] libmultipath: don't free paths in orphan_paths() Martin Wilck
2025-12-17 21:20 ` [PATCH 07/21] libmultipath: free orphaned paths in check_removed_paths() Martin Wilck
2025-12-17 21:21 ` [PATCH 08/21] libmultipath: remove free_paths argument from free_pathgroup() Martin Wilck
2025-12-17 21:21 ` [PATCH 09/21] libmultipath: fix numeric value of free_paths in free_multipaths() Martin Wilck
2025-12-19  0:10   ` Benjamin Marzinski
2025-12-17 21:21 ` [PATCH 10/21] libmultipath: remove free_paths argument from free_pgvec() Martin Wilck
2025-12-17 21:21 ` [PATCH 11/21] libmultipath: remove free_paths argument from free_multipathvec() Martin Wilck
2025-12-17 21:21 ` [PATCH 12/21] libmultipath: free_multipath: fix FREE_PATHS case Martin Wilck
2025-12-19  0:15   ` Benjamin Marzinski
2025-12-17 21:21 ` [PATCH 13/21] multipath-tools: Fix ISO C23 errors with strchr() Martin Wilck
2025-12-17 21:21 ` [PATCH 14/21] libmultipath: simplify sysfs_get_target_nodename() Martin Wilck
2025-12-17 21:21 ` [PATCH 15/21] multipathd: join the init_unwinder dummy thread Martin Wilck
2025-12-17 21:21 ` [PATCH 16/21] kpartx: fix some memory leaks Martin Wilck
2025-12-17 21:21 ` [PATCH 17/21] libmpathutil: use union for bitfield Martin Wilck
2025-12-19  0:17   ` Benjamin Marzinski
2025-12-19  8:08     ` Martin Wilck
2025-12-17 21:21 ` [PATCH 18/21] libmpathutil: add wrapper code for libudev Martin Wilck
2025-12-19  0:38   ` Benjamin Marzinski
2025-12-19  8:06     ` Martin Wilck
2025-12-19 17:27       ` Benjamin Marzinski
2025-12-17 21:21 ` [PATCH 19/21] multipath-tools: use the libudev wrapper functions Martin Wilck
2025-12-17 21:21 ` [PATCH 20/21] Makefile: add functionality to determine cmocka version Martin Wilck
2025-12-17 21:21 ` [PATCH 21/21] multipath-tools tests: adaptations for cmocka 2.0 Martin Wilck
2025-12-19  0:40 ` [PATCH 00/21] 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=aUSPcsNAzvD5rj4M@redhat.com \
    --to=bmarzins@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox