FreeBSD/sys/dev/xen/blkback/blkback.c
/**
 * Complete a request list.
 *
 * \param xbb        Per-instance xbb configuration structure.
 * \param reqlist    Allocated internal request list structure.
 */
Complete a request list.
\param xbb        Per-instance xbb configuration structure.
\param reqlist    Allocated internal request list structure.
Complete a request list . \ param xbb Per - instance xbb configuration structure . \ param reqlist Allocated internal request list structure .
static void
xbb_complete_reqlist(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist)
{
	struct xbb_xen_req *nreq;
	off_t		    sectors_sent;
	int		    notify, run_taskqueue;
	sectors_sent = 0;
	if (reqlist->flags & XBB_REQLIST_MAPPED)
		xbb_unmap_reqlist(reqlist);
	mtx_lock(&xbb->lock);
	STAILQ_FOREACH(nreq, &reqlist->contig_req_list, links) {
		off_t cur_sectors_sent;
		xbb_queue_response(xbb, nreq, reqlist->status);
		if (reqlist->status == BLKIF_RSP_OKAY)
			cur_sectors_sent = nreq->nr_512b_sectors;
		else
			cur_sectors_sent = 0;
		sectors_sent += cur_sectors_sent;
		devstat_end_transaction(xbb->xbb_stats_in,
					cur_sectors_sent << 9,
					reqlist->ds_tag_type,
					reqlist->ds_trans_type,
					NULL,
					&nreq->ds_t0);
	}
	sectors_sent -= reqlist->residual_512b_sectors;
	if (sectors_sent < 0)
		sectors_sent = 0;
	devstat_end_transaction(xbb->xbb_stats,
				 sectors_sent << 9,
				reqlist->ds_tag_type,
				reqlist->ds_trans_type,
				NULL,
				&reqlist->ds_t0);
	xbb_release_reqlist(xbb, reqlist,  1);
	xbb_push_responses(xbb, &run_taskqueue, &notify);
	mtx_unlock(&xbb->lock);
	if (run_taskqueue)
		taskqueue_enqueue(xbb->io_taskqueue, &xbb->io_task); 
	if (notify)
		xen_intr_signal(xbb->xen_intr_handle);
}
static void xbb_complete_reqlist ( struct xbb_softc * xbb , struct xbb_xen_reqlist * reqlist ) { struct xbb_xen_req * nreq ; off_t sectors_sent ; int notify , run_taskqueue ; sectors_sent = 0 ; if ( reqlist -> flags & XBB_REQLIST_MAPPED ) xbb_unmap_reqlist ( reqlist ) ; mtx_lock ( & xbb -> lock ) ; STAILQ_FOREACH ( nreq , & reqlist -> contig_req_list , links ) { off_t cur_sectors_sent ; xbb_queue_response ( xbb , nreq , reqlist -> status ) ; if ( reqlist -> status == BLKIF_RSP_OKAY ) cur_sectors_sent = nreq -> nr_512b_sectors ; else cur_sectors_sent = 0 ; sectors_sent += cur_sectors_sent ; devstat_end_transaction ( xbb -> xbb_stats_in , cur_sectors_sent << 9 , reqlist -> ds_tag_type , reqlist -> ds_trans_type , NULL , & nreq -> ds_t0 ) ; } sectors_sent -= reqlist -> residual_512b_sectors ; if ( sectors_sent < 0 ) sectors_sent = 0 ; devstat_end_transaction ( xbb -> xbb_stats , sectors_sent << 9 , reqlist -> ds_tag_type , reqlist -> ds_trans_type , NULL , & reqlist -> ds_t0 ) ; xbb_release_reqlist ( xbb , reqlist , 1 ) ; xbb_push_responses ( xbb , & run_taskqueue , & notify ) ; mtx_unlock ( & xbb -> lock ) ; if ( run_taskqueue ) taskqueue_enqueue ( xbb -> io_taskqueue , & xbb -> io_task ) ; if ( notify ) xen_intr_signal ( xbb -> xen_intr_handle ) ; }
Complete a request list.
Complete a request list .
/*
	 * All I/O is done, send the response. A lock is not necessary
	 * to protect the request list, because all requests have
	 * completed.  Therefore this is the only context accessing this
	 * reqlist right now.  However, in order to make sure that no one
	 * else queues responses onto the queue or pushes them to the other
	 * side while we're active, we need to hold the lock across the
	 * calls to xbb_queue_response() and xbb_push_responses().
	 */ /* Put this response on the ring, but don't push yet */ /* We don't report bytes sent if there is an error. */ /*bytes*/ /*now*/ /*then*/ /*
	 * Take out any sectors not sent.  If we wind up negative (which
	 * might happen if an error is reported as well as a residual), just
	 * report 0 sectors sent.
	 */ /*bytes*/ /*now*/ /*then*/ /*wakeup*/