static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i)

{

    BDRVQcowState *s = bs->opaque;

    int ret = 0;



    if (!c->entries[i].dirty || !c->entries[i].offset) {

        return 0;

    }



    trace_qcow2_cache_entry_flush(qemu_coroutine_self(),

                                  c == s->l2_table_cache, i);



    if (c->depends) {

        ret = qcow2_cache_flush_dependency(bs, c);

    } else if (c->depends_on_flush) {

        ret = bdrv_flush(bs->file);

        if (ret >= 0) {

            c->depends_on_flush = false;

        }

    }



    if (ret < 0) {

        return ret;

    }



    if (c == s->refcount_block_cache) {

        ret = qcow2_pre_write_overlap_check(bs,

                QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_BLOCK,

                c->entries[i].offset, s->cluster_size);

    } else if (c == s->l2_table_cache) {

        ret = qcow2_pre_write_overlap_check(bs,

                QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L2,

                c->entries[i].offset, s->cluster_size);

    } else {

        ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT,

                c->entries[i].offset, s->cluster_size);

    }



    if (ret < 0) {

        return ret;

    }



    if (c == s->refcount_block_cache) {

        BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE_PART);

    } else if (c == s->l2_table_cache) {

        BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE);

    }



    ret = bdrv_pwrite(bs->file, c->entries[i].offset, c->entries[i].table,

        s->cluster_size);

    if (ret < 0) {

        return ret;

    }



    c->entries[i].dirty = false;



    return 0;

}

static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i)

{

    BDRVQcowState *s = bs->opaque;

    int ret = 0;



    if (!c->entries[i].dirty || !c->entries[i].offset) {

        return 0;

    }



    trace_qcow2_cache_entry_flush(qemu_coroutine_self(),

                                  c == s->l2_table_cache, i);



    if (c->depends) {

        ret = qcow2_cache_flush_dependency(bs, c);

    } else if (c->depends_on_flush) {

        ret = bdrv_flush(bs->file);

        if (ret >= 0) {

            c->depends_on_flush = false;

        }

    }



    if (ret < 0) {

        return ret;

    }



    if (c == s->refcount_block_cache) {

        ret = qcow2_pre_write_overlap_check(bs,

                QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_BLOCK,

                c->entries[i].offset, s->cluster_size);

    } else if (c == s->l2_table_cache) {

        ret = qcow2_pre_write_overlap_check(bs,

                QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L2,

                c->entries[i].offset, s->cluster_size);

    } else {

        ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT,

                c->entries[i].offset, s->cluster_size);

    }



    if (ret < 0) {

        return ret;

    }



    if (c == s->refcount_block_cache) {

        BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE_PART);

    } else if (c == s->l2_table_cache) {

        BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE);

    }



    ret = bdrv_pwrite(bs->file, c->entries[i].offset, c->entries[i].table,

        s->cluster_size);

    if (ret < 0) {

        return ret;

    }



    c->entries[i].dirty = false;



    return 0;

}

        ret = qcow2_pre_write_overlap_check(bs,                 QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_BLOCK,         ret = qcow2_pre_write_overlap_check(bs,                 QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L2,         ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT,         ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT,         ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT,
static int FUNC_0(BlockDriverState *VAR_0, Qcow2Cache *VAR_1, int VAR_2)

{

    BDRVQcowState *s = VAR_0->opaque;

    int VAR_3 = 0;



    if (!VAR_1->entries[VAR_2].dirty || !VAR_1->entries[VAR_2].offset) {

        return 0;

    }



    trace_qcow2_cache_entry_flush(qemu_coroutine_self(),

                                  VAR_1 == s->l2_table_cache, VAR_2);



    if (VAR_1->depends) {

        VAR_3 = qcow2_cache_flush_dependency(VAR_0, VAR_1);

    } else if (VAR_1->depends_on_flush) {

        VAR_3 = bdrv_flush(VAR_0->file);

        if (VAR_3 >= 0) {

            VAR_1->depends_on_flush = false;

        }

    }



    if (VAR_3 < 0) {

        return VAR_3;

    }



    if (VAR_1 == s->refcount_block_cache) {

        VAR_3 = qcow2_pre_write_overlap_check(VAR_0,

                QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_BLOCK,

                VAR_1->entries[VAR_2].offset, s->cluster_size);

    } else if (VAR_1 == s->l2_table_cache) {

        VAR_3 = qcow2_pre_write_overlap_check(VAR_0,

                QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L2,

                VAR_1->entries[VAR_2].offset, s->cluster_size);

    } else {

        VAR_3 = qcow2_pre_write_overlap_check(VAR_0, QCOW2_OL_DEFAULT,

                VAR_1->entries[VAR_2].offset, s->cluster_size);

    }



    if (VAR_3 < 0) {

        return VAR_3;

    }



    if (VAR_1 == s->refcount_block_cache) {

        BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_UPDATE_PART);

    } else if (VAR_1 == s->l2_table_cache) {

        BLKDBG_EVENT(VAR_0->file, BLKDBG_L2_UPDATE);

    }



    VAR_3 = bdrv_pwrite(VAR_0->file, VAR_1->entries[VAR_2].offset, VAR_1->entries[VAR_2].table,

        s->cluster_size);

    if (VAR_3 < 0) {

        return VAR_3;

    }



    VAR_1->entries[VAR_2].dirty = false;



    return 0;

}

static int FUNC_0(BlockDriverState *VAR_0, Qcow2Cache *VAR_1, int VAR_2)
{ BDRVQcowState *s = VAR_0->opaque; int VAR_3 = 0; if (!VAR_1->entries[VAR_2].dirty || !VAR_1->entries[VAR_2].offset) { return 0; } trace_qcow2_cache_entry_flush(qemu_coroutine_self(),
VAR_1 == s->l2_table_cache, VAR_2); if (VAR_1->depends) { VAR_3 = qcow2_cache_flush_dependency(VAR_0, VAR_1); } else if (VAR_1->depends_on_flush) { VAR_3 = bdrv_flush(VAR_0->file); if (VAR_3 >= 0) { VAR_1->depends_on_flush = false; } } if (VAR_3 < 0) { return VAR_3; } if (VAR_1 == s->refcount_block_cache) { VAR_3 = qcow2_pre_write_overlap_check(VAR_0,
QCOW2_OL_DEFAULT & ~QCOW2_OL_REFCOUNT_BLOCK,
VAR_1->entries[VAR_2].offset, s->cluster_size); } else if (VAR_1 == s->l2_table_cache) { VAR_3 = qcow2_pre_write_overlap_check(VAR_0,
QCOW2_OL_DEFAULT & ~QCOW2_OL_ACTIVE_L2,
VAR_1->entries[VAR_2].offset, s->cluster_size); } else { VAR_3 = qcow2_pre_write_overlap_check(VAR_0, QCOW2_OL_DEFAULT,
VAR_1->entries[VAR_2].offset, s->cluster_size); } if (VAR_3 < 0) { return VAR_3; } if (VAR_1 == s->refcount_block_cache) { BLKDBG_EVENT(VAR_0->file, BLKDBG_REFBLOCK_UPDATE_PART); } else if (VAR_1 == s->l2_table_cache) { BLKDBG_EVENT(VAR_0->file, BLKDBG_L2_UPDATE); } VAR_3 = bdrv_pwrite(VAR_0->file, VAR_1->entries[VAR_2].offset, VAR_1->entries[VAR_2].table,
s->cluster_size); if (VAR_3 < 0) { return VAR_3; } VAR_1->entries[VAR_2].dirty = false; return 0; }