--On 28 May 2011 01:25:13 +0200 Wouter Verhelst <[email protected]> wrote:
> Will have an in-depth review of your patch tomorrow (it's too late (or
> should I say, early?) right now to do that properly), and if it looks
> fine, will merge.
Rereading it, I think I have found a problem with the way we handle
oversize writes (both before and after my patch). NBD_CMD_WRITE is
handled liked this:
while(len > 0) {
readit(client->net, buf, currlen);
...
if (expwrite(request.from, buf, len, client,
request.type & NBD_CMD_FLAG_FUA)) {
DEBUG("Write failed: %m" );
ERROR(client, reply, errno);
continue;
}
SEND(client->net, reply);
len -= currlen;
currlen = (len < BUFSIZE) ? len : BUFSIZE;
}
DEBUG("OK!\n");
Surely the SEND() should be outside the loop, or we will send multiple
replies to one NBD_CMD_READ (which will really upset the kernel as
the request will be freed).
Again, only tested with "make check", but I don't think we test
oversize writes (we probably should do in the oversize test).
Available from git.alex.org.uk as usual.
Signed-off-by: Alex Bligh <[email protected]>
---
nbd-server.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/nbd-server.c b/nbd-server.c
index a99c27b..6d734b3 100644
--- a/nbd-server.c
+++ b/nbd-server.c
@@ -1535,10 +1535,10 @@ int mainloop(CLIENT *client) {
ERROR(client, reply, errno);
continue;
}
- SEND(client->net, reply);
len -= currlen;
currlen = (len < BUFSIZE) ? len : BUFSIZE;
}
+ SEND(client->net, reply);
DEBUG("OK!\n");
continue;
--
1.7.4.1
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Nbd-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nbd-general