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

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



On Mon, Mar 04, 2013 at 04:29:23PM +0100, folkert wrote:
> 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:

applied.

> 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
> 
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Nbd-general mailing list
> Nbd-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nbd-general
> 

-- 
Copyshops should do vouchers. So that next time some bureaucracy requires you
to mail a form in triplicate, you can mail it just once, add a voucher, and
save on postage.



Reply to: