static int ioreq_runio_qemu_sync(struct ioreq *ioreq)

{

    struct XenBlkDev *blkdev = ioreq->blkdev;

    int i, rc, len = 0;

    off_t pos;



    if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1)

	goto err;

    if (ioreq->presync)

	bdrv_flush(blkdev->bs);



    switch (ioreq->req.operation) {

    case BLKIF_OP_READ:

	pos = ioreq->start;

	for (i = 0; i < ioreq->v.niov; i++) {

	    rc = bdrv_read(blkdev->bs, pos / BLOCK_SIZE,

			   ioreq->v.iov[i].iov_base,

			   ioreq->v.iov[i].iov_len / BLOCK_SIZE);

	    if (rc != 0) {

		xen_be_printf(&blkdev->xendev, 0, "rd I/O error (%p, len %zd)\n",

			      ioreq->v.iov[i].iov_base,

			      ioreq->v.iov[i].iov_len);

		goto err;

	    }

	    len += ioreq->v.iov[i].iov_len;

	    pos += ioreq->v.iov[i].iov_len;

	}

	break;

    case BLKIF_OP_WRITE:

    case BLKIF_OP_WRITE_BARRIER:

        if (!ioreq->req.nr_segments)

            break;

	pos = ioreq->start;

	for (i = 0; i < ioreq->v.niov; i++) {

	    rc = bdrv_write(blkdev->bs, pos / BLOCK_SIZE,

			    ioreq->v.iov[i].iov_base,

			    ioreq->v.iov[i].iov_len / BLOCK_SIZE);

	    if (rc != 0) {

		xen_be_printf(&blkdev->xendev, 0, "wr I/O error (%p, len %zd)\n",

			      ioreq->v.iov[i].iov_base,

			      ioreq->v.iov[i].iov_len);

		goto err;

	    }

	    len += ioreq->v.iov[i].iov_len;

	    pos += ioreq->v.iov[i].iov_len;

	}

	break;

    default:

	/* unknown operation (shouldn't happen -- parse catches this) */

	goto err;

    }



    if (ioreq->postsync)

	bdrv_flush(blkdev->bs);

    ioreq->status = BLKIF_RSP_OKAY;



    ioreq_unmap(ioreq);

    ioreq_finish(ioreq);

    return 0;



err:

    ioreq->status = BLKIF_RSP_ERROR;

    return -1;

}

static int ioreq_runio_qemu_sync(struct ioreq *ioreq)

{

    struct XenBlkDev *blkdev = ioreq->blkdev;

    int i, rc, len = 0;

    off_t pos;



    if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1)

	goto err;

    if (ioreq->presync)

	bdrv_flush(blkdev->bs);



    switch (ioreq->req.operation) {

    case BLKIF_OP_READ:

	pos = ioreq->start;

	for (i = 0; i < ioreq->v.niov; i++) {

	    rc = bdrv_read(blkdev->bs, pos / BLOCK_SIZE,

			   ioreq->v.iov[i].iov_base,

			   ioreq->v.iov[i].iov_len / BLOCK_SIZE);

	    if (rc != 0) {

		xen_be_printf(&blkdev->xendev, 0, "rd I/O error (%p, len %zd)\n",

			      ioreq->v.iov[i].iov_base,

			      ioreq->v.iov[i].iov_len);

		goto err;

	    }

	    len += ioreq->v.iov[i].iov_len;

	    pos += ioreq->v.iov[i].iov_len;

	}

	break;

    case BLKIF_OP_WRITE:

    case BLKIF_OP_WRITE_BARRIER:

        if (!ioreq->req.nr_segments)

            break;

	pos = ioreq->start;

	for (i = 0; i < ioreq->v.niov; i++) {

	    rc = bdrv_write(blkdev->bs, pos / BLOCK_SIZE,

			    ioreq->v.iov[i].iov_base,

			    ioreq->v.iov[i].iov_len / BLOCK_SIZE);

	    if (rc != 0) {

		xen_be_printf(&blkdev->xendev, 0, "wr I/O error (%p, len %zd)\n",

			      ioreq->v.iov[i].iov_base,

			      ioreq->v.iov[i].iov_len);

		goto err;

	    }

	    len += ioreq->v.iov[i].iov_len;

	    pos += ioreq->v.iov[i].iov_len;

	}

	break;

    default:

	

	goto err;

    }



    if (ioreq->postsync)

	bdrv_flush(blkdev->bs);

    ioreq->status = BLKIF_RSP_OKAY;



    ioreq_unmap(ioreq);

    ioreq_finish(ioreq);

    return 0;



err:

    ioreq->status = BLKIF_RSP_ERROR;

    return -1;

}

	goto err; 	goto err;
static int FUNC_0(struct VAR_0 *VAR_0)

