Blame SOURCES/0205-RHBZ-1416569-reset-stats.patch

4ae388
---
4ae388
 multipathd/cli.c          |    2 ++
4ae388
 multipathd/cli_handlers.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
4ae388
 multipathd/cli_handlers.h |    2 ++
4ae388
 multipathd/main.c         |    2 ++
4ae388
 multipathd/multipathd.8   |    6 ++++++
4ae388
 5 files changed, 56 insertions(+)
4ae388
4ae388
Index: multipath-tools-130222/multipathd/cli.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli.c
4ae388
+++ multipath-tools-130222/multipathd/cli.c
4ae388
@@ -482,6 +482,8 @@ cli_init (void) {
4ae388
 	add_handler(LIST+BLACKLIST, NULL);
4ae388
 	add_handler(LIST+DEVICES, NULL);
4ae388
 	add_handler(LIST+WILDCARDS, NULL);
4ae388
+	add_handler(RESET+MAPS+STATS, NULL);
4ae388
+	add_handler(RESET+MAP+STATS, NULL);
4ae388
 	add_handler(ADD+PATH, NULL);
4ae388
 	add_handler(DEL+PATH, NULL);
4ae388
 	add_handler(ADD+MAP, NULL);
4ae388
Index: multipath-tools-130222/multipathd/cli_handlers.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli_handlers.c
4ae388
+++ multipath-tools-130222/multipathd/cli_handlers.c
4ae388
@@ -233,6 +233,17 @@ show_config (char ** r, int * len)
4ae388
 	return 0;
4ae388
 }
4ae388
 
4ae388
+void
4ae388
+reset_stats(struct multipath * mpp)
4ae388
+{
4ae388
+	mpp->stat_switchgroup = 0;
4ae388
+	mpp->stat_path_failures = 0;
4ae388
+	mpp->stat_map_loads = 0;
4ae388
+	mpp->stat_total_queueing_time = 0;
4ae388
+	mpp->stat_queueing_timeouts = 0;
4ae388
+	mpp->stat_map_failures = 0;
4ae388
+}
4ae388
+
4ae388
 int
4ae388
 cli_list_config (void * v, char ** reply, int * len, void * data)
4ae388
 {
4ae388
@@ -501,6 +512,39 @@ cli_list_daemon (void * v, char ** reply
4ae388
 }
4ae388
 
4ae388
 int
4ae388
+cli_reset_maps_stats (void * v, char ** reply, int * len, void * data)
4ae388
+{
4ae388
+	struct vectors * vecs = (struct vectors *)data;
4ae388
+	int i;
4ae388
+	struct multipath * mpp;
4ae388
+
4ae388
+	condlog(3, "reset multipaths stats (operator)");
4ae388
+
4ae388
+	vector_foreach_slot(vecs->mpvec, mpp, i) {
4ae388
+		reset_stats(mpp);
4ae388
+	}
4ae388
+	return 0;
4ae388
+}
4ae388
+
4ae388
+int
4ae388
+cli_reset_map_stats (void * v, char ** reply, int * len, void * data)
4ae388
+{
4ae388
+	struct vectors * vecs = (struct vectors *)data;
4ae388
+	struct multipath * mpp;
4ae388
+	char * param = get_keyparam(v, MAP);
4ae388
+
4ae388
+	param = convert_dev(param, 0);
4ae388
+	mpp = find_mp_by_str(vecs->mpvec, param);
4ae388
+
4ae388
+	if (!mpp)
4ae388
+		return 1;
4ae388
+
4ae388
+	condlog(3, "reset multipath %s stats (operator)", param);
4ae388
+	reset_stats(mpp);
4ae388
+	return 0;
4ae388
+}
4ae388
+
4ae388
+int
4ae388
 cli_add_path (void * v, char ** reply, int * len, void * data)
4ae388
 {
4ae388
 	struct vectors * vecs = (struct vectors *)data;
4ae388
Index: multipath-tools-130222/multipathd/cli_handlers.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/cli_handlers.h
4ae388
+++ multipath-tools-130222/multipathd/cli_handlers.h
4ae388
@@ -16,6 +16,8 @@ int cli_list_config (void * v, char ** r
4ae388
 int cli_list_blacklist (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_devices (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_list_wildcards (void * v, char ** reply, int * len, void * data);
4ae388
+int cli_reset_maps_stats (void * v, char ** reply, int * len, void * data);
4ae388
+int cli_reset_map_stats (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_add_path (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_del_path (void * v, char ** reply, int * len, void * data);
4ae388
 int cli_add_map (void * v, char ** reply, int * len, void * data);
4ae388
Index: multipath-tools-130222/multipathd/main.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/main.c
4ae388
+++ multipath-tools-130222/multipathd/main.c
4ae388
@@ -1011,6 +1011,8 @@ uxlsnrloop (void * ap)
4ae388
 	set_handler_callback(LIST+BLACKLIST, cli_list_blacklist);
4ae388
 	set_handler_callback(LIST+DEVICES, cli_list_devices);
4ae388
 	set_handler_callback(LIST+WILDCARDS, cli_list_wildcards);
4ae388
+	set_handler_callback(RESET+MAPS+STATS, cli_reset_maps_stats);
4ae388
+	set_handler_callback(RESET+MAP+STATS, cli_reset_map_stats);
4ae388
 	set_handler_callback(ADD+PATH, cli_add_path);
4ae388
 	set_handler_callback(DEL+PATH, cli_del_path);
4ae388
 	set_handler_callback(ADD+MAP, cli_add_map);
4ae388
Index: multipath-tools-130222/multipathd/multipathd.8
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipathd/multipathd.8
4ae388
+++ multipath-tools-130222/multipathd/multipathd.8
4ae388
@@ -87,6 +87,12 @@ Show all available block devices by name
4ae388
 .B list|show status
4ae388
 Show the number of path checkers in each possible state, the number of monitored paths, and whether multipathd is currently handling a uevent.
4ae388
 .TP
4ae388
+.B reset maps|multipaths stats
4ae388
+Reset the stat counters for all multipath devices.
4ae388
+.TP
4ae388
+.B reset map|multipath $map stats
4ae388
+Reset the stat counters for a specific multipath device.
4ae388
+.TP
4ae388
 .B add path $path
4ae388
 Add a path to the list of monitored paths. $path is as listed in /sys/block (e.g. sda).
4ae388
 .TP