From 811e4ab2cd45488941bb63ccb9d769e0385cbaa3 Mon Sep 17 00:00:00 2001 From: Matthew Bloch Date: Tue, 22 May 2012 00:22:06 +0100 Subject: [PATCH] Fixed mirroring to work (error reporting suspect though). --- serve.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/serve.c b/serve.c index b8af350..fb77abe 100644 --- a/serve.c +++ b/serve.c @@ -327,10 +327,16 @@ void* mirror_runner(void* serve_params_uncast) for (pass=0; pass < 7 /* biblical */; pass++) { uint64_t current = 0; + debug("mirror start pass=%d", pass); + while (current < serve->size) { int run = bitset_run_count(map, current, longest_run); + debug("mirror current=%d, run=%d", current, run); + if (bitset_is_set_at(map, current)) { + debug("^^^ writing", current, run); + /* dirty area */ socket_nbd_write( serve->mirror->client, @@ -351,7 +357,7 @@ void* mirror_runner(void* serve_params_uncast) void control_mirror(struct control_params* client) { - off64_t size; + off64_t size, remote_size; int fd, map_fd; struct mirror_status *mirror; union mysockaddr connect_to; @@ -377,6 +383,8 @@ void control_mirror(struct control_params* client) fd = socket_connect(&connect_to.generic); /* FIXME uses wrong error handler */ + remote_size = socket_nbd_read_hello(fd); + mirror = xmalloc(sizeof(struct mirror_status)); mirror->client = fd; mirror->max_bytes_per_second = 0;