28.05.2021 14:01, Paolo Bonzini wrote:
On 28/05/21 12:24, Paolo Bonzini wrote:
It's still more complicated, because you need to add some kind of
method = s->method;
This would even have to be a separate, one-line critical section...
Or atomic operation.. What I don't like that all troubles are for unused code.
Many things may change to the moment when we actually reuse this for qemu-img
convert.
And, qemu-img convert probably don't need this complicated logic with different
methods. It may be better just return error if copy_range failed. What's a good
reason for fall-back to normal write if copy-range is explicitly requested by
user?
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.
--
Best regards,
Vladimir