FreeBSD/sys/geom/eli/g_eli_privacy.c
/*
 * The function is called after data encryption.
 *
 * g_eli_start -> g_eli_crypto_run -> G_ELI_CRYPTO_WRITE_DONE -> g_io_request -> g_eli_write_done -> g_io_deliver
 */
The function is called after data encryption.
The function is called after data encryption .
static int
g_eli_crypto_write_done(struct cryptop *crp)
{
	struct g_eli_softc *sc;
	struct g_geom *gp;
	struct g_consumer *cp;
	struct bio *bp, *cbp;
	if (crp->crp_etype == EAGAIN) {
		if (g_eli_crypto_rerun(crp) == 0)
			return (0);
	}
	bp = (struct bio *)crp->crp_opaque;
	bp->bio_inbed++;
	if (crp->crp_etype == 0) {
		G_ELI_DEBUG(3, "Crypto WRITE request done (%d/%d).",
		    bp->bio_inbed, bp->bio_children);
	} else {
		G_ELI_DEBUG(1, "Crypto WRITE request failed (%d/%d) error=%d.",
		    bp->bio_inbed, bp->bio_children, crp->crp_etype);
		if (bp->bio_error == 0)
			bp->bio_error = crp->crp_etype;
	}
	gp = bp->bio_to->geom;
	sc = gp->softc;
	g_eli_key_drop(sc, crp->crp_desc->crd_key);
	if (bp->bio_inbed < bp->bio_children)
		return (0);
	bp->bio_inbed = 0;
	bp->bio_children = 1;
	cbp = bp->bio_driver1;
	bp->bio_driver1 = NULL;
	if (bp->bio_error != 0) {
		G_ELI_LOGREQ(0, bp, "Crypto WRITE request failed (error=%d).",
		    bp->bio_error);
		free(bp->bio_driver2, M_ELI);
		bp->bio_driver2 = NULL;
		g_destroy_bio(cbp);
		g_io_deliver(bp, bp->bio_error);
		atomic_subtract_int(&sc->sc_inflight, 1);
		return (0);
	}
	cbp->bio_data = bp->bio_driver2;
	cbp->bio_done = g_eli_write_done;
	cp = LIST_FIRST(&gp->consumer);
	cbp->bio_to = cp->provider;
	G_ELI_LOGREQ(2, cbp, "Sending request.");
	g_io_request(cbp, cp);
	return (0);
}
static int g_eli_crypto_write_done ( struct cryptop * crp ) { struct g_eli_softc * sc ; struct g_geom * gp ; struct g_consumer * cp ; struct bio * bp , * cbp ; if ( crp -> crp_etype == EAGAIN ) { if ( g_eli_crypto_rerun ( crp ) == 0 ) return ( 0 ) ; } bp = ( struct bio * ) crp -> crp_opaque ; bp -> bio_inbed ++ ; if ( crp -> crp_etype == 0 ) { G_ELI_DEBUG ( 3 , " " , bp -> bio_inbed , bp -> bio_children ) ; } else { G_ELI_DEBUG ( 1 , " " , bp -> bio_inbed , bp -> bio_children , crp -> crp_etype ) ; if ( bp -> bio_error == 0 ) bp -> bio_error = crp -> crp_etype ; } gp = bp -> bio_to -> geom ; sc = gp -> softc ; g_eli_key_drop ( sc , crp -> crp_desc -> crd_key ) ; if ( bp -> bio_inbed < bp -> bio_children ) return ( 0 ) ; bp -> bio_inbed = 0 ; bp -> bio_children = 1 ; cbp = bp -> bio_driver1 ; bp -> bio_driver1 = NULL ; if ( bp -> bio_error != 0 ) { G_ELI_LOGREQ ( 0 , bp , " " , bp -> bio_error ) ; free ( bp -> bio_driver2 , M_ELI ) ; bp -> bio_driver2 = NULL ; g_destroy_bio ( cbp ) ; g_io_deliver ( bp , bp -> bio_error ) ; atomic_subtract_int ( & sc -> sc_inflight , 1 ) ; return ( 0 ) ; } cbp -> bio_data = bp -> bio_driver2 ; cbp -> bio_done = g_eli_write_done ; cp = LIST_FIRST ( & gp -> consumer ) ; cbp -> bio_to = cp -> provider ; G_ELI_LOGREQ ( 2 , cbp , " " ) ; g_io_request ( cbp , cp ) ; return ( 0 ) ; }
The function is called after data encryption.
The function is called after data encryption .
/*
	 * All sectors are already encrypted?
	 */ /*
	 * Send encrypted data to the provider.
	 */