]> git.ipfire.org Git - people/amarx/ipfire-3.x.git/blob - multipath-tools/patches/0006-RH-add-find-multipaths.patch
sysvinit: Remove pidof
[people/amarx/ipfire-3.x.git] / multipath-tools / patches / 0006-RH-add-find-multipaths.patch
1 ---
2 libmultipath/config.c | 1 +
3 libmultipath/config.h | 1 +
4 libmultipath/configure.c | 11 +++++++++++
5 libmultipath/defaults.h | 1 +
6 libmultipath/dict.c | 34 ++++++++++++++++++++++++++++++++++
7 libmultipath/wwids.c | 26 ++++++++++++++++++++++++++
8 libmultipath/wwids.h | 1 +
9 multipath/main.c | 2 +-
10 multipathd/main.c | 6 ++++++
11 9 files changed, 82 insertions(+), 1 deletion(-)
12
13 Index: multipath-tools-130222/libmultipath/config.c
14 ===================================================================
15 --- multipath-tools-130222.orig/libmultipath/config.c
16 +++ multipath-tools-130222/libmultipath/config.c
17 @@ -547,6 +547,7 @@ load_config (char * file)
18 conf->reassign_maps = DEFAULT_REASSIGN_MAPS;
19 conf->checkint = DEFAULT_CHECKINT;
20 conf->max_checkint = MAX_CHECKINT(conf->checkint);
21 + conf->find_multipaths = DEFAULT_FIND_MULTIPATHS;
22 conf->fast_io_fail = DEFAULT_FAST_IO_FAIL;
23 conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER;
24 conf->detect_prio = DEFAULT_DETECT_PRIO;
25 Index: multipath-tools-130222/libmultipath/configure.c
26 ===================================================================
27 --- multipath-tools-130222.orig/libmultipath/configure.c
28 +++ multipath-tools-130222/libmultipath/configure.c
29 @@ -508,6 +508,10 @@ coalesce_paths (struct vectors * vecs, v
30
31 memset(empty_buff, 0, WWID_SIZE);
32
33 + /* ignore refwwid if it's empty */
34 + if (refwwid && !strlen(refwwid))
35 + refwwid = NULL;
36 +
37 if (force_reload) {
38 vector_foreach_slot (pathvec, pp1, k) {
39 pp1->mpp = NULL;
40 @@ -537,6 +541,13 @@ coalesce_paths (struct vectors * vecs, v
41 if (refwwid && strncmp(pp1->wwid, refwwid, WWID_SIZE))
42 continue;
43
44 + /* If find_multipaths was selected check if the path is valid */
45 + if (conf->find_multipaths && !refwwid &&
46 + !should_multipath(pp1, pathvec)) {
47 + orphan_path(pp1);
48 + continue;
49 + }
50 +
51 /*
52 * at this point, we know we really got a new mp
53 */
54 Index: multipath-tools-130222/libmultipath/defaults.h
55 ===================================================================
56 --- multipath-tools-130222.orig/libmultipath/defaults.h
57 +++ multipath-tools-130222/libmultipath/defaults.h
58 @@ -15,6 +15,7 @@
59 #define DEFAULT_USER_FRIENDLY_NAMES 0
60 #define DEFAULT_VERBOSITY 2
61 #define DEFAULT_REASSIGN_MAPS 1
62 +#define DEFAULT_FIND_MULTIPATHS 0
63 #define DEFAULT_FAST_IO_FAIL 5
64 #define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_OFF
65 #define DEFAULT_DETECT_PRIO DETECT_PRIO_OFF
66 Index: multipath-tools-130222/libmultipath/dict.c
67 ===================================================================
68 --- multipath-tools-130222.orig/libmultipath/dict.c
69 +++ multipath-tools-130222/libmultipath/dict.c
70 @@ -585,6 +585,27 @@ def_reservation_key_handler(vector strve
71 }
72
73 static int
74 +def_find_multipaths_handler(vector strvec)
75 +{
76 + char * buff;
77 +
78 + buff = set_value(strvec);
79 +
80 + if (!buff)
81 + return 1;
82 +
83 + if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
84 + (strlen(buff) == 1 && !strcmp(buff, "0")))
85 + conf->find_multipaths = 0;
86 + else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
87 + (strlen(buff) == 1 && !strcmp(buff, "1")))
88 + conf->find_multipaths = 1;
89 +
90 + FREE(buff);
91 + return 0;
92 +}
93 +
94 +static int
95 def_names_handler(vector strvec)
96 {
97 char * buff;
98 @@ -2700,6 +2721,18 @@ snprint_def_log_checker_err (char * buff
99 }
100
101 static int
102 +snprint_def_find_multipaths (char * buff, int len, void * data)
103 +{
104 + if (conf->find_multipaths == DEFAULT_FIND_MULTIPATHS)
105 + return 0;
106 + if (!conf->find_multipaths)
107 + return snprintf(buff, len, "no");
108 +
109 + return snprintf(buff, len, "yes");
110 +}
111 +
112 +
113 +static int
114 snprint_def_user_friendly_names (char * buff, int len, void * data)
115 {
116 if (conf->user_friendly_names == USER_FRIENDLY_NAMES_ON)
117 @@ -2833,6 +2866,7 @@ init_keywords(void)
118 install_keyword("wwids_file", &wwids_file_handler, &snprint_def_wwids_file);
119 install_keyword("log_checker_err", &def_log_checker_err_handler, &snprint_def_log_checker_err);
120 install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key);
121 + install_keyword("find_multipaths", &def_find_multipaths_handler, &snprint_def_find_multipaths);
122 install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler_handler);
123 install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio);
124 __deprecated install_keyword("default_selector", &def_selector_handler, NULL);
125 Index: multipath-tools-130222/libmultipath/wwids.c
126 ===================================================================
127 --- multipath-tools-130222.orig/libmultipath/wwids.c
128 +++ multipath-tools-130222/libmultipath/wwids.c
129 @@ -125,6 +125,32 @@ out:
130 }
131
132 int
133 +should_multipath(struct path *pp1, vector pathvec)
134 +{
135 + int i;
136 + struct path *pp2;
137 +
138 + condlog(4, "checking if %s should be multipathed", pp1->dev);
139 + vector_foreach_slot(pathvec, pp2, i) {
140 + if (pp1->dev == pp2->dev)
141 + continue;
142 + if (strncmp(pp1->wwid, pp2->wwid, WWID_SIZE) == 0) {
143 + condlog(3, "found multiple paths with wwid %s, "
144 + "multipathing %s", pp1->wwid, pp1->dev);
145 + return 1;
146 + }
147 + }
148 + if (check_wwids_file(pp1->wwid, 0) < 0) {
149 + condlog(3, "wwid %s not in wwids file, skipping %s",
150 + pp1->wwid, pp1->dev);
151 + return 0;
152 + }
153 + condlog(3, "found wwid %s in wwids file, multipathing %s", pp1->wwid,
154 + pp1->dev);
155 + return 1;
156 +}
157 +
158 +int
159 remember_wwid(char *wwid)
160 {
161 int ret = check_wwids_file(wwid, 1);
162 Index: multipath-tools-130222/libmultipath/wwids.h
163 ===================================================================
164 --- multipath-tools-130222.orig/libmultipath/wwids.h
165 +++ multipath-tools-130222/libmultipath/wwids.h
166 @@ -12,6 +12,7 @@
167 "#\n" \
168 "# Valid WWIDs:\n"
169
170 +int should_multipath(struct path *pp, vector pathvec);
171 int remember_wwid(char *wwid);
172 int check_wwids_file(char *wwid, int write_wwid);
173
174 Index: multipath-tools-130222/multipath/main.c
175 ===================================================================
176 --- multipath-tools-130222.orig/multipath/main.c
177 +++ multipath-tools-130222/multipath/main.c
178 @@ -333,7 +333,7 @@ configure (void)
179 /*
180 * core logic entry point
181 */
182 - r = coalesce_paths(&vecs, NULL, NULL, conf->force_reload);
183 + r = coalesce_paths(&vecs, NULL, refwwid, conf->force_reload);
184
185 out:
186 if (refwwid)
187 Index: multipath-tools-130222/multipathd/main.c
188 ===================================================================
189 --- multipath-tools-130222.orig/multipathd/main.c
190 +++ multipath-tools-130222/multipathd/main.c
191 @@ -49,6 +49,7 @@
192 #include <print.h>
193 #include <configure.h>
194 #include <prio.h>
195 +#include <wwids.h>
196 #include <pgpolicies.h>
197 #include <uevent.h>
198
199 @@ -471,6 +472,11 @@ rescan:
200 return 1;
201 }
202
203 + if (conf->find_multipaths &&
204 + !should_multipath(pp, vecs->pathvec)) {
205 + orphan_path(pp);
206 + return 0;
207 + }
208 condlog(4,"%s: creating new map", pp->dev);
209 if ((mpp = add_map_with_path(vecs, pp, 1))) {
210 mpp->action = ACT_CREATE;
211 Index: multipath-tools-130222/libmultipath/config.h
212 ===================================================================
213 --- multipath-tools-130222.orig/libmultipath/config.h
214 +++ multipath-tools-130222/libmultipath/config.h
215 @@ -106,6 +106,7 @@ struct config {
216 unsigned int dev_loss;
217 int log_checker_err;
218 int allow_queueing;
219 + int find_multipaths;
220 uid_t uid;
221 gid_t gid;
222 mode_t mode;