16 pp = (struct path *)MALLOC(sizeof(struct path));
19 pp->sg_id.host_no = -1;
20 pp->sg_id.channel = -1;
21 pp->sg_id.scsi_id = -1;
29 free_path (struct path * pp)
34 if (pp->checker_context)
35 free(pp->checker_context);
44 free_pathvec (vector vec, int free_paths)
53 vector_foreach_slot(vec, pp, i)
60 alloc_pathgroup (void)
62 struct pathgroup * pgp;
64 pgp = (struct pathgroup *)MALLOC(sizeof(struct pathgroup));
69 pgp->paths = vector_alloc();
78 free_pathgroup (struct pathgroup * pgp, int free_paths)
83 free_pathvec(pgp->paths, free_paths);
88 free_pgvec (vector pgvec, int free_paths)
91 struct pathgroup * pgp;
96 vector_foreach_slot(pgvec, pgp, i)
97 free_pathgroup(pgp, free_paths);
103 alloc_multipath (void)
105 struct multipath * mpp;
107 mpp = (struct multipath *)MALLOC(sizeof(struct multipath));
116 free_multipath (struct multipath * mpp, int free_paths)
122 mpp->selector != conf->selector &&
123 (!mpp->mpe || (mpp->mpe && mpp->selector != mpp->mpe->selector)) &&
124 (!mpp->hwe || (mpp->hwe && mpp->selector != mpp->hwe->selector)))
128 (!mpp->mpe || (mpp->mpe && mpp->alias != mpp->mpe->alias)) &&
129 (mpp->wwid && mpp->alias != mpp->wwid))
133 mpp->features != conf->features &&
134 (!mpp->hwe || (mpp->hwe && mpp->features != mpp->hwe->features)))
137 if (mpp->hwhandler &&
138 mpp->hwhandler != conf->default_hwhandler &&
139 (!mpp->hwe || (mpp->hwe && mpp->hwhandler != mpp->hwe->hwhandler)))
140 FREE(mpp->hwhandler);
142 free_pathvec(mpp->paths, free_paths);
143 free_pgvec(mpp->pg, free_paths);
148 drop_multipath (vector mpvec, char * wwid, int free_paths)
151 struct multipath * mpp;
156 vector_foreach_slot (mpvec, mpp, i) {
157 if (!strncmp(mpp->wwid, wwid, WWID_SIZE)) {
158 free_multipath(mpp, free_paths);
159 vector_del_slot(mpvec, i);
166 free_multipathvec (vector mpvec, int free_paths)
169 struct multipath * mpp;
174 vector_foreach_slot (mpvec, mpp, i)
175 free_multipath(mpp, free_paths);
181 store_path (vector pathvec, struct path * pp)
183 if (!vector_alloc_slot(pathvec))
186 vector_set_slot(pathvec, pp);
192 store_pathgroup (vector pgvec, struct pathgroup * pgp)
194 if (!vector_alloc_slot(pgvec))
197 vector_set_slot(pgvec, pgp);
203 find_mp_by_minor (vector mp, int minor)
206 struct multipath * mpp;
208 vector_foreach_slot (mp, mpp, i)
209 if (mpp->minor == minor)
216 find_mp_by_wwid (vector mp, char * wwid)
219 struct multipath * mpp;
221 vector_foreach_slot (mp, mpp, i)
222 if (!strncmp(mpp->wwid, wwid, WWID_SIZE))
229 find_mp (vector mp, char * alias)
233 struct multipath * mpp;
240 vector_foreach_slot (mp, mpp, i) {
241 if (strlen(mpp->alias) == len &&
242 !strncmp(mpp->alias, alias, len))
249 find_path_by_dev (vector pathvec, char * dev)
254 vector_foreach_slot (pathvec, pp, i)
255 if (!strcmp_chomp(pp->dev, dev))
258 condlog(3, "path %s not found in pathvec\n", dev);
263 find_path_by_devt (vector pathvec, char * dev_t)
268 vector_foreach_slot (pathvec, pp, i)
269 if (!strcmp_chomp(pp->dev_t, dev_t))
272 condlog(3, "path %s not found in pathvec\n", dev_t);