Error when reading sent data fails
If the client cuts off part-way through the write, it should cause an error, not a fatal. Previously this happened if the open file had a fiemap, but not if there was no allocation map. This patch fixes that, along with an associated valgrind error.
This commit is contained in:
26
src/client.c
26
src/client.c
@@ -387,26 +387,28 @@ void client_reply_to_write( struct client* client, struct nbd_request request )
|
||||
write_not_zeroes( client, request.from, request.len );
|
||||
}
|
||||
else {
|
||||
FATAL_IF_NEGATIVE(
|
||||
readloop(
|
||||
client->socket,
|
||||
client->mapped + request.from,
|
||||
request.len),
|
||||
"read failed from=%ld, len=%d",
|
||||
request.from,
|
||||
request.len );
|
||||
debug("No allocation map, writing directly.");
|
||||
/* If we get cut off partway through reading this data
|
||||
* */
|
||||
ERROR_IF_NEGATIVE(
|
||||
readloop( client->socket,
|
||||
client->mapped + request.from,
|
||||
request.len),
|
||||
"reading write data failed from=%ld, len=%d",
|
||||
request.from,
|
||||
request.len
|
||||
);
|
||||
server_dirty(client->serve, request.from, request.len);
|
||||
}
|
||||
|
||||
|
||||
if (1) /* not sure whether this is necessary... */
|
||||
{
|
||||
/* multiple of 4K page size */
|
||||
uint64_t from_rounded = request.from & (!0xfff);
|
||||
uint64_t len_rounded = request.len + (request.from - from_rounded);
|
||||
|
||||
|
||||
FATAL_IF_NEGATIVE(
|
||||
msync(
|
||||
client->mapped + from_rounded,
|
||||
msync( client->mapped + from_rounded,
|
||||
len_rounded,
|
||||
MS_SYNC),
|
||||
"msync failed %ld %ld", request.from, request.len
|
||||
|
Reference in New Issue
Block a user