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

Re: [Nbd] nbd-client hangs



On 5/18/06, Wouter Verhelst <wouter@...3...> wrote:
On Wed, May 17, 2006 at 06:05:33PM -0400, Mike Snitzer wrote:
> On 5/3/06, Wouter Verhelst <wouter@...3...> wrote:
> >On Tue, May 02, 2006 at 08:59:04PM -0400, Gaurav Gupta wrote:
> >> Here are the details.
> >>
> >> I am running the server on a fedor 5 box which has the ip address
> >> 192.168.1.103(private ip address). The server create several large
> >> files, all bellow 500 MB and is running on ports 4101 - 4117. I have
> >> another box connected to the server through a switch. The client can
> >> ping the server.
> >>
> >> The client is also running fedora 5. This is what I did on the client.
> >>
> >> ./MAKEDEV /dev/nb1
> >>
> >> Nbd-client 192.168.1.103 4101 /dev/nb1
> >> Output is
> >> Negotiating:
> >>
> >> Nothing further than this
> >
> >Right. It would appear something is going very wrong, then :)
>
> Has there been any progress on this negotiation issue?  We (myself and
> coworkers) have seen this issue on 2.6.15 w/ nbd 2.8.4.  I didn't see
> anything in svn that spoke to progress on this issue but please let me
> know if there has been since Gaurav originally reported it.

No, because I haven't been able to reproduce it myself.

One way to reproduce this negotiation hang is to have the nbd-server
export a loop device that hasn't been setup.  Surprisingly the
nbd-server daemonize()s and responds with:

** Message: connect from 192.168.13.11, assigned file is /dev/loop0
** Message: Can't open authorization file (null) (Bad address).
** Message: Authorized client
** Message: Starting to serve
Opening /dev/loop0
looking for export size with ioctl BLKGETSIZE
looking for export size with fstat
looking for export size with lseek SEEK_END
lseek failed: 4Error: Could not find size of exported block device: Bad address
accept, ** Message: Child exited with 0
** Message: pid is 9113
Removing 9113 from the list of children**

<this repeats on each accept()ed client connection attempt, the server
will eventually hang the client's negotiation>

I'm fairly certain this is _not_ the cause of my initial
client<->server negotiation issue as I was using actual scsi devices
last I saw the client hang.  But in the end the negotiation does hang
(I've yet to pinpoint where, haven't looked yet).

The attached patch will actually verify that the desired export file
appears to be valid prior to daemonizing the nbd-server.  It would be
nice if some form of nbd export verification were to make it upstream.

Mike
diff -Naur nbd-2.8.4.orig/nbd-server.c nbd-2.8.4/nbd-server.c
--- nbd-2.8.4.orig/nbd-server.c	2006-02-28 05:07:56.000000000 -0500
+++ nbd-2.8.4/nbd-server.c	2006-05-30 16:58:57.000000000 -0400
@@ -899,12 +899,32 @@
 	struct sockaddr_in addrin;
 	struct sigaction sa;
 	int addrinlen = sizeof(addrin);
+	int fhandle;
 #ifndef sun
 	int yes=1;
 #else
 	char yes='1';
 #endif /* sun */
 
+	/**
+	 * verify the existence of the block device that
+	 * this server instance will export
+	 **/
+	DEBUG2( "Opening %s\n", serve->exportname);
+	if ((fhandle = open(serve->exportname,
+			    (serve->flags & F_READONLY) ? O_RDONLY : O_RDWR)) == -1) {
+		err("Could not open exported file: %m");
+	}
+	/**
+	 * if the exported file's size can't be detected	   
+	 * size_autodetect() will exit()... and export can be
+	 * considered invalid
+	 **/
+	size_autodetect(fhandle);
+	close(fhandle);
+	
+	daemonize(serve);
+	
 	if ((serve->socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
 		err("socket: %m");
 
@@ -1026,8 +1046,7 @@
           	set_peername(0,client);
           	serveconnection(client);
           	return 0;
-        }
-	daemonize(serve);
+        }	
 	setup_serve(serve);
 	serveloop(serve);
 	return 0 ;

Reply to: