Lines Matching refs:wp

78 static void g_bde_delete_sector(struct g_bde_softc *wp, struct g_bde_sector *sp);
79 static struct g_bde_sector * g_bde_new_sector(struct g_bde_work *wp, u_int len);
80 static void g_bde_release_keysector(struct g_bde_work *wp);
81 static struct g_bde_sector *g_bde_get_keysector(struct g_bde_work *wp);
98 struct g_bde_work *wp;
100 wp = malloc(sizeof *wp, M_GBDE, M_NOWAIT | M_ZERO);
101 if (wp == NULL)
102 return (wp);
103 wp->state = SETUP;
104 wp->softc = sc;
107 TAILQ_INSERT_TAIL(&sc->worklist, wp, list);
108 return (wp);
112 g_bde_delete_work(struct g_bde_work *wp)
116 sc = wp->softc;
119 TAILQ_REMOVE(&sc->worklist, wp, list);
120 free(wp, M_GBDE);
144 g_bde_new_sector(struct g_bde_work *wp, u_int len)
160 wp->softc->nsect++;
162 sp->softc = wp->softc;
164 sp->owner = wp;
165 sp->offset = wp->so;
201 g_bde_get_keysector(struct g_bde_work *wp)
207 offset = wp->kso;
208 g_trace(G_T_TOPOLOGY, "g_bde_get_keysector(%p, %jd)", wp, (intmax_t)offset);
209 sc = wp->softc;
225 KASSERT(sp->softc == wp->softc, ("wrong softc"));
227 sp->owner = wp;
239 sp = g_bde_new_sector(wp, sc->sectorsize);
249 sp->softc = wp->softc;
251 sp->owner = wp;
261 wp->ksp = sp;
266 g_bde_release_keysector(struct g_bde_work *wp)
272 sp = wp->ksp;
277 KASSERT(wp == sp->owner, ("Releasing, not owner"));
279 wp->ksp = NULL;
286 KASSERT(wp2 != wp, ("Self-reowning"));
332 g_bde_read_keysector(struct g_bde_softc *sc, struct g_bde_work *wp)
336 g_trace(G_T_TOPOLOGY, "g_bde_read_keysector(%p)", wp);
337 sp = g_bde_get_keysector(wp);
340 sp = g_bde_get_keysector(wp);
344 if (sp->owner != wp)
350 g_bde_release_keysector(wp);
393 g_bde_work_done(struct g_bde_work *wp, int error)
396 g_bde_contribute(wp->bp, wp->length, error);
397 if (wp->sp != NULL)
398 g_bde_delete_sector(wp->softc, wp->sp);
399 if (wp->ksp != NULL)
400 g_bde_release_keysector(wp);
401 g_bde_delete_work(wp);
413 struct g_bde_work *wp;
427 wp = sp->owner;
428 if (wp->error == 0)
429 wp->error = sp->error;
431 if (wp->bp->bio_cmd == BIO_DELETE) {
432 KASSERT(sp == wp->sp, ("trashed delete op"));
433 g_bde_work_done(wp, wp->error);
438 KASSERT(wp->bp->bio_cmd == BIO_WRITE, ("Confused in g_bde_write_done()"));
439 KASSERT(sp == wp->sp || sp == wp->ksp, ("trashed write op"));
440 if (wp->sp == sp) {
441 g_bde_delete_sector(sc, wp->sp);
442 wp->sp = NULL;
446 if (wp->sp == NULL && wp->ksp != NULL && wp->ksp->state == VALID)
447 g_bde_work_done(wp, wp->error);
551 struct g_bde_work *wp, *twp;
562 TAILQ_FOREACH_SAFE(wp, &sc->worklist, list, twp) {
563 KASSERT(wp != NULL, ("NULL wp"));
564 KASSERT(wp->softc != NULL, ("NULL wp->softc"));
565 if (wp->state != WAIT)
568 KASSERT(wp->bp != NULL, ("NULL wp->bp"));
569 KASSERT(wp->sp != NULL, ("NULL wp->sp"));
571 if (wp->ksp != NULL) {
572 if (wp->ksp->owner != wp)
574 if (wp->ksp->state == IO)
576 KASSERT(wp->ksp->state == VALID,
578 wp->ksp->state));
581 if (wp->bp->bio_cmd == BIO_READ && wp->sp->state == IO)
584 if (wp->ksp != NULL && wp->ksp->error != 0) {
585 g_bde_work_done(wp, wp->ksp->error);
588 switch(wp->bp->bio_cmd) {
590 if (wp->ksp == NULL) {
591 KASSERT(wp->error != 0,
593 g_bde_work_done(wp, wp->error);
596 if (wp->sp->error != 0) {
597 g_bde_work_done(wp, wp->sp->error);
601 g_bde_crypt_read(wp);
604 g_bde_work_done(wp, wp->sp->error);
607 wp->state = FINISH;
608 KASSERT(wp->sp->owner == wp,
610 KASSERT(wp->ksp->owner == wp,
613 g_bde_crypt_write(wp);
616 error = g_bde_start_write(wp->sp);
618 g_bde_work_done(wp, error);
621 error = g_bde_start_write(wp->ksp);
622 if (wp->error != 0)
623 wp->error = error;
626 wp->state = FINISH;
628 g_bde_crypt_delete(wp);
631 g_bde_start_write(wp->sp);
677 g_bde_start2(struct g_bde_work *wp)
681 KASSERT(wp != NULL, ("NULL wp in g_bde_start2"));
682 KASSERT(wp->softc != NULL, ("NULL wp->softc"));
683 g_trace(G_T_TOPOLOGY, "g_bde_start2(%p)", wp);
684 sc = wp->softc;
685 switch (wp->bp->bio_cmd) {
687 wp->sp = g_bde_new_sector(wp, 0);
688 if (wp->sp == NULL) {
689 g_bde_work_done(wp, ENOMEM);
692 wp->sp->size = wp->length;
693 wp->sp->data = wp->data;
694 if (g_bde_start_read(wp->sp) != 0) {
695 g_bde_work_done(wp, ENOMEM);
698 g_bde_read_keysector(sc, wp);
699 if (wp->ksp == NULL)
700 wp->error = ENOMEM;
703 wp->sp = g_bde_new_sector(wp, wp->length);
704 if (wp->sp == NULL) {
705 g_bde_work_done(wp, ENOMEM);
710 wp->sp = g_bde_new_sector(wp, wp->length);
711 if (wp->sp == NULL) {
712 g_bde_work_done(wp, ENOMEM);
715 g_bde_read_keysector(sc, wp);
716 if (wp->ksp == NULL) {
717 g_bde_work_done(wp, ENOMEM);
723 ("Wrong bio_cmd %d in g_bde_start2", wp->bp->bio_cmd));
726 wp->state = WAIT;
739 struct g_bde_work *wp;
747 wp = g_bde_new_work(sc);
748 if (wp != NULL) {
749 wp->bp = bp;
750 wp->offset = bp->bio_offset + done;
751 wp->data = bp->bio_data + done;
752 wp->length = bp->bio_length - done;
753 g_bde_map_sector(wp);
754 done += wp->length;
755 g_bde_start2(wp);
757 if (wp == NULL || bp->bio_error != 0) {