From root@naranja.diatel.upm.es  Sat Jan 14 19:08:52 2006
Return-Path: <root@naranja.diatel.upm.es>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 4AA4116A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Jan 2006 19:08:52 +0000 (GMT)
	(envelope-from root@naranja.diatel.upm.es)
Received: from naranja.diatel.upm.es (naranja.diatel.upm.es [138.100.49.124])
	by mx1.FreeBSD.org (Postfix) with ESMTP id CF41D43D49
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Jan 2006 19:08:51 +0000 (GMT)
	(envelope-from root@naranja.diatel.upm.es)
Received: from naranja.diatel.upm.es (localhost [127.0.0.1])
	by naranja.diatel.upm.es (8.13.4/8.13.4) with ESMTP id k0EJ7WtV023655
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 14 Jan 2006 20:07:32 +0100 (CET)
	(envelope-from root@naranja.diatel.upm.es)
Received: (from root@localhost)
	by naranja.diatel.upm.es (8.13.4/8.13.4/Submit) id k0EJ7WbP023654;
	Sat, 14 Jan 2006 20:07:32 +0100 (CET)
	(envelope-from root)
Message-Id: <200601141907.k0EJ7WbP023654@naranja.diatel.upm.es>
Date: Sat, 14 Jan 2006 20:07:32 +0100 (CET)
From: Javier Martn Rueda <jmrueda@diatel.upm.es>
Reply-To: Javier Martn Rueda <jmrueda@diatel.upm.es>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: ggated core dumps on amd64 after client connection
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         91799
>Category:       amd64
>Synopsis:       ggated core dumps on amd64 after client connection
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pjd
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 14 19:10:03 GMT 2006
>Closed-Date:    Wed Dec 20 17:23:23 GMT 2006
>Last-Modified:  Wed Dec 20 17:30:16 GMT 2006
>Originator:     Javier Martn Rueda
>Release:        FreeBSD 6.0-RELEASE amd64
>Organization:
<organization of PR aes)> Universidad Politcnica de Madrid
>Environment:
System: FreeBSD naranja.diatel.upm.es 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Fri Jan 13 14:11:52 CET 2006 root@naranja.diatel.upm.es:/usr/src/sys/amd64/compile/SMP amd64


	
>Description:
	

On a amd64 system where a GGATE disk has been setup, ggated crashes
on the server when the client connects to it. If the server is run
with the -v option, the following message appears:

Assertion failed: ((req->r_length % conn->c_sectorsize) == 0), function disk_thr
ead, file ggated.c, line 714.

Incidentally, the client is left in such a state that you'll be forced to do a hard reset,
as the ggatec process must block something in the kernel that seems to prevent
other disk activity on it, and it is impossible to log into it, ctrl-alt-del, shutdown, etc.

>How-To-Repeat:
	

Create a basic ggated config file on the server, like this:

172.16.1.1	RW	/dev/da1s1g

Start the server executing ggated. Then start the client with
ggatec 172.16.1.1 /dev/da1s1g.

The ggated process on the server will start core dumping and restarting,
unsuccessfully. The client will hang (waiting for the server to service it).
Warning: you may leave the client in such a state that a only a hard reset
will take it out from it (no ordered shutdown will be possible).


>Fix:

	

The problem is that the ggated code uses a data type for the sector
size of the device it is serving which is inconsistent with the one used in the kernel
by the ioctl that returns the sector size. The incorrect data type happens to work for a 32 bit
system, but not for a 64 bit. To correct it, apply the following patch to the source
tree and recompile and install ggated:


--- src/sbin/ggate/shared/ggate.h.orig	Fri Jul  8 23:28:26 2005
+++ src/sbin/ggate/shared/ggate.h	Sat Jan 14 19:40:52 2006
@@ -98,7 +98,7 @@
 void	g_gate_xvlog(const char *message, va_list ap);
 void	g_gate_xlog(const char *message, ...);
 off_t	g_gate_mediasize(int fd);
-size_t	g_gate_sectorsize(int fd);
+u_int	g_gate_sectorsize(int fd);
 void	g_gate_open_device(void);
 void	g_gate_close_device(void);
 void	g_gate_ioctl(unsigned long req, void *data);
--- src/sbin/ggate/shared/ggate.c.orig	Fri Jul  8 23:28:26 2005
+++ src/sbin/ggate/shared/ggate.c	Sat Jan 14 19:40:52 2006
@@ -149,10 +149,10 @@
 	return (mediasize);
 }
 
