Re: [Nbd] nbd-client - Problem with disconnect
- To: Jean Wolter <jean@...1096...>
- Cc: nbd-general@...72..., Paul Clements <Paul.Clements@...124...>
- Subject: Re: [Nbd] nbd-client - Problem with disconnect
- From: Wouter Verhelst <w@...112...>
- Date: Wed, 2 May 2012 17:15:32 +0200
- Message-id: <20120502151532.GB11628@...3...>
- In-reply-to: <4FA1468A.6040900@...1096...>
- References: <4FA1468A.6040900@...1096...>
Hi Jean,
On Wed, May 02, 2012 at 04:36:58PM +0200, Jean Wolter wrote:
> Hello,
>
> I played around with nbd and stumbled across a problem when
> disconnecting an nbd block device via nbd-client -d <nbd device>. The
> nbd-client expects a return value of EBADR after a disconnect:
>
> if (ioctl(nbd, NBD_DO_IT) < 0) {
> if(errno==EBADR) {
> /* The user probably did 'nbd-client -d' on us.
> * quit */
> ...
>
> Unfortunately the current kernel driver returns EPIPE after a
> disconnect. EPIPE is generated by sock_xmit, when it gets a 0 as return
> value from kernel_recvmsg(). It converts the 0 into -EPIPE, which is
> then passed all the way up to user level via lo->harderror.
>
> According to the man page rcvmsg() returns 0 in the following case:
> "The return value will be 0 when the peer has performed an orderly
> shutdown."
>
> To me it looks like nbd-client -d generated a disconnect request, the
> nbd-server shuts down the network connection on its side and rcvmsg
> returns with 0. The 0 is then converted to EPIPE and passed up to user
> level. The nbd-client is started with -persist, expects EBADR and
> therefore does not terminate. It reconnects to the server instead.
>
> Now I am wondering, which side needs to be fixed, block driver or user
> level program.
Good question :-)
I'm not sure. I don't think the case of what happens when the
NBD_DISCONNECT ioctl is called is very well defined. Currently, the
client just sends a NBD_DISC packet off to the server, and then all bets
are off. I don't think the -persist/disconnect combination has ever
worked very well (and that makes -persist less useful than it could be).
This could probably benefit from making it a bit clearer. Paul, what do
you think?
--
The volume of a pizza of thickness a and radius z can be described by
the following formula:
pi zz a
Reply to: