[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Nbd] BUG: read-command with data size 0 does not return a response header



Hi,

NBD-server v3.2 has a problem: if a client does a read-request of 0
bytes in length, then the nbd-server does not return a response header.
This is not in line with a write request which always returns a response
header.
This patch solves that behaviour:

diff -uNrBbd nbd-3.2.org/nbd-server.c nbd-3.2/nbd-server.c
--- nbd-3.2.org/nbd-server.c	2012-07-03 22:54:53.000000000 +0200
+++ nbd-3.2/nbd-server.c	2013-03-04 16:21:04.000000000 +0100
@@ -1821,11 +1821,11 @@
 
 		case NBD_CMD_READ:
 			DEBUG("exp->buf, ");
-			memcpy(buf, &reply, sizeof(struct nbd_reply));
 			if (client->transactionlogfd != -1)
 				writeit(client->transactionlogfd, &reply, sizeof(reply));
-			p = buf + sizeof(struct nbd_reply);
-			writelen = currlen + sizeof(struct nbd_reply);
+			writeit(client->net, &reply, sizeof(reply));
+			p = buf;
+			writelen = currlen;
 			while(len > 0) {
 				if (expread(request.from, p, currlen, client)) {
 					DEBUG("Read failed: %m");

After applying this fix, I measured that nbd-server has a latency of
0.02ms which is quite nice!


Folkert van Heusden

-- 
MultiTail na wan makriki wrokosani fu tan luku den logfile nanga san
den commando spiti puru. Piki puru spesrutu sani, wroko nanga difrenti
kroru, tya kon makandra, nanga wan lo moro.
http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com



Reply to: