static void qed_aio_write_alloc(QEDAIOCB *acb, size_t len)

{

    BDRVQEDState *s = acb_to_s(acb);



    /* Freeze this request if another allocating write is in progress */

    if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {

        QSIMPLEQ_INSERT_TAIL(&s->allocating_write_reqs, acb, next);

    }

    if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {

        return; /* wait for existing request to finish */

    }



    acb->cur_nclusters = qed_bytes_to_clusters(s,

            qed_offset_into_cluster(s, acb->cur_pos) + len);

    acb->cur_cluster = qed_alloc_clusters(s, acb->cur_nclusters);

    qemu_iovec_copy(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);



    if (qed_should_set_need_check(s)) {

        s->header.features |= QED_F_NEED_CHECK;

        qed_write_header(s, qed_aio_write_prefill, acb);

    } else {

        qed_aio_write_prefill(acb, 0);

    }

}

static void qed_aio_write_alloc(QEDAIOCB *acb, size_t len)

{

    BDRVQEDState *s = acb_to_s(acb);



    

    if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {

        QSIMPLEQ_INSERT_TAIL(&s->allocating_write_reqs, acb, next);

    }

    if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {

        return; 

    }



    acb->cur_nclusters = qed_bytes_to_clusters(s,

            qed_offset_into_cluster(s, acb->cur_pos) + len);

    acb->cur_cluster = qed_alloc_clusters(s, acb->cur_nclusters);

    qemu_iovec_copy(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);



    if (qed_should_set_need_check(s)) {

        s->header.features |= QED_F_NEED_CHECK;

        qed_write_header(s, qed_aio_write_prefill, acb);

    } else {

        qed_aio_write_prefill(acb, 0);

    }

}

    if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {
static void FUNC_0(QEDAIOCB *VAR_0, size_t VAR_1)

{

    BDRVQEDState *s = acb_to_s(VAR_0);



    

    if (VAR_0 != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {

        QSIMPLEQ_INSERT_TAIL(&s->allocating_write_reqs, VAR_0, next);

    }

    if (VAR_0 != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {

        return; 

    }



    VAR_0->cur_nclusters = qed_bytes_to_clusters(s,

            qed_offset_into_cluster(s, VAR_0->cur_pos) + VAR_1);

    VAR_0->cur_cluster = qed_alloc_clusters(s, VAR_0->cur_nclusters);

    qemu_iovec_copy(&VAR_0->cur_qiov, VAR_0->qiov, VAR_0->qiov_offset, VAR_1);



    if (qed_should_set_need_check(s)) {

        s->header.features |= QED_F_NEED_CHECK;

        qed_write_header(s, qed_aio_write_prefill, VAR_0);

    } else {

        qed_aio_write_prefill(VAR_0, 0);

    }

}

static void FUNC_0(QEDAIOCB *VAR_0, size_t VAR_1)
{ BDRVQEDState *s = acb_to_s(VAR_0); if (VAR_0 != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) { QSIMPLEQ_INSERT_TAIL(&s->allocating_write_reqs, VAR_0, next); } if (VAR_0 != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) { return; } VAR_0->cur_nclusters = qed_bytes_to_clusters(s,
qed_offset_into_cluster(s, VAR_0->cur_pos) + VAR_1); VAR_0->cur_cluster = qed_alloc_clusters(s, VAR_0->cur_nclusters); qemu_iovec_copy(&VAR_0->cur_qiov, VAR_0->qiov, VAR_0->qiov_offset, VAR_1); if (qed_should_set_need_check(s)) { s->header.features |= QED_F_NEED_CHECK; qed_write_header(s, qed_aio_write_prefill, VAR_0); } else { qed_aio_write_prefill(VAR_0, 0); } }