static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)

{

    BlockRequest *blkreq;

    uint64_t sector;



    sector = virtio_ldq_p(VIRTIO_DEVICE(req->dev), &req->out.sector);



    trace_virtio_blk_handle_write(req, sector, req->qiov.size / 512);



    if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {

        virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);

        virtio_blk_free_request(req);

        return;

    }



    block_acct_start(bdrv_get_stats(req->dev->bs), &req->acct, req->qiov.size,

                     BLOCK_ACCT_WRITE);



    if (mrb->num_writes == 32) {

        virtio_submit_multiwrite(req->dev->bs, mrb);

    }



    blkreq = &mrb->blkreq[mrb->num_writes];

    blkreq->sector = sector;

    blkreq->nb_sectors = req->qiov.size / BDRV_SECTOR_SIZE;

    blkreq->qiov = &req->qiov;

    blkreq->cb = virtio_blk_rw_complete;

    blkreq->opaque = req;

    blkreq->error = 0;



    mrb->num_writes++;

}

static void virtio_blk_handle_write(VirtIOBlockReq *req, MultiReqBuffer *mrb)

{

    BlockRequest *blkreq;

    uint64_t sector;



    sector = virtio_ldq_p(VIRTIO_DEVICE(req->dev), &req->out.sector);



    trace_virtio_blk_handle_write(req, sector, req->qiov.size / 512);



    if (!virtio_blk_sect_range_ok(req->dev, sector, req->qiov.size)) {

        virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);

        virtio_blk_free_request(req);

        return;

    }



    block_acct_start(bdrv_get_stats(req->dev->bs), &req->acct, req->qiov.size,

                     BLOCK_ACCT_WRITE);



    if (mrb->num_writes == 32) {

        virtio_submit_multiwrite(req->dev->bs, mrb);

    }



    blkreq = &mrb->blkreq[mrb->num_writes];

    blkreq->sector = sector;

    blkreq->nb_sectors = req->qiov.size / BDRV_SECTOR_SIZE;

    blkreq->qiov = &req->qiov;

    blkreq->cb = virtio_blk_rw_complete;

    blkreq->opaque = req;

    blkreq->error = 0;



    mrb->num_writes++;

}

static void FUNC_0(VirtIOBlockReq *VAR_0, MultiReqBuffer *VAR_1)

{

    BlockRequest *blkreq;

    uint64_t sector;



    sector = virtio_ldq_p(VIRTIO_DEVICE(VAR_0->dev), &VAR_0->out.sector);



    trace_virtio_blk_handle_write(VAR_0, sector, VAR_0->qiov.size / 512);



    if (!virtio_blk_sect_range_ok(VAR_0->dev, sector, VAR_0->qiov.size)) {

        virtio_blk_req_complete(VAR_0, VIRTIO_BLK_S_IOERR);

        virtio_blk_free_request(VAR_0);

        return;

    }



    block_acct_start(bdrv_get_stats(VAR_0->dev->bs), &VAR_0->acct, VAR_0->qiov.size,

                     BLOCK_ACCT_WRITE);



    if (VAR_1->num_writes == 32) {

        virtio_submit_multiwrite(VAR_0->dev->bs, VAR_1);

    }



    blkreq = &VAR_1->blkreq[VAR_1->num_writes];

    blkreq->sector = sector;

    blkreq->nb_sectors = VAR_0->qiov.size / BDRV_SECTOR_SIZE;

    blkreq->qiov = &VAR_0->qiov;

    blkreq->cb = virtio_blk_rw_complete;

    blkreq->opaque = VAR_0;

    blkreq->error = 0;



    VAR_1->num_writes++;

}

static void FUNC_0(VirtIOBlockReq *VAR_0, MultiReqBuffer *VAR_1)
{ BlockRequest *blkreq; uint64_t sector; sector = virtio_ldq_p(VIRTIO_DEVICE(VAR_0->dev), &VAR_0->out.sector); trace_virtio_blk_handle_write(VAR_0, sector, VAR_0->qiov.size / 512); if (!virtio_blk_sect_range_ok(VAR_0->dev, sector, VAR_0->qiov.size)) { virtio_blk_req_complete(VAR_0, VIRTIO_BLK_S_IOERR); virtio_blk_free_request(VAR_0); return; } block_acct_start(bdrv_get_stats(VAR_0->dev->bs), &VAR_0->acct, VAR_0->qiov.size,
BLOCK_ACCT_WRITE); if (VAR_1->num_writes == 32) { virtio_submit_multiwrite(VAR_0->dev->bs, VAR_1); } blkreq = &VAR_1->blkreq[VAR_1->num_writes]; blkreq->sector = sector; blkreq->nb_sectors = VAR_0->qiov.size / BDRV_SECTOR_SIZE; blkreq->qiov = &VAR_0->qiov; blkreq->cb = virtio_blk_rw_complete; blkreq->opaque = VAR_0; blkreq->error = 0; VAR_1->num_writes++; }