All of lore.kernel.org
 help / color / mirror / Atom feed
* [dm-devel] [PATCH] libmultipath: add path wildcard "%I" for init state
@ 2021-11-05 11:03 mwilck
  2021-11-05 23:04 ` Benjamin Marzinski
  0 siblings, 1 reply; 2+ messages in thread
From: mwilck @ 2021-11-05 11:03 UTC (permalink / raw)
  To: Christophe Varoqui, Benjamin Marzinski; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

Enable printing pp->initialized with 'multipathd show paths format "%I"'.
This is supposed to go on top of Ben's "multipathd: remove udev settle 
dependency" series, to simplify checking multipathd's state.

---
 libmultipath/print.c   | 21 +++++++++++++++++++++
 libmultipath/structs.h |  1 +
 2 files changed, 22 insertions(+)

diff --git a/libmultipath/print.c b/libmultipath/print.c
index 2fb9f4e..b5b9905 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -504,6 +504,26 @@ snprint_dm_path_state (struct strbuf *buff, const struct path * pp)
 	}
 }
 
+static int snprint_initialized(struct strbuf *buff, const struct path * pp)
+{
+	static const char *init_state_name[] = {
+		[INIT_NEW] = "new",
+		[INIT_FAILED] = "failed",
+		[INIT_MISSING_UDEV] = "udev-missing",
+		[INIT_REQUESTED_UDEV] = "udev-requested",
+		[INIT_OK] = "ok",
+		[INIT_REMOVED] = "removed",
+		[INIT_PARTIAL] = "partial",
+	};
+	const char *str;
+
+	if (pp->initialized < INIT_NEW || pp->initialized >= __INIT_LAST)
+		str = "undef";
+	else
+		str = init_state_name[pp->initialized];
+	return append_strbuf_str(buff, str);
+}
+
 static int
 snprint_vpr (struct strbuf *buff, const struct path * pp)
 {
@@ -804,6 +824,7 @@ struct path_data pd[] = {
 	{'g', "vpd page data", 0, snprint_path_vpd_data},
 	{'0', "failures",      0, snprint_path_failures},
 	{'P', "protocol",      0, snprint_path_protocol},
+	{'I', "init_st",       0, snprint_initialized},
 	{0, NULL, 0 , NULL}
 };
 
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index 69409fd..d8c24b5 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -206,6 +206,7 @@ enum initialized_states {
 	 * change uevent is received.
 	 */
 	INIT_PARTIAL,
+	__INIT_LAST,
 };
 
 enum prkey_sources {
-- 
2.33.1


--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [dm-devel] [PATCH] libmultipath: add path wildcard "%I" for init state
  2021-11-05 11:03 [dm-devel] [PATCH] libmultipath: add path wildcard "%I" for init state mwilck
@ 2021-11-05 23:04 ` Benjamin Marzinski
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Marzinski @ 2021-11-05 23:04 UTC (permalink / raw)
  To: mwilck; +Cc: dm-devel

On Fri, Nov 05, 2021 at 12:03:12PM +0100, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> 
> Enable printing pp->initialized with 'multipathd show paths format "%I"'.
> This is supposed to go on top of Ben's "multipathd: remove udev settle 
> dependency" series, to simplify checking multipathd's state.
> 
> ---
>  libmultipath/print.c   | 21 +++++++++++++++++++++
>  libmultipath/structs.h |  1 +
>  2 files changed, 22 insertions(+)
> 
> diff --git a/libmultipath/print.c b/libmultipath/print.c
> index 2fb9f4e..b5b9905 100644
> --- a/libmultipath/print.c
> +++ b/libmultipath/print.c
> @@ -504,6 +504,26 @@ snprint_dm_path_state (struct strbuf *buff, const struct path * pp)
>  	}
>  }
>  
> +static int snprint_initialized(struct strbuf *buff, const struct path * pp)
> +{
> +	static const char *init_state_name[] = {
> +		[INIT_NEW] = "new",
> +		[INIT_FAILED] = "failed",
> +		[INIT_MISSING_UDEV] = "udev-missing",
> +		[INIT_REQUESTED_UDEV] = "udev-requested",
> +		[INIT_OK] = "ok",
> +		[INIT_REMOVED] = "removed",
> +		[INIT_PARTIAL] = "partial",
> +	};
> +	const char *str;
> +
> +	if (pp->initialized < INIT_NEW || pp->initialized >= __INIT_LAST)
> +		str = "undef";
> +	else
> +		str = init_state_name[pp->initialized];
> +	return append_strbuf_str(buff, str);
> +}
> +
>  static int
>  snprint_vpr (struct strbuf *buff, const struct path * pp)
>  {
> @@ -804,6 +824,7 @@ struct path_data pd[] = {
>  	{'g', "vpd page data", 0, snprint_path_vpd_data},
>  	{'0', "failures",      0, snprint_path_failures},
>  	{'P', "protocol",      0, snprint_path_protocol},
> +	{'I', "init_st",       0, snprint_initialized},
>  	{0, NULL, 0 , NULL}
>  };
>  
> diff --git a/libmultipath/structs.h b/libmultipath/structs.h
> index 69409fd..d8c24b5 100644
> --- a/libmultipath/structs.h
> +++ b/libmultipath/structs.h
> @@ -206,6 +206,7 @@ enum initialized_states {
>  	 * change uevent is received.
>  	 */
>  	INIT_PARTIAL,
> +	__INIT_LAST,
>  };
>  
>  enum prkey_sources {
> -- 
> 2.33.1

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-05 23:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05 11:03 [dm-devel] [PATCH] libmultipath: add path wildcard "%I" for init state mwilck
2021-11-05 23:04 ` Benjamin Marzinski

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.