Lines Matching +full:de +full:- +full:activated

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
118 g_shsec_maxmem -= g_shsec_maxmem % maxphys; in g_shsec_init()
138 for (i = 0; i < sc->sc_ndisks; i++) { in g_shsec_nvalid()
139 if (sc->sc_disks[i] != NULL) in g_shsec_nvalid()
152 KASSERT(cp != NULL, ("Non-valid disk in %s.", __func__)); in g_shsec_remove_disk()
153 sc = (struct g_shsec_softc *)cp->private; in g_shsec_remove_disk()
155 no = cp->index; in g_shsec_remove_disk()
157 G_SHSEC_DEBUG(0, "Disk %s removed from %s.", cp->provider->name, in g_shsec_remove_disk()
158 sc->sc_name); in g_shsec_remove_disk()
160 sc->sc_disks[no] = NULL; in g_shsec_remove_disk()
161 if (sc->sc_provider != NULL) { in g_shsec_remove_disk()
162 g_wither_provider(sc->sc_provider, ENXIO); in g_shsec_remove_disk()
163 sc->sc_provider = NULL; in g_shsec_remove_disk()
164 G_SHSEC_DEBUG(0, "Device %s removed.", sc->sc_name); in g_shsec_remove_disk()
167 if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) in g_shsec_remove_disk()
180 gp = cp->geom; in g_shsec_orphan()
181 sc = gp->softc; in g_shsec_orphan()
187 if (LIST_EMPTY(&gp->consumer)) in g_shsec_orphan()
192 g_shsec_access(struct g_provider *pp, int dr, int dw, int de) in g_shsec_access() argument
199 gp = pp->geom; in g_shsec_access()
200 sc = gp->softc; in g_shsec_access()
203 if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) in g_shsec_access()
204 de++; in g_shsec_access()
206 if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0) in g_shsec_access()
207 de--; in g_shsec_access()
210 LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) { in g_shsec_access()
211 error = g_access(cp1, dr, dw, de); in g_shsec_access()
214 if (cp1->acr == 0 && cp1->acw == 0 && cp1->ace == 0 && in g_shsec_access()
215 cp1->flags & G_CF_ORPHAN) { in g_shsec_access()
222 if (LIST_EMPTY(&gp->consumer)) in g_shsec_access()
229 LIST_FOREACH(cp2, &gp->consumer, consumer) { in g_shsec_access()
232 g_access(cp2, -dr, -dw, -de); in g_shsec_access()
241 for (; len > 0; len -= sizeof(uint32_t), dst++) in g_shsec_xor1()
251 pbp = bp->bio_parent; in g_shsec_done()
252 if (bp->bio_error == 0) in g_shsec_done()
256 bp->bio_error); in g_shsec_done()
257 if (pbp->bio_error == 0) in g_shsec_done()
258 pbp->bio_error = bp->bio_error; in g_shsec_done()
260 if (pbp->bio_cmd == BIO_READ) { in g_shsec_done()
261 if ((pbp->bio_pflags & G_SHSEC_BFLAG_FIRST) != 0) { in g_shsec_done()
262 bcopy(bp->bio_data, pbp->bio_data, pbp->bio_length); in g_shsec_done()
263 pbp->bio_pflags = 0; in g_shsec_done()
265 g_shsec_xor1((uint32_t *)bp->bio_data, in g_shsec_done()
266 (uint32_t *)pbp->bio_data, in g_shsec_done()
267 (ssize_t)pbp->bio_length); in g_shsec_done()
270 if (bp->bio_data != NULL) { in g_shsec_done()
271 explicit_bzero(bp->bio_data, bp->bio_length); in g_shsec_done()
272 uma_zfree(g_shsec_zone, bp->bio_data); in g_shsec_done()
275 pbp->bio_inbed++; in g_shsec_done()
276 if (pbp->bio_children == pbp->bio_inbed) { in g_shsec_done()
277 pbp->bio_completed = pbp->bio_length; in g_shsec_done()
278 g_io_deliver(pbp, pbp->bio_error); in g_shsec_done()
286 for (; len > 0; len -= sizeof(uint32_t), dst++) { in g_shsec_xor2()
304 sc = bp->bio_to->geom->softc; in g_shsec_start()
311 bp->bio_to->error, bp->bio_to->name)); in g_shsec_start()
315 switch (bp->bio_cmd) { in g_shsec_start()
336 len = bp->bio_length; in g_shsec_start()
337 if (bp->bio_cmd == BIO_READ) in g_shsec_start()
338 bp->bio_pflags = G_SHSEC_BFLAG_FIRST; in g_shsec_start()
339 for (no = 0; no < sc->sc_ndisks; no++) { in g_shsec_start()
350 cbp->bio_done = g_shsec_done; in g_shsec_start()
351 cbp->bio_caller2 = sc->sc_disks[no]; in g_shsec_start()
352 if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) { in g_shsec_start()
353 cbp->bio_data = uma_zalloc(g_shsec_zone, M_NOWAIT); in g_shsec_start()
354 if (cbp->bio_data == NULL) { in g_shsec_start()
359 if (bp->bio_cmd == BIO_WRITE) { in g_shsec_start()
361 dst = (uint32_t *)cbp->bio_data; in g_shsec_start()
362 bcopy(bp->bio_data, dst, len); in g_shsec_start()
364 g_shsec_xor2((uint32_t *)cbp->bio_data, in g_shsec_start()
377 cp = cbp->bio_caller2; in g_shsec_start()
378 cbp->bio_caller2 = NULL; in g_shsec_start()
379 cbp->bio_to = cp->provider; in g_shsec_start()
387 bp->bio_children--; in g_shsec_start()
388 if (cbp->bio_data != NULL) { in g_shsec_start()
389 explicit_bzero(cbp->bio_data, cbp->bio_length); in g_shsec_start()
390 uma_zfree(g_shsec_zone, cbp->bio_data); in g_shsec_start()
394 if (bp->bio_error == 0) in g_shsec_start()
395 bp->bio_error = error; in g_shsec_start()
396 g_io_deliver(bp, bp->bio_error); in g_shsec_start()
405 if (g_shsec_nvalid(sc) != sc->sc_ndisks) in g_shsec_check_and_run()
408 sc->sc_provider = g_new_providerf(sc->sc_geom, "shsec/%s", sc->sc_name); in g_shsec_check_and_run()
412 mediasize = sc->sc_disks[0]->provider->mediasize; in g_shsec_check_and_run()
413 mediasize -= sc->sc_disks[0]->provider->sectorsize; in g_shsec_check_and_run()
414 sectorsize = sc->sc_disks[0]->provider->sectorsize; in g_shsec_check_and_run()
415 for (no = 1; no < sc->sc_ndisks; no++) { in g_shsec_check_and_run()
416 ms = sc->sc_disks[no]->provider->mediasize; in g_shsec_check_and_run()
417 ms -= sc->sc_disks[no]->provider->sectorsize; in g_shsec_check_and_run()
421 sc->sc_disks[no]->provider->sectorsize); in g_shsec_check_and_run()
423 sc->sc_provider->sectorsize = sectorsize; in g_shsec_check_and_run()
424 sc->sc_provider->mediasize = mediasize; in g_shsec_check_and_run()
425 g_error_provider(sc->sc_provider, 0); in g_shsec_check_and_run()
427 G_SHSEC_DEBUG(0, "Device %s activated.", sc->sc_name); in g_shsec_check_and_run()
442 pp = cp->provider; in g_shsec_read_metadata()
444 buf = g_read_data(cp, pp->mediasize - pp->sectorsize, pp->sectorsize, in g_shsec_read_metadata()
447 g_access(cp, -1, 0, 0); in g_shsec_read_metadata()
470 if (no >= sc->sc_ndisks) in g_shsec_add_disk()
474 if (sc->sc_disks[no] != NULL) in g_shsec_add_disk()
477 gp = sc->sc_geom; in g_shsec_add_disk()
478 fcp = LIST_FIRST(&gp->consumer); in g_shsec_add_disk()
487 if (fcp != NULL && (fcp->acr > 0 || fcp->acw > 0 || fcp->ace > 0)) { in g_shsec_add_disk()
488 error = g_access(cp, fcp->acr, fcp->acw, fcp->ace); in g_shsec_add_disk()
502 strcmp(md.md_name, sc->sc_name) != 0 || md.md_id != sc->sc_id) { in g_shsec_add_disk()
503 G_SHSEC_DEBUG(0, "Metadata on %s changed.", pp->name); in g_shsec_add_disk()
507 cp->private = sc; in g_shsec_add_disk()
508 cp->index = no; in g_shsec_add_disk()
509 sc->sc_disks[no] = cp; in g_shsec_add_disk()
511 G_SHSEC_DEBUG(0, "Disk %s attached to %s.", pp->name, sc->sc_name); in g_shsec_add_disk()
517 if (fcp != NULL && (fcp->acr > 0 || fcp->acw > 0 || fcp->ace > 0)) in g_shsec_add_disk()
518 g_access(cp, -fcp->acr, -fcp->acw, -fcp->ace); in g_shsec_add_disk()
531 G_SHSEC_DEBUG(1, "Creating device %s (id=%u).", md->md_name, md->md_id); in g_shsec_create()
534 if (md->md_all < 2) { in g_shsec_create()
535 G_SHSEC_DEBUG(0, "Too few disks defined for %s.", md->md_name); in g_shsec_create()
540 LIST_FOREACH(gp, &mp->geom, geom) { in g_shsec_create()
541 sc = gp->softc; in g_shsec_create()
542 if (sc != NULL && strcmp(sc->sc_name, md->md_name) == 0) { in g_shsec_create()
544 sc->sc_name); in g_shsec_create()
548 gp = g_new_geomf(mp, "%s", md->md_name); in g_shsec_create()
550 gp->start = g_shsec_start; in g_shsec_create()
551 gp->spoiled = g_shsec_orphan; in g_shsec_create()
552 gp->orphan = g_shsec_orphan; in g_shsec_create()
553 gp->access = g_shsec_access; in g_shsec_create()
554 gp->dumpconf = g_shsec_dumpconf; in g_shsec_create()
556 sc->sc_id = md->md_id; in g_shsec_create()
557 sc->sc_ndisks = md->md_all; in g_shsec_create()
558 sc->sc_disks = malloc(sizeof(struct g_consumer *) * sc->sc_ndisks, in g_shsec_create()
560 for (no = 0; no < sc->sc_ndisks; no++) in g_shsec_create()
561 sc->sc_disks[no] = NULL; in g_shsec_create()
563 gp->softc = sc; in g_shsec_create()
564 sc->sc_geom = gp; in g_shsec_create()
565 sc->sc_provider = NULL; in g_shsec_create()
567 G_SHSEC_DEBUG(0, "Device %s created (id=%u).", sc->sc_name, sc->sc_id); in g_shsec_create()
584 pp = sc->sc_provider; in g_shsec_destroy()
585 if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) { in g_shsec_destroy()
588 "can't be definitely removed.", pp->name); in g_shsec_destroy()
591 "Device %s is still open (r%dw%de%d).", pp->name, in g_shsec_destroy()
592 pp->acr, pp->acw, pp->ace); in g_shsec_destroy()
597 for (no = 0; no < sc->sc_ndisks; no++) { in g_shsec_destroy()
598 if (sc->sc_disks[no] != NULL) in g_shsec_destroy()
599 g_shsec_remove_disk(sc->sc_disks[no]); in g_shsec_destroy()
602 gp = sc->sc_geom; in g_shsec_destroy()
603 gp->softc = NULL; in g_shsec_destroy()
604 KASSERT(sc->sc_provider == NULL, ("Provider still exists? (device=%s)", in g_shsec_destroy()
605 gp->name)); in g_shsec_destroy()
606 free(sc->sc_disks, M_SHSEC); in g_shsec_destroy()
609 pp = LIST_FIRST(&gp->provider); in g_shsec_destroy()
610 if (pp == NULL || (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)) in g_shsec_destroy()
611 G_SHSEC_DEBUG(0, "Device %s destroyed.", gp->name); in g_shsec_destroy()
624 sc = gp->softc; in g_shsec_destroy_geom()
637 g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name); in g_shsec_taste()
641 if (pp->acw > 0) in g_shsec_taste()
644 G_SHSEC_DEBUG(3, "Tasting %s.", pp->name); in g_shsec_taste()
647 gp->start = g_shsec_start; in g_shsec_taste()
648 gp->access = g_shsec_access; in g_shsec_taste()
649 gp->orphan = g_shsec_orphan; in g_shsec_taste()
651 cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; in g_shsec_taste()
667 pp->name); in g_shsec_taste()
675 md.md_provsize = pp->mediasize; in g_shsec_taste()
678 !g_compare_names(md.md_provider, pp->name)) in g_shsec_taste()
680 if (md.md_provsize != pp->mediasize) in g_shsec_taste()
687 LIST_FOREACH(gp, &mp->geom, geom) { in g_shsec_taste()
688 sc = gp->softc; in g_shsec_taste()
691 if (strcmp(md.md_name, sc->sc_name) != 0) in g_shsec_taste()
693 if (md.md_id != sc->sc_id) in g_shsec_taste()
698 G_SHSEC_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name); in g_shsec_taste()
702 pp->name, gp->name, error); in g_shsec_taste()
711 sc = gp->softc; in g_shsec_taste()
712 G_SHSEC_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name); in g_shsec_taste()
716 pp->name, gp->name, error); in g_shsec_taste()
730 LIST_FOREACH(gp, &mp->geom, geom) { in g_shsec_find_device()
731 sc = gp->softc; in g_shsec_find_device()
734 if (strcmp(sc->sc_name, name) == 0) in g_shsec_find_device()
781 sc->sc_name, error); in g_shsec_ctl_destroy()
818 sc = gp->softc; in g_shsec_dumpconf()
825 (u_int)cp->index); in g_shsec_dumpconf()
827 sbuf_printf(sb, "%s<ID>%u</ID>\n", indent, (u_int)sc->sc_id); in g_shsec_dumpconf()
829 indent, sc->sc_ndisks, g_shsec_nvalid(sc)); in g_shsec_dumpconf()
831 if (sc->sc_provider != NULL && sc->sc_provider->error == 0) in g_shsec_dumpconf()