On Wed, Dec 17, 2025 at 10:21:01PM +0100, Martin Wilck wrote:
> free_paths is an enum, use the enum value.

I think free_multipath() should always keep the paths. It only doesn't
in cleanup_multipath_and_paths(), which is used in two places, and is
wrong in one and unnecessary in the other. check_usable_paths() could
just use cleanup_multipath(). The paths will be added to the pathvec by
update_multipath_table__(), and we can clean that up with a cleanup
handler that calls free_pathvec(). In add_map_without_path() using
cleanup_multipath_and_paths() is just wrong. We don't want it to free
all the paths. Instead it should orphan the paths before calling
free_multipath(). That will flag paths that need to get removed for
removing, but it won't actually free paths that are in the pathvec
(without removing them from the pathvec, to make matters worse).
 
> Signed-off-by: Martin Wilck <[email protected]>
> ---
>  libmultipath/structs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libmultipath/structs.c b/libmultipath/structs.c
> index aaa7e50..059d454 100644
> --- a/libmultipath/structs.c
> +++ b/libmultipath/structs.c
> @@ -310,7 +310,7 @@ free_multipath (struct multipath * mpp, enum 
> free_path_mode free_paths)
>               mpp->alias = NULL;
>       }
>  
> -     if (!free_paths && mpp->pg) {
> +     if (free_paths == KEEP_PATHS && mpp->pg) {
>               struct pathgroup *pgp;
>               struct path *pp;
>               int i, j;
> -- 
> 2.52.0


Reply via email to