int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c)

{

    BDRVQcow2State *s = bs->opaque;

    int result = 0;

    int ret;

    int i;



    trace_qcow2_cache_flush(qemu_coroutine_self(), c == s->l2_table_cache);



    for (i = 0; i < c->size; i++) {

        ret = qcow2_cache_entry_flush(bs, c, i);

        if (ret < 0 && result != -ENOSPC) {

            result = ret;

        }

    }



    if (result == 0) {

        ret = bdrv_flush(bs->file->bs);

        if (ret < 0) {

            result = ret;

        }

    }



    return result;

}

int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c)

{

    BDRVQcow2State *s = bs->opaque;

    int result = 0;

    int ret;

    int i;



    trace_qcow2_cache_flush(qemu_coroutine_self(), c == s->l2_table_cache);



    for (i = 0; i < c->size; i++) {

        ret = qcow2_cache_entry_flush(bs, c, i);

        if (ret < 0 && result != -ENOSPC) {

            result = ret;

        }

    }



    if (result == 0) {

        ret = bdrv_flush(bs->file->bs);

        if (ret < 0) {

            result = ret;

        }

    }



    return result;

}

int FUNC_0(BlockDriverState *VAR_0, Qcow2Cache *VAR_1)

{

    BDRVQcow2State *s = VAR_0->opaque;

    int VAR_2 = 0;

    int VAR_3;

    int VAR_4;



    trace_qcow2_cache_flush(qemu_coroutine_self(), VAR_1 == s->l2_table_cache);



    for (VAR_4 = 0; VAR_4 < VAR_1->size; VAR_4++) {

        VAR_3 = qcow2_cache_entry_flush(VAR_0, VAR_1, VAR_4);

        if (VAR_3 < 0 && VAR_2 != -ENOSPC) {

            VAR_2 = VAR_3;

        }

    }



    if (VAR_2 == 0) {

        VAR_3 = bdrv_flush(VAR_0->file->VAR_0);

        if (VAR_3 < 0) {

            VAR_2 = VAR_3;

        }

    }



    return VAR_2;

}

int FUNC_0(BlockDriverState *VAR_0, Qcow2Cache *VAR_1)
{ BDRVQcow2State *s = VAR_0->opaque; int VAR_2 = 0; int VAR_3; int VAR_4; trace_qcow2_cache_flush(qemu_coroutine_self(), VAR_1 == s->l2_table_cache); for (VAR_4 = 0; VAR_4 < VAR_1->size; VAR_4++) { VAR_3 = qcow2_cache_entry_flush(VAR_0, VAR_1, VAR_4); if (VAR_3 < 0 && VAR_2 != -ENOSPC) { VAR_2 = VAR_3; } } if (VAR_2 == 0) { VAR_3 = bdrv_flush(VAR_0->file->VAR_0); if (VAR_3 < 0) { VAR_2 = VAR_3; } } return VAR_2; }