* [PATCH] Take undef enum into account for correct array index comparison
@ 2025-08-17 19:49 Alex Kalenyuk
2025-08-18 17:19 ` Benjamin Marzinski
0 siblings, 1 reply; 3+ messages in thread
From: Alex Kalenyuk @ 2025-08-17 19:49 UTC (permalink / raw)
To: dm-devel; +Cc: bmarzins, mwilck
Previously this would compare to the wrong index
since the enum has an additional UNDEF entry
Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
---
libmultipath/dict.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
index a06a6138..2e820b2e 100644
--- a/libmultipath/dict.c
+++ b/libmultipath/dict.c
@@ -550,6 +550,7 @@ static int snprint_def_partition_delim(struct config *conf, struct strbuf *buff,
}
static const char * const find_multipaths_optvals[] = {
+ [FIND_MULTIPATHS_UNDEF] = "undef",
[FIND_MULTIPATHS_OFF] = "off",
[FIND_MULTIPATHS_ON] = "on",
[FIND_MULTIPATHS_STRICT] = "strict",
@@ -793,6 +794,7 @@ declare_def_snprint(allow_usb_devices, print_yes_no)
static const char * const flush_on_last_del_optvals[] = {
+ [FLUSH_UNDEF] = "undef",
[FLUSH_NEVER] = "never",
[FLUSH_ALWAYS] = "always",
[FLUSH_UNUSED] = "unused",
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Take undef enum into account for correct array index comparison
2025-08-17 19:49 [PATCH] Take undef enum into account for correct array index comparison Alex Kalenyuk
@ 2025-08-18 17:19 ` Benjamin Marzinski
2025-08-19 7:14 ` Alex Kalenyuk
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Marzinski @ 2025-08-18 17:19 UTC (permalink / raw)
To: Alex Kalenyuk; +Cc: dm-devel, mwilck
On Sun, Aug 17, 2025 at 10:49:23PM +0300, Alex Kalenyuk wrote:
> Previously this would compare to the wrong index
> since the enum has an additional UNDEF entry
Are you actually seeing multipath getting misconfigured here, because
the code doesn't look wrong to me. We didn't and the "undef" elements
because we don't want to accept "undef" as a valid value from the config
file.
This code is admittedly a little confusing. We aren't looping from 0 to
the last value, we are looping from FIND_MULTIPATHS_OFF or FLUSH_NEVER
(which have the value of 1). The way the loop works, we won't even check
the config text against the array elements you added. We intentionally
only set elements in those arrays at the values we want to start
checking at: FIND_MULTIPATHS_OFF and FLUSH_NEVER. As long as the text in
the optvals array is correct for the value we are using as its index, if
we match the config text with the optvals text, 'i' must be equal to the
value we want (since the value we want is array index of the matching
text).
If you are seeing a configuration issue, we do want to hear about it.
I'm not saying there isn't a bug, but unless I'm missing something, I
don't think that this is it. Also multipath's configuration priority
isn't always super intuitive, so sometimes it is working as designed,
but not you might intuitively expect.
-Ben
>
> Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
> ---
> libmultipath/dict.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/libmultipath/dict.c b/libmultipath/dict.c
> index a06a6138..2e820b2e 100644
> --- a/libmultipath/dict.c
> +++ b/libmultipath/dict.c
> @@ -550,6 +550,7 @@ static int snprint_def_partition_delim(struct config *conf, struct strbuf *buff,
> }
>
> static const char * const find_multipaths_optvals[] = {
> + [FIND_MULTIPATHS_UNDEF] = "undef",
> [FIND_MULTIPATHS_OFF] = "off",
> [FIND_MULTIPATHS_ON] = "on",
> [FIND_MULTIPATHS_STRICT] = "strict",
> @@ -793,6 +794,7 @@ declare_def_snprint(allow_usb_devices, print_yes_no)
>
>
> static const char * const flush_on_last_del_optvals[] = {
> + [FLUSH_UNDEF] = "undef",
> [FLUSH_NEVER] = "never",
> [FLUSH_ALWAYS] = "always",
> [FLUSH_UNUSED] = "unused",
> --
> 2.50.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Take undef enum into account for correct array index comparison
2025-08-18 17:19 ` Benjamin Marzinski
@ 2025-08-19 7:14 ` Alex Kalenyuk
0 siblings, 0 replies; 3+ messages in thread
From: Alex Kalenyuk @ 2025-08-19 7:14 UTC (permalink / raw)
To: Benjamin Marzinski; +Cc: dm-devel, mwilck
You're totally right, I had an older multipath running on my system,
and I did not realize (only yes/no in flush_last_del).
This commit can be safely ignored, everything is working as expected, thank you!
On Mon, Aug 18, 2025 at 8:19 PM Benjamin Marzinski <bmarzins@redhat.com> wrote:
>
> On Sun, Aug 17, 2025 at 10:49:23PM +0300, Alex Kalenyuk wrote:
> > Previously this would compare to the wrong index
> > since the enum has an additional UNDEF entry
>
> Are you actually seeing multipath getting misconfigured here, because
> the code doesn't look wrong to me. We didn't and the "undef" elements
> because we don't want to accept "undef" as a valid value from the config
> file.
>
> This code is admittedly a little confusing. We aren't looping from 0 to
> the last value, we are looping from FIND_MULTIPATHS_OFF or FLUSH_NEVER
> (which have the value of 1). The way the loop works, we won't even check
> the config text against the array elements you added. We intentionally
> only set elements in those arrays at the values we want to start
> checking at: FIND_MULTIPATHS_OFF and FLUSH_NEVER. As long as the text in
> the optvals array is correct for the value we are using as its index, if
> we match the config text with the optvals text, 'i' must be equal to the
> value we want (since the value we want is array index of the matching
> text).
>
> If you are seeing a configuration issue, we do want to hear about it.
> I'm not saying there isn't a bug, but unless I'm missing something, I
> don't think that this is it. Also multipath's configuration priority
> isn't always super intuitive, so sometimes it is working as designed,
> but not you might intuitively expect.
>
> -Ben
>
> >
> > Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
> > ---
> > libmultipath/dict.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/libmultipath/dict.c b/libmultipath/dict.c
> > index a06a6138..2e820b2e 100644
> > --- a/libmultipath/dict.c
> > +++ b/libmultipath/dict.c
> > @@ -550,6 +550,7 @@ static int snprint_def_partition_delim(struct config *conf, struct strbuf *buff,
> > }
> >
> > static const char * const find_multipaths_optvals[] = {
> > + [FIND_MULTIPATHS_UNDEF] = "undef",
> > [FIND_MULTIPATHS_OFF] = "off",
> > [FIND_MULTIPATHS_ON] = "on",
> > [FIND_MULTIPATHS_STRICT] = "strict",
> > @@ -793,6 +794,7 @@ declare_def_snprint(allow_usb_devices, print_yes_no)
> >
> >
> > static const char * const flush_on_last_del_optvals[] = {
> > + [FLUSH_UNDEF] = "undef",
> > [FLUSH_NEVER] = "never",
> > [FLUSH_ALWAYS] = "always",
> > [FLUSH_UNUSED] = "unused",
> > --
> > 2.50.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-19 7:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-17 19:49 [PATCH] Take undef enum into account for correct array index comparison Alex Kalenyuk
2025-08-18 17:19 ` Benjamin Marzinski
2025-08-19 7:14 ` Alex Kalenyuk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).