<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="Osso Notes">
<title></title></head>
<body>
<p>Hi Ben,
<br>
<br>Do you mind if I merge this output to the 'show status' command output ?
<br>
<br>----- Message d'origine -----
<br>> This adds a new multipathd command, "count paths". which returns information in
<br>> the format
<br>>
<br>> Paths: <nr_of_paths>
<br>> Busy: <True|False>
<br>>
<br>> where "Paths" is the number of monitored paths, and "Busy" is set when
<br>> multipathd is currently handling uevents. With this, it is possible to quickly
<br>> get the number of paths being monitored, as well as an idea if more paths may
<br>> be showing up shortly.
<br>>
<br>> Signed-off-by: Benjamin Marzinski <<a href="mailto:bmarzins@redhat.com">bmarzins@redhat.com</a>>
<br>> ---
<br>> libmultipath/uevent.c | 8 ++++++++
<br>> libmultipath/uevent.h | 1 +
<br>> multipathd/cli.c | 2 ++
<br>> multipathd/cli.h | 2 ++
<br>> multipathd/cli_handlers.c | 33 +++++++++++++++++++++++++++++++++
<br>> multipathd/cli_handlers.h | 1 +
<br>> multipathd/main.c | 1 +
<br>> multipathd/multipathd.8 | 4 ++++
<br>> 8 files changed, 52 insertions(+)
<br>>
<br>> Index: multipath-tools-100510/libmultipath/uevent.c
<br>> ===================================================================
<br>> --- multipath-tools-100510.orig/libmultipath/uevent.c
<br>> +++ multipath-tools-100510/libmultipath/uevent.c
<br>> @@ -52,6 +52,12 @@ pthread_mutex_t uevc_lock, *uevc_lockp =
<br>> pthread_cond_t uev_cond, *uev_condp = &uev_cond;
<br>> uev_trigger *my_uev_trigger;
<br>> void * my_trigger_data;
<br>> +int servicing_uev;
<br>> +
<br>> +int is_uevent_busy(void)
<br>> +{
<br>> + return (uevqhp != NULL || servicing_uev);
<br>> +}
<br>>
<br>> static struct uevent * alloc_uevent (void)
<br>> {
<br>> @@ -96,7 +102,9 @@ uevq_thread(void * et)
<br>>
<br>> while (1) {
<br>> pthread_mutex_lock(uevc_lockp);
<br>> + servicing_uev = 0;
<br>> pthread_cond_wait(uev_condp, uevc_lockp);
<br>> + servicing_uev = 1;
<br>> pthread_mutex_unlock(uevc_lockp);
<br>>
<br>> service_uevq();
<br>> Index: multipath-tools-100510/libmultipath/uevent.h
<br>> ===================================================================
<br>> --- multipath-tools-100510.orig/libmultipath/uevent.h
<br>> +++ multipath-tools-100510/libmultipath/uevent.h
<br>> @@ -17,3 +17,4 @@ struct uevent {
<br>>
<br>> int uevent_listen(int (*store_uev)(struct uevent *, void * trigger_data),
<br>> void * trigger_data);
<br>> +int is_uevent_busy(void);
<br>> Index: multipath-tools-100510/multipathd/cli.c
<br>> ===================================================================
<br>> --- multipath-tools-100510.orig/multipathd/cli.c
<br>> +++ multipath-tools-100510/multipathd/cli.c
<br>> @@ -174,6 +174,7 @@ load_keys (void)
<br>> r += add_key(keys, "devices", DEVICES, 0);
<br>> r += add_key(keys, "format", FMT, 1);
<br>> r += add_key(keys, "wildcards", WILDCARDS, 0);
<br>> + r += add_key(keys, "count", COUNT, 0);
<br>> r += add_key(keys, "quit", QUIT, 0);
<br>> r += add_key(keys, "exit", QUIT, 0);
<br>>
<br>> @@ -443,6 +444,7 @@ cli_init (void) {
<br>> add_handler(RESTOREQ+MAPS, NULL);
<br>> add_handler(REINSTATE+PATH, NULL);
<br>> add_handler(FAIL+PATH, NULL);
<br>> + add_handler(COUNT+PATHS, NULL);
<br>> add_handler(QUIT, NULL);
<br>>
<br>> return 0;
<br>> Index: multipath-tools-100510/multipathd/cli_handlers.h
<br>> ===================================================================
<br>> --- multipath-tools-100510.orig/multipathd/cli_handlers.h
<br>> +++ multipath-tools-100510/multipathd/cli_handlers.h
<br>> @@ -25,5 +25,6 @@ int cli_restore_all_queueing(void * v, c
<br>> int cli_suspend(void * v, char ** reply, int * len, void * data);
<br>> int cli_resume(void * v, char ** reply, int * len, void * data);
<br>> int cli_reinstate(void * v, char ** reply, int * len, void * data);
<br>> +int cli_count_paths(void * v, char ** reply, int * len, void * data);
<br>> int cli_fail(void * v, char ** reply, int * len, void * data);
<br>> int cli_quit(void * v, char ** reply, int * len, void * data);
<br>> Index: multipath-tools-100510/multipathd/main.c
<br>> ===================================================================
<br>> --- multipath-tools-100510.orig/multipathd/main.c
<br>> +++ multipath-tools-100510/multipathd/main.c
<br>> @@ -783,6 +783,7 @@ uxlsnrloop (void * ap)
<br>> set_handler_callback(RESTOREQ+MAP, cli_restore_queueing);
<br>> set_handler_callback(DISABLEQ+MAPS, cli_disable_all_queueing);
<br>> set_handler_callback(RESTOREQ+MAPS, cli_restore_all_queueing);
<br>> + set_handler_callback(COUNT+PATHS, cli_count_paths);
<br>> set_handler_callback(QUIT, cli_quit);
<br>>
<br>> umask(077);
<br>> Index: multipath-tools-100510/multipathd/cli.h
<br>> ===================================================================
<br>> --- multipath-tools-100510.orig/multipathd/cli.h
<br>> +++ multipath-tools-100510/multipathd/cli.h
<br>> @@ -23,6 +23,7 @@ enum {
<br>> __BLACKLIST,
<br>> __DEVICES,
<br>> __FMT,
<br>> + __COUNT,
<br>> __WILDCARDS,
<br>> __QUIT,
<br>> };
<br>> @@ -51,6 +52,7 @@ enum {
<br>> #define BLACKLIST (1 << __BLACKLIST)
<br>> #define DEVICES (1 << __DEVICES)
<br>> #define FMT (1 << __FMT)
<br>> +#define COUNT (1 << __COUNT)
<br>> #define WILDCARDS (1 << __WILDCARDS)
<br>> #define QUIT (1 << __QUIT)
<br>>
<br>> Index: multipath-tools-100510/multipathd/cli_handlers.c
<br>> ===================================================================
<br>> --- multipath-tools-100510.orig/multipathd/cli_handlers.c
<br>> +++ multipath-tools-100510/multipathd/cli_handlers.c
<br>> @@ -18,6 +18,29 @@
<br>>
<br>> #include "main.h"
<br>> #include "cli.h"
<br>> +#include "uevent.h"
<br>> +
<br>> +int
<br>> +count_paths(char **r, int *l, struct vectors *vecs)
<br>> +{
<br>> + int i, len;
<br>> + struct path *pp;
<br>> + char * reply;
<br>> + unsigned int maxlen = INITIAL_REPLY_LEN;
<br>> + int monitored_count = 0;
<br>> +
<br>> + reply = MALLOC(maxlen);
<br>> + if (!reply)
<br>> + return 1;
<br>> + vector_foreach_slot(vecs->pathvec, pp, i)
<br>> + if (pp->fd != -1)
<br>> + monitored_count++;
<br>> + len = sprintf(reply, "Paths: %d\nBusy: %s\n", monitored_count,
<br>> + is_uevent_busy()? "True" : "False");
<br>> + *r = reply;
<br>> + *l = len + 1;
<br>> + return 0;
<br>> +}
<br>>
<br>> int
<br>> show_paths (char ** r, int * len, struct vectors * vecs, char * style)
<br>> @@ -176,6 +199,16 @@ cli_list_config (void * v, char ** reply
<br>> }
<br>>
<br>> int
<br>> +cli_count_paths (void * v, char ** reply, int * len, void * data)
<br>> +{
<br>> + struct vectors * vecs = (struct vectors *)data;
<br>> +
<br>> + condlog(3, "count paths (operator)");
<br>> +
<br>> + return count_paths(reply, len, vecs);
<br>> +}
<br>> +
<br>> +int
<br>> cli_list_paths (void * v, char ** reply, int * len, void * data)
<br>> {
<br>> struct vectors * vecs = (struct vectors *)data;
<br>> Index: multipath-tools-100510/multipathd/multipathd.8
<br>> ===================================================================
<br>> --- multipath-tools-100510.orig/multipathd/multipathd.8
<br>> +++ multipath-tools-100510/multipathd/multipathd.8
<br>> @@ -69,6 +69,10 @@ Add a path to the list of monitored path
<br>> .B remove|del path $path
<br>> Stop monitoring a path. $path is as listed in /sys/block (e.g. sda).
<br>> .TP
<br>> +.B count paths
<br>> +Show the number of monitored paths, and whether multipathd is currently
<br>> +handling a uevent.
<br>> +.TP
<br>> .B add map $map
<br>> Add a multipath device to the list of monitored devices. $map can either be a
<br>> device-mapper device as listed in /sys/block (e.g. dm-0) or it can be the alias
<br>> for the multipath device (e.g. mpath1) or the uid of the multipath device (e.g.
<br>> 36005076303ffc56200000000000010aa). .TP
<br>>
<br>> --
<br>> dm-devel mailing list
<br>> <a href="mailto:dm-devel@redhat.com">dm-devel@redhat.com</a>
<br>> <a href="https://www.redhat.com/mailman/listinfo/dm-devel">https://www.redhat.com/mailman/listinfo/dm-devel</a>
<br><br></p>
</body>
</html>