Coda File System

Re: Coda on AMD64 (Linux) and Windows2000/Xp

From: Brett Lymn <blymn_at_baesystems.com.au>
Date: Fri, 28 Jan 2005 01:16:46 +1030
On Tue, Jan 25, 2005 at 02:41:11PM -0500, Jan Harkes wrote:
> 
> Ahh, makes sense, push quad instead of push long. I do wonder why there
> is no 'push all' equivalent.
> 

Well, it is really a quad register :)  I suppose that there is no pusha
because it is actually quite rare to use it - most compilers and programmers
carefully save the registers they use because there is too much overhead in
pushing and pulling registers you never touch.

> 
> Using pthreads does give better portability and allows us to
> debug deadlock or memory problems with gdb and valgrind.
>

Yes, the other benefit is on machines that support kernel threads the
threading should be a bit better than a pure userland solution.  I was
queried by some of the NetBSD developers when I committed the patch to
lwp in pkgsrc as to why it was not using pthreads...last time I tried to
make lwp use pthreads the NetBSD libpthread was missing the yield()
function (whatever it's called) but I think that is fixed now.
 
I had a bit of a poke at fixing the RPC2_Integer sizing.  Below is a diff
against 1.26 of the rpc2 code.  It builds without too many warnings, about
the only thing I am concerned about it there are a couple of places where
I have cast int's to intptr_t (this may or may not be a NetBSD specific
typedef - basically it is a integer that is guarenteed to be big enough to
hold a pointer for the architecture you are running on), I am not entirely
sure that was the correct thing to do - I _think_ it was.

Of course, this makes the coda build explode in a mess of incompatiable
pointer to int conversions and such like.  Some of them are quite easy to
fix but others, I am not so sure about - the worst I have come across so
far is Inode - it is declared as RPC2_Integer but in some cases the
inodeNumber element of VnodeDiskObjectStruct is used to store a pointer
to a PDirInode structure (coda-src/vol/dirvnode.cc is the main culprit
for this).  As I see it, the choice is either to promote inodeNumber to
a type large enough to hold a pointer or add another element to the
structure to hold the pointer to the PDirInode.  I think the latter would
be cleaner as long as it does not bork other things by changing the size of
VnodeDiskObjectStruct.  Thoughts?

patches for RPC2:


Index: fail/filtutil.c
===================================================================
RCS file: /home/siren/src/rpc2/fail/filtutil.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 filtutil.c
--- fail/filtutil.c	27 Jan 2005 14:10:02 -0000	1.1.1.1
+++ fail/filtutil.c	26 Jan 2005 14:06:03 -0000
@@ -437,7 +437,7 @@
 }
 
 /* another connect function that is still referenced from some places */
