]> git.ipfire.org Git - people/amarx/ipfire-3.x.git/blob - pkgs/multipath-tools/patches/0015-RH-add-multipathd-count-paths-cmd.patch
87826ef698ca088e9b817a500430f17b981eb117
[people/amarx/ipfire-3.x.git] / pkgs / multipath-tools / patches / 0015-RH-add-multipathd-count-paths-cmd.patch
1 Index: multipath-tools/libmultipath/uevent.c
2 ===================================================================
3 --- multipath-tools.orig/libmultipath/uevent.c
4 +++ multipath-tools/libmultipath/uevent.c
5 @@ -52,6 +52,12 @@ pthread_mutex_t uevc_lock, *uevc_lockp =
6 pthread_cond_t uev_cond, *uev_condp = &uev_cond;
7 uev_trigger *my_uev_trigger;
8 void * my_trigger_data;
9 +int servicing_uev;
10 +
11 +int is_uevent_busy(void)
12 +{
13 + return (uevqhp != NULL || servicing_uev);
14 +}
15
16 static struct uevent * alloc_uevent (void)
17 {
18 @@ -96,7 +102,9 @@ uevq_thread(void * et)
19
20 while (1) {
21 pthread_mutex_lock(uevc_lockp);
22 + servicing_uev = 0;
23 pthread_cond_wait(uev_condp, uevc_lockp);
24 + servicing_uev = 1;
25 pthread_mutex_unlock(uevc_lockp);
26
27 service_uevq();
28 Index: multipath-tools/libmultipath/uevent.h
29 ===================================================================
30 --- multipath-tools.orig/libmultipath/uevent.h
31 +++ multipath-tools/libmultipath/uevent.h
32 @@ -17,3 +17,4 @@ struct uevent {
33
34 int uevent_listen(int (*store_uev)(struct uevent *, void * trigger_data),
35 void * trigger_data);
36 +int is_uevent_busy(void);
37 Index: multipath-tools/multipathd/cli.c
38 ===================================================================
39 --- multipath-tools.orig/multipathd/cli.c
40 +++ multipath-tools/multipathd/cli.c
41 @@ -174,6 +174,7 @@ load_keys (void)
42 r += add_key(keys, "devices", DEVICES, 0);
43 r += add_key(keys, "format", FMT, 1);
44 r += add_key(keys, "wildcards", WILDCARDS, 0);
45 + r += add_key(keys, "count", COUNT, 0);
46 r += add_key(keys, "quit", QUIT, 0);
47 r += add_key(keys, "exit", QUIT, 0);
48
49 @@ -443,6 +444,7 @@ cli_init (void) {
50 add_handler(RESTOREQ+MAPS, NULL);
51 add_handler(REINSTATE+PATH, NULL);
52 add_handler(FAIL+PATH, NULL);
53 + add_handler(COUNT+PATHS, NULL);
54 add_handler(QUIT, NULL);
55
56 return 0;
57 Index: multipath-tools/multipathd/cli_handlers.h
58 ===================================================================
59 --- multipath-tools.orig/multipathd/cli_handlers.h
60 +++ multipath-tools/multipathd/cli_handlers.h
61 @@ -25,5 +25,6 @@ int cli_restore_all_queueing(void * v, c
62 int cli_suspend(void * v, char ** reply, int * len, void * data);
63 int cli_resume(void * v, char ** reply, int * len, void * data);
64 int cli_reinstate(void * v, char ** reply, int * len, void * data);
65 +int cli_count_paths(void * v, char ** reply, int * len, void * data);
66 int cli_fail(void * v, char ** reply, int * len, void * data);
67 int cli_quit(void * v, char ** reply, int * len, void * data);
68 Index: multipath-tools/multipathd/main.c
69 ===================================================================
70 --- multipath-tools.orig/multipathd/main.c
71 +++ multipath-tools/multipathd/main.c
72 @@ -768,6 +768,7 @@ uxlsnrloop (void * ap)
73 set_handler_callback(RESTOREQ+MAP, cli_restore_queueing);
74 set_handler_callback(DISABLEQ+MAPS, cli_disable_all_queueing);
75 set_handler_callback(RESTOREQ+MAPS, cli_restore_all_queueing);
76 + set_handler_callback(COUNT+PATHS, cli_count_paths);
77 set_handler_callback(QUIT, cli_quit);
78
79 umask(077);
80 Index: multipath-tools/multipathd/cli.h
81 ===================================================================
82 --- multipath-tools.orig/multipathd/cli.h
83 +++ multipath-tools/multipathd/cli.h
84 @@ -23,6 +23,7 @@ enum {
85 __BLACKLIST,
86 __DEVICES,
87 __FMT,
88 + __COUNT,
89 __WILDCARDS,
90 __QUIT,
91 };
92 @@ -51,6 +52,7 @@ enum {
93 #define BLACKLIST (1 << __BLACKLIST)
94 #define DEVICES (1 << __DEVICES)
95 #define FMT (1 << __FMT)
96 +#define COUNT (1 << __COUNT)
97 #define WILDCARDS (1 << __WILDCARDS)
98 #define QUIT (1 << __QUIT)
99
100 Index: multipath-tools/multipathd/cli_handlers.c
101 ===================================================================
102 --- multipath-tools.orig/multipathd/cli_handlers.c
103 +++ multipath-tools/multipathd/cli_handlers.c
104 @@ -18,6 +18,29 @@
105
106 #include "main.h"
107 #include "cli.h"
108 +#include "uevent.h"
109 +
110 +int
111 +count_paths(char **r, int *l, struct vectors *vecs)
112 +{
113 + int i, len;
114 + struct path *pp;
115 + char * reply;
116 + unsigned int maxlen = INITIAL_REPLY_LEN;
117 + int monitored_count = 0;
118 +
119 + reply = MALLOC(maxlen);
120 + if (!reply)
121 + return 1;
122 + vector_foreach_slot(vecs->pathvec, pp, i)
123 + if (pp->fd != -1)
124 + monitored_count++;
125 + len = sprintf(reply, "Paths: %d\nBusy: %s\n", monitored_count,
126 + is_uevent_busy()? "True" : "False");
127 + *r = reply;
128 + *l = len + 1;
129 + return 0;
130 +}
131
132 int
133 show_paths (char ** r, int * len, struct vectors * vecs, char * style)
134 @@ -176,6 +199,16 @@ cli_list_config (void * v, char ** reply
135 }
136
137 int
138 +cli_count_paths (void * v, char ** reply, int * len, void * data)
139 +{
140 + struct vectors * vecs = (struct vectors *)data;
141 +
142 + condlog(3, "count paths (operator)");
143 +
144 + return count_paths(reply, len, vecs);
145 +}
146 +
147 +int
148 cli_list_paths (void * v, char ** reply, int * len, void * data)
149 {
150 struct vectors * vecs = (struct vectors *)data;