Use msync rather than fsync to flush the entire disc

This involves storing the size of the mapped disc in the client struct,
and then supplying that to the msync command.
This commit is contained in:
Patrick J Cherry
2018-02-05 17:01:32 +00:00
parent ad2014ac9d
commit afa1bb0efb
2 changed files with 5 additions and 2 deletions

View File

@@ -500,7 +500,7 @@ void client_reply_to_flush( struct client* client, struct nbd_request request )
debug("request flush from=%"PRIu64", len=%"PRIu32", handle=0x%08X", request.from, request.len, request.handle);
ERROR_IF_NEGATIVE(
fsync(client->fileno),
msync(client->mapped, client->mapped_size, MS_SYNC | MS_INVALIDATE),
"flush failed"
);
@@ -697,7 +697,7 @@ void* client_serve(void* client_uncast)
open_and_mmap(
client->serve->filename,
&client->fileno,
NULL,
&client->mapped_size,
(void**) &client->mapped
),
"Couldn't open/mmap file %s: %s", client->serve->filename, strerror( errno )