{

    struct XenBlkDev *VAR_1 = VAR_0->VAR_1;

    int VAR_2, VAR_3, VAR_4 = 0;

    off_t pos;



    if (VAR_0->req.nr_segments && ioreq_map(VAR_0) == -1)

	goto err;

    if (VAR_0->presync)

	bdrv_flush(VAR_1->bs);



    switch (VAR_0->req.operation) {

    case BLKIF_OP_READ:

	pos = VAR_0->start;

	for (VAR_2 = 0; VAR_2 < VAR_0->v.niov; VAR_2++) {

	    VAR_3 = bdrv_read(VAR_1->bs, pos / BLOCK_SIZE,

			   VAR_0->v.iov[VAR_2].iov_base,

			   VAR_0->v.iov[VAR_2].iov_len / BLOCK_SIZE);

	    if (VAR_3 != 0) {

		xen_be_printf(&VAR_1->xendev, 0, "rd I/O error (%p, VAR_4 %zd)\n",

			      VAR_0->v.iov[VAR_2].iov_base,

			      VAR_0->v.iov[VAR_2].iov_len);

		goto err;

	    }

	    VAR_4 += VAR_0->v.iov[VAR_2].iov_len;

	    pos += VAR_0->v.iov[VAR_2].iov_len;

	}

	break;

    case BLKIF_OP_WRITE:

    case BLKIF_OP_WRITE_BARRIER:

        if (!VAR_0->req.nr_segments)

            break;

	pos = VAR_0->start;

	for (VAR_2 = 0; VAR_2 < VAR_0->v.niov; VAR_2++) {

	    VAR_3 = bdrv_write(VAR_1->bs, pos / BLOCK_SIZE,

			    VAR_0->v.iov[VAR_2].iov_base,

			    VAR_0->v.iov[VAR_2].iov_len / BLOCK_SIZE);

	    if (VAR_3 != 0) {

		xen_be_printf(&VAR_1->xendev, 0, "wr I/O error (%p, VAR_4 %zd)\n",

			      VAR_0->v.iov[VAR_2].iov_base,

			      VAR_0->v.iov[VAR_2].iov_len);

		goto err;

	    }

	    VAR_4 += VAR_0->v.iov[VAR_2].iov_len;

	    pos += VAR_0->v.iov[VAR_2].iov_len;

	}

	break;

    default:

	

	goto err;

    }



    if (VAR_0->postsync)

	bdrv_flush(VAR_1->bs);

    VAR_0->status = BLKIF_RSP_OKAY;



    ioreq_unmap(VAR_0);

    ioreq_finish(VAR_0);

    return 0;



err:

    VAR_0->status = BLKIF_RSP_ERROR;

    return -1;

}

static int FUNC_0(struct VAR_0 *VAR_0)
{ struct XenBlkDev *VAR_1 = VAR_0->VAR_1; int VAR_2, VAR_3, VAR_4 = 0; off_t pos; if (VAR_0->req.nr_segments && ioreq_map(VAR_0) == -1)
goto err; if (VAR_0->presync)
bdrv_flush(VAR_1->bs); switch (VAR_0->req.operation) { case BLKIF_OP_READ:
pos = VAR_0->start; for (VAR_2 = 0; VAR_2 < VAR_0->v.niov; VAR_2++) { VAR_3 = bdrv_read(VAR_1->bs, pos / BLOCK_SIZE,
VAR_0->v.iov[VAR_2].iov_base,
VAR_0->v.iov[VAR_2].iov_len / BLOCK_SIZE); if (VAR_3 != 0) { xen_be_printf(&VAR_1->xendev, 0, "rd I/O error (%p, VAR_4 %zd)\n",
VAR_0->v.iov[VAR_2].iov_base,
VAR_0->v.iov[VAR_2].iov_len); goto err; } VAR_4 += VAR_0->v.iov[VAR_2].iov_len; pos += VAR_0->v.iov[VAR_2].iov_len; } break; case BLKIF_OP_WRITE:
case BLKIF_OP_WRITE_BARRIER:
if (!VAR_0->req.nr_segments)
break; pos = VAR_0->start; for (VAR_2 = 0; VAR_2 < VAR_0->v.niov; VAR_2++) { VAR_3 = bdrv_write(VAR_1->bs, pos / BLOCK_SIZE,
VAR_0->v.iov[VAR_2].iov_base,
VAR_0->v.iov[VAR_2].iov_len / BLOCK_SIZE); if (VAR_3 != 0) { xen_be_printf(&VAR_1->xendev, 0, "wr I/O error (%p, VAR_4 %zd)\n",
VAR_0->v.iov[VAR_2].iov_base,
VAR_0->v.iov[VAR_2].iov_len); goto err; } VAR_4 += VAR_0->v.iov[VAR_2].iov_len; pos += VAR_0->v.iov[VAR_2].iov_len; } break; default:
goto err; } if (VAR_0->postsync)
bdrv_flush(VAR_1->bs); VAR_0->status = BLKIF_RSP_OKAY; ioreq_unmap(VAR_0); ioreq_finish(VAR_0); return 0; err:
VAR_0->status = BLKIF_RSP_ERROR; return -1; }