int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s,

                             void *data, uint32_t length, uint64_t offset)

{

    int ret = 0;

    VHDXLogSequence logs = { .valid = true,

                             .count = 1,

                             .hdr = { 0 } };





    /* Make sure data written (new and/or changed blocks) is stable

     * on disk, before creating log entry */

    bdrv_flush(bs);

    ret = vhdx_log_write(bs, s, data, length, offset);

    if (ret < 0) {

        goto exit;

    }

    logs.log = s->log;



    /* Make sure log is stable on disk */

    bdrv_flush(bs);

    ret = vhdx_log_flush(bs, s, &logs);

    if (ret < 0) {

        goto exit;

    }



    s->log = logs.log;



exit:

    return ret;

}

int vhdx_log_write_and_flush(BlockDriverState *bs, BDRVVHDXState *s,

                             void *data, uint32_t length, uint64_t offset)

{

    int ret = 0;

    VHDXLogSequence logs = { .valid = true,

                             .count = 1,

                             .hdr = { 0 } };





    



    bdrv_flush(bs);

    ret = vhdx_log_write(bs, s, data, length, offset);

    if (ret < 0) {

        goto exit;

    }

    logs.log = s->log;



    

    bdrv_flush(bs);

    ret = vhdx_log_flush(bs, s, &logs);

    if (ret < 0) {

        goto exit;

    }



    s->log = logs.log;



exit:

    return ret;

}

int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1,

                             void *VAR_2, uint32_t VAR_3, uint64_t VAR_4)

{

    int VAR_5 = 0;

    VHDXLogSequence logs = { .valid = true,

                             .count = 1,

                             .hdr = { 0 } };





    



    bdrv_flush(VAR_0);

    VAR_5 = vhdx_log_write(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);

    if (VAR_5 < 0) {

        goto exit;

    }

    logs.log = VAR_1->log;



    

    bdrv_flush(VAR_0);

    VAR_5 = vhdx_log_flush(VAR_0, VAR_1, &logs);

    if (VAR_5 < 0) {

        goto exit;

    }



    VAR_1->log = logs.log;



exit:

    return VAR_5;

}

int FUNC_0(BlockDriverState *VAR_0, BDRVVHDXState *VAR_1,
void *VAR_2, uint32_t VAR_3, uint64_t VAR_4)
{ int VAR_5 = 0; VHDXLogSequence logs = { .valid = true, .count = 1,
.hdr = { 0 } }; bdrv_flush(VAR_0); VAR_5 = vhdx_log_write(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); if (VAR_5 < 0) { goto exit; } logs.log = VAR_1->log; bdrv_flush(VAR_0); VAR_5 = vhdx_log_flush(VAR_0, VAR_1, &logs); if (VAR_5 < 0) { goto exit; } VAR_1->log = logs.log; exit:
return VAR_5; }