int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors)

{

    BDRVQcow2State *s = bs->opaque;

    unsigned int nb_clusters;

    int ret;



    /* The zero flag is only supported by version 3 and newer */

    if (s->qcow_version < 3) {

        return -ENOTSUP;

    }



    /* Each L2 table is handled by its own loop iteration */

    nb_clusters = size_to_clusters(s, nb_sectors << BDRV_SECTOR_BITS);



    s->cache_discards = true;



    while (nb_clusters > 0) {

        ret = zero_single_l2(bs, offset, nb_clusters);

        if (ret < 0) {

            goto fail;

        }



        nb_clusters -= ret;

        offset += (ret * s->cluster_size);

    }



    ret = 0;

fail:

    s->cache_discards = false;

    qcow2_process_discards(bs, ret);



    return ret;

}

int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors)

{

    BDRVQcow2State *s = bs->opaque;

    unsigned int nb_clusters;

    int ret;



    

    if (s->qcow_version < 3) {

        return -ENOTSUP;

    }



    

    nb_clusters = size_to_clusters(s, nb_sectors << BDRV_SECTOR_BITS);



    s->cache_discards = true;



    while (nb_clusters > 0) {

        ret = zero_single_l2(bs, offset, nb_clusters);

        if (ret < 0) {

            goto fail;

        }



        nb_clusters -= ret;

        offset += (ret * s->cluster_size);

    }



    ret = 0;

fail:

    s->cache_discards = false;

    qcow2_process_discards(bs, ret);



    return ret;

}

int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, int VAR_2)

{

    BDRVQcow2State *s = VAR_0->opaque;

    unsigned int VAR_3;

    int VAR_4;



    

    if (s->qcow_version < 3) {

        return -ENOTSUP;

    }



    

    VAR_3 = size_to_clusters(s, VAR_2 << BDRV_SECTOR_BITS);



    s->cache_discards = true;



    while (VAR_3 > 0) {

        VAR_4 = zero_single_l2(VAR_0, VAR_1, VAR_3);

        if (VAR_4 < 0) {

            goto fail;

        }



        VAR_3 -= VAR_4;

        VAR_1 += (VAR_4 * s->cluster_size);

    }



    VAR_4 = 0;

fail:

    s->cache_discards = false;

    qcow2_process_discards(VAR_0, VAR_4);



    return VAR_4;

}

int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, int VAR_2)
{ BDRVQcow2State *s = VAR_0->opaque; unsigned int VAR_3; int VAR_4; if (s->qcow_version < 3) { return -ENOTSUP; } VAR_3 = size_to_clusters(s, VAR_2 << BDRV_SECTOR_BITS); s->cache_discards = true; while (VAR_3 > 0) { VAR_4 = zero_single_l2(VAR_0, VAR_1, VAR_3); if (VAR_4 < 0) { goto fail; } VAR_3 -= VAR_4; VAR_1 += (VAR_4 * s->cluster_size); } VAR_4 = 0; fail:
s->cache_discards = false; qcow2_process_discards(VAR_0, VAR_4); return VAR_4; }