qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 6/6] mirror: Use copy offloading


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 6/6] mirror: Use copy offloading
Date: Fri, 15 Jun 2018 17:23:08 +0100
User-agent: Mutt/1.10.0 (2018-05-17)

On Fri, Jun 08, 2018 at 02:04:17PM +0800, Fam Zheng wrote:
> +static void mirror_copy_range_complete(void *opaque, int ret)
> +{
> +    MirrorOp *op = opaque;
> +    MirrorBlockJob *s = op->s;
> +
> +    aio_context_acquire(blk_get_aio_context(s->common.blk));
> +    trace_mirror_copy_range_complete(s, ret, op->offset, op->bytes);
> +    if (!ret) {
> +        mirror_iteration_done(op, ret);
> +    } else {
> +        uint64_t bytes;
> +
> +        s->use_copy_range = false;
> +        s->in_flight--;
> +        s->bytes_in_flight -= op->bytes;
> +        bytes = mirror_do_read(s, op->offset, op->bytes);

A coroutine_fn cannot be called from a non-coroutine_fn.  This will
crash if mirror_do_read() yields.

> +        /* No alignment adjusting in mirror_do_read since we've already done
> +         * that in mirror_do_copy(). */
> +        assert(bytes == op->bytes);
> +        g_free(op);
> +    }
> +    aio_context_release(blk_get_aio_context(s->common.blk));
> +}
> +
> +static uint64_t mirror_do_copy(MirrorBlockJob *s, int64_t offset,
> +                               uint64_t bytes)
> +{
> +    uint64_t ret;
> +    MirrorOp *op;
> +
> +    if (!s->use_copy_range || offset < BLOCK_PROBE_BUF_SIZE) {

BLOCK_PROBE_BUF_SIZE is a detail of the raw-format.c driver.  Is it
appropriate to do this in the mirror job?

Can raw-format.c's copy_range() callbacks check BLOCK_PROBE_BUF_SIZE and
handle this case?  That way nothing besides raw-format.c needs to know
about probe protection.

> +        return mirror_do_read(s, offset, bytes);

mirror_do_read() can (indirectly) yield, so mirror_do_copy() must be
declared coroutine_fn.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]