void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)

{

    Error *local_err = NULL;

    int ret;



    if (!bs->drv)  {

        return;

    }



    if (!(bs->open_flags & BDRV_O_INACTIVE)) {

        return;

    }

    bs->open_flags &= ~BDRV_O_INACTIVE;



    if (bs->drv->bdrv_invalidate_cache) {

        bs->drv->bdrv_invalidate_cache(bs, &local_err);

    } else if (bs->file) {

        bdrv_invalidate_cache(bs->file->bs, &local_err);

    }

    if (local_err) {

        bs->open_flags |= BDRV_O_INACTIVE;

        error_propagate(errp, local_err);

        return;

    }



    ret = refresh_total_sectors(bs, bs->total_sectors);

    if (ret < 0) {

        bs->open_flags |= BDRV_O_INACTIVE;

        error_setg_errno(errp, -ret, "Could not refresh total sector count");

        return;

    }

}

void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)

{

    Error *local_err = NULL;

    int ret;



    if (!bs->drv)  {

        return;

    }



    if (!(bs->open_flags & BDRV_O_INACTIVE)) {

        return;

    }

    bs->open_flags &= ~BDRV_O_INACTIVE;



    if (bs->drv->bdrv_invalidate_cache) {

        bs->drv->bdrv_invalidate_cache(bs, &local_err);

    } else if (bs->file) {

        bdrv_invalidate_cache(bs->file->bs, &local_err);

    }

    if (local_err) {

        bs->open_flags |= BDRV_O_INACTIVE;

        error_propagate(errp, local_err);

        return;

    }



    ret = refresh_total_sectors(bs, bs->total_sectors);

    if (ret < 0) {

        bs->open_flags |= BDRV_O_INACTIVE;

        error_setg_errno(errp, -ret, "Could not refresh total sector count");

        return;

    }

}

void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)

{

    Error *local_err = NULL;

    int VAR_2;



    if (!VAR_0->drv)  {

        return;

    }



    if (!(VAR_0->open_flags & BDRV_O_INACTIVE)) {

        return;

    }

    VAR_0->open_flags &= ~BDRV_O_INACTIVE;



    if (VAR_0->drv->FUNC_0) {

        VAR_0->drv->FUNC_0(VAR_0, &local_err);

    } else if (VAR_0->file) {

        FUNC_0(VAR_0->file->VAR_0, &local_err);

    }

    if (local_err) {

        VAR_0->open_flags |= BDRV_O_INACTIVE;

        error_propagate(VAR_1, local_err);

        return;

    }



    VAR_2 = refresh_total_sectors(VAR_0, VAR_0->total_sectors);

    if (VAR_2 < 0) {

        VAR_0->open_flags |= BDRV_O_INACTIVE;

        error_setg_errno(VAR_1, -VAR_2, "Could not refresh total sector count");

        return;

    }

}

void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)
{ Error *local_err = NULL; int VAR_2; if (!VAR_0->drv)  { return; } if (!(VAR_0->open_flags & BDRV_O_INACTIVE)) { return; } VAR_0->open_flags &= ~BDRV_O_INACTIVE; if (VAR_0->drv->FUNC_0) { VAR_0->drv->FUNC_0(VAR_0, &local_err); } else if (VAR_0->file) { FUNC_0(VAR_0->file->VAR_0, &local_err); } if (local_err) { VAR_0->open_flags |= BDRV_O_INACTIVE; error_propagate(VAR_1, local_err); return; } VAR_2 = refresh_total_sectors(VAR_0, VAR_0->total_sectors); if (VAR_2 < 0) { VAR_0->open_flags |= BDRV_O_INACTIVE; error_setg_errno(VAR_1, -VAR_2, "Could not refresh total sector count"); return; } }