Commit fb420569 authored by Richard W.M. Jones's avatar Richard W.M. Jones
Browse files

Revert "copy: Always allow multiple connections"

This reverts commit bfd7ec3e.

This doesn't work with qemu-nbd because it appears to internally
prevent multiple connections to the same export name.  Using this
patch would require using qemu-nbd without locking[1] which would be
unsafe.

[1] ie. a theoretical qemu-nbd -U option which qemu-nbd doesn't seem
to support
parent bfd7ec3e
......@@ -321,6 +321,10 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
/* If multi-conn is not supported, force connections to 1. */
if (! src->ops->can_multi_conn (src) || ! dst->ops->can_multi_conn (dst))
connections = 1;
/* Calculate the number of threads from the number of connections. */
if (threads == 0) {
long t;
......@@ -375,26 +379,15 @@ main (int argc, char *argv[])
synchronous ? "true" : "false");
}
/* If using multiple connections, then at this point we
/* If multi-conn is enabled on either side, then at this point we
* need to ask the backend to open the extra connections.
*
* Using multiple connections when the server does not report
* can_multi_conn is not safe in general, but is safe for the special
* access pattern in nbdcopy.
*
* - We split the image to 128m segments, and every segment is written
* by single worker.
*
* - Writes do not overlap, and are never partial block that another
* worker may modify at the same time.
*
* - We never read from the destination so we don't have caching
* synchronization issue between clients.
*/
if (connections > 1) {
assert (threads == connections);
src->ops->start_multi_conn (src);
dst->ops->start_multi_conn (dst);
if (src->ops->can_multi_conn (src))
src->ops->start_multi_conn (src);
if (dst->ops->can_multi_conn (dst))
dst->ops->start_multi_conn (dst);
}
/* If the source is NBD and we couldn't negotiate meta
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment