FreeBSD/sys/dev/xen/blkback/blkback.c
/**
 * Create and queue a response to a blkif request.
 * 
 * \param xbb     Per-instance xbb configuration structure.
 * \param req     The request structure to which to respond.
 * \param status  The status code to report.  See BLKIF_RSP_*
 *                in sys/xen/interface/io/blkif.h.
 */
Create and queue a response to a blkif request.

\param xbb     Per-instance xbb configuration structure.
\param req     The request structure to which to respond.
\param status  The status code to report.
Create and queue a response to a blkif request . \ param xbb Per - instance xbb configuration structure . \ param req The request structure to which to respond . \ param status The status code to report .
static void
xbb_queue_response(struct xbb_softc *xbb, struct xbb_xen_req *req, int status)
{
	blkif_response_t *resp;
	mtx_assert(&xbb->lock, MA_OWNED);
	switch (xbb->abi) {
	case BLKIF_PROTOCOL_NATIVE:
		resp = RING_GET_RESPONSE(&xbb->rings.native,
					 xbb->rings.native.rsp_prod_pvt);
		break;
	case BLKIF_PROTOCOL_X86_32:
		resp = (blkif_response_t *)
		    RING_GET_RESPONSE(&xbb->rings.x86_32,
				      xbb->rings.x86_32.rsp_prod_pvt);
		break;
	case BLKIF_PROTOCOL_X86_64:
		resp = (blkif_response_t *)
		    RING_GET_RESPONSE(&xbb->rings.x86_64,
				      xbb->rings.x86_64.rsp_prod_pvt);
		break;
	default:
		panic("Unexpected blkif protocol ABI.");
	}
	resp->id        = req->id;
	resp->operation = req->operation;
	resp->status    = status;
	if (status != BLKIF_RSP_OKAY)
		xbb->reqs_completed_with_error++;
	xbb->rings.common.rsp_prod_pvt++;
	xbb->reqs_queued_for_completion++;
}
static void xbb_queue_response ( struct xbb_softc * xbb , struct xbb_xen_req * req , int status ) { blkif_response_t * resp ; mtx_assert ( & xbb -> lock , MA_OWNED ) ; switch ( xbb -> abi ) { case BLKIF_PROTOCOL_NATIVE : resp = RING_GET_RESPONSE ( & xbb -> rings . native , xbb -> rings . native . rsp_prod_pvt ) ; break ; case BLKIF_PROTOCOL_X86_32 : resp = ( blkif_response_t * ) RING_GET_RESPONSE ( & xbb -> rings . x86_32 , xbb -> rings . x86_32 . rsp_prod_pvt ) ; break ; case BLKIF_PROTOCOL_X86_64 : resp = ( blkif_response_t * ) RING_GET_RESPONSE ( & xbb -> rings . x86_64 , xbb -> rings . x86_64 . rsp_prod_pvt ) ; break ; default : panic ( " " ) ; } resp -> id = req -> id ; resp -> operation = req -> operation ; resp -> status = status ; if ( status != BLKIF_RSP_OKAY ) xbb -> reqs_completed_with_error ++ ; xbb -> rings . common . rsp_prod_pvt ++ ; xbb -> reqs_queued_for_completion ++ ; }
Create and queue a response to a blkif request.
Create and queue a response to a blkif request .
/*
	 * The mutex is required here, and should be held across this call
	 * until after the subsequent call to xbb_push_responses().  This
	 * is to guarantee that another context won't queue responses and
	 * push them while we're active.
	 *
	 * That could lead to the other end being notified of responses
	 * before the resources have been freed on this end.  The other end
	 * would then be able to queue additional I/O, and we may run out
 	 * of resources because we haven't freed them all yet.
	 */ /*
	 * Place on the response ring for the relevant domain.
	 * For now, only the spacing between entries is different
	 * in the different ABIs, not the response entry layout.
	 */