static void crypt_free_req(struct crypt_config *cc, struct ablkcipher_request *req, struct bio *base_bio) { struct dm_crypt_io *io = dm_per_bio_data(base_bio, cc->per_bio_data_size); if ((struct ablkcipher_request *)(io + 1) != req) mempool_free(req, cc->req_pool); }
/* * Issue a BIO to a zone. The BIO may only partially process the * original target BIO. */ static int dmz_submit_read_bio(struct dmz_target *dmz, struct dm_zone *zone, struct bio *bio, sector_t chunk_block, unsigned int nr_blocks) { struct dmz_bioctx *bioctx = dm_per_bio_data(bio, sizeof(struct dmz_bioctx)); sector_t sector; struct bio *clone; /* BIO remap sector */ sector = dmz_start_sect(dmz->metadata, zone) + dmz_blk2sect(chunk_block); /* If the read is not partial, there is no need to clone the BIO */ if (nr_blocks == dmz_bio_blocks(bio)) { /* Setup and submit the BIO */ bio->bi_iter.bi_sector = sector; atomic_inc(&bioctx->ref); generic_make_request(bio); return 0; } /* Partial BIO: we need to clone the BIO */ clone = bio_clone_fast(bio, GFP_NOIO, dmz->bio_set); if (!clone) return -ENOMEM; /* Setup the clone */ clone->bi_iter.bi_sector = sector; clone->bi_iter.bi_size = dmz_blk2sect(nr_blocks) << SECTOR_SHIFT; clone->bi_end_io = dmz_read_bio_end_io; clone->bi_private = bioctx; bio_advance(bio, clone->bi_iter.bi_size); /* Submit the clone */ atomic_inc(&bioctx->ref); generic_make_request(clone); return 0; }