static void mirror_iteration_done(MirrorOp *op, int ret)

{

    MirrorBlockJob *s = op->s;

    struct iovec *iov;

    int64_t chunk_num;

    int i, nb_chunks, sectors_per_chunk;



    trace_mirror_iteration_done(s, op->sector_num, op->nb_sectors, ret);



    s->in_flight--;

    s->sectors_in_flight -= op->nb_sectors;

    iov = op->qiov.iov;

    for (i = 0; i < op->qiov.niov; i++) {

        MirrorBuffer *buf = (MirrorBuffer *) iov[i].iov_base;

        QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next);

        s->buf_free_count++;

    }



    sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;

    chunk_num = op->sector_num / sectors_per_chunk;

    nb_chunks = DIV_ROUND_UP(op->nb_sectors, sectors_per_chunk);

    bitmap_clear(s->in_flight_bitmap, chunk_num, nb_chunks);

    if (ret >= 0) {

        if (s->cow_bitmap) {

            bitmap_set(s->cow_bitmap, chunk_num, nb_chunks);

        }

        s->common.offset += (uint64_t)op->nb_sectors * BDRV_SECTOR_SIZE;

    }



    qemu_iovec_destroy(&op->qiov);

    g_free(op);



    if (s->waiting_for_io) {

        qemu_coroutine_enter(s->common.co, NULL);

    }

}

static void mirror_iteration_done(MirrorOp *op, int ret)

{

    MirrorBlockJob *s = op->s;

    struct iovec *iov;

    int64_t chunk_num;

    int i, nb_chunks, sectors_per_chunk;



    trace_mirror_iteration_done(s, op->sector_num, op->nb_sectors, ret);



    s->in_flight--;

    s->sectors_in_flight -= op->nb_sectors;

    iov = op->qiov.iov;

    for (i = 0; i < op->qiov.niov; i++) {

        MirrorBuffer *buf = (MirrorBuffer *) iov[i].iov_base;

        QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next);

        s->buf_free_count++;

    }



    sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;

    chunk_num = op->sector_num / sectors_per_chunk;

    nb_chunks = DIV_ROUND_UP(op->nb_sectors, sectors_per_chunk);

    bitmap_clear(s->in_flight_bitmap, chunk_num, nb_chunks);

    if (ret >= 0) {

        if (s->cow_bitmap) {

            bitmap_set(s->cow_bitmap, chunk_num, nb_chunks);

        }

        s->common.offset += (uint64_t)op->nb_sectors * BDRV_SECTOR_SIZE;

    }



    qemu_iovec_destroy(&op->qiov);

    g_free(op);



    if (s->waiting_for_io) {

        qemu_coroutine_enter(s->common.co, NULL);

    }

}

        qemu_coroutine_enter(s->common.co, NULL);
static void FUNC_0(MirrorOp *VAR_0, int VAR_1)

{

    MirrorBlockJob *s = VAR_0->s;

    struct iovec *VAR_2;

    int64_t chunk_num;

    int VAR_3, VAR_4, VAR_5;



    trace_mirror_iteration_done(s, VAR_0->sector_num, VAR_0->nb_sectors, VAR_1);



    s->in_flight--;

    s->sectors_in_flight -= VAR_0->nb_sectors;

    VAR_2 = VAR_0->qiov.VAR_2;

    for (VAR_3 = 0; VAR_3 < VAR_0->qiov.niov; VAR_3++) {

        MirrorBuffer *buf = (MirrorBuffer *) VAR_2[VAR_3].iov_base;

        QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next);

        s->buf_free_count++;

    }



    VAR_5 = s->granularity >> BDRV_SECTOR_BITS;

    chunk_num = VAR_0->sector_num / VAR_5;

    VAR_4 = DIV_ROUND_UP(VAR_0->nb_sectors, VAR_5);

    bitmap_clear(s->in_flight_bitmap, chunk_num, VAR_4);

    if (VAR_1 >= 0) {

        if (s->cow_bitmap) {

            bitmap_set(s->cow_bitmap, chunk_num, VAR_4);

        }

        s->common.offset += (uint64_t)VAR_0->nb_sectors * BDRV_SECTOR_SIZE;

    }



    qemu_iovec_destroy(&VAR_0->qiov);

    g_free(VAR_0);



    if (s->waiting_for_io) {

        qemu_coroutine_enter(s->common.co, NULL);

    }

}

static void FUNC_0(MirrorOp *VAR_0, int VAR_1)
{ MirrorBlockJob *s = VAR_0->s; struct iovec *VAR_2; int64_t chunk_num; int VAR_3, VAR_4, VAR_5; trace_mirror_iteration_done(s, VAR_0->sector_num, VAR_0->nb_sectors, VAR_1); s->in_flight--; s->sectors_in_flight -= VAR_0->nb_sectors; VAR_2 = VAR_0->qiov.VAR_2; for (VAR_3 = 0; VAR_3 < VAR_0->qiov.niov; VAR_3++) { MirrorBuffer *buf = (MirrorBuffer *) VAR_2[VAR_3].iov_base; QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); s->buf_free_count++; } VAR_5 = s->granularity >> BDRV_SECTOR_BITS; chunk_num = VAR_0->sector_num / VAR_5; VAR_4 = DIV_ROUND_UP(VAR_0->nb_sectors, VAR_5); bitmap_clear(s->in_flight_bitmap, chunk_num, VAR_4); if (VAR_1 >= 0) { if (s->cow_bitmap) { bitmap_set(s->cow_bitmap, chunk_num, VAR_4); } s->common.offset += (uint64_t)VAR_0->nb_sectors * BDRV_SECTOR_SIZE; } qemu_iovec_destroy(&VAR_0->qiov); g_free(VAR_0); if (s->waiting_for_io) { qemu_coroutine_enter(s->common.co, NULL); } }