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(-)
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
31 memset(empty_buff, 0, WWID_SIZE);
33 + /* ignore refwwid if it's empty */
34 + if (refwwid && !strlen(refwwid))
38 vector_foreach_slot (pathvec, pp1, k) {
40 @@ -537,6 +541,13 @@ coalesce_paths (struct vectors * vecs, v
41 if (refwwid && strncmp(pp1->wwid, refwwid, WWID_SIZE))
44 + /* If find_multipaths was selected check if the path is valid */
45 + if (conf->find_multipaths && !refwwid &&
46 + !should_multipath(pp1, pathvec)) {
52 * at this point, we know we really got a new mp
54 Index: multipath-tools-130222/libmultipath/defaults.h
55 ===================================================================
56 --- multipath-tools-130222.orig/libmultipath/defaults.h
57 +++ multipath-tools-130222/libmultipath/defaults.h
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
74 +def_find_multipaths_handler(vector strvec)
78 + buff = set_value(strvec);
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;
95 def_names_handler(vector strvec)
98 @@ -2700,6 +2721,18 @@ snprint_def_log_checker_err (char * buff
102 +snprint_def_find_multipaths (char * buff, int len, void * data)
104 + if (conf->find_multipaths == DEFAULT_FIND_MULTIPATHS)
106 + if (!conf->find_multipaths)
107 + return snprintf(buff, len, "no");
109 + return snprintf(buff, len, "yes");
114 snprint_def_user_friendly_names (char * buff, int len, void * data)
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:
133 +should_multipath(struct path *pp1, vector pathvec)
138 + condlog(4, "checking if %s should be multipathed", pp1->dev);
139 + vector_foreach_slot(pathvec, pp2, i) {
140 + if (pp1->dev == pp2->dev)
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);
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);
153 + condlog(3, "found wwid %s in wwids file, multipathing %s", pp1->wwid,
159 remember_wwid(char *wwid)
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
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);
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)
180 * core logic entry point
182 - r = coalesce_paths(&vecs, NULL, NULL, conf->force_reload);
183 + r = coalesce_paths(&vecs, NULL, refwwid, conf->force_reload);
187 Index: multipath-tools-130222/multipathd/main.c
188 ===================================================================
189 --- multipath-tools-130222.orig/multipathd/main.c
190 +++ multipath-tools-130222/multipathd/main.c
193 #include <configure.h>
196 #include <pgpolicies.h>
199 @@ -471,6 +472,11 @@ rescan:
203 + if (conf->find_multipaths &&
204 + !should_multipath(pp, vecs->pathvec)) {
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;
219 + int find_multipaths;