-int NewConn(char *hostname, short port, unsigned long *cid)
+int NewConn(char *hostname, short port, RPC2_Unsigned *cid)
 {
     int rc;
     RPC2_HostIdent hident;
Index: include/rpc2/rpc2.h
===================================================================
RCS file: /home/siren/src/rpc2/include/rpc2/rpc2.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 rpc2.h
--- include/rpc2/rpc2.h	27 Jan 2005 14:10:02 -0000	1.1.1.1
+++ include/rpc2/rpc2.h	26 Jan 2005 13:31:50 -0000
@@ -254,10 +254,10 @@
 ************************* Data Types known to RPGen ***********************
 */
 typedef
-    long RPC2_Integer;     /*32-bit,  2's  complement representation.  On other machines, an explicit
+    int32_t RPC2_Integer;     /*32-bit,  2's  complement representation.  On other machines, an explicit
                         conversion may be needed.*/
 typedef
-    unsigned long RPC2_Unsigned;     /* 32-bits.*/
+    uint32_t RPC2_Unsigned;     /* 32-bits.*/
 
 typedef
     unsigned char RPC2_Byte;      /*A single 8-bit byte.*/
Index: rp2gen/util.c
===================================================================
RCS file: /home/siren/src/rpc2/rp2gen/util.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 util.c
--- rp2gen/util.c	27 Jan 2005 14:10:02 -0000	1.1.1.1
+++ rp2gen/util.c	26 Jan 2005 14:06:04 -0000
@@ -279,7 +279,7 @@
 
 char *date()
 {
-    long clock;
+    time_t clock;
 
     clock = time(NULL);
     return ctime(&clock);
Index: rpc2-src/host.c
===================================================================
RCS file: /home/siren/src/rpc2/rpc2-src/host.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 host.c
--- rpc2-src/host.c	27 Jan 2005 14:10:02 -0000	1.1.1.1
+++ rpc2-src/host.c	26 Jan 2005 13:43:55 -0000
@@ -327,7 +327,7 @@
 
     say(0, RPC2_DebugLevel, "uRTT: 0x%lx %lu %lu %lu\n", elapsed_us, elapsed_us, InBytes, OutBytes);
     
-    if ((long)elapsed_us < 0) elapsed_us = 0;
+    if ((int32_t)elapsed_us < 0) elapsed_us = 0;
 
     /* we need to clamp elapsed elapsed_us to about 16 seconds to avoid
      * overflows with the 31 bit calculations below */
Index: rpc2-src/multi1.c
===================================================================
RCS file: /home/siren/src/rpc2/rpc2-src/multi1.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 multi1.c
--- rpc2-src/multi1.c	27 Jan 2005 14:10:02 -0000	1.1.1.1
+++ rpc2-src/multi1.c	26 Jan 2005 13:51:36 -0000
@@ -98,7 +98,7 @@
 static void MSend_Cleanup(int HowMany, MultiCon *mcon,
 			  SE_Descriptor SDescList[],
 			  struct timeval *Timeout, PacketCon *pcon);
-static inline long EXIT_MRPC(long code, int HowMany, long *RCList, MultiCon *context, struct MEntry *me);
+static inline long EXIT_MRPC(long code, int HowMany, RPC2_Integer *RCList, MultiCon *context, struct MEntry *me);
 
 #define GOODSEDLE(i)  (SDescList && SDescList[i].Tag != OMITSE)
 
@@ -200,7 +200,7 @@
 
 /* easier to manage than the former macro definition */
 static inline long
-EXIT_MRPC(long code, int HowMany, long *RCList, MultiCon *mcon,
+EXIT_MRPC(long code, int HowMany, RPC2_Integer *RCList, MultiCon *mcon,
 	  struct MEntry *me)
 {
     int i;
Index: rpc2-src/rpc2a.c
===================================================================
RCS file: /home/siren/src/rpc2/rpc2-src/rpc2a.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 rpc2a.c
--- rpc2-src/rpc2a.c	27 Jan 2005 14:10:02 -0000	1.1.1.1
+++ rpc2-src/rpc2a.c	26 Jan 2005 13:46:11 -0000
@@ -115,7 +115,7 @@
 static RPC2_PacketBuffer *HeldReq(RPC2_RequestFilter *filter, struct CEntry **ce);
 static int GetFilter(RPC2_RequestFilter *inf, RPC2_RequestFilter *outf);
 static long GetNewRequest(IN RPC2_RequestFilter *filter, IN struct timeval *timeout, OUT struct RPC2_PacketBuffer **pb, OUT struct CEntry **ce);
-static long MakeFake(INOUT RPC2_PacketBuffer *pb, IN struct CEntry *ce, RPC2_Integer *AuthenticationType, OUT long *xrand, OUT RPC2_CountedBS *cident);
+static long MakeFake(INOUT RPC2_PacketBuffer *pb, IN struct CEntry *ce, RPC2_Integer *xrand, OUT RPC2_Integer *AuthenticationType, OUT RPC2_CountedBS *cident);
 static long Test3(RPC2_PacketBuffer *pb, struct CEntry *ce, long yrand, RPC2_EncryptionKey ekey);
 
 FILE *rpc2_logfile;
@@ -229,7 +229,8 @@
 	RPC2_PacketBuffer *pb;
 	RPC2_Integer AuthenticationType;
 	RPC2_CountedBS cident;
-	long rc, saveXRandom;
+        RPC2_Integer saveXRandom;
+	long rc;
 
 	rpc2_Enter();
 	say(0, RPC2_DebugLevel, "RPC2_GetRequest()\n");
@@ -1075,7 +1076,7 @@
 static long MakeFake(INOUT pb, IN ce, OUT xrand, OUT authenticationtype, OUT cident)
     RPC2_PacketBuffer *pb;
     struct CEntry *ce;
-    long *xrand;
+    RPC2_Integer *xrand;
     RPC2_Integer *authenticationtype;
     RPC2_CountedBS *cident;
     {
Index: rpc2-src/sftp6.c
===================================================================
RCS file: /home/siren/src/rpc2/rpc2-src/sftp6.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 sftp6.c
--- rpc2-src/sftp6.c	27 Jan 2005 14:10:02 -0000	1.1.1.1
+++ rpc2-src/sftp6.c	26 Jan 2005 14:00:37 -0000
@@ -226,7 +226,7 @@
 				if (HOSTSEOK(host))
 				    {
 				    /* copy packet body in case retries are singlecasted */
-				    assert(sftp_AddPiggy(&req[host],(char *)me->CurrentPacket->Header.SEDataOffset, rc, SFTP_MAXPACKETSIZE) == 0);
+				    assert(sftp_AddPiggy(&req[host],(char *)(intptr_t)me->CurrentPacket->Header.SEDataOffset, rc, SFTP_MAXPACKETSIZE) == 0);
                                     sftp_Progress(&SDescList[host], rc);
 				    sftp_didpiggy++;
 				    }
Index: rpc2-src/stest.c
===================================================================
RCS file: /home/siren/src/rpc2/rpc2-src/stest.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 stest.c
--- rpc2-src/stest.c	27 Jan 2005 14:10:02 -0000	1.1.1.1
+++ rpc2-src/stest.c	26 Jan 2005 14:12:55 -0000
@@ -172,7 +172,7 @@
 	    (numLWPs < maxLWPs)) {
 #if	__GNUC__ >= 2
 	    i = LWP_CreateProcess((PFIC)HandleRequests, STESTSTACK, LWP_NORMAL_PRIORITY,
-			      (char *)numLWPs, "server", &pids[numLWPs]);
+			      (char *)(intptr_t)numLWPs, "server", &pids[numLWPs]);
 /* ??? */
 #else
 	    i = LWP_CreateProcess(HandleRequests, STESTSTACK, LWP_NORMAL_PRIORITY,
-- 
Brett Lymn
Received on 2005-01-27 09:49:32