Commit 29cdb251 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Kevin Wolf
Browse files

block: push recursive flushing up from drivers



Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent d7bb72c8
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -2331,11 +2331,9 @@ void bdrv_flush_all(void)
    BlockDriverState *bs;

    QTAILQ_FOREACH(bs, &bdrv_states, list) {
        if (!bdrv_is_read_only(bs) && bdrv_is_inserted(bs)) {
        bdrv_flush(bs);
    }
}
}

int bdrv_has_zero_init(BlockDriverState *bs)
{
@@ -3520,7 +3518,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
{
    int ret;

    if (!bs->drv) {
    if (!bs || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
        return 0;
    }

@@ -3538,7 +3536,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
    }

    if (bs->drv->bdrv_co_flush_to_disk) {
        return bs->drv->bdrv_co_flush_to_disk(bs);
        ret = bs->drv->bdrv_co_flush_to_disk(bs);
    } else if (bs->drv->bdrv_aio_flush) {
        BlockDriverAIOCB *acb;
        CoroutineIOCompletion co = {
@@ -3547,10 +3545,10 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)

        acb = bs->drv->bdrv_aio_flush(bs, bdrv_co_io_em_complete, &co);
        if (acb == NULL) {
            return -EIO;
            ret = -EIO;
        } else {
            qemu_coroutine_yield();
            return co.ret;
            ret = co.ret;
        }
    } else {
        /*
@@ -3564,8 +3562,16 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
         *
         * Let's hope the user knows what he's doing.
         */
        return 0;
        ret = 0;
    }
    if (ret < 0) {
        return ret;
    }

    /* Now flush the underlying protocol.  It will also have BDRV_O_NO_FLUSH
     * in the case of cache=unsafe, so there are no useless flushes.
     */
    return bdrv_co_flush(bs->file);
}

void bdrv_invalidate_cache(BlockDriverState *bs)
+0 −7
Original line number Diff line number Diff line
@@ -397,12 +397,6 @@ static void blkdebug_close(BlockDriverState *bs)
    }
}

static BlockDriverAIOCB *blkdebug_aio_flush(BlockDriverState *bs,
    BlockDriverCompletionFunc *cb, void *opaque)
{
    return bdrv_aio_flush(bs->file, cb, opaque);
}

static void process_rule(BlockDriverState *bs, struct BlkdebugRule *rule,
    BlkdebugVars *old_vars)
{
@@ -452,7 +446,6 @@ static BlockDriver bdrv_blkdebug = {

    .bdrv_aio_readv     = blkdebug_aio_readv,
    .bdrv_aio_writev    = blkdebug_aio_writev,
    .bdrv_aio_flush     = blkdebug_aio_flush,

    .bdrv_debug_event   = blkdebug_debug_event,
};
+0 −6
Original line number Diff line number Diff line
@@ -318,11 +318,6 @@ exit:
    return ret;
}

static coroutine_fn int cow_co_flush(BlockDriverState *bs)
{
    return bdrv_co_flush(bs->file);
}

static QEMUOptionParameter cow_create_options[] = {
    {
        .name = BLOCK_OPT_SIZE,
@@ -348,7 +343,6 @@ static BlockDriver bdrv_cow = {

    .bdrv_read              = cow_co_read,
    .bdrv_write             = cow_co_write,
    .bdrv_co_flush_to_disk  = cow_co_flush,
    .bdrv_co_is_allocated   = cow_co_is_allocated,

    .create_options = cow_create_options,
+0 −6
Original line number Diff line number Diff line
@@ -835,11 +835,6 @@ fail:
    return ret;
}

static coroutine_fn int qcow_co_flush(BlockDriverState *bs)
{
    return bdrv_co_flush(bs->file);
}

static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
    BDRVQcowState *s = bs->opaque;
@@ -877,7 +872,6 @@ static BlockDriver bdrv_qcow = {

    .bdrv_co_readv          = qcow_co_readv,
    .bdrv_co_writev         = qcow_co_writev,
    .bdrv_co_flush_to_disk  = qcow_co_flush,
    .bdrv_co_is_allocated   = qcow_co_is_allocated,

    .bdrv_set_key           = qcow_set_key,
+0 −6
Original line number Diff line number Diff line
@@ -1253,11 +1253,6 @@ static coroutine_fn int qcow2_co_flush_to_os(BlockDriverState *bs)
    return 0;
}

static coroutine_fn int qcow2_co_flush_to_disk(BlockDriverState *bs)
{
    return bdrv_co_flush(bs->file);
}

static int64_t qcow2_vm_state_offset(BDRVQcowState *s)
{
	return (int64_t)s->l1_vm_state_index << (s->cluster_bits + s->l2_bits);
@@ -1377,7 +1372,6 @@ static BlockDriver bdrv_qcow2 = {
    .bdrv_co_readv          = qcow2_co_readv,
    .bdrv_co_writev         = qcow2_co_writev,
    .bdrv_co_flush_to_os    = qcow2_co_flush_to_os,
    .bdrv_co_flush_to_disk  = qcow2_co_flush_to_disk,

    .bdrv_co_discard        = qcow2_co_discard,
    .bdrv_truncate          = qcow2_truncate,
Loading