-size_t
+u_int
 g_gate_sectorsize(int fd)
 {
-	size_t secsize;
+	u_int secsize;
 	struct stat sb;
 
 	if (fstat(fd, &sb) == -1)
--- src/sbin/ggate/ggated/ggated.c.orig	Sun Jul 10 23:10:20 2005
+++ src/sbin/ggate/ggated/ggated.c	Sat Jan 14 19:40:29 2006
@@ -60,7 +60,7 @@
 
 struct ggd_connection {
 	off_t		 c_mediasize;
-	off_t		 c_sectorsize;
+	u_int		 c_sectorsize;
 	unsigned	 c_flags;	/* flags (RO/RW) */
 	int		 c_diskfd;
 	int		 c_sendfd;
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-amd64->pjd 
Responsible-Changed-By: pav 
Responsible-Changed-When: Sat Jan 14 20:42:27 UTC 2006 
Responsible-Changed-Why:  
Over to volunteer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=91799 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: amd64/91799: commit references a PR
Date: Fri, 15 Dec 2006 18:17:02 +0000 (UTC)

 pjd         2006-12-15 18:16:47 UTC
 
   FreeBSD src repository
 
   Modified files:
     sbin/ggate/ggated    ggated.c 
     sbin/ggate/shared    ggate.c ggate.h 
   Log:
   Fix ggated for platforms with 64bit size_t. The DIOCGSECTORSIZE ioctl
   returns u_int.
   
   Reported by:    Javier Martn Rueda <jmrueda@diatel.upm.es>
   PR:             amd64/91799
   MFC after:      3 days
   
   Revision  Changes    Path
   1.8       +1 -1      src/sbin/ggate/ggated/ggated.c
   1.7       +2 -2      src/sbin/ggate/shared/ggate.c
   1.4       +1 -1      src/sbin/ggate/shared/ggate.h
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: pjd 
State-Changed-When: Fri Dec 15 21:16:41 UTC 2006 
State-Changed-Why:  
Committed to HEAD. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=91799 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: amd64/91799: commit references a PR
Date: Mon, 18 Dec 2006 11:25:26 +0000 (UTC)

 pjd         2006-12-18 11:25:02 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     sbin/ggate/ggated    ggated.c 
     sbin/ggate/shared    ggate.c ggate.h 
   Log:
   MFC:    sbin/ggate/ggated/ggated.c      1.8,1.9
           sbin/ggate/shared/ggate.c       1.7,1.8
           sbin/ggate/shared/ggate.h       1.4,1.5
   
   Fix ggated for platforms with 64bit size_t. The DIOCGSECTORSIZE ioctl
   returns u_int.
   
   Reported by:    Javier Martn Rueda <jmrueda@diatel.upm.es>
   PR:             amd64/91799
   
   Revision  Changes    Path
   1.7.2.1   +1 -1      src/sbin/ggate/ggated/ggated.c
   1.5.2.2   +2 -2      src/sbin/ggate/shared/ggate.c
   1.3.2.1   +1 -1      src/sbin/ggate/shared/ggate.h
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: pjd 
State-Changed-When: Wed Dec 20 17:22:58 UTC 2006 
State-Changed-Why:  
Fix committed to both RELENG_6 and RELENG_6_2 branches. 
Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=91799 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: amd64/91799: commit references a PR
Date: Wed, 20 Dec 2006 17:22:42 +0000 (UTC)

 pjd         2006-12-20 17:21:54 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6_2)
     sbin/ggate/ggated    ggated.c 
     sbin/ggate/shared    ggate.c ggate.h 
   Log:
   MFC:    sbin/ggate/ggated/ggated.c      1.8,1.9
           sbin/ggate/shared/ggate.c       1.7,1.8
           sbin/ggate/shared/ggate.h       1.4,1.5
   
   Fix ggated for platforms with 64bit size_t. The DIOCGSECTORSIZE ioctl
   returns u_int.
   
   Reported by:    Javier Martn Rueda <jmrueda@diatel.upm.es>
   PR:             amd64/91799
   Approved by:    re (bmah)
   
   Revision     Changes    Path
   1.7.8.1      +1 -1      src/sbin/ggate/ggated/ggated.c
   1.5.2.1.2.1  +2 -2      src/sbin/ggate/shared/ggate.c
   1.3.8.1      +1 -1      src/sbin/ggate/shared/ggate.h
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
