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.
signature.asc
Description: PGP signature