On 26/05/21 19:18, Vladimir Sementsov-Ogievskiy wrote:
It's actually the original idea of block_copy_do_copy() function: do
only simple copy, don't interact with the state. It's a kind of wrapper
on top of bdrv_co<io functions>.
So, actually updating s->use_copy_range here was a bad idea.
It's still more complicated, because you need to add some kind of
method = s->method;
ret = block_copy_do_copy(..., method);
if (ret < 0 && method <= COPY_RANGE_SMALL) {
method = COPY_RANGE_READ_WRITE;
ret = block_copy_do_copy(..., method);
}
lock();
if (method == s->method) {
/* compute new method */
}
which makes it more complicated than this patch IMO. But yeah at least
it's a viable alternative to the atomics.
Paolo