diff --git a/src/client.c b/src/client.c index b6de009..1189a42 100644 --- a/src/client.c +++ b/src/client.c @@ -485,7 +485,7 @@ void* client_serve(void* client_uncast) error_set_handler((cleanup_handler*) client_cleanup, client); - debug("client: mmap"); + info("client: mmaping file"); FATAL_IF_NEGATIVE( open_and_mmap( client->serve->filename, diff --git a/src/ioutil.c b/src/ioutil.c index 4519217..8c7df08 100644 --- a/src/ioutil.c +++ b/src/ioutil.c @@ -83,13 +83,22 @@ int open_and_mmap(const char* filename, int* out_fd, off64_t *out_size, void **o { off64_t size; - *out_fd = open(filename, O_RDWR|O_DIRECT|O_SYNC); + /* O_DIRECT seems to be intermittently supported. Leaving it as + * a compile-time option for now. */ +#ifdef DIRECT_IO + *out_fd = open(filename, O_RDWR | O_DIRECT | O_SYNC ); +#else + *out_fd = open(filename, O_RDWR | O_SYNC ); +#endif + if (*out_fd < 1) { + warn("open(%s) failed: does it exist?", filename); return *out_fd; } size = lseek64(*out_fd, 0, SEEK_END); if (size < 0) { + warn("lseek64() failed"); return size; } if (out_size) { @@ -100,6 +109,7 @@ int open_and_mmap(const char* filename, int* out_fd, off64_t *out_size, void **o *out_map = mmap64(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, *out_fd, 0); if (((long) *out_map) == -1) { + warn("mmap64() failed"); return -1; } } diff --git a/src/mirror.c b/src/mirror.c index 1a75525..9fb5ca9 100644 --- a/src/mirror.c +++ b/src/mirror.c @@ -244,11 +244,13 @@ void mirror_give_control( struct mirror * mirror ) * The entrust signifies that all the data has been sent, and * the client is currently paused but not disconnected. * The disconnect signifies that the client has been - * safely disconnected. - * TODO: Disconnect the client! + * safely prevented from making any more writes. + * + * Since we lock io and close the server it in mirror_on_exit before + * releasing, we don't actually need to take any action between the + * two here. */ socket_nbd_entrust( mirror->client ); - debug("TODO: The client *should* be disconnected here, but isn't yet"); socket_nbd_disconnect( mirror->client ); }