Lines Matching +full:- +full:gp
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2011-2013 Alexander Motin <mav@FreeBSD.org>
5 * Copyright (c) 2006-2007 Matthew Jacob <mjacob@FreeBSD.org>
125 g_multipath_good(struct g_geom *gp) in g_multipath_good() argument
130 LIST_FOREACH(cp, &gp->consumer, consumer) { in g_multipath_good()
131 if ((cp->index & MP_BAD) == 0) in g_multipath_good()
142 struct g_geom *gp; in g_multipath_fault() local
144 gp = cp->geom; in g_multipath_fault()
145 sc = gp->softc; in g_multipath_fault()
146 cp->index |= cause; in g_multipath_fault()
147 if (g_multipath_good(gp) == 0 && sc->sc_ndisks > 0) { in g_multipath_fault()
148 LIST_FOREACH(lcp, &gp->consumer, consumer) { in g_multipath_fault()
149 if (lcp->provider == NULL || in g_multipath_fault()
150 (lcp->index & (MP_LOST | MP_NEW))) in g_multipath_fault()
152 if (sc->sc_ndisks > 1 && lcp == cp) in g_multipath_fault()
156 sc->sc_name, lcp->provider->name); in g_multipath_fault()
158 sc->sc_name, lcp->provider->name); in g_multipath_fault()
159 lcp->index &= ~MP_FAIL; in g_multipath_fault()
162 if (cp != sc->sc_active) in g_multipath_fault()
164 sc->sc_active = NULL; in g_multipath_fault()
165 LIST_FOREACH(lcp, &gp->consumer, consumer) { in g_multipath_fault()
166 if ((lcp->index & MP_BAD) == 0) { in g_multipath_fault()
167 sc->sc_active = lcp; in g_multipath_fault()
171 if (sc->sc_active == NULL) { in g_multipath_fault()
173 sc->sc_name); in g_multipath_fault()
174 } else if (sc->sc_active_active != 1) { in g_multipath_fault()
176 sc->sc_active->provider->name, sc->sc_name); in g_multipath_fault()
181 g_multipath_choose(struct g_geom *gp, struct bio *bp) in g_multipath_choose() argument
186 sc = gp->softc; in g_multipath_choose()
187 if (sc->sc_active_active == 0 || in g_multipath_choose()
188 (sc->sc_active_active == 2 && bp->bio_cmd != BIO_READ)) in g_multipath_choose()
189 return (sc->sc_active); in g_multipath_choose()
191 LIST_FOREACH(cp, &gp->consumer, consumer) { in g_multipath_choose()
192 if (cp->index & MP_BAD) in g_multipath_choose()
194 cp->index += MP_IDLE; in g_multipath_choose()
195 if (best == NULL || cp->private < best->private || in g_multipath_choose()
196 (cp->private == best->private && cp->index > best->index)) in g_multipath_choose()
200 best->index &= ~MP_IDLE_MASK; in g_multipath_choose()
207 struct g_geom *gp; in g_mpd() local
214 gp = cp->geom; in g_mpd()
215 if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) { in g_mpd()
216 w = cp->acw; in g_mpd()
217 g_access(cp, -cp->acr, -cp->acw, -cp->ace); in g_mpd()
218 if (w > 0 && cp->provider != NULL && in g_mpd()
219 (cp->provider->geom->flags & G_GEOM_WITHER) == 0) { in g_mpd()
220 cp->index |= MP_WITHER; in g_mpd()
225 sc = gp->softc; in g_mpd()
226 mtx_lock(&sc->sc_mtx); in g_mpd()
227 if (cp->provider) { in g_mpd()
229 cp->provider->name, gp->name); in g_mpd()
231 gp->name, cp->provider->name); in g_mpd()
235 mtx_unlock(&sc->sc_mtx); in g_mpd()
236 if (LIST_EMPTY(&gp->consumer)) in g_mpd()
237 g_multipath_destroy(gp); in g_mpd()
248 cp->provider->name, cp->geom->name); in g_multipath_orphan()
250 cp->geom->name, cp->provider->name); in g_multipath_orphan()
251 sc = cp->geom->softc; in g_multipath_orphan()
252 cnt = (uintptr_t *)&cp->private; in g_multipath_orphan()
253 mtx_lock(&sc->sc_mtx); in g_multipath_orphan()
254 sc->sc_ndisks--; in g_multipath_orphan()
256 if (*cnt == 0 && (cp->index & MP_POSTED) == 0) { in g_multipath_orphan()
257 cp->index |= MP_POSTED; in g_multipath_orphan()
258 mtx_unlock(&sc->sc_mtx); in g_multipath_orphan()
261 mtx_unlock(&sc->sc_mtx); in g_multipath_orphan()
268 struct g_geom *gp; in g_multipath_resize() local
277 gp = cp->geom; in g_multipath_resize()
278 pp = cp->provider; in g_multipath_resize()
279 sc = gp->softc; in g_multipath_resize()
281 if (sc->sc_stopping) in g_multipath_resize()
284 if (pp->mediasize < sc->sc_size) { in g_multipath_resize()
285 size = pp->mediasize; in g_multipath_resize()
286 ssize = pp->sectorsize; in g_multipath_resize()
289 mtx_lock(&sc->sc_mtx); in g_multipath_resize()
290 LIST_FOREACH(cp1, &gp->consumer, consumer) { in g_multipath_resize()
291 pp = cp1->provider; in g_multipath_resize()
294 if (pp->mediasize < size) { in g_multipath_resize()
295 size = pp->mediasize; in g_multipath_resize()
296 ssize = pp->sectorsize; in g_multipath_resize()
299 mtx_unlock(&sc->sc_mtx); in g_multipath_resize()
300 if (size == OFF_MAX || size == sc->sc_size) in g_multipath_resize()
303 psize = size - ((sc->sc_uuid[0] != 0) ? ssize : 0); in g_multipath_resize()
305 sc->sc_name, sc->sc_pp->mediasize, psize); in g_multipath_resize()
306 if (sc->sc_uuid[0] != 0 && size < sc->sc_size) { in g_multipath_resize()
310 (memcmp(md.md_uuid, sc->sc_uuid, sizeof(sc->sc_uuid)) != 0) || in g_multipath_resize()
311 (strcmp(md.md_name, sc->sc_name) != 0) || in g_multipath_resize()
314 g_multipath_destroy(gp); in g_multipath_resize()
318 sc->sc_size = size; in g_multipath_resize()
319 g_resize_provider(sc->sc_pp, psize); in g_multipath_resize()
321 if (sc->sc_uuid[0] != 0) { in g_multipath_resize()
322 pp = cp->provider; in g_multipath_resize()
324 memcpy(md.md_uuid, sc->sc_uuid, sizeof(sc->sc_uuid)); in g_multipath_resize()
325 strlcpy(md.md_name, sc->sc_name, sizeof(md.md_name)); in g_multipath_resize()
329 md.md_active_active = sc->sc_active_active; in g_multipath_resize()
333 "(%d)\n", pp->name, error); in g_multipath_resize()
341 struct g_geom *gp; in g_multipath_start() local
346 gp = bp->bio_to->geom; in g_multipath_start()
347 sc = gp->softc; in g_multipath_start()
354 mtx_lock(&sc->sc_mtx); in g_multipath_start()
355 cp = g_multipath_choose(gp, bp); in g_multipath_start()
357 mtx_unlock(&sc->sc_mtx); in g_multipath_start()
362 if ((uintptr_t)bp->bio_driver1 < sc->sc_ndisks) in g_multipath_start()
363 bp->bio_driver1 = (void *)(uintptr_t)sc->sc_ndisks; in g_multipath_start()
364 cnt = (uintptr_t *)&cp->private; in g_multipath_start()
366 mtx_unlock(&sc->sc_mtx); in g_multipath_start()
367 cbp->bio_done = g_multipath_done; in g_multipath_start()
378 if (bp->bio_error == ENXIO || bp->bio_error == EIO) { in g_multipath_done()
384 cp = bp->bio_from; in g_multipath_done()
385 sc = cp->geom->softc; in g_multipath_done()
386 cnt = (uintptr_t *)&cp->private; in g_multipath_done()
387 mtx_lock(&sc->sc_mtx); in g_multipath_done()
388 (*cnt)--; in g_multipath_done()
389 if (*cnt == 0 && (cp->index & MP_LOST)) { in g_multipath_done()
391 cp->index |= MP_POSTED; in g_multipath_done()
392 mtx_unlock(&sc->sc_mtx); in g_multipath_done()
394 mtx_unlock(&sc->sc_mtx); in g_multipath_done()
395 if (bp->bio_error == 0 && in g_multipath_done()
396 bp->bio_cmd == BIO_GETATTR && in g_multipath_done()
397 !strcmp(bp->bio_attribute, "GEOM::physpath")) in g_multipath_done()
399 strlcat(bp->bio_data, "/mp", bp->bio_length); in g_multipath_done()
409 struct g_geom *gp; in g_multipath_done_error() local
423 pbp = bp->bio_parent; in g_multipath_done_error()
424 gp = pbp->bio_to->geom; in g_multipath_done_error()
425 sc = gp->softc; in g_multipath_done_error()
426 cp = bp->bio_from; in g_multipath_done_error()
427 pp = cp->provider; in g_multipath_done_error()
428 cnt = (uintptr_t *)&cp->private; in g_multipath_done_error()
430 mtx_lock(&sc->sc_mtx); in g_multipath_done_error()
431 if ((cp->index & MP_FAIL) == 0) { in g_multipath_done_error()
433 bp->bio_error, pp->name, sc->sc_name); in g_multipath_done_error()
435 sc->sc_name, pp->name, bp->bio_error); in g_multipath_done_error()
438 (*cnt)--; in g_multipath_done_error()
439 if (*cnt == 0 && (cp->index & (MP_LOST | MP_POSTED)) == MP_LOST) { in g_multipath_done_error()
440 cp->index |= MP_POSTED; in g_multipath_done_error()
441 mtx_unlock(&sc->sc_mtx); in g_multipath_done_error()
444 mtx_unlock(&sc->sc_mtx); in g_multipath_done_error()
449 if (pbp->bio_children < (uintptr_t)pbp->bio_driver1) { in g_multipath_done_error()
450 pbp->bio_inbed++; in g_multipath_done_error()
489 struct g_geom *gp; in g_multipath_access() local
494 gp = pp->geom; in g_multipath_access()
499 LIST_FOREACH(cp, &gp->consumer, consumer) { in g_multipath_access()
500 if (cp->index & MP_WITHER) in g_multipath_access()
513 sc = gp->softc; in g_multipath_access()
514 sc->sc_opened += dr + dw + de; in g_multipath_access()
515 if (sc->sc_stopping && sc->sc_opened == 0) in g_multipath_access()
516 g_multipath_destroy(gp); in g_multipath_access()
521 LIST_FOREACH(cp, &gp->consumer, consumer) { in g_multipath_access()
524 if (cp->index & MP_WITHER) in g_multipath_access()
527 (void) g_access(cp, -dr, -dw, -de); in g_multipath_access()
536 struct g_geom *gp; in g_multipath_create() local
541 LIST_FOREACH(gp, &mp->geom, geom) { in g_multipath_create()
542 sc = gp->softc; in g_multipath_create()
543 if (sc == NULL || sc->sc_stopping) in g_multipath_create()
545 if (strcmp(gp->name, md->md_name) == 0) { in g_multipath_create()
547 md->md_name); in g_multipath_create()
552 gp = g_new_geom(mp, md->md_name); in g_multipath_create()
554 mtx_init(&sc->sc_mtx, "multipath", NULL, MTX_DEF); in g_multipath_create()
555 memcpy(sc->sc_uuid, md->md_uuid, sizeof(sc->sc_uuid)); in g_multipath_create()
556 memcpy(sc->sc_name, md->md_name, sizeof(sc->sc_name)); in g_multipath_create()
557 sc->sc_active_active = md->md_active_active; in g_multipath_create()
558 sc->sc_size = md->md_size; in g_multipath_create()
559 gp->softc = sc; in g_multipath_create()
560 gp->start = g_multipath_start; in g_multipath_create()
561 gp->orphan = g_multipath_orphan; in g_multipath_create()
562 gp->resize = g_multipath_resize; in g_multipath_create()
563 gp->access = g_multipath_access; in g_multipath_create()
564 gp->dumpconf = g_multipath_dumpconf; in g_multipath_create()
566 pp = g_new_providerf(gp, "multipath/%s", md->md_name); in g_multipath_create()
567 pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE; in g_multipath_create()
568 if (md->md_size != 0) { in g_multipath_create()
569 pp->mediasize = md->md_size - in g_multipath_create()
570 ((md->md_uuid[0] != 0) ? md->md_sectorsize : 0); in g_multipath_create()
571 pp->sectorsize = md->md_sectorsize; in g_multipath_create()
573 sc->sc_pp = pp; in g_multipath_create()
575 printf("GEOM_MULTIPATH: %s created\n", gp->name); in g_multipath_create()
576 return (gp); in g_multipath_create()
580 g_multipath_add_disk(struct g_geom *gp, struct g_provider *pp) in g_multipath_add_disk() argument
588 sc = gp->softc; in g_multipath_add_disk()
594 LIST_FOREACH(cp, &gp->consumer, consumer) { in g_multipath_add_disk()
595 if (cp->provider == pp) in g_multipath_add_disk()
600 pp->name, gp->name); in g_multipath_add_disk()
603 cp = g_new_consumer(gp); in g_multipath_add_disk()
604 cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; in g_multipath_add_disk()
605 cp->private = NULL; in g_multipath_add_disk()
606 cp->index = MP_NEW; in g_multipath_add_disk()
610 pp->name, sc->sc_name); in g_multipath_add_disk()
618 if (sc->sc_pp) { in g_multipath_add_disk()
619 acr = sc->sc_pp->acr; in g_multipath_add_disk()
620 acw = sc->sc_pp->acw; in g_multipath_add_disk()
621 ace = sc->sc_pp->ace; in g_multipath_add_disk()
633 pp->name, sc->sc_name, error); in g_multipath_add_disk()
638 if (sc->sc_size == 0) { in g_multipath_add_disk()
639 sc->sc_size = pp->mediasize - in g_multipath_add_disk()
640 ((sc->sc_uuid[0] != 0) ? pp->sectorsize : 0); in g_multipath_add_disk()
641 sc->sc_pp->mediasize = sc->sc_size; in g_multipath_add_disk()
642 sc->sc_pp->sectorsize = pp->sectorsize; in g_multipath_add_disk()
644 if (sc->sc_pp->stripesize == 0 && sc->sc_pp->stripeoffset == 0) { in g_multipath_add_disk()
645 sc->sc_pp->stripesize = pp->stripesize; in g_multipath_add_disk()
646 sc->sc_pp->stripeoffset = pp->stripeoffset; in g_multipath_add_disk()
648 sc->sc_pp->flags |= pp->flags & G_PF_ACCEPT_UNMAPPED; in g_multipath_add_disk()
649 mtx_lock(&sc->sc_mtx); in g_multipath_add_disk()
650 cp->index = 0; in g_multipath_add_disk()
651 sc->sc_ndisks++; in g_multipath_add_disk()
652 mtx_unlock(&sc->sc_mtx); in g_multipath_add_disk()
654 pp->name, sc->sc_name); in g_multipath_add_disk()
655 if (sc->sc_active == NULL) { in g_multipath_add_disk()
656 sc->sc_active = cp; in g_multipath_add_disk()
657 if (sc->sc_active_active != 1) in g_multipath_add_disk()
659 pp->name, sc->sc_name); in g_multipath_add_disk()
665 g_multipath_destroy(struct g_geom *gp) in g_multipath_destroy() argument
671 if (gp->softc == NULL) in g_multipath_destroy()
673 sc = gp->softc; in g_multipath_destroy()
674 if (!sc->sc_stopping) { in g_multipath_destroy()
675 printf("GEOM_MULTIPATH: destroying %s\n", gp->name); in g_multipath_destroy()
676 sc->sc_stopping = 1; in g_multipath_destroy()
678 if (sc->sc_opened != 0) { in g_multipath_destroy()
679 g_wither_provider(sc->sc_pp, ENXIO); in g_multipath_destroy()
680 sc->sc_pp = NULL; in g_multipath_destroy()
683 LIST_FOREACH_SAFE(cp, &gp->consumer, consumer, cp1) { in g_multipath_destroy()
684 mtx_lock(&sc->sc_mtx); in g_multipath_destroy()
685 if ((cp->index & MP_POSTED) == 0) { in g_multipath_destroy()
686 cp->index |= MP_POSTED; in g_multipath_destroy()
687 mtx_unlock(&sc->sc_mtx); in g_multipath_destroy()
692 mtx_unlock(&sc->sc_mtx); in g_multipath_destroy()
694 if (!LIST_EMPTY(&gp->consumer)) in g_multipath_destroy()
696 mtx_destroy(&sc->sc_mtx); in g_multipath_destroy()
697 g_free(gp->softc); in g_multipath_destroy()
698 gp->softc = NULL; in g_multipath_destroy()
699 printf("GEOM_MULTIPATH: %s destroyed\n", gp->name); in g_multipath_destroy()
700 g_wither_geom(gp, ENXIO); in g_multipath_destroy()
706 struct g_geom *gp) in g_multipath_destroy_geom() argument
709 return (g_multipath_destroy(gp)); in g_multipath_destroy_geom()
713 g_multipath_rotate(struct g_geom *gp) in g_multipath_rotate() argument
716 struct g_multipath_softc *sc = gp->softc; in g_multipath_rotate()
722 LIST_FOREACH(lcp, &gp->consumer, consumer) { in g_multipath_rotate()
723 if ((lcp->index & MP_BAD) == 0) { in g_multipath_rotate()
729 if (sc->sc_active == lcp) in g_multipath_rotate()
734 if (lcp && lcp != sc->sc_active) { in g_multipath_rotate()
735 sc->sc_active = lcp; in g_multipath_rotate()
736 if (sc->sc_active_active != 1) in g_multipath_rotate()
738 lcp->provider->name, sc->sc_name); in g_multipath_rotate()
776 pp = cp->provider; in g_multipath_read_metadata()
778 buf = g_read_data(cp, pp->mediasize - pp->sectorsize, in g_multipath_read_metadata()
779 pp->sectorsize, &error); in g_multipath_read_metadata()
781 g_access(cp, -1, 0, 0); in g_multipath_read_metadata()
801 pp = cp->provider; in g_multipath_write_metadata()
803 buf = g_malloc(pp->sectorsize, M_WAITOK | M_ZERO); in g_multipath_write_metadata()
805 error = g_write_data(cp, pp->mediasize - pp->sectorsize, in g_multipath_write_metadata()
806 buf, pp->sectorsize); in g_multipath_write_metadata()
808 g_access(cp, -1, -1, -1); in g_multipath_write_metadata()
819 struct g_geom *gp, *gp1; in g_multipath_taste() local
824 gp = g_new_geom(mp, "multipath:taste"); in g_multipath_taste()
825 gp->start = g_multipath_start; in g_multipath_taste()
826 gp->access = g_multipath_access; in g_multipath_taste()
827 gp->orphan = g_multipath_orphan; in g_multipath_taste()
828 cp = g_new_consumer(gp); in g_multipath_taste()
829 cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; in g_multipath_taste()
836 g_destroy_geom(gp); in g_multipath_taste()
839 gp = NULL; in g_multipath_taste()
843 printf("%s is not MULTIPATH\n", pp->name); in g_multipath_taste()
847 printf("%s has version %d multipath id- this module is version " in g_multipath_taste()
848 " %d: rejecting\n", pp->name, md.md_version, in g_multipath_taste()
852 if (md.md_size != 0 && md.md_size != pp->mediasize) in g_multipath_taste()
854 if (md.md_sectorsize != 0 && md.md_sectorsize != pp->sectorsize) in g_multipath_taste()
872 LIST_FOREACH(gp, &mp->geom, geom) { in g_multipath_taste()
873 sc = gp->softc; in g_multipath_taste()
874 if (sc == NULL || sc->sc_stopping) in g_multipath_taste()
876 if (strncmp(md.md_uuid, sc->sc_uuid, sizeof(md.md_uuid)) == 0) in g_multipath_taste()
880 LIST_FOREACH(gp1, &mp->geom, geom) { in g_multipath_taste()
881 if (gp1 == gp) in g_multipath_taste()
883 sc = gp1->softc; in g_multipath_taste()
884 if (sc == NULL || sc->sc_stopping) in g_multipath_taste()
886 if (strncmp(md.md_name, sc->sc_name, sizeof(md.md_name)) == 0) in g_multipath_taste()
891 * If gp is NULL, we had no extant MULTIPATH geom with this uuid. in g_multipath_taste()
896 * If gp is NULL, then modify the name with a random number and in g_multipath_taste()
899 * If gp is *not* NULL, just use the geom's name as we're attaching in g_multipath_taste()
904 sc = gp1->softc; in g_multipath_taste()
905 if (gp == NULL) { in g_multipath_taste()
909 snprintf(buf, sizeof(buf), "%s-%lu", md.md_name, rand); in g_multipath_taste()
911 sc->sc_name, sc->sc_uuid); in g_multipath_taste()
916 strlcpy(md.md_name, sc->sc_name, sizeof(md.md_name)); in g_multipath_taste()
920 if (gp == NULL) { in g_multipath_taste()
921 gp = g_multipath_create(mp, &md); in g_multipath_taste()
922 if (gp == NULL) { in g_multipath_taste()
932 sc = gp->softc; in g_multipath_taste()
934 error = g_multipath_add_disk(gp, pp); in g_multipath_taste()
937 g_multipath_destroy(gp); in g_multipath_taste()
940 return (gp); in g_multipath_taste()
948 struct g_geom *gp; in g_multipath_ctl_add_name() local
961 gp = g_multipath_find_geom(mp, mpname); in g_multipath_ctl_add_name()
962 if (gp == NULL) { in g_multipath_ctl_add_name()
966 sc = gp->softc; in g_multipath_ctl_add_name()
977 LIST_FOREACH(cp, &gp->consumer, consumer) { in g_multipath_ctl_add_name()
978 if (cp->provider == pp) { in g_multipath_ctl_add_name()
980 pp->name); in g_multipath_ctl_add_name()
984 if (sc->sc_pp->mediasize != 0 && in g_multipath_ctl_add_name()
985 sc->sc_pp->mediasize + (sc->sc_uuid[0] != 0 ? pp->sectorsize : 0) in g_multipath_ctl_add_name()
986 != pp->mediasize) { in g_multipath_ctl_add_name()
988 (intmax_t) sc->sc_pp->mediasize + in g_multipath_ctl_add_name()
989 (sc->sc_uuid[0] != 0 ? pp->sectorsize : 0), in g_multipath_ctl_add_name()
990 (intmax_t) pp->mediasize); in g_multipath_ctl_add_name()
993 if (sc->sc_pp->sectorsize != 0 && in g_multipath_ctl_add_name()
994 sc->sc_pp->sectorsize != pp->sectorsize) { in g_multipath_ctl_add_name()
996 sc->sc_pp->sectorsize, pp->sectorsize); in g_multipath_ctl_add_name()
1000 error = g_multipath_add_disk(gp, pp); in g_multipath_ctl_add_name()
1008 struct g_geom *gp; in g_multipath_ctl_prefer() local
1022 gp = g_multipath_find_geom(mp, mpname); in g_multipath_ctl_prefer()
1023 if (gp == NULL) { in g_multipath_ctl_prefer()
1027 sc = gp->softc; in g_multipath_ctl_prefer()
1048 LIST_FOREACH(cp, &gp->consumer, consumer) { in g_multipath_ctl_prefer()
1049 if (cp->provider != NULL in g_multipath_ctl_prefer()
1050 && strcmp(cp->provider->name, name) == 0) in g_multipath_ctl_prefer()
1059 mtx_lock(&sc->sc_mtx); in g_multipath_ctl_prefer()
1061 if (cp->index & MP_BAD) { in g_multipath_ctl_prefer()
1063 mtx_unlock(&sc->sc_mtx); in g_multipath_ctl_prefer()
1069 sc->sc_active = cp; in g_multipath_ctl_prefer()
1070 if (!sc->sc_active_active) in g_multipath_ctl_prefer()
1072 sc->sc_active->provider->name, sc->sc_name); in g_multipath_ctl_prefer()
1074 mtx_unlock(&sc->sc_mtx); in g_multipath_ctl_prefer()
1080 struct g_geom *gp; in g_multipath_ctl_add() local
1088 gp = g_multipath_find_geom(mp, mpname); in g_multipath_ctl_add()
1089 if (gp == NULL) { in g_multipath_ctl_add()
1107 struct g_geom *gp; in g_multipath_ctl_create() local
1125 gp = g_multipath_find_geom(mp, mpname); in g_multipath_ctl_create()
1126 if (gp != NULL) { in g_multipath_ctl_create()
1145 gp = g_multipath_create(mp, &md); in g_multipath_ctl_create()
1146 if (gp == NULL) { in g_multipath_ctl_create()
1151 sc = gp->softc; in g_multipath_ctl_create()
1159 if (sc->sc_ndisks != (*nargs - 1)) in g_multipath_ctl_create()
1160 g_multipath_destroy(gp); in g_multipath_ctl_create()
1167 struct g_geom *gp; in g_multipath_ctl_configure() local
1181 gp = g_multipath_find_geom(mp, name); in g_multipath_ctl_configure()
1182 if (gp == NULL) { in g_multipath_ctl_configure()
1186 sc = gp->softc; in g_multipath_ctl_configure()
1189 sc->sc_active_active = 1; in g_multipath_ctl_configure()
1192 sc->sc_active_active = 2; in g_multipath_ctl_configure()
1195 sc->sc_active_active = 0; in g_multipath_ctl_configure()
1196 if (sc->sc_uuid[0] != 0 && sc->sc_active != NULL) { in g_multipath_ctl_configure()
1197 cp = sc->sc_active; in g_multipath_ctl_configure()
1198 pp = cp->provider; in g_multipath_ctl_configure()
1200 memcpy(md.md_uuid, sc->sc_uuid, sizeof(sc->sc_uuid)); in g_multipath_ctl_configure()
1203 md.md_size = pp->mediasize; in g_multipath_ctl_configure()
1204 md.md_sectorsize = pp->sectorsize; in g_multipath_ctl_configure()
1205 md.md_active_active = sc->sc_active_active; in g_multipath_ctl_configure()
1209 pp->name, error); in g_multipath_ctl_configure()
1217 struct g_geom *gp; in g_multipath_ctl_fail() local
1227 gp = g_multipath_find_geom(mp, mpname); in g_multipath_ctl_fail()
1228 if (gp == NULL) { in g_multipath_ctl_fail()
1232 sc = gp->softc; in g_multipath_ctl_fail()
1241 mtx_lock(&sc->sc_mtx); in g_multipath_ctl_fail()
1242 LIST_FOREACH(cp, &gp->consumer, consumer) { in g_multipath_ctl_fail()
1243 if (cp->provider != NULL && in g_multipath_ctl_fail()
1244 strcmp(cp->provider->name, name) == 0 && in g_multipath_ctl_fail()
1245 (cp->index & MP_LOST) == 0) { in g_multipath_ctl_fail()
1247 if (!fail == !(cp->index & MP_FAIL)) in g_multipath_ctl_fail()
1250 name, sc->sc_name, fail ? "FAIL" : "OK"); in g_multipath_ctl_fail()
1254 sc->sc_name, cp->provider->name, 0); in g_multipath_ctl_fail()
1256 cp->index &= ~MP_FAIL; in g_multipath_ctl_fail()
1258 sc->sc_name, cp->provider->name); in g_multipath_ctl_fail()
1262 mtx_unlock(&sc->sc_mtx); in g_multipath_ctl_fail()
1271 struct g_geom *gp; in g_multipath_ctl_remove() local
1282 gp = g_multipath_find_geom(mp, mpname); in g_multipath_ctl_remove()
1283 if (gp == NULL) { in g_multipath_ctl_remove()
1287 sc = gp->softc; in g_multipath_ctl_remove()
1296 mtx_lock(&sc->sc_mtx); in g_multipath_ctl_remove()
1297 LIST_FOREACH_SAFE(cp, &gp->consumer, consumer, cp1) { in g_multipath_ctl_remove()
1298 if (cp->provider != NULL && in g_multipath_ctl_remove()
1299 strcmp(cp->provider->name, name) == 0 && in g_multipath_ctl_remove()
1300 (cp->index & MP_LOST) == 0) { in g_multipath_ctl_remove()
1303 cp->provider->name, cp->geom->name); in g_multipath_ctl_remove()
1305 cp->geom->name, cp->provider->name); in g_multipath_ctl_remove()
1306 sc->sc_ndisks--; in g_multipath_ctl_remove()
1308 cnt = (uintptr_t *)&cp->private; in g_multipath_ctl_remove()
1309 if (*cnt == 0 && (cp->index & MP_POSTED) == 0) { in g_multipath_ctl_remove()
1310 cp->index |= MP_POSTED; in g_multipath_ctl_remove()
1311 mtx_unlock(&sc->sc_mtx); in g_multipath_ctl_remove()
1315 mtx_lock(&sc->sc_mtx); in g_multipath_ctl_remove()
1319 mtx_unlock(&sc->sc_mtx); in g_multipath_ctl_remove()
1327 struct g_geom *gp; in g_multipath_find_geom() local
1330 LIST_FOREACH(gp, &mp->geom, geom) { in g_multipath_find_geom()
1331 sc = gp->softc; in g_multipath_find_geom()
1332 if (sc == NULL || sc->sc_stopping) in g_multipath_find_geom()
1334 if (strcmp(gp->name, name) == 0) in g_multipath_find_geom()
1335 return (gp); in g_multipath_find_geom()
1343 struct g_geom *gp; in g_multipath_ctl_stop() local
1354 gp = g_multipath_find_geom(mp, name); in g_multipath_ctl_stop()
1355 if (gp == NULL) { in g_multipath_ctl_stop()
1359 error = g_multipath_destroy(gp); in g_multipath_ctl_stop()
1367 struct g_geom *gp; in g_multipath_ctl_destroy() local
1382 gp = g_multipath_find_geom(mp, name); in g_multipath_ctl_destroy()
1383 if (gp == NULL) { in g_multipath_ctl_destroy()
1387 sc = gp->softc; in g_multipath_ctl_destroy()
1389 if (sc->sc_uuid[0] != 0 && sc->sc_active != NULL) { in g_multipath_ctl_destroy()
1390 cp = sc->sc_active; in g_multipath_ctl_destroy()
1391 pp = cp->provider; in g_multipath_ctl_destroy()
1394 gctl_error(req, "Can't open %s (%d)", pp->name, error); in g_multipath_ctl_destroy()
1398 buf = g_malloc(pp->sectorsize, M_WAITOK | M_ZERO); in g_multipath_ctl_destroy()
1399 error = g_write_data(cp, pp->mediasize - pp->sectorsize, in g_multipath_ctl_destroy()
1400 buf, pp->sectorsize); in g_multipath_ctl_destroy()
1402 g_access(cp, -1, -1, -1); in g_multipath_ctl_destroy()
1405 pp->name, error); in g_multipath_ctl_destroy()
1409 error = g_multipath_destroy(gp); in g_multipath_ctl_destroy()
1417 struct g_geom *gp; in g_multipath_ctl_rotate() local
1428 gp = g_multipath_find_geom(mp, name); in g_multipath_ctl_rotate()
1429 if (gp == NULL) { in g_multipath_ctl_rotate()
1433 error = g_multipath_rotate(gp); in g_multipath_ctl_rotate()
1443 struct g_geom *gp; in g_multipath_ctl_getactive() local
1457 gp = g_multipath_find_geom(mp, name); in g_multipath_ctl_getactive()
1458 if (gp == NULL) { in g_multipath_ctl_getactive()
1462 sc = gp->softc; in g_multipath_ctl_getactive()
1463 if (sc->sc_active_active == 1) { in g_multipath_ctl_getactive()
1465 LIST_FOREACH(cp, &gp->consumer, consumer) { in g_multipath_ctl_getactive()
1466 if (cp->index & MP_BAD) in g_multipath_ctl_getactive()
1470 sbuf_cat(sb, cp->provider->name); in g_multipath_ctl_getactive()
1476 } else if (sc->sc_active && sc->sc_active->provider) { in g_multipath_ctl_getactive()
1477 sbuf_printf(sb, "%s\n", sc->sc_active->provider->name); in g_multipath_ctl_getactive()
1524 g_multipath_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, in g_multipath_dumpconf() argument
1532 sc = gp->softc; in g_multipath_dumpconf()
1537 (cp->index & MP_NEW) ? "NEW" : in g_multipath_dumpconf()
1538 (cp->index & MP_LOST) ? "LOST" : in g_multipath_dumpconf()
1539 (cp->index & MP_FAIL) ? "FAIL" : in g_multipath_dumpconf()
1540 (sc->sc_active_active == 1 || sc->sc_active == cp) ? in g_multipath_dumpconf()
1542 sc->sc_active_active == 2 ? "READ" : "PASSIVE"); in g_multipath_dumpconf()
1544 good = g_multipath_good(gp); in g_multipath_dumpconf()
1547 (good != sc->sc_ndisks || sc->sc_ndisks == 1) ? in g_multipath_dumpconf()
1551 sbuf_printf(sb, "%s<UUID>%s</UUID>\n", indent, sc->sc_uuid); in g_multipath_dumpconf()
1553 sc->sc_active_active == 2 ? "Read" : in g_multipath_dumpconf()
1554 sc->sc_active_active == 1 ? "Active" : "Passive"); in g_multipath_dumpconf()
1556 sc->sc_uuid[0] == 0 ? "MANUAL" : "AUTOMATIC"); in g_multipath_dumpconf()