/* They must be separated as otherwise the final stages could be starved by new requests which can block in the first stages due to memory allocation.  */
static void crypt_endio(struct bio *clone, int error)
/* They must be separated as otherwise the final stages could be starved by new requests which can block in the first stages due to memory allocation.  */
static void crypt_endio(struct bio *clone, int error)
{
	struct dm_crypt_io *io = clone->bi_private;
	struct crypt_config *cc = io->target->private;
	unsigned rw = bio_data_dir(clone);
	if (unlikely(!bio_flagged(clone, BIO_UPTODATE) && !error))
		error = -EIO;
	if (rw == WRITE)
		crypt_free_buffer_pages(cc, clone);
	bio_put(clone);
	if (rw == READ && !error) {
		kcryptd_queue_crypt(io);
		return;
	}
	if (unlikely(error))
		io->error = error;
	crypt_dec_pending(io);
}