On Thu, 2023-11-02 at 18:15 -0400, Benjamin Marzinski wrote:
> This option gives multipathd the ability to automatically resize a
> device when it detects that all of the path devices have changed. By
> default it is set to never, and multipathd will continue to work like
> it
> always has, where a users must manually resize a multipath device.
> 
> Signed-off-by: Benjamin Marzinski <[email protected]>
> ---
>  libmultipath/config.c         |  2 ++
>  libmultipath/config.h         |  3 +++
>  libmultipath/configure.c      |  1 +
>  libmultipath/defaults.h       |  1 +
>  libmultipath/dict.c           | 48
> +++++++++++++++++++++++++++++++++++
>  libmultipath/dict.h           |  1 +
>  libmultipath/hwtable.c        |  1 +
>  libmultipath/propsel.c        | 17 +++++++++++++
>  libmultipath/propsel.h        |  1 +
>  libmultipath/structs.h        |  8 ++++++
>  multipath/multipath.conf.5.in | 16 ++++++++++++
>  multipathd/main.c             | 24 +++++++++++++++++-
>  12 files changed, 122 insertions(+), 1 deletion(-)
> 
> diff --git a/libmultipath/config.c b/libmultipath/config.c
> index 9d90f512..e6024955 100644
> --- a/libmultipath/config.c
> +++ b/libmultipath/config.c
> @@ -464,6 +464,7 @@ merge_hwe (struct hwentry * dst, struct hwentry *
> src)
>       merge_num(ghost_delay);
>       merge_num(all_tg_pt);
>       merge_num(recheck_wwid);
> +     merge_num(auto_resize);

Why make this a hardware-specific option? Isn't it sufficient to just
set this in the defaults section? I can hardly imagine users wanting
auto-resize for one array and not for another.

Other than that, looks good to me (one nit below).

Martin


> diff --git a/multipath/multipath.conf.5.in
> b/multipath/multipath.conf.5.in
> index 41f3927e..c90383cf 100644
> --- a/multipath/multipath.conf.5.in
> +++ b/multipath/multipath.conf.5.in
> @@ -1333,6 +1333,22 @@ The default is: \fBno\fR
>  .
>  .
>  .TP
> +.B auto_resize
> +Controls when multipathd will automatically resize a multipath
> device.  If set
> +to \fInever\fR, multipath devices must always be manually resized by
> either
> +running \fBmultipathd resize map <name>\fR or \fRmultipath -r
> <name>\fR.  If

I suggest not mentioning "multipath -r" here.

> +set to \fIgrow_only\fR, when multipathd detects that all of a
> multipath
> +device's paths have increased in size, it will automatically grow
> the multipath
> +device to the new size. If set to \fIgrow_shrink\fR, multipathd will
> also
> +automatically shrink the device once it detects all of its paths
> have decreased
> +in size.
> +.RS
> +.TP
> +The default is: \fBnever\fR
> +.RE
> +.
> +.
> +.TP
>  .B enable_foreign
>  Enables or disables foreign libraries (see section
>  .I FOREIGN MULTIPATH SUPPORT
> diff --git a/multipathd/main.c b/multipathd/main.c
> index 3b4c5b09..ac733491 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -1633,7 +1633,6 @@ uev_update_path (struct uevent *uev, struct
> vectors * vecs)
>               ro = uevent_get_disk_ro(uev);
>               if (needs_ro_update(mpp, ro)) {
>                       condlog(2, "%s: update path write_protect to
> '%d' (uevent)", uev->kernel, ro);
> -
>                       if (mpp->wait_for_udev)
>                               mpp->wait_for_udev = 2;
>                       else {
> @@ -1648,6 +1647,29 @@ uev_update_path (struct uevent *uev, struct
> vectors * vecs)
>                               }
>                       }
>               }
> +             if (mpp->auto_resize != AUTO_RESIZE_NEVER &&
> +                 !mpp->wait_for_udev) {
> +                     struct pathgroup *pgp;
> +                     struct path *pp2;
> +                     unsigned int i, j;
> +                     unsigned long long orig_size = mpp->size;
> +
> +                     if (!pp->size || pp->size == mpp->size ||
> +                            (pp->size < mpp->size &&

There's a whitespace issue here (space indentation).

> +                          mpp->auto_resize ==
> AUTO_RESIZE_GROW_ONLY))
> +                             goto out;
> +
> +                     vector_foreach_slot(mpp->pg, pgp, i)
> +                             vector_foreach_slot (pgp->paths,
> pp2, j)
> +                                     if (pp2->size && pp2->size
> != pp->size)
> +                                             goto out;
> +                     retval = resize_map(mpp, pp->size, vecs);
> +                     if (retval == 2)
> +                             condlog(2, "%s: map removed during
> resize", pp->dev);
> +                     else if (retval == 0)
> +                             condlog(2, "%s: resized map from
> %llu to %llu",
> +                                     mpp->alias, orig_size, pp-
> >size);
> +             }
>       }
>  out:
>       lock_cleanup_pop(vecs->lock);


Reply via email to