[OpenAFS-devel] Patches for AIX 5.1 and others

Hartmut Reuter reuter@rzg.mpg.de
Wed, 11 Jun 2003 11:07:27 +0200


This is a multi-part message in MIME format.
--------------090100060406080303000008
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hello all,

I am glad to have now also an AFS client for 64-bit kernels for AIX 5.1.
There is, however, still one mysterium: with the 64-bit kernel I had to 
skip the in_cksum() call in src/rx/AIX/rx_knet.c.

In order to build both (32 and 64-bit) kernel extensions I had to modify 
the way the kernel extensions are built. This made is necessary to 
rename some source files and to add some new ones.

At the end of the attachements you find the diffs which also show where 
to put the other attached files.

make dest (always assuming you configured with --enable-transarc-paths) 
builds kernel extensions for both 32- and 64-bit kernels. The afs.rc 
script was modified to load the correct ones when starting.

Some of the patches are corrections for bugs I introduced in previous 
patches.

The most important one is for xdr_int64.c where I had used for some 
unclear reason static variables which under havy load could lead to 
incorrect chunks being transfered! (but only with large files support).

In src/afs/VNOPS/afs_vnop_read.c I removed the whole FastRead stuff 
because it never is used anywhere.

We are using the AIX 5.1 client in production since half a year with 
32-bit kernels and since a month with 64-bit-kernels. We get best 
performance with ramdisk-caches which on the big Regatta systems with 64 
to 256 GB of main memory is easily affordable.

I hope I have not created to many new bugs! I am not a good programmer 
(just a physicist). If you feel some parts could be written better feel 
free to do so.

Thanks in advance,
Hartmut



--------------090100060406080303000008
Content-Type: text/plain;
 name="osi_assem32.s"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="osi_assem32.s"

# Copyright 2000, International Business Machines Corporation and others.
# All Rights Reserved.
# 
# This software has been released under the terms of the IBM Public
# License.  For details, see the LICENSE file in the top-level source
# directory or online at http://www.openafs.org/dl/license10.html

# $Locker:  $
#
# misc.s -	miscellaneous assembler routines for the rs/6000
#

#
# get_toc -	return the current TOC
#
 	.csect .get_toc[PR]
	 .globl .get_toc[PR]
	mr	3,2		# get TOC
	br
        .align 2
	.tbtag 0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0

 	.toc
	.csect  get_toc[DS]
	.globl  get_toc[DS]
	.long  .get_toc[PR]
	.long  TOC[t0]

#
# get_ret_addr -	return the caller's return address
#
	.csect .get_ret_addr[PR]
	.globl .get_ret_addr[PR]
	l	3, 0(1)		# caller's saved stack pointer
	l	3, 8(3)		# caller's saved link register
	br
	.align 2
	.tbtag 0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
 	.toc
        .csect  get_ret_addr[DS]
        .globl  get_ret_addr[DS]
	.long  .get_ret_addr[PR]
        .long  TOC[t0]

--------------090100060406080303000008
Content-Type: text/plain;
 name="osi_assem64.s"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="osi_assem64.s"

# Copyright 2000, International Business Machines Corporation and others.
# All Rights Reserved.
# 
# This software has been released under the terms of the IBM Public
# License.  For details, see the LICENSE file in the top-level source
# directory or online at http://www.openafs.org/dl/license10.html

# $Locker:  $
#
# misc.s -	miscellaneous assembler routines for the rs/6000
#

#
# get_toc -	return the current TOC
#
 	.csect .get_toc[PR]
	 .globl .get_toc[PR]
	mr	3,2		# get TOC
	br
        .align 2
	.tbtag 0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0

 	.toc
	.csect  get_toc[DS]
	.globl  get_toc[DS]
	.llong  .get_toc[PR]
	.llong  TOC[t0]

#
# get_ret_addr -	return the caller's return address
#
	.csect .get_ret_addr[PR]
	.globl .get_ret_addr[PR]
	l	3, 0(1)		# caller's saved stack pointer
	l	3, 8(3)		# caller's saved link register
	br
	.align 2
	.tbtag 0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0
 	.toc
        .csect  get_ret_addr[DS]
        .globl  get_ret_addr[DS]
	.llong  .get_ret_addr[PR]
        .llong  TOC[t0]

--------------090100060406080303000008
Content-Type: text/plain;
 name="export4-64.exp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="export4-64.exp"

#!/unix
*
* $Locker:  $
*
* EXPORT exports
*
import_kfunc
import_kvar
*
* Overwrite vanilla system calls
*
osetgroups	syscall
okioctl		syscall




--------------090100060406080303000008
Content-Type: text/plain;
 name="export4.exp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="export4.exp"

#!/unix
*
* $Locker:  $
*
* EXPORT exports
*
import_kfunc
import_kvar
*
* Overwrite vanilla system calls
*
osetgroups	syscall
okioctl		syscall




--------------090100060406080303000008
Content-Type: text/plain;
 name="export5-64.exp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="export5-64.exp"

#!/unix
*
* $Locker:  $
*
* EXPORT exports
*
import_kfunc
import_kvar
*
* Overwrite vanilla system calls
*
okioctl  	syscall




--------------090100060406080303000008
Content-Type: text/plain;
 name="afs4.exp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="afs4.exp"

#!/unix
*
* $Locker:  $
*
*
* Exports for the AFS kernel extension for AIX 3.1
*
icreate		syscall
syscall		syscall
iopen		syscall
iinc		syscall
idec		syscall
* iread		syscall
* iwrite		syscall
lsetpag		syscall
lpioctl		syscall

*
* Exported variables (useful for debugging)
*
* afs_debug

*
* We replace the following system calls
*
setgroups	syscall
kioctl		syscall

*
*
*
root_exported
afs_users
CellLRU
afs_servers
afs_volumes
afs_vhashT
afs_cmstats
afs_stats_cmperf
afs_xvcache
afs_xdcache
afs_xserver
afs_xvcb
afs_xbrs
afs_xcell
afs_xconn
afs_xuser
afs_xvolume
afs_setTimeHost
afs_volCounter
afs_cellindex
afs_sysname
afs_marinerHost
* afs_marinerPort
afs_mariner
cacheInfoModTime
freeVCList
afs_freeDCList
afs_freeDCCount
afs_freeDSList
cacheInode
volumeInode
cacheDiskType
afs_indexCounter
afs_cacheFiles
afs_cacheBlocks
afs_cacheStats
afs_blocksUsed
afs_fsfragsize
osi_flplock
rx_epoch
rx_stats
rx_extraQuota
rx_extraPackets
rx_stackSize
rx_connDeadTime
rx_idleConnectionTime
rx_idlePeerTime
rx_nPackets
rx_nFreePackets
rx_socket
rx_port
* rx_selectMask
* rx_maxSocketNumber
rx_packetQuota
rx_nextCid
rx_waitingForPackets
rxi_nCalls
rxi_dataQuota
rxi_availProcs
rxi_totalMin
rxi_minDeficit
rx_peerHashTable
rx_connHashTable
rx_services
afs_indexTable
afs_indexFlags
afs_indexTimes
rxi_Alloccnt
rxi_Allocsize
afs_dcentries
rxevent_nFree
rxevent_nPosted
afs_brsWaiters
afs_brsDaemons
afs_brs
afs_callo
VLRU
afs_DLRU
afs_xcbhash
rx_serverPool_lock
rx_incomingCallQueue
rx_freeCallQueue
rx_idleServerQueue
rx_freePktQ_lock
freeSQEList_lock
rx_freeCallQueue_lock
rx_waitingForPackets_cv
rx_peerHashTable_lock
rx_connHashTable_lock
rxevent_lock
* rxdb_idHash
* rxdb_lockList
afs_duplicate_nfs_fids
rx_tq_debug
afs_totalServers
afs_totalSrvAddrs
afs_srvAddrs
afs_global_lock
afs_indexUnique
afs_dvnextTbl
afs_dcnextTbl
afs_discardDCCount
afs_TruncateDaemonRunning
afs_CacheTooFull
afs_blocksDiscarded
afs_gcpags
afs_gcpags_procsize
afs_discardDCList
afs_WaitForCacheDrain

--------------090100060406080303000008
Content-Type: text/plain;
 name="afs5.exp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="afs5.exp"

#!/unix
*
* $Locker:  $
*
*
* Exports for the AFS kernel extension for AIX 3.1
*
icreate		syscall
syscall		syscall
iopen		syscall
iinc		syscall
idec		syscall
* iread		syscall
* iwrite		syscall
lsetpag		syscall
lpioctl		syscall

*
* Exported variables (useful for debugging)
*
* afs_debug

*
* We replace the following system calls
*
*setgroups	syscall
kioctl32	syscall

*
*
*
root_exported
afs_users
CellLRU
afs_servers
afs_volumes
afs_vhashT
afs_cmstats
afs_stats_cmperf
afs_xvcache
afs_xdcache
afs_xserver
afs_xvcb
afs_xbrs
afs_xcell
afs_xconn
afs_xuser
afs_xvolume
afs_setTimeHost
afs_volCounter
afs_cellindex
afs_sysname
afs_marinerHost
* afs_marinerPort
afs_mariner
cacheInfoModTime
freeVCList
afs_freeDCList
afs_freeDCCount
afs_freeDSList
cacheInode
volumeInode
cacheDiskType
afs_indexCounter
afs_cacheFiles
afs_cacheBlocks
afs_cacheStats
afs_blocksUsed
afs_fsfragsize
osi_flplock
rx_epoch
rx_stats
rx_extraQuota
rx_extraPackets
rx_stackSize
rx_connDeadTime
rx_idleConnectionTime
rx_idlePeerTime
rx_nPackets
rx_nFreePackets
rx_socket
rx_port
* rx_selectMask
* rx_maxSocketNumber
rx_packetQuota
rx_nextCid
rx_waitingForPackets
rxi_nCalls
rxi_dataQuota
rxi_availProcs
rxi_totalMin
rxi_minDeficit
rx_peerHashTable
rx_connHashTable
rx_services
afs_indexTable
afs_indexFlags
afs_indexTimes
rxi_Alloccnt
rxi_Allocsize
afs_dcentries
rxevent_nFree
rxevent_nPosted
afs_brsWaiters
afs_brsDaemons
afs_brs
afs_callo
VLRU
afs_DLRU
afs_xcbhash
rx_serverPool_lock
rx_incomingCallQueue
rx_freeCallQueue
rx_idleServerQueue
rx_freePktQ_lock
freeSQEList_lock
rx_freeCallQueue_lock
rx_waitingForPackets_cv
rx_peerHashTable_lock
rx_connHashTable_lock
rxevent_lock
* rxdb_idHash
* rxdb_lockList
afs_duplicate_nfs_fids
rx_tq_debug
afs_totalServers
afs_totalSrvAddrs
afs_srvAddrs
afs_global_lock
afs_indexUnique
afs_dvnextTbl
afs_dcnextTbl
afs_discardDCCount
afs_TruncateDaemonRunning
afs_CacheTooFull
afs_blocksDiscarded
afs_gcpags
afs_gcpags_procsize
afs_discardDCList
afs_WaitForCacheDrain

--------------090100060406080303000008
Content-Type: text/plain;
 name="afsl4.exp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="afsl4.exp"

#!/unix
*
* $Locker:  $
*
*
* Exports for the AFS kernel extension for AIX 3.1
*
icreate		syscall
syscall		syscall
iopen		syscall
iinc		syscall
idec		syscall
* iread		syscall
* iwrite		syscall
lsetpag		syscall
lpioctl		syscall

*
* Exported variables (useful for debugging)
*
* afs_debug

*
* We replace the following system calls
*
setgroups	syscall
kioctl		syscall

--------------090100060406080303000008
Content-Type: text/plain;
 name="afsl5.exp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="afsl5.exp"

#!/unix
*
* $Locker:  $
*
*
* Exports for the AFS kernel extension for AIX 3.1
*
icreate		syscall
syscall		syscall
iopen		syscall
iinc		syscall
idec		syscall
* iread		syscall
* iwrite		syscall
lsetpag		syscall
lpioctl		syscall

*
* Exported variables (useful for debugging)
*
* afs_debug

*
* We replace the following system calls
*
*setgroups	syscall
kioctl32	syscall

--------------090100060406080303000008
Content-Type: text/plain;
 name="diffs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="diffs"

? diffs
? rs_aix51
? src/afs/AIX/osi_assem32.s
? src/afs/AIX/osi_assem64.s
? src/export/export4-64.exp
? src/export/export4.exp
? src/export/export5-64.exp
? src/sys/afs4.exp
? src/sys/afs5.exp
? src/sys/afsl4.exp
? src/sys/afsl5.exp
Index: src/afs/afs_call.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_call.c,v
retrieving revision 1.56
diff -u -b -r1.56 afs_call.c
--- src/afs/afs_call.c	22 May 2003 15:51:08 -0000	1.56
+++ src/afs/afs_call.c	11 Jun 2003 08:35:56 -0000
@@ -1551,8 +1551,12 @@
 int afs_icl_sizeofLong = 2;
 #endif /* SGI62 */
 #else
+#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
+int afs_icl_sizeofLong = 2;
+#else
 int afs_icl_sizeofLong = 1;
 #endif
+#endif
 
 int afs_icl_inited = 0;
 
@@ -1577,7 +1581,11 @@
 #if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
     size_t temp;
 #else /* AFS_SGI61_ENV */
+#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
+    afs_uint64 temp;
+#else
     afs_uint32 temp;
+#endif
 #endif /* AFS_SGI61_ENV */
     char tname[65];
     afs_int32 startCookie;
@@ -1627,6 +1635,11 @@
 	if (code) goto done;
 	AFS_COPYOUT((char *) &startCookie, (char *)p4, sizeof(afs_int32), code);
 	if (code) goto done;
+#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
+	if (!(IS64U))
+	     *retval = ((long) ((flags<<24) | (elts & 0xffffff))) << 32;
+	else
+#endif
 	*retval = (flags<<24) | (elts & 0xffffff);
       done:
 	afs_icl_LogRele(logp);
@@ -1908,7 +1921,6 @@
 }
 
 /* add a long to the log, ignoring overflow (checked already) */
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
 #define ICL_APPENDINT32(lp, x) \
     MACRO_BEGIN \
         (lp)->datap[(lp)->firstFree] = (x); \
@@ -1918,6 +1930,7 @@
         (lp)->logElements++; \
     MACRO_END
 
+#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 #define ICL_APPENDLONG(lp, x) \
     MACRO_BEGIN \
 	ICL_APPENDINT32((lp), ((x) >> 32) & 0xffffffffL); \
@@ -1925,15 +1938,7 @@
     MACRO_END
 
 #else /* AFS_ALPHA_ENV */
-#define ICL_APPENDLONG(lp, x) \
-    MACRO_BEGIN \
-        (lp)->datap[(lp)->firstFree] = (x); \
-	if (++((lp)->firstFree) >= (lp)->logSize) { \
-		(lp)->firstFree = 0; \
-	} \
-        (lp)->logElements++; \
-    MACRO_END
-#define ICL_APPENDINT32(lp, x) ICL_APPENDLONG((lp), (x))
+#define ICL_APPENDLONG(lp, x) ICL_APPENDINT32((lp), (x))
 #endif /* AFS_ALPHA_ENV */
 
 /* routine to tell whether we're dealing with the address or the
@@ -2075,7 +2080,7 @@
 	    ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[2]);
 	    ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[3]);
 	}
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
+#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 	else if (t1 == ICL_TYPE_INT32)
 	    ICL_APPENDINT32(logp, (afs_int32)p1);
 #endif /* AFS_ALPHA_ENV */
@@ -2113,7 +2118,7 @@
 	    ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[2]);
 	    ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[3]);
 	}
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
+#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 	else if (t2 == ICL_TYPE_INT32)
 	    ICL_APPENDINT32(logp, (afs_int32)p2);
 #endif /* AFS_ALPHA_ENV */
@@ -2151,7 +2156,7 @@
 	    ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[2]);
 	    ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[3]);
 	}
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
+#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 	else if (t3 == ICL_TYPE_INT32)
 	    ICL_APPENDINT32(logp, (afs_int32)p3);
 #endif /* AFS_ALPHA_ENV */
@@ -2189,7 +2194,7 @@
 	    ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[2]);
 	    ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[3]);
 	}
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64))
+#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 	else if (t4 == ICL_TYPE_INT32)
 	    ICL_APPENDINT32(logp, (afs_int32)p4);
 #endif /* AFS_ALPHA_ENV */
Index: src/afs/afs_cell.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_cell.c,v
retrieving revision 1.26
diff -u -b -r1.26 afs_cell.c
--- src/afs/afs_cell.c	14 May 2003 15:14:54 -0000	1.26
+++ src/afs/afs_cell.c	11 Jun 2003 08:35:56 -0000
@@ -463,7 +463,7 @@
 
 struct afs_q CellLRU;		/* Export for kdump */
 static char *afs_thiscell;
-static afs_int32 afs_cellindex;
+afs_int32 afs_cellindex;        /* Export for kdump */
 
 static void afs_UpdateCellLRU(struct cell *c)
 {
Index: src/afs/afs_daemons.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_daemons.c,v
retrieving revision 1.25
diff -u -b -r1.25 afs_daemons.c
--- src/afs/afs_daemons.c	22 Jan 2003 21:25:14 -0000	1.25
+++ src/afs/afs_daemons.c	11 Jun 2003 08:35:56 -0000
@@ -12,6 +12,11 @@
 
 RCSID("$Header: /cvs/openafs/src/afs/afs_daemons.c,v 1.25 2003/01/22 21:25:14 rees Exp $");
 
+#ifdef AFS_AIX51_ENV
+#define __FULL_PROTO
+#include <sys/sleep.h>
+#endif
+
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #include "afsincludes.h"	/* Afs-based standard headers */
 #include "afs/afs_stats.h"   /* statistics gathering code */
@@ -585,7 +590,7 @@
  * The modifications here will work for either a UP or MP machine.
  */
 struct buf *afs_asyncbuf = (struct buf*)0;
-afs_int32 afs_asyncbuf_cv = EVENT_NULL;
+tid_t afs_asyncbuf_cv = EVENT_NULL;
 afs_int32 afs_biodcnt = 0;
 
 /* in implementing this, I assumed that all external linked lists were
@@ -620,7 +625,7 @@
     struct buf *bp = NULL;
     struct buf *bestbp;
     struct buf **bestlbpP, **lbpP;
-    int bestage, stop;
+    long bestage, stop;
     struct buf *t1P, *t2P;      /* temp pointers for list manipulation */
     int oldPriority;
     afs_uint32 wait_ret;
@@ -639,16 +644,16 @@
 	if (afs_asyncbuf) {
 	    /* look for oldest buffer */
 	    bp = bestbp = afs_asyncbuf;
-	    bestage = (int) bestbp->av_back;
+	    bestage = (long) bestbp->av_back;
 	    bestlbpP = &afs_asyncbuf;
 	    while (1) {
 		lbpP = &bp->av_forw;
 		bp = *lbpP;
 		if (!bp) break;
-		if ((int) bp->av_back - bestage < 0) {
+		if ((long) bp->av_back - bestage < 0) {
 		    bestbp = bp;
 		    bestlbpP = lbpP;
-		    bestage = (int) bp->av_back;
+		    bestage = (long) bp->av_back;
 		}
 	    }
 	    bp = bestbp;
@@ -814,7 +819,7 @@
 	 * also want to hang onto the old one.
 	 */
 	tmpaddr = bp->b_baddr;
-	bp->b_baddr = vm_att (bp->b_xmemd.subspace_id, tmpaddr);
+	bp->b_baddr = (caddr_t) vm_att (bp->b_xmemd.subspace_id, tmpaddr);
 	tmperr = afs_ustrategy(bp);	/* temp variable saves offset calculation */
 	if (tmperr) {			/* in non-error case */
 	    bp->b_flags |= B_ERROR;		/* should other flags remain set ??? */
@@ -824,7 +829,7 @@
 	/* Unmap the buffer's data area by calling vm_det.  Reset data area
 	 * to the value that we saved above.
 	 */
-	vm_det(bp->b_un.b_addr);
+	vm_det(bp->b_baddr);
 	bp->b_baddr = tmpaddr;
 
 	/*
Index: src/afs/afs_dcache.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_dcache.c,v
retrieving revision 1.37
diff -u -b -r1.37 afs_dcache.c
--- src/afs/afs_dcache.c	22 Jan 2003 21:25:15 -0000	1.37
+++ src/afs/afs_dcache.c	11 Jun 2003 08:35:56 -0000
@@ -331,6 +331,8 @@
     adc->dflags |= DFEntryMod;
     oldSize = ((adc->f.chunkBytes + afs_fsfragsize)^afs_fsfragsize)>>10;/* round up */
     adc->f.chunkBytes = newSize;
+    if (!newSize)
+	adc->validPos = 0;
     newSize = ((newSize + afs_fsfragsize)^afs_fsfragsize)>>10;/* round up */
     if (newSize > oldSize) {
 	/* We're growing the file, wakeup the daemon */
@@ -2759,6 +2761,10 @@
     }
     tdc->refCount = 1;
     tdc->index = aslot;
+    if (tdc->f.chunk >= 0)
+	tdc->validPos = AFS_CHUNKTOBASE(tdc->f.chunk) + tdc->f.chunkBytes;
+    else
+	tdc->validPos = 0;
 
     if (existing) {
 	osi_Assert(0 == NBObtainWriteLock(&tdc->lock, 674));
Index: src/afs/afs_lock.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_lock.c,v
retrieving revision 1.7
diff -u -b -r1.7 afs_lock.c
--- src/afs/afs_lock.c	16 Oct 2002 03:58:16 -0000	1.7
+++ src/afs/afs_lock.c	11 Jun 2003 08:35:56 -0000
@@ -120,6 +120,7 @@
 void Afs_Lock_Obtain(register struct afs_lock *lock, int how)
 {
     osi_timeval_t tt1, tt2, et;
+    afs_uint32 us;
 
     AFS_STATCNT(Lock_Obtain);
   
@@ -170,9 +171,12 @@
     osi_GetuTime(&tt2);
     afs_stats_GetDiff(et, tt1, tt2);
     afs_stats_AddTo((lock->time_waiting), et);
+    us = (et.tv_sec << 20) + et.tv_usec;
 
     if (afs_trclock) {
-	afs_Trace2(afs_iclSetp, CM_TRACE_LOCKSLEPT, ICL_TYPE_POINTER, lock,
+	afs_Trace3(afs_iclSetp, CM_TRACE_LOCKSLEPT, 
+			ICL_TYPE_INT32, us,
+			ICL_TYPE_POINTER, lock,
 		   ICL_TYPE_INT32, how);
     }
 }
Index: src/afs/afs_memcache.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_memcache.c,v
retrieving revision 1.13
diff -u -b -r1.13 afs_memcache.c
--- src/afs/afs_memcache.c	28 Dec 2002 05:17:08 -0000	1.13
+++ src/afs/afs_memcache.c	11 Jun 2003 08:35:56 -0000
@@ -416,6 +416,7 @@
       if(!tiov) {
 	osi_Panic("afs_MemCacheFetchProc: osi_AllocSmallSpace for iovecs returned NULL\n");
       }
+      adc->validPos = abase;
       do {
 	  if (moredata) {
               RX_AFS_GUNLOCK();
@@ -467,7 +468,12 @@
 	      abase += tlen;
 	      length -= tlen;
 	      adc->validPos = abase;
-	      afs_osi_Wakeup(&adc->validPos);
+	      if (afs_osi_Wakeup(&adc->validPos) == 0)
+		 afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE,
+                           ICL_TYPE_STRING, __FILE__,
+                           ICL_TYPE_INT32, __LINE__,
+                           ICL_TYPE_POINTER, adc,
+                           ICL_TYPE_INT32, adc->dflags);
 	  }
       } while (moredata);
       /* max of two sizes */
Index: src/afs/afs_osi.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_osi.c,v
retrieving revision 1.33
diff -u -b -r1.33 afs_osi.c
--- src/afs/afs_osi.c	23 Mar 2003 06:45:02 -0000	1.33
+++ src/afs/afs_osi.c	11 Jun 2003 08:35:56 -0000
@@ -517,10 +517,10 @@
 			 ^ ((((handle) & ~vmker.stoinio) & vmker.stoimask) << vmker.stoihash) \
 			 ) & 0x000fffff)
 
-    if (avc->vmh) {
+    if (avc->segid) {
 	unsigned int pagef, pri, index, next;
 
-	index = VMHASH(avc->vmh);
+	index = VMHASH(avc->segid);
 	if (scb_valid(index)) {  /* could almost be an ASSERT */
 
 	    pri = disable_ints();
@@ -899,7 +899,11 @@
     xmem_userp = NULL;
     xm = XMEM_FAIL;
     /* simple_lock(&proc_tbl_lock); */
+#ifdef __64BIT__
+    if (pproc->p_adspace != vm_handle(NULLSEGID, (int32long64_t) 0)) {
+#else
     if (pproc->p_adspace != NULLSEGVAL) {
+#endif
 
 #ifdef AFS_AIX51_ENV
 	simple_lock(&pproc->p_pvprocp->pv_lock);
Index: src/afs/afs_osi.h
===================================================================
RCS file: /cvs/openafs/src/afs/afs_osi.h,v
retrieving revision 1.15
diff -u -b -r1.15 afs_osi.h
--- src/afs/afs_osi.h	23 Apr 2003 23:03:46 -0000	1.15
+++ src/afs/afs_osi.h	11 Jun 2003 08:35:56 -0000
@@ -51,8 +51,12 @@
 #if	defined(AFS_HPUX102_ENV)
     k_off_t offset;
 #else
+#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
+    afs_offs_t offset;
+#else
     afs_int32 offset;
 #endif
+#endif
     int	(*proc)(struct osi_file *afile, afs_int32 code);	/* proc, which, if not null, is called on writes */
     char *rock;		/* rock passed to proc */
     ino_t inum;         /* guarantee validity of hint */
@@ -66,7 +70,11 @@
     struct mount *mp;
     struct vnode *held_vnode;
 #else
+#ifdef AFS_AIX42_ENV
+    dev_t dev;
+#else
     afs_int32 dev;
+#endif
 #endif
 };
 
Index: src/afs/afs_pioctl.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_pioctl.c,v
retrieving revision 1.64
diff -u -b -r1.64 afs_pioctl.c
--- src/afs/afs_pioctl.c	22 May 2003 15:16:19 -0000	1.64
+++ src/afs/afs_pioctl.c	11 Jun 2003 08:35:57 -0000
@@ -193,6 +193,17 @@
 copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst)
 {
 	int code;
+#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
+       struct afs_ioctl32 dst32;
+
+       if (!(IS64U)) {
+               AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
+               if (!code)
+                       afs_ioctl32_to_afs_ioctl(&dst32, dst);
+               return code;
+       }
+#endif /* defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) */
+
 
 #if defined(AFS_HPUX_64BIT_ENV)
 	struct afs_ioctl32 dst32;
Index: src/afs/afs_segments.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_segments.c,v
retrieving revision 1.14
diff -u -b -r1.14 afs_segments.c
--- src/afs/afs_segments.c	16 Oct 2002 03:58:16 -0000	1.14
+++ src/afs/afs_segments.c	11 Jun 2003 08:35:57 -0000
@@ -44,7 +44,7 @@
     struct AFSVolSync tsync;
     register afs_int32 code;
     register struct rx_call *tcall;
-    afs_size_t tlen, base = 0;
+    afs_size_t tlen, xlen = 0;
     XSTATS_DECLS
 
     AFS_STATCNT(afs_StoreMini);
@@ -75,16 +75,16 @@
 	    XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREDATA);
             afs_Trace4(afs_iclSetp, CM_TRACE_STOREDATA64, 
 		ICL_TYPE_FID, &avc->fid.Fid,
-	       	ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(base), 
-	       	ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(tlen), 
-	       	ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
+	       	ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length),
+	       	ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(xlen), 
+	       	ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(tlen));
 	    RX_AFS_GUNLOCK();
 #ifdef AFS_64BIT_CLIENT
 	    if (!afs_serverHasNo64Bit(tc)) {
 	        code = StartRXAFS_StoreData64(tcall,
 					(struct AFSFid *)&avc->fid.Fid,
 					&InStatus, avc->m.Length,
-					base, tlen);
+					(afs_size_t) 0, tlen);
 	    } else {
 		afs_int32 l1, l2;
 		l1 = avc->m.Length;
@@ -523,9 +523,11 @@
 		    if (!code) doProcessFS = 1;	/* Flag to run afs_ProcessFS() later on */
 		}
 		if (tcall) {
+		    afs_int32 code2;
 		    RX_AFS_GUNLOCK();
-		    code = rx_EndCall(tcall, code);  
+		    code2 = rx_EndCall(tcall, code);  
 		    RX_AFS_GLOCK();
+		    if (code2) code = code2;
 		}
 	    } while (afs_Analyze(tc, code, &avc->fid, areq,
 				 AFS_STATS_FS_RPCIDX_STOREDATA,
Index: src/afs/afs_trace.et
===================================================================
RCS file: /cvs/openafs/src/afs/afs_trace.et,v
retrieving revision 1.15
diff -u -b -r1.15 afs_trace.et
--- src/afs/afs_trace.et	9 Oct 2002 01:02:47 -0000	1.15
+++ src/afs/afs_trace.et	11 Jun 2003 08:35:57 -0000
@@ -56,7 +56,7 @@
 	ec	CM_TRACE_GETDCACHE1, "Getdcache vp 0x%lx failed to find chunk 0x%x"
 	ec	CM_TRACE_GETDCACHE2, "GetdCache vp 0x%lx dcache 0x%lx dcache low-version 0x%x, vcache low-version 0x%x"
 	ec	CM_TRACE_GETDCACHE3, "GetdCache tlen 0x%x flags 0x%x abyte (0x%x, 0x%x) Position (0x%x, 0x%x)"
-	ec	CM_TRACE_STOREMINI, "storemini vp 0x%lx length 0x%x"
+	ec	CM_TRACE_STOREMINI, "storemini vp 0x%lx length (0x%x, 0x%x)"
 	ec	CM_TRACE_STOREDCACHE, "StoreDCache vp 0x%lx chunk 0x%x length 0x%x at position 0x%x"
 	ec	CM_TRACE_STOREDCACHEDONE, "StoreDCache Done for vp 0x%lx (returns 0x%x)"
 	ec	CM_TRACE_STOREALLDONE, "StoreAll Done vp 0x%lx length 0x%x (returns 0x%x)"
@@ -71,7 +71,7 @@
 	ec	CM_TRACE_NFSOUT, "NfsOut op 0x%x vp 0x%lx fid (%x:%d.%d.%d)"
 	ec	CM_TRACE_NFSIN, "NfsIn op 0x%x"
 	ec	CM_TRACE_NFSIN1, "Nfs Root fid client 0x%lx fid (%x:%d.%d.%d)"
-	ec	CM_TRACE_FLUSHPAGES, "flushpages vp 0x%x data version low 0x%x length 0x%x"
+	ec	CM_TRACE_FLUSHPAGES, "flushpages vp 0x%lx data version low 0x%x length 0x%x"
 	ec	CM_TRACE_SYNCVM, "SyncVM vp 0x%lx length 0x%x"
 	ec	CM_TRACE_PIOCTL, "Pioctl command 0x%x for vp 0x%lx, follow=%d"
 	ec	CM_TRACE_CHECKCODE, "Returning code %d from %d"
@@ -85,13 +85,13 @@
 	ec	CM_TRACE_READ, "Read vp 0x%lx off (0x%x, 0x%x) resid  0x%x file length (0x%x, 0x%x)"
 	ec	CM_TRACE_PARTIALWRITE, "Partial write vp 0x%lx length (0x%x, 0x%x)"
 	ec	CM_TRACE_GETATTR, "Getattr vp 0x%lx len (0x%x, 0x%x)"
-	ec	CM_TRACE_SETATTR, "Setattr vp 0x%lx len (0x%x, 0x%x)"
+	ec	CM_TRACE_SETATTR, "Setattr vp 0x%lx mask 0x%x newlen (0x%x, 0x%x) oldlen (0x%x, 0x%x)"
 	ec	CM_TRACE_ACCESS, "Access vp 0x%lx mode 0x%x len (0x%x, 0x%x)"
 	ec	CM_TRACE_LOOKUP, "Lookup adp 0x%lx name %s fid (%d:%d.%d.%d), code=%d"
 	ec	CM_TRACE_LOOKUP1, "Mount point is to vp 0x%lx fid (%d:%d.%d.%d)"
 	ec	CM_TRACE_CREATE, "create file in vp 0x%lx name %s mode 0x%x"
 	ec	CM_TRACE_REMOVE, "remove dir 0x%lx name %s"
-	ec	CM_TRACE_LINK, "hard link dir 0x%lx vp %lx name %s"
+	ec	CM_TRACE_LINK, "hard link dir 0x%lx vp 0x%lx name %s"
 	ec	CM_TRACE_RENAME, "Rename d1 0x%lx name %s to d2 0x%lx name %s"
 	ec	CM_TRACE_MKDIR, "Mkdir parent 0x%lx entry %s"
 	ec	CM_TRACE_RMDIR, "Rmdir parent 0x%lx entry %s"
@@ -102,7 +102,7 @@
 	ec      CM_TRACE_LOCKDONE,  "%s line %d: Released lock 0x%lx level %d"
 	ec	CM_TRACE_LOCKDOWN,  "%s line %d: Downgraded lock 0x%lx to %d"
 	ec	CM_TRACE_LOCKOBTAIN,"%s line %d: Obtained lock 0x%lx level %d"
-	ec	CM_TRACE_LOCKSLEPT, "%s line %d: Slept for lock 0x%lx level %d"
+	ec	CM_TRACE_LOCKSLEPT, "Slept %lu us for lock 0x%lx level %d"
 
 	ec	CM_TRACE_PAGE_READ, "0x%lx called page_read (returned %d) states 0x%x"
 	ec	CM_TRACE_PAGE_WRITE, "0x%lx called page_write (returned %d) states 0x%x"
@@ -128,23 +128,23 @@
 	ec	CM_TRACE_UPDATEPAGE, "Iupdatepage ip 0x%lx pp 0x%x count 0x%x code %d"
 	ec	CM_TRACE_VM_CLOSE, "VMclose ip 0x%lx mapcnt %d opens %d XoW %d"
 	ec	CM_TRACE_FETCH64, "FetchProc for vp = 0x%lx oldserver was %d, found length (0x%x, 0x%x)"
-	ec	CM_TRACE_UFSLINK, "UFSHandleLink: vp = 0x%lx, tdc 0 0x%lx,  len (0x%x, 0x%x)"
+	ec	CM_TRACE_UFSLINK, "UFSHandleLink: vp = 0x%lx, tdc 0x%lx, len (0x%x, 0x%x)"
 	ec	CM_TRACE_VMRDWR, "afs_vm_rdwr: vp = 0x%lx, xfrSize 0x%lx,  toffset 0x%x"
 	ec	CM_TRACE_READFAST, "ReadFast vp 0x%lx off (0x%x, 0x%x) resid 0x%x file length (0x%x, 0x%x)"
-	ec	CM_TRACE_FETCH64CODE, "StartRX_FetchData64 for vp 0x%x returned %d"
-	ec	CM_TRACE_FETCH64LENG, "FetchData64 for vp 0x%x code = %d, length = (0x%x, 0x%x)"
-	ec	CM_TRACE_FETCH64READ, "FetchData64 for vp 0x%x code = %d, length = 0x%x"
-	ec	CM_TRACE_VMWRITE, "afs_vm_rdwr: vp 0x%x offset (0x%x, 0x%x) length (0x%x, 0x%x)"
-	ec	CM_TRACE_VMWRITE2, "afs_vm_rdwr: vp 0x%x first page 0x%x pages %d"
-	ec	CM_TRACE_VMSTOREALL, "osi_VM_StoreAllSegments for vp 0x%x call %d"
+	ec	CM_TRACE_FETCH64CODE, "StartRX_FetchData64 for vp 0x%lx returned %d"
+	ec	CM_TRACE_FETCH64LENG, "FetchData64 for vp 0xl%x code = %d, length = (0x%x, 0x%x)"
+	ec	CM_TRACE_FETCH64READ, "FetchData64 for vp 0xl%x code = %d, length = 0x%x"
+	ec	CM_TRACE_VMWRITE, "afs_vm_rdwr: vp 0x%lx offset (0x%x, 0x%x) length (0x%x, 0x%x)"
+	ec	CM_TRACE_VMWRITE2, "afs_vm_rdwr: vp 0x%lx first page 0x%x pages %d"
+	ec	CM_TRACE_VMSTOREALL, "osi_VM_StoreAllSegments for vp 0x%lx call %d"
 	ec	CM_TRACE_PARTIALWRITE0, "Partial write currDirty %d maxDirty %d"
-	ec	CM_TRACE_DIRECTRDWR, "direct_rdwr: vp 0x%x offset (0x%x, 0x%x) resid 0x%x"
+	ec	CM_TRACE_DIRECTRDWR, "direct_rdwr: vp 0x%lx offset (0x%x, 0x%x) resid 0x%x"
 	ec	CM_TRACE_GOPRDWR, "gop_rdwr: offset (0x%x, 0x%x) len 0x%x resid 0x%x code %d"
 	ec	CM_TRACE_GRDWR1, "Gn_rdwr error vp 0x%lx returns %d"
-	ec	CM_TRACE_READTDC, "UFSRead: vp 0x%lx  tdc 0x%x at %d refcount 0x%x"
-	ec	CM_TRACE_MEMFETCH, "MemFetch: vp 0x%x  mceP 0x%x offset (0x%x, 0x%x) length 0x%x"
-	ec	CM_TRACE_VMWRITE3, "afs_vm_rdwr: vp 0x%x code %d"
-	ec	CM_TRACE_STOREALL2, "StoreAll 2 vp 0x%x chunk 0x%x index %d inode %d"
+	ec	CM_TRACE_READTDC, "UFSRead: vp 0x%lx  tdc 0x%lx at %d refcount 0x%x"
+	ec	CM_TRACE_MEMFETCH, "MemFetch: vp 0x%lx  mceP 0x%lx offset (0x%x, 0x%x) length 0x%x"
+	ec	CM_TRACE_VMWRITE3, "afs_vm_rdwr: vp 0x%lx code %d"
+	ec	CM_TRACE_STOREALL2, "StoreAll 2 vp 0x%lx chunk 0x%x index %d inode %d"
 	ec	CM_TRACE_MEMOPEN, "MemOpen blkno %d mceP 0x%x data 0x%x = %s"
 	ec	CM_TRACE_VCACHE2INODE, "vcache2inode: avc 0x%x event %d"
 	ec	CM_TRACE_STOREDATA64, "StoreData64: fid (%d:%d.%d.%d) offs (0x%x, 0x%x) len (0x%x, 0x%x) file length (0x%x, 0x%x)"
@@ -154,9 +154,9 @@
 	ec	CM_TRACE_ADJUSTSIZE, "AdjustSize index %d oldSize %d newSize %d blocksUsed %d"
 	ec	CM_TRACE_SETLENGTH, "%s line %d: m.Length was (0x%x, 0x%x), now (0x%x, 0x%x)"
 	ec	CM_TRACE_DCACHEWAIT, "%s line %d: waiting for 0x%x flags 0x%x" 
-	ec	CM_TRACE_VNODEREAD, "UFSRead: tdc 0x%x, offset (0x%x, 0x%x) len (0x%x 0x%x)" 
-	ec	CM_TRACE_SLEEP, "Sleep: evp 0x%x, count %d seq 0x%x evp->seq 0x%x" 
-	ec	CM_TRACE_WAKE, "Wakeup: evp 0x%x, evp->seq 0x%x"
+	ec	CM_TRACE_VNODEREAD, "UFSRead: tdc 0x%lx, offset (0x%x, 0x%x) len (0x%x 0x%x)" 
+	ec	CM_TRACE_SLEEP, "Sleep: evp 0x%lx, count %d seq 0x%x evp->seq 0x%x" 
+	ec	CM_TRACE_WAKE, "Wakeup: evp 0x%lx, evp->seq 0x%x"
 	ec	CM_TRACE_DENTRYDELETE, "d_delete inode 0x%x d_name %s/%s"
 	ec	CM_TRACE_DENTRYIPUT, "d_iput inode 0x%x d_name %s/%s"
 	ec	CM_TRACE_TRYFLUSHDCACHECHILDREN, "TryFlushDcacheChildren ip 0x%x name %s parent %s"
@@ -168,5 +168,10 @@
 	ec      CM_TRACE_GNGETACL, "Gn_getacl vp 0x%lx (returns 0x%x)"
 	ec      CM_TRACE_EINVAL, "EINVAL in %s at line %d"
 	ec      CM_TRACE_VNODEREAD2, "negative length tdc 0x%lx validPos (0x%x, 0x%x) chunkBytes 0x%x dflags 0x%x"
+	ec	CM_TRACE_WASHERE, "Was here: %s line %d, code = %d"
+	ec	CM_TRACE_LOCKWAIT,"%s line %d: Waiting for lock 0x%lx level %d"
+	ec	CM_TRACE_WRITEFAILED, "osi_Write failed len %ld resid %ld err %ld"
+	ec	CM_TRACE_ADJUSTSIZE2, "AdjustSize dc = 0x%lx, chunkBytes = 0x%x
+ used = %ld, diff = %ld"
 end
 
Index: src/afs/afs_vcache.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_vcache.c,v
retrieving revision 1.48
diff -u -b -r1.48 afs_vcache.c
--- src/afs/afs_vcache.c	30 Jan 2003 21:43:54 -0000	1.48
+++ src/afs/afs_vcache.c	11 Jun 2003 08:35:57 -0000
@@ -1881,7 +1881,7 @@
     if (!tvc) {
         /* no cache entry, better grab one */
 	UpgradeSToWLock(&afs_xvcache,22);
-        tvc = afs_NewVCache(&nfid, NULL);
+        tvc = afs_NewVCache(&nfid, serverp);
 	newvcache = 1;
         ConvertWToSLock(&afs_xvcache);
     }
Index: src/afs/AIX/osi_config.c
===================================================================
RCS file: /cvs/openafs/src/afs/AIX/osi_config.c,v
retrieving revision 1.6
diff -u -b -r1.6 osi_config.c
--- src/afs/AIX/osi_config.c	16 Oct 2002 03:58:16 -0000	1.6
+++ src/afs/AIX/osi_config.c	11 Jun 2003 08:35:57 -0000
@@ -75,6 +75,12 @@
 extern struct gfs afs_gfs;
 extern struct vnodeops locked_afs_gn_vnodeops;
 
+#ifdef __64BIT__
+afs_uint64 get_toc();
+#else
+afs_uint32 get_toc();
+#endif
+
 #define	AFS_CALLOUT_TBL_SIZE	256
 
 #include <sys/lock_alloc.h>
@@ -272,7 +278,11 @@
 kluge_init() {
 	register struct k_func *kf;
 	register struct k_var  *kv;
+#ifdef __64BIT__
+        register afs_uint64  toc;
+#else
 	register afs_uint32  toc;
+#endif
 	register err = 0;
 
 	toc = get_toc();
@@ -334,10 +344,19 @@
 iget(dev, ino, ipp, doscan, vfsp)
 dev_t dev;
 ino_t ino;
+#ifdef __64BIT__
+afs_size_t doscan;
+#endif
 struct vfs *vfsp;
 struct inode **ipp; {
+#ifdef __64BIT__
+    afs_int64 dummy[10];
+    dummy[0] = doscan;
 
+    return (*kluge_iget)(dev, ino, ipp, (afs_size_t) doscan, vfsp, &dummy);
+#else
     return (*kluge_iget)(dev, ino, ipp, doscan, vfsp);
+#endif
 }
 
 iput(ip, vfsp)
Index: src/afs/AIX/osi_file.c
===================================================================
RCS file: /cvs/openafs/src/afs/AIX/osi_file.c,v
retrieving revision 1.7
diff -u -b -r1.7 osi_file.c
--- src/afs/AIX/osi_file.c	16 Oct 2002 03:58:16 -0000	1.7
+++ src/afs/AIX/osi_file.c	11 Jun 2003 08:35:57 -0000
@@ -166,8 +166,13 @@
 retry_IO:
     /* Note the difference in the way the afile->offset is passed (see comments in gop_rdwr() in afs_aix_subr.c for comments) */
     AFS_GUNLOCK();
+#ifdef AFS_64BIT_KERNEL
+    code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize,
+                   &afile->offset, AFS_UIOSYS, NULL, &resid);
+#else
     code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize,
 		    (off_t)&afile->offset, AFS_UIOSYS, NULL, &resid);
+#endif
     AFS_GLOCK();
     if (code == 0) {
 	code = asize - resid;
@@ -203,14 +208,28 @@
     if (offset != -1) afile->offset = offset;
     /* Note the difference in the way the afile->offset is passed (see comments in gop_rdwr() in afs_aix_subr.c for comments) */
     AFS_GUNLOCK();
+#ifdef AFS_64BIT_KERNEL
+    code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize,
+                   &afile->offset, AFS_UIOSYS, NULL, &resid);
+#else
     code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize,
 		    (off_t)&afile->offset, AFS_UIOSYS, NULL, &resid);
+#endif
     AFS_GLOCK();
     if (code == 0) {
+       if (resid)
+           afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED,
+                       ICL_TYPE_INT32, asize,
+                       ICL_TYPE_INT32, resid,
+                       ICL_TYPE_INT32, code);
 	code = asize - resid;
 	afile->offset += code;
     }
     else {
+        afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED,
+                       ICL_TYPE_INT32, asize,
+                       ICL_TYPE_INT32, resid,
+                       ICL_TYPE_INT32, code);
 	if (code == ENOSPC) afs_warnuser("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
 	setuerror(code);
 	code = -1;
Index: src/afs/AIX/osi_groups.c
===================================================================
RCS file: /cvs/openafs/src/afs/AIX/osi_groups.c,v
retrieving revision 1.6
diff -u -b -r1.6 osi_groups.c
--- src/afs/AIX/osi_groups.c	16 Oct 2002 03:58:16 -0000	1.6
+++ src/afs/AIX/osi_groups.c	11 Jun 2003 08:35:57 -0000
@@ -36,7 +36,7 @@
     gid_t *gidset,
     int change_parent);
 
-#ifndef AFS_AIX5_ENV
+#ifndef AFS_AIX51_ENV
 int
 setgroups(ngroups, gidset)
     int ngroups;
Index: src/afs/AIX/osi_inode.c
===================================================================
RCS file: /cvs/openafs/src/afs/AIX/osi_inode.c,v
retrieving revision 1.6
diff -u -b -r1.6 osi_inode.c
--- src/afs/AIX/osi_inode.c	16 Oct 2002 03:58:16 -0000	1.6
+++ src/afs/AIX/osi_inode.c	11 Jun 2003 08:35:58 -0000
@@ -156,6 +156,7 @@
 /* get an existing inode.  Common code for iopen, iread/write, iinc/dec. */
 /* Also used by rmt_remote to support passing of inode number from venus */
 extern int iget();
+extern struct vnode *filevp;
 struct inode *
 igetinode(dev, vfsp, inode, vpp,perror)
         struct vfs *vfsp;
@@ -178,7 +179,11 @@
 	 * If it isn't, then we need to reexamine our code to make
 	 * sure that it is still okay.
 	 */
+#ifdef __64BIT__
+/*      osi_Assert(offsetof(struct inode, afs_inode_lock) == 208); */
+#else
 	osi_Assert(offsetof(struct inode, afs_inode_lock) == 128);
+#endif
 
 	if (!vfsp && !(vfsp = devtovfs((dev_t)dev))) {
 	    afs_warn("Dev=%d not mounted!!; quitting\n", dev);
@@ -201,7 +206,11 @@
 	}
 
 	ICACHE_LOCK(); 
+#ifdef __64BIT__
+        if ((code = iget(dev, inode, &ip, (afs_size_t) 1, nvfsp))) {
+#else
 	if ((code = iget(dev, inode, &ip, 1, nvfsp))) {
+#endif
 	    IGI_error = code;
 	    IGI_inode = inode;
 	    *perror = BAD_IGET;
Index: src/afs/AIX/osi_misc.c
===================================================================
RCS file: /cvs/openafs/src/afs/AIX/osi_misc.c,v
retrieving revision 1.5
diff -u -b -r1.5 osi_misc.c
--- src/afs/AIX/osi_misc.c	16 Oct 2002 03:58:16 -0000	1.5
+++ src/afs/AIX/osi_misc.c	11 Jun 2003 08:35:58 -0000
@@ -85,7 +85,11 @@
 enum uio_rw	rw;
 struct vnode	*vp;
 caddr_t		base;
+#ifdef AFS_64BIT_KERNEL
+offset_t        *offset;
+#else
 off_t		*offset;
+#endif
 int		len, segflg;
 int		*aresid;
 int		unit;	    /* Ignored */
@@ -106,8 +110,14 @@
     uio_struct.uio_resid = len;
     uio_struct.uio_fmode = (rw == UIO_READ ? FREAD : FWRITE);
 
+#ifdef AFS_64BIT_KERNEL
+    code = VNOP_RDWR(vp, rw,
+               (int32long64_t)(rw == UIO_READ ? FREAD : FWRITE), &uio_struct,
+               (ext_t) 0, (caddr_t) 0, (struct vattr *)0, &afs_osi_cred);
+#else
     code = VNOP_RDWR(vp, rw, (rw == UIO_READ ? FREAD : FWRITE), &uio_struct,
 		     NULL, NULL, NULL, &afs_osi_cred);
+#endif
     *aresid = uio_struct.uio_resid;
     return code;
 }
Index: src/afs/AIX/osi_sleep.c
===================================================================
RCS file: /cvs/openafs/src/afs/AIX/osi_sleep.c,v
retrieving revision 1.8
diff -u -b -r1.8 osi_sleep.c
--- src/afs/AIX/osi_sleep.c	16 Oct 2002 03:58:16 -0000	1.8
+++ src/afs/AIX/osi_sleep.c	11 Jun 2003 08:35:58 -0000
@@ -85,7 +85,7 @@
     int seq;			/* Sequence number: this is incremented
 				   by wakeup calls; wait will not return until
 				   it changes */
-    int cond;
+    tid_t cond;
 } afs_event_t;
 
 #define HASHSIZE 128
Index: src/afs/AIX/osi_vm.c
===================================================================
RCS file: /cvs/openafs/src/afs/AIX/osi_vm.c,v
retrieving revision 1.7
diff -u -b -r1.7 osi_vm.c
--- src/afs/AIX/osi_vm.c	16 Oct 2002 03:58:17 -0000	1.7
+++ src/afs/AIX/osi_vm.c	11 Jun 2003 08:35:58 -0000
@@ -68,7 +68,7 @@
  */
 void osi_VM_StoreAllSegments(struct vcache *avc)
 {
-    if (avc->vmh) {
+    if (avc->segid) {
 	/*
 	 * The execsOrWriters test is done so that we don't thrash on
 	 * the vm_writep call below. We only initiate a pageout of the
@@ -82,8 +82,8 @@
          */
 	ReleaseWriteLock(&avc->lock);		/* XXX */
 	AFS_GUNLOCK();
-	vm_writep(avc->vmh, 0, MAXFSIZE/PAGESIZE -1 );
-	vms_iowait(avc->vmh);
+	vm_writep(avc->segid, 0, MAXFSIZE/PAGESIZE -1 );
+	vms_iowait(avc->segid);
 	AFS_GLOCK();
 	ObtainWriteLock(&avc->lock,93);		/* XXX */
 	/*
@@ -125,7 +125,7 @@
 	ReleaseWriteLock(&avc->lock);
 	AFS_GUNLOCK();
 	vm_flushp(avc->segid, 0, MAXFSIZE/PAGESIZE - 1);
-	vms_iowait(avc->vmh);		/* XXX Wait?? XXX */
+	vms_iowait(avc->segid);		/* XXX Wait?? XXX */
 	AFS_GLOCK();
 	ObtainWriteLock(&avc->lock,60);
     }
@@ -142,7 +142,7 @@
         /*
          * XXX We probably don't need to wait but better be safe XXX
          */
-        vms_iowait(avc->vmh);
+        vms_iowait(avc->segid);
     }
 }
 
@@ -157,6 +157,6 @@
     if (avc->segid) {
         int firstpage = (alen + PAGESIZE-1)/PAGESIZE;
         vm_releasep(avc->segid, firstpage, MAXFSIZE/PAGESIZE - firstpage);
-        vms_iowait(avc->vmh);	/* Do we need this? */
+        vms_iowait(avc->segid);	/* Do we need this? */
     }
 }
Index: src/afs/AIX/osi_vnodeops.c
===================================================================
RCS file: /cvs/openafs/src/afs/AIX/osi_vnodeops.c,v
retrieving revision 1.12
diff -u -b -r1.12 osi_vnodeops.c
--- src/afs/AIX/osi_vnodeops.c	16 Oct 2002 03:58:17 -0000	1.12
+++ src/afs/AIX/osi_vnodeops.c	11 Jun 2003 08:35:58 -0000
@@ -187,7 +187,7 @@
 
     AFS_STATCNT(afs_gn_link);
     error = afs_link(vp, dp, name, cred);
-    afs_Trace3(afs_iclSetp, CM_TRACE_GNLINK, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace3(afs_iclSetp, CM_TRACE_GNLINK, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_STRING, name, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -217,7 +217,7 @@
     if (! error) {
 	AFS_RELE(vp);
     }
-    afs_Trace4(afs_iclSetp, CM_TRACE_GMKDIR, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace4(afs_iclSetp, CM_TRACE_GMKDIR, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -282,7 +282,7 @@
 
    AFS_STATCNT(afs_gn_remove);
    error = afs_remove(dp, name, cred);
-   afs_Trace3(afs_iclSetp, CM_TRACE_GREMOVE, ICL_TYPE_POINTER, (afs_int32)dp,
+   afs_Trace3(afs_iclSetp, CM_TRACE_GREMOVE, ICL_TYPE_POINTER, dp,
 	      ICL_TYPE_STRING, name, ICL_TYPE_LONG, error);
    return(error);
 }
@@ -302,7 +302,7 @@
 
    AFS_STATCNT(afs_gn_rename);
     error = afs_rename(dp, name, tdp, tname, cred);
-    afs_Trace4(afs_iclSetp, CM_TRACE_GRENAME, ICL_TYPE_POINTER, (afs_int32)dp,
+    afs_Trace4(afs_iclSetp, CM_TRACE_GRENAME, ICL_TYPE_POINTER, dp,
 	       ICL_TYPE_STRING, name, ICL_TYPE_STRING, tname, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -323,7 +323,7 @@
 	if (error == 66 /* 4.3's ENOTEMPTY */)
 	    error = EEXIST; 	/* AIX returns EEXIST where 4.3 used ENOTEMPTY */
     }
-    afs_Trace3(afs_iclSetp, CM_TRACE_GRMDIR, ICL_TYPE_POINTER, (afs_int32)dp,
+    afs_Trace3(afs_iclSetp, CM_TRACE_GRMDIR, ICL_TYPE_POINTER, dp,
 	       ICL_TYPE_STRING, name, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -347,7 +347,7 @@
 
    AFS_STATCNT(afs_gn_lookup);
     error = afs_lookup(dp, name, vpp, cred);
-    afs_Trace3(afs_iclSetp, CM_TRACE_GLOOKUP, ICL_TYPE_POINTER, (afs_int32)dp,
+    afs_Trace3(afs_iclSetp, CM_TRACE_GLOOKUP, ICL_TYPE_POINTER, dp,
 	       ICL_TYPE_STRING, name, ICL_TYPE_LONG, error);
    if (vattrp != NULL && error == 0)
        afs_gn_getattr(*vpp, vattrp, cred);
@@ -365,7 +365,7 @@
 
     AFS_STATCNT(afs_gn_fid);
     error =  afs_fid(vp, fidp);
-    afs_Trace3(afs_iclSetp, CM_TRACE_GFID, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace3(afs_iclSetp, CM_TRACE_GFID, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, (afs_int32)fidp, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -434,7 +434,7 @@
     }
 
 abort:
-    afs_Trace3(afs_iclSetp, CM_TRACE_GOPEN, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace3(afs_iclSetp, CM_TRACE_GOPEN, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, flags, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -495,7 +495,7 @@
 	*vinfop	= cred; /* save user creds in fp->f_vinfo */
 	error = afs_open(vpp, flags, cred);
     }
-    afs_Trace4(afs_iclSetp, CM_TRACE_GCREATE, ICL_TYPE_POINTER, (afs_int32)dp,
+    afs_Trace4(afs_iclSetp, CM_TRACE_GCREATE, ICL_TYPE_POINTER, dp,
 	       ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG, error);
     return error;
 }
@@ -593,7 +593,7 @@
     /*
      * We map the segment into our address space using the handle returned by vm_create.
      */
-    if (!vcp->vmh) {
+    if (!vcp->segid) {
         afs_uint32 tlen = vcp->m.Length;
 #ifdef AFS_64BIT_CLIENT
         if (vcp->m.Length > afs_vmMappingEnd)
@@ -604,7 +604,11 @@
 	    ReleaseWriteLock(&vcp->lock);
 	    return(EOPNOTSUPP);
 	}
+#ifdef AFS_64BIT_KERNEL
+        vcp->vmh = vm_handle(vcp->segid, (int32long64_t) 0);
+#else
 	vcp->vmh = SRVAL(vcp->segid, 0, 0);
+#endif
     }
     vcp->v.v_gnode->gn_seg = vcp->segid; 	/* XXX Important XXX */
     if (flag & SHM_RDONLY) {
@@ -628,7 +632,7 @@
     }
     ReleaseWriteLock(&vcp->lock);
     VN_HOLD(vp);
-    afs_Trace4(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace4(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, addr, ICL_TYPE_LONG, len, ICL_TYPE_LONG, off);
     return(0);
 }
@@ -715,7 +719,7 @@
   
     }
 out:
-    afs_Trace3(afs_iclSetp, CM_TRACE_GACCESS, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace3(afs_iclSetp, CM_TRACE_GACCESS, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, mode, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -731,34 +735,30 @@
 
    AFS_STATCNT(afs_gn_getattr);
     error = afs_getattr(vp, vattrp, cred);
-    afs_Trace2(afs_iclSetp, CM_TRACE_GGETATTR, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace2(afs_iclSetp, CM_TRACE_GGETATTR, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, error);
     return(error);
 }
 
 
 int
-afs_gn_setattr(vp, Op, Arg1, Arg2, Arg3, cred)
+afs_gn_setattr(vp, op, arg1, arg2, arg3, cred)
 struct	vnode	*vp;
 #ifdef AFS_AIX51_ENV
-int32long64_t	Op;
-int32long64_t	Arg1;
-int32long64_t	Arg2;
-int32long64_t	Arg3;
-#else
-int		Op;
-int		Arg1;
-int		Arg2;
-int		Arg3;
+int32long64_t	op;
+int32long64_t	arg1;
+int32long64_t	arg2;
+int32long64_t	arg3;
+#else
+int		op;
+int		arg1;
+int		arg2;
+int		arg3;
 #endif
 struct ucred	*cred;
 {
     struct	vattr	va;
     int		error = 0;
-    int		op = Op;
-    int		arg1 = Arg1;
-    int		arg2 = Arg2;
-    int		arg3 = Arg3;
 
    AFS_STATCNT(afs_gn_setattr);
     VATTR_NULL(&va);
@@ -794,7 +794,7 @@
 
     error = afs_setattr(vp, &va, cred);
 out:
-    afs_Trace2(afs_iclSetp, CM_TRACE_GSETATTR, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace2(afs_iclSetp, CM_TRACE_GSETATTR, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, error);
     return(error);
 }
@@ -835,7 +835,7 @@
     if (avc->segid) {
 	AFS_GUNLOCK();
 	vm_flushp(avc->segid, 0, MAXFSIZE/PAGESIZE - 1);
-	vms_iowait(avc->vmh);	
+	vms_iowait(avc->segid);	
 	AFS_GLOCK();
     }	
     uio.afsio_offset = offset;
@@ -850,7 +850,7 @@
 	if (error = afs_rdwr(vp, &uio, UIO_WRITE, 0, cred))
 	    break;
     }
-    afs_Trace4(afs_iclSetp, CM_TRACE_GFCLEAR, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace4(afs_iclSetp, CM_TRACE_GFCLEAR, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, offset, ICL_TYPE_LONG, length, ICL_TYPE_LONG, error);
     return (error);
 }
@@ -872,7 +872,7 @@
 
    AFS_STATCNT(afs_gn_fsync);
     error = afs_fsync(vp, cred);
-    afs_Trace3(afs_iclSetp, CM_TRACE_GFSYNC, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace3(afs_iclSetp, CM_TRACE_GFSYNC, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, flags, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -897,7 +897,7 @@
     VATTR_NULL(&va);
     va.va_size = length;
     error = afs_setattr(vp, &va, cred);
-    afs_Trace4(afs_iclSetp, CM_TRACE_GFTRUNC, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace4(afs_iclSetp, CM_TRACE_GFTRUNC, ICL_TYPE_POINTER, vp,
 	       	ICL_TYPE_LONG, flags, 
 		ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(length), 
 		ICL_TYPE_LONG, error);
@@ -933,7 +933,7 @@
     if (vcp->vc_error) {
 	if (op == UIO_WRITE) {
             afs_Trace2(afs_iclSetp, CM_TRACE_GRDWR1, 
-	    ICL_TYPE_POINTER, (afs_int32)vp,
+	    ICL_TYPE_POINTER, vp,
 	    ICL_TYPE_LONG, vcp->vc_error);
 	    return vcp->vc_error;
 	} else
@@ -1026,7 +1026,7 @@
     if (vattrp != NULL && error == 0)
 	afs_gn_getattr(vp, vattrp, cred);
 
-    afs_Trace4(afs_iclSetp, CM_TRACE_GRDWR, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace4(afs_iclSetp, CM_TRACE_GRDWR, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, flags, ICL_TYPE_LONG, op, ICL_TYPE_LONG, error);
 
     if (free_cred)
@@ -1046,10 +1046,10 @@
     register int i;
     afs_int32 blockSize;
     afs_size_t fileSize, xfrOffset, offset, old_offset, xfrSize;
-    afs_int32 txfrSize;
+    vmsize_t txfrSize;
 #ifdef AFS_64BIT_CLIENT
     afs_size_t finalOffset;
-    afs_int32 toffset;
+    off_t toffset;
     int mixed = 0;
 #endif /* AFS_64BIT_CLIENT */
     register struct vcache *vcp = VTOAFS(vp);
@@ -1123,7 +1123,7 @@
     }
 #endif /* AFS_64BIT_CLIENT */
 
-    if (!vcp->vmh) {
+    if (!vcp->segid) {
         afs_uint32 tlen = vcp->m.Length;
 #ifdef AFS_64BIT_CLIENT
         if (vcp->m.Length > afs_vmMappingEnd)
@@ -1134,7 +1134,11 @@
 			      tlen, 0, 0)) {
 	    goto fail;
 	}
+#ifdef AFS_64BIT_KERNEL
+        vcp->vmh = vm_handle(vcp->segid, (int32long64_t) 0);
+#else
 	vcp->vmh = SRVAL(vcp->segid, 0, 0);	
+#endif
     }
     vcp->v.v_gnode->gn_seg = vcp->segid;
     if (rw == UIO_READ) {
@@ -1197,7 +1201,7 @@
     if (vcp->m.Length > afs_vmMappingEnd)
         last_page = afs_vmMappingEnd/PAGESIZE;
 #endif
-    vm_protectp(vcp->vmh, last_page, 1, FILEKEY);
+    vm_protectp(vcp->segid, last_page, 1, FILEKEY);
     if (xfrSize + xfrOffset > fileSize) {
 	vcp->m.Length = xfrSize+xfrOffset;
     }	    
@@ -1287,7 +1291,7 @@
 	first_page = (afs_size_t)old_offset >> PGSHIFT;
 	pages = 1 + (((afs_size_t)old_offset + (len - 1)) >> PGSHIFT) - first_page;
         afs_Trace3(afs_iclSetp, CM_TRACE_VMWRITE2, 
-		ICL_TYPE_POINTER, (afs_int32) vcp,
+		ICL_TYPE_POINTER, vcp,
 		ICL_TYPE_INT32, first_page,
 		ICL_TYPE_INT32, pages);
 	AFS_GUNLOCK();
@@ -1310,7 +1314,7 @@
     if (code == 0 && (vcp->states & CDirty)) {
 	code = afs_DoPartialWrite(vcp, &treq);
     }
-    vm_protectp(vcp->vmh, last_page, 1, RDONLY);
+    vm_protectp(vcp->segid, last_page, 1, RDONLY);
     ReleaseWriteLock(&vcp->lock);
     
     /* If requested, fsync the file after every write */
@@ -1393,7 +1397,7 @@
         ReleaseWriteLock(&vcp->lock);
     }	    
     afs_Trace3(afs_iclSetp, CM_TRACE_DIRECTRDWR, 
-			ICL_TYPE_POINTER, (afs_int32)vp,
+			ICL_TYPE_POINTER, vp,
 			ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(uiop->afsio_offset),
 	       		ICL_TYPE_LONG, uiop->afsio_resid);
     code = afs_rdwr(vp, uiop, rw, ioflag, credp);
@@ -1495,7 +1499,7 @@
    lckdat->l_len    = flkd.l_len;
    lckdat->l_pid    = flkd.l_pid;
    lckdat->l_sysid  = flkd.l_sysid;
-    afs_Trace3(afs_iclSetp, CM_TRACE_GLOCKCTL, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace3(afs_iclSetp, CM_TRACE_GLOCKCTL, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, ncmd, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -1520,7 +1524,7 @@
     AFS_STATCNT(afs_gn_ioctl);
     /* This seems to be a perfect fit for our ioctl redirection (afs_xioctl hack); thus the ioctl(2) entry in sysent.c is unaffected in the aix/afs port. */ 
     error = afs_ioctl(vp, cmd, arg);
-    afs_Trace3(afs_iclSetp, CM_TRACE_GIOCTL, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace3(afs_iclSetp, CM_TRACE_GIOCTL, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, cmd, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -1536,7 +1540,7 @@
 
    AFS_STATCNT(afs_gn_readlink);
     error = afs_readlink(vp, uiop, cred);
-    afs_Trace2(afs_iclSetp, CM_TRACE_GREADLINK, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace2(afs_iclSetp, CM_TRACE_GREADLINK, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, error);
     return(error);
 }
@@ -1569,7 +1573,7 @@
     VATTR_NULL(&va);
     va.va_mode = 0777;
     error = afs_symlink(vp, link, &va, target, cred);
-    afs_Trace4(afs_iclSetp, CM_TRACE_GSYMLINK, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace4(afs_iclSetp, CM_TRACE_GSYMLINK, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_STRING, link, ICL_TYPE_STRING, target, ICL_TYPE_LONG, error);
     return(error);
 }
@@ -1585,7 +1589,7 @@
 
    AFS_STATCNT(afs_gn_readdir);
     error = afs_readdir(vp, uiop, cred);
-    afs_Trace2(afs_iclSetp, CM_TRACE_GREADDIR, ICL_TYPE_POINTER, (afs_int32)vp,
+    afs_Trace2(afs_iclSetp, CM_TRACE_GREADDIR, ICL_TYPE_POINTER, vp,
 	       ICL_TYPE_LONG, error);
     return(error);
 }
@@ -1615,7 +1619,11 @@
 register struct buf *abp; 
 {
     register struct buf **lbp, *tbp;
+#ifdef AFS_64BIT_KERNEL
+    afs_int64 *lwbp;    /* last quy in work chain */
+#else
     int *lwbp;		/* last guy in work chain */
+#endif
     struct buf *nbp, *qbp, *qnbp, *firstComparable;
     int doMerge;
     int oldPriority;
@@ -1725,7 +1733,11 @@
 
 		    /* merge both of these blocks together */
 		    /* first set age to the older of the two */
+#ifdef AFS_64BIT_KERNEL
+		    if ((afs_int64) qnbp->av_back - (afs_int64) qbp->av_back < 0)
+#else
 		    if ((int) qnbp->av_back - (int) qbp->av_back < 0)
+#endif
 			qbp->av_back = qnbp->av_back;
 		    lwbp = &qbp->b_work;
 		    /* find end of qbp's work queue */
@@ -1737,7 +1749,11 @@
 		     */
 		    qbp->av_forw = qnbp->av_forw; /* splice out qnbp */
 		    qbp->b_bcount += qnbp->b_bcount; /* fix count */
+#ifdef AFS_64BIT_KERNEL
+		    *lwbp = (afs_int64) qnbp; /* append qnbp to end */
+#else
 		    *lwbp = (int) qnbp; /* append qnbp to end */
+#endif
 		    /*
 		     * note that qnbp is bogus, but it doesn't matter because
 		     * we're going to restart the for loop now.
Index: src/afs/UKERNEL/sysincludes.h
===================================================================
RCS file: /cvs/openafs/src/afs/UKERNEL/sysincludes.h,v
retrieving revision 1.12
diff -u -b -r1.12 sysincludes.h
--- src/afs/UKERNEL/sysincludes.h	14 May 2003 15:15:03 -0000	1.12
+++ src/afs/UKERNEL/sysincludes.h	11 Jun 2003 08:35:58 -0000
@@ -973,6 +973,9 @@
 #define uprintf			printf
 
 #define usr_getpid()		(int)(usr_thread_self())
+#ifdef ISAFS_GLOCK
+#undef ISAFS_GLOCK
+#endif
 #define ISAFS_GLOCK() (usr_thread_self() == afs_global_owner)
 
 #endif /* NETSCAPE_NSAPI */
Index: src/afs/VNOPS/afs_vnop_attrs.c
===================================================================
RCS file: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v
retrieving revision 1.23
diff -u -b -r1.23 afs_vnop_attrs.c
--- src/afs/VNOPS/afs_vnop_attrs.c	14 May 2003 15:47:24 -0000	1.23
+++ src/afs/VNOPS/afs_vnop_attrs.c	11 Jun 2003 08:35:58 -0000
@@ -450,7 +450,9 @@
     OSI_VC_CONVERT(avc)
 
     AFS_STATCNT(afs_setattr);
-    afs_Trace2(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc, 
+    afs_Trace4(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc, 
+		ICL_TYPE_INT32, attrs->va_mask,
+		ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(attrs->va_size),
 	       ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
     if ((code = afs_InitReq(&treq, acred))) return code;
  
Index: src/afs/VNOPS/afs_vnop_read.c
===================================================================
RCS file: /cvs/openafs/src/afs/VNOPS/afs_vnop_read.c,v
retrieving revision 1.21
diff -u -b -r1.21 afs_vnop_read.c
--- src/afs/VNOPS/afs_vnop_read.c	16 Oct 2002 03:58:24 -0000	1.21
+++ src/afs/VNOPS/afs_vnop_read.c	11 Jun 2003 08:35:58 -0000
@@ -11,7 +11,6 @@
  * Implements:
  * afs_MemRead
  * afs_PrefetchChunk
- * afs_UFSReadFast
  * afs_UFSRead
  * 
  */
@@ -233,17 +232,20 @@
 		error = code;
 		break;
 	    }
-	    /* fetching flag gone, data is here, or we never tried (BBusy for instance) */
+	    /* fetching flag gone, data is here, or we never tried 
+	     * (BBusy for instance) */
 	    if (tdc->dflags & DFFetching) {
-		/* still fetching, some new data is here: compute length and offset */
+		/* still fetching, some new data is here: 
+		 * compute length and offset */
 		offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk);
 		len = tdc->validPos - filePos;
 	    }
 	    else {
-		/* no longer fetching, verify data version (avoid new GetDCache call) */
-		if (hsame(avc->m.DataVersion, tdc->f.versionNo)) {
+		/* no longer fetching, verify data version 
+		 * (avoid new GetDCache call) */
+		if (hsame(avc->m.DataVersion, tdc->f.versionNo) 
+		    && ((len = tdc->validPos - filePos) > 0)) {
 		    offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk);
-		    len = tdc->f.chunkBytes - offset;
 		}
 		else {
 		    /* don't have current data, so get it below */
@@ -258,6 +260,10 @@
 	    }
 
 	    if (!tdc) {
+                /* If we get, it was not possible to start the
+                 * background daemon. With flag == 1 afs_GetDCache
+                 * does the FetchData rpc synchronously.
+                 */
 		ReleaseReadLock(&avc->lock);
 		tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 1);
 		ObtainReadLock(&avc->lock);
@@ -265,6 +271,10 @@
 	    }
 	}
 
+        afs_Trace3(afs_iclSetp, CM_TRACE_VNODEREAD,
+                        ICL_TYPE_POINTER, tdc,
+                        ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(offset),
+                        ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(len));
 	if (!tdc) {
 	    error = EIO;
 	    break;
@@ -418,170 +428,6 @@
     }
 }
 
-
-/* if the vcache is up-to-date, and the request fits entirely into the chunk
- * that the hint here references, then we just use it quickly, otherwise we
- * have to call the slow read.
- *
- * This could be generalized in several ways to take advantage of partial 
- * state even when all the chips don't fall the right way.  For instance,
- * if the hint is good and the first part of the read request can be 
- * satisfied from the chunk, then just do the read.  After the read has
- * completed, check to see if there's more. (Chances are there won't be.)
- * If there is more, then just call afs_UFSReadSlow and let it do the rest.
- *
- * For the time being, I'm ignoring quick.f, but it should be used at
- * some future date.
- * do this in the future avc->quick.f = tfile; but I think it
- * has to be done under a write lock, but don't want to wait on the
- * write lock
- */
-    /* everywhere that a dcache can be freed (look for NULLIDX) 
-     * probably does it under a write lock on xdcache.  Need to invalidate
-     * stamp there, too.  
-     * Also need to worry about DFFetching, and IFFree, I think. */
-static struct dcache *savedc = 0;
-
-int afs_UFSReadFast(register struct vcache *avc, struct uio *auio, 
-	struct AFS_UCRED *acred, daddr_t albn, struct buf **abpp, int noLock)
-{
-    struct vrequest treq;
-    int offDiff;
-    struct dcache *tdc;
-    struct osi_file *tfile;
-    afs_int32 code = 0;
-
-    if (!noLock)
-	ObtainReadLock(&avc->lock);  
-    ObtainReadLock(&afs_xdcache);
-
-    if ((avc->states & CStatd)                                /* up to date */
-	&& (tdc = avc->quick.dc) && (tdc->index != NULLIDX) 
-	&& !(afs_indexFlags[tdc->index] & (IFFree | IFDiscarded)))   {
-
-	int readLocked = 0;
-
-	afs_RefDCache(tdc);
-	ReleaseReadLock(&afs_xdcache);
-	if (tdc->stamp == avc->quick.stamp) {
-	    readLocked = 1;
-	    ObtainReadLock(&tdc->lock);
-	}
-
-	if ((tdc->stamp == avc->quick.stamp)                /* hint matches */
-	    && ((offDiff = (afs_size_t)(auio->afsio_offset - avc->quick.minLoc)) >= 0)
-	    && (tdc->f.chunkBytes >= auio->afsio_resid + offDiff)
-	    && !(tdc->dflags & DFFetching)) { /* fits in chunk */
-
-	    auio->afsio_offset -= avc->quick.minLoc;
-
-	    afs_Trace4(afs_iclSetp, CM_TRACE_READFAST, ICL_TYPE_POINTER, avc,
-			ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(auio->afsio_offset),
-			ICL_TYPE_INT32, auio->afsio_resid,
-			ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length));
-
-	    tfile = (struct osi_file *)osi_UFSOpen(tdc->f.inode);
-
-#ifdef	AFS_AIX_ENV
-#ifdef	AFS_AIX41_ENV
-	    AFS_GUNLOCK();
-	    code = VNOP_RDWR(tfile->vnode, UIO_READ, FREAD, auio, NULL, NULL, NULL, &afs_osi_cred);
-	    AFS_GLOCK();
-#else
-#ifdef AFS_AIX32_ENV
-	    code = VNOP_RDWR(tfile->vnode, UIO_READ, FREAD, auio, NULL, NULL);
-#else
-	    code = VNOP_RDWR(tfile->vnode, UIO_READ, FREAD, (off_t)&auio->afsio_offset, auio, NULL, NULL, -1);
-#endif
-#endif
-#else
-#ifdef	AFS_SUN5_ENV
-	    AFS_GUNLOCK();
-	    VOP_RWLOCK(tfile->vnode, 0);
-	    code = VOP_READ(tfile->vnode, auio, 0, &afs_osi_cred);
-	    VOP_RWUNLOCK(tfile->vnode, 0);
-	    AFS_GLOCK();
-#else
-#if defined(AFS_SGI_ENV)
-            AFS_GUNLOCK();
-            AFS_VOP_RWLOCK(tfile->vnode, VRWLOCK_READ);
-            AFS_VOP_READ(tfile->vnode, auio, IO_ISLOCKED, &afs_osi_cred, code);
-            AFS_VOP_RWUNLOCK(tfile->vnode, VRWLOCK_READ);
-            AFS_GLOCK();
-#else
-#ifdef	AFS_OSF_ENV
-	    auio->uio_rw = UIO_READ;
-	    AFS_GUNLOCK();
-	    VOP_READ(tfile->vnode, auio, 0, &afs_osi_cred, code);
-	    AFS_GLOCK();
-#else	/* AFS_OSF_ENV */
-#if defined(AFS_HPUX100_ENV)
-	    AFS_GUNLOCK();
-	    code = VOP_RDWR(tfile->vnode, auio, UIO_READ, 0, &afs_osi_cred);
-            AFS_GLOCK();
-#else
-#if defined(AFS_LINUX20_ENV)
-	    AFS_GUNLOCK();
-	    code = osi_file_uio_rdwr(tfile, auio, UIO_READ);
-	    AFS_GLOCK();
-#else
-#if defined(AFS_DARWIN_ENV)
-            AFS_GUNLOCK();
-            VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc());
-            code = VOP_READ(tfile->vnode, auio, 0, &afs_osi_cred);
-            VOP_UNLOCK(tfile->vnode, 0, current_proc());
-            AFS_GLOCK();
-#else
-#if defined(AFS_XBSD_ENV)
-            AFS_GUNLOCK();
-            VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curproc);
-            code = VOP_READ(tfile->vnode, auio, 0, &afs_osi_cred);
-            VOP_UNLOCK(tfile->vnode, 0, curproc);
-            AFS_GLOCK();
-#else
-	    code = VOP_RDWR(tfile->vnode, auio, UIO_READ, 0, &afs_osi_cred);
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-#endif
-	    auio->afsio_offset += avc->quick.minLoc;
-	    osi_UFSClose(tfile);
-	    /* Fix up LRU info */
-	    hset(afs_indexTimes[tdc->index], afs_indexCounter);
-	    hadd32(afs_indexCounter, 1);
-
-	    if (!noLock) {
-		ReleaseReadLock(&avc->lock);
-#if !defined(AFS_VM_RDWR_ENV)
-		if (!(code = afs_InitReq(&treq, acred))) {
-		    if (!(tdc->mflags & DFNextStarted))
-			afs_PrefetchChunk(avc, tdc, acred, &treq);
-		}
-#endif
-	    }
-	    if (readLocked) ReleaseReadLock(&tdc->lock);
-	    afs_PutDCache(tdc);
-	    return (code);
-	}
-	if (!tdc->f.chunkBytes) {   /* debugging f.chunkBytes == 0 problem */
-	    savedc = tdc;
-	}
-	if (readLocked) ReleaseReadLock(&tdc->lock);
-	afs_PutDCache(tdc);
-    } else {
-	ReleaseReadLock(&afs_xdcache);
-    }
-
-    /* come here if fast path doesn't work for some reason or other */
-    if (!noLock)
-	ReleaseReadLock(&avc->lock);
-    return afs_UFSRead(avc, auio, acred, albn, abpp, noLock);
-}
-
 int afs_UFSRead(register struct vcache *avc, struct uio *auio,
 	struct AFS_UCRED *acred, daddr_t albn, struct buf **abpp, int noLock)
 {
@@ -655,7 +501,7 @@
 	    if (tdc) {
 		ObtainReadLock(&tdc->lock);
 		offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk);
-		len = tdc->f.chunkBytes - offset;
+		len = tdc->validPos - filePos;
 	    }
 	} else {
 	    /* a tricky question: does the presence of the DFFetching flag
@@ -694,9 +540,6 @@
 	    }
 	    tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 2);
 	    ObtainReadLock(&tdc->lock);
-	    if (tdc == savedc) {
-		savedc = 0;
-	    }
 	    /* now, first try to start transfer, if we'll need the data.  If
 	     * data already coming, we don't need to do this, obviously.  Type
 	     * 2 requests never return a null dcache entry, btw. */
@@ -782,9 +625,8 @@
 		/* no longer fetching, verify data version (avoid new
 		 * GetDCache call) */
 		if (hsame(avc->m.DataVersion, tdc->f.versionNo) 
-							&& tdc->f.chunkBytes) {
+		    && ((len = tdc->validPos - filePos) > 0)) {
 		    offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk);
-		    len = tdc->f.chunkBytes - offset;
 		}
 		else {
 		    /* don't have current data, so get it below */
@@ -810,14 +652,15 @@
 	    }
 	}
 	
-	afs_Trace3(afs_iclSetp, CM_TRACE_VNODEREAD,
-			ICL_TYPE_POINTER, tdc,
-			ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(offset),
-			ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(len));
 	if (!tdc) {
 	    error = EIO;
 	    break;
 	}
+	len = tdc->validPos - filePos;
+	afs_Trace3(afs_iclSetp, CM_TRACE_VNODEREAD,
+			ICL_TYPE_POINTER, tdc,
+			ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(offset),
+			ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(len));
 	if (len	> totalLength) len = totalLength;   /* will read len bytes */
 	if (len	<= 0) {	/* shouldn't get here if DFFetching is on */
 	    afs_Trace4(afs_iclSetp, CM_TRACE_VNODEREAD2,
Index: src/afs/VNOPS/afs_vnop_readdir.c
===================================================================
RCS file: /cvs/openafs/src/afs/VNOPS/afs_vnop_readdir.c,v
retrieving revision 1.19
diff -u -b -r1.19 afs_vnop_readdir.c
--- src/afs/VNOPS/afs_vnop_readdir.c	13 Feb 2003 23:44:28 -0000	1.19
+++ src/afs/VNOPS/afs_vnop_readdir.c	11 Jun 2003 08:35:58 -0000
@@ -158,11 +158,12 @@
 #else
 #if defined(AFS_SUN_ENV) || defined(AFS_AIX32_ENV)
     afs_int32	d_off;
+    afs_uint32  d_fileno;
 #endif
 #if     defined(AFS_HPUX100_ENV)
     unsigned long long d_off;
-#endif
     afs_uint32	d_fileno;
+#endif
     u_short	d_reclen;
     u_short	d_namlen;
 #endif
@@ -295,7 +296,7 @@
 #if	defined(AFS_SUN56_ENV)
     struct dirent64 *direntp;
 #else
-#ifdef	AFS_SUN5_ENV
+#if  defined(AFS_SUN5_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
     struct dirent *direntp;
 #endif
 #endif /* AFS_SUN56_ENV */
@@ -367,7 +368,7 @@
     }
 }
 #else /* AFS_SGI53_ENV */
-#ifdef	AFS_SUN5_ENV
+#if  defined(AFS_SUN5_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 #if	defined(AFS_SUN56_ENV)
     direntp = (struct dirent64 *) osi_AllocLargeSpace(AFS_LRALLOCSIZ);
 #else
@@ -375,7 +376,12 @@
 #endif
     direntp->d_ino =  (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode);
     FIXUPSTUPIDINODE(direntp->d_ino);
+#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
+    direntp->d_offset = off;
+    direntp->d_namlen = slen;
+#else
     direntp->d_off = off;
+#endif
     direntp->d_reclen = rlen;
     strcpy(direntp->d_name, de->name);
     AFS_UIOMOVE((caddr_t)direntp, rlen, UIO_READ, auio, code);
Index: src/afs/VNOPS/afs_vnop_strategy.c
===================================================================
RCS file: /cvs/openafs/src/afs/VNOPS/afs_vnop_strategy.c,v
retrieving revision 1.15
diff -u -b -r1.15 afs_vnop_strategy.c
--- src/afs/VNOPS/afs_vnop_strategy.c	16 Apr 2003 22:28:54 -0000	1.15
+++ src/afs/VNOPS/afs_vnop_strategy.c	11 Jun 2003 08:35:58 -0000
@@ -122,7 +122,7 @@
 	    if (dbtob(abp->b_blkno) + abp->b_bcount > tvc->m.Length) {
 		if ((abp->b_flags & B_PFSTORE) == 0) {
 		    AFS_GUNLOCK();
-		    vm_protectp(tvc->vmh, dbtob(abp->b_blkno)/PAGESIZE,
+		    vm_protectp(tvc->segid, dbtob(abp->b_blkno)/PAGESIZE,
 				abp->b_bcount/PAGESIZE, RDONLY);
 		    AFS_GLOCK();
 		}
Index: src/afs/VNOPS/afs_vnop_write.c
===================================================================
RCS file: /cvs/openafs/src/afs/VNOPS/afs_vnop_write.c,v
retrieving revision 1.30
diff -u -b -r1.30 afs_vnop_write.c
--- src/afs/VNOPS/afs_vnop_write.c	20 Nov 2002 23:00:34 -0000	1.30
+++ src/afs/VNOPS/afs_vnop_write.c	11 Jun 2003 08:35:58 -0000
@@ -274,6 +274,8 @@
 	if (offset + len > tdc->f.chunkBytes) {
 	    afs_int32 tlength = offset+len;
 	    afs_AdjustSize(tdc, tlength);
+            if (tdc->validPos < filePos + len)
+                tdc->validPos = filePos + len;
 	}
 	totalLength -= len;
 	transferLength += len;
@@ -426,7 +428,7 @@
     tvec = (struct iovec *) osi_AllocSmallSpace(sizeof(struct iovec));
     while (totalLength > 0) {
         /* 
-         *  The following lines are necessary because afs_GetDCache with
+         *  The following line is necessary because afs_GetDCache with
 	 *  flag == 4 expects the length field to be filled. It decides
 	 *  from this whether it's necessary to fetch data into the chunk
 	 *  before writing or not (when the whole chunk is overwritten!).
@@ -595,6 +597,8 @@
 	if (offset + len > tdc->f.chunkBytes) {
 	    afs_int32 tlength = offset+len;
 	    afs_AdjustSize(tdc, tlength);
+            if (tdc->validPos < filePos + len)
+                tdc->validPos = filePos + len;
 	}
 	totalLength -= len;
 	transferLength += len;
Index: src/afsd/rc.afs.rs_aix
===================================================================
RCS file: /cvs/openafs/src/afsd/rc.afs.rs_aix,v
retrieving revision 1.2
diff -u -b -r1.2 rc.afs.rs_aix
--- src/afsd/rc.afs.rs_aix	4 Nov 2000 10:03:34 -0000	1.2
+++ src/afsd/rc.afs.rs_aix	11 Jun 2003 08:35:58 -0000
@@ -46,10 +46,26 @@
   RMTSYS=""
 fi
 
+# find out whether we have 32 or 64 bit kernel
+
+kernel=32
+if [ -x /bin/w64 ]; then
+    /bin/w64 >/dev/null 2>&1
+    if [ $? -eq 0 ]; then
+        kernel=64
+    fi
+fi
+
 # Load AFS into the kernel
+
 cd /usr/vice/etc/dkload
-/usr/vice/etc/dkload/cfgexport -a /usr/vice/etc/dkload/export.ext${ExportExt}
-/usr/vice/etc/dkload/cfgafs -a /usr/vice/etc/dkload/afs.ext${AFSExt}
+if [ $kernel -eq 32 ]; then
+    echo "32-bit kernel found"
+    ./cfgexport -a export.ext${ExportExt} && ./cfgafs -a afs.ext.32
+else
+    echo "64-bit kernel assumed"
+    ./cfgexport64 -a export64.ext${ExportExt} && ./cfgafs64 -a afs.ext.64
+fi
 if [ $? -ne 0 ]; then
   /bin/echo "Unable to load AFS extensions into kernel. Not starting client."
   exit 1
Index: src/afsd/rc.dkload.client.rs_aix
===================================================================
RCS file: /cvs/openafs/src/afsd/rc.dkload.client.rs_aix,v
retrieving revision 1.2
diff -u -b -r1.2 rc.dkload.client.rs_aix
--- src/afsd/rc.dkload.client.rs_aix	4 Nov 2000 10:03:34 -0000	1.2
+++ src/afsd/rc.dkload.client.rs_aix	11 Jun 2003 08:35:58 -0000
@@ -6,5 +6,19 @@
 # directory or online at http://www.openafs.org/dl/license10.html
 
 echo 'Loading AFS ...'>/dev/console
-/usr/vice/etc/dkload/cfgexport -a /usr/vice/etc/dkload/export.ext.nonfs
-/usr/vice/etc/dkload/cfgafs  -a /usr/vice/etc/dkload/afs.ext
+# Load AFS into the kernel
+cd /usr/vice/etc/dkload
+./cfgexport -a /usr/vice/etc/dkload/export.ext.nonfs
+if [ $? -eq 0 ]; then
+    echo "32-bit kernel found"
+    ./cfgafs -a /usr/vice/etc/dkload/afs.ext.32
+else
+    echo "64-bit kernel assumed"
+    ./cfgexport64 -a /usr/vice/etc/dkload/export64.ext.nonfs
+    ./cfgafs64 -a /usr/vice/etc/dkload/afs.ext.64
+fi
+if [ $? -ne 0 ]; then
+  /bin/echo "Unable to load AFS extensions into kernel."
+  exit 1
+fi
+
Index: src/export/Makefile.in
===================================================================
RCS file: /cvs/openafs/src/export/Makefile.in,v
retrieving revision 1.11
diff -u -b -r1.11 Makefile.in
--- src/export/Makefile.in	11 Jan 2003 07:34:10 -0000	1.11
+++ src/export/Makefile.in	11 Jun 2003 08:35:59 -0000
@@ -25,7 +25,7 @@
 
 install: ${DESTDIR}${libdir}/afs/export.exp ${DESTDIR}${libdir}/afs/extras.exp  
 
-export.ext: export4.exp export5.exp
+export.exp: export4.exp export5.exp
 	case ${SYS_NAME} in \
 	rs_aix4* ) \
 		cp -p export4.exp export.exp ; \
Index: src/export/export.c
===================================================================
RCS file: /cvs/openafs/src/export/export.c,v
retrieving revision 1.7
diff -u -b -r1.7 export.c
--- src/export/export.c	7 Jan 2003 23:24:58 -0000	1.7
+++ src/export/export.c	11 Jun 2003 08:35:59 -0000
@@ -14,7 +14,7 @@
 /* Unsafe: conflicts with _KERNEL inclusion of headers below */
 /* #include <afs/param.h> */
 /* #include <afsconfig.h> */
-/* RCSID("$Header: /cvs/openafs/src/export/export.c,v 1.7 2003/01/07 23:24:58 shadow Exp $"); */
+/* RCSID("$Header: /cvs/openafs/src/export/export.c,v 1.6 2002/09/26 07:01:22 shadow Exp $"); */
 
 #define _KERNEL
 #include "sys/types.h"
@@ -168,7 +168,11 @@
 #endif
 
 	if (!myg_toc) {
+#ifdef __XCOFF64__
+		sym = sym_lookup("ktoc", 0);
+#else
 		sym = sym_lookup("g_toc", 0);
+#endif
 		if (!sym) {
 			printf("\nimport: can't ascertain kernel's TOC\n");
 			return EINVAL;
@@ -183,7 +187,7 @@
 	}
 
 	kfp->fdesc[0] = sym->n_value;
-	kfp->fdesc[1] = myg_toc;
+	kfp->fdesc[1] = *myg_toc;
 	kfp->fdesc[2] = 0;
 
 #ifdef __XCOFF64__
Index: src/export/export5.exp
===================================================================
RCS file: /cvs/openafs/src/export/export5.exp,v
retrieving revision 1.1
diff -u -b -r1.1 export5.exp
--- src/export/export5.exp	9 Oct 2002 01:02:53 -0000	1.1
+++ src/export/export5.exp	11 Jun 2003 08:35:59 -0000
@@ -9,8 +9,7 @@
 *
 * Overwrite vanilla system calls
 *
-*osetgroups	syscall
-okioctl		syscall
+okioctl32	syscall
 
 
 
Index: src/libafs/MakefileProto.AIX.in
===================================================================
RCS file: /cvs/openafs/src/libafs/MakefileProto.AIX.in,v
retrieving revision 1.18
diff -u -b -r1.18 MakefileProto.AIX.in
--- src/libafs/MakefileProto.AIX.in	11 Jan 2003 07:34:40 -0000	1.18
+++ src/libafs/MakefileProto.AIX.in	11 Jun 2003 08:35:59 -0000
@@ -8,7 +8,6 @@
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 
-
 # OS specific object files:
 AFS_OS_OBJS = \
 	osi_assem.o \
@@ -44,7 +43,9 @@
 
 IMPORTS = -bI:/lib/kernex.exp -bI:/lib/syscalls.exp -bI:/lib/sockets.exp \
 	-bI:/lib/netinet.exp \
-	-bI:${TOP_LIBDIR}/extras.exp -bI:${TOP_LIBDIR}/export.exp
+	-bI:${TOP_LIBDIR}/extras.exp 
+IMPORTS32 = -bI:${TOP_LIBDIR}/export.exp
+IMPORTS64 = -bI:${TOP_LIBDIR}/export64.exp
 KDEFS = -U_IBMR2 -D_POWER -D_AIX -DNLS -D_NLS -DMSG -D__STR31__ -Daiws \
 	-D_POWER_RS -D_POWER_PC -D_POWER_RS1 -D_POWER_RS2 -D_POWER_RSC \
 	 -D_POWER_601 -D_POWER_603 -D_POWER_604 -D_THREADS -M  -D_KERNEL \
@@ -52,27 +53,24 @@
 	 -DGETMOUNT -H8 -DAFS -DAFS_COMMON -D_VOPS -D_SUN -DKERNEL
 LDSTUFF= -b"binder:/usr/lib/bind glink:/usr/lib/glink.o" -bnoentry -b h:4 \
 	-D0 -T512
+LDSTUFF64= -b"binder:/usr/lib/bind glink:/usr/lib/glink64.o" -bnoentry -b h:4 \
+	-D0 -T512
 LDFLAGS = -m -eafs_config -bexport:${TOP_LIBDIR}/afs.exp ${IMPORTS} \
-	 -lsys -lcsys 
+	 -lsys -lcsys  ${KLDOPTS}
 
 CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(KDEFS) $(KOPTS) ${DBUG}
 
 # Name of directory to hold object files and libraries.
-KOBJ = MODLOAD
+KOBJ = MODLOAD MODLOAD64
 
 # This tells Makefile.common to use it's single directory build target.
-COMPDIRS = single_compdir
-INSTDIRS = single_instdir
-DESTDIRS = single_destdir
+COMPDIRS = aix_compdirs
+INSTDIRS = aix_instdirs
+DESTDIRS = aix_destdirs
 
 include Makefile.common
 
 setup:
-	-mkdir $(KOBJ)
-	-$(RM) $(KOBJ)/Makefile $(KOBJ)/Makefile.common $(KOBJ)/config
-	ln -fs ../Makefile $(KOBJ)/Makefile
-	ln -fs ../Makefile.common $(KOBJ)/Makefile.common
-	ln -fs ../config $(KOBJ)/config
 	-$(RM) -f  h net netinet rpc ufs nfs  machine sys
 	ln -fs /usr/include/sys h
 	ln -fs /usr/include/net net
@@ -81,7 +79,46 @@
 	ln -fs /usr/include/sys sys
 	ln -fs /usr/include/nfs nfs
 	ln -fs /usr/include/jfs ufs
+	for m in 32 64 ; do \
+		KDIR=MODLOAD-$$m ; \
+		mkdir -p $${KDIR} ; \
+		ln -fs ../Makefile $${KDIR}/Makefile ; \
+		ln -fs ../Makefile.common $${KDIR}/Makefile.common ; \
+		ln -fs ../config $${KDIR}/config ; \
+	done
+
+${COMPDIRS} ${INSTDIRS} ${DESTDIRS}:
+	for m in 32 64 ; do \
+		KDIR=MODLOAD-$$m ; \
+		echo Building in directory: $${KDIR} ; \
+		if [ "$$m" = "32" ] ; then \
+			KOPTS="-q32" ; \
+			KLDOPTS="-b32" ; \
+			KASOPTS="32" ; \
+			TARG="afs.ext.32" ; \
+		elif [ "$$m" = "64" ] ; then \
+			KOPTS="-q64 -DAFS_64BIT_KERNEL -D__64BIT_KERNEL" ; \
+			KLDOPTS="-b64" ; \
+			KASOPTS="64" ; \
+			TARG="afs.ext.64" ; \
+		fi ; \
+		cd $${KDIR} ; \
+		$(MAKE) DEST="$${DEST}" KOPTS="$${KOPTS}"  KLDOPTS="$${KLDOPTS}" KASOPTS="$${KASOPTS}" $@_$${TARG} || exit $$?; \
+		cd ../ ; \
+	done
+
+aix_compdirs_afs.ext.32: afs.ext.32
+aix_compdirs_afs.ext.64: afs.ext.64
+aix_instdirs_afs.ext.32: install_afs.ext.32
+aix_instdirs_afs.ext.64: install_afs.ext.64
+aix_destdirs_afs.ext.32: dest_afs.ext.32
+aix_destdirs_afs.ext.64: dest_afs.ext.64
 
+dest_afs.ext.32: $(DEST)/root.client/usr/vice/etc/dkload/afs.ext.32
+	echo Install for 32-bit Kernel Complete
+
+dest_afs.ext.64: $(DEST)/root.client/usr/vice/etc/dkload/afs.ext.64
+	echo Install for 64-bit Kernel Complete
 
 # Standard AFS->NFS translator support is removed in AFS 3.5 in favor of
 # the iauth authentication mechanism. The model was changed by IBM in the
@@ -93,14 +130,18 @@
 LIBAFS = afs.ext
 
 DEST_LIBAFSIAUTH = $(DEST)/root.client/usr/vice/etc/dkload/$(LIBAFSIAUTH)
-DEST_LIBAFS = $(DEST)/root.client/usr/vice/etc/dkload/$(LIBAFS)
 
 INST_LIBAFSIAUTH = ${DESTDIR}${afskerneldir}/$(LIBAFSIAUTH)
 INST_LIBAFS = ${DESTDIR}${afskerneldir}/$(LIBAFS)
 
-$(DEST_LIBAFS): $(LIBAFS)
+$(DEST)/root.client/usr/vice/etc/dkload/afs.ext.32: afs.ext.32
 	$(INSTALL) -f $? $@
-	-${STRIP} $@
+	-${STRIP} -X 32 $@
+	$(INSTALL) -f $?.map $@.map
+	
+$(DEST)/root.client/usr/vice/etc/dkload/afs.ext.64: afs.ext.64
+	$(INSTALL) -f $? $@
+	-${STRIP} -X 64 $@
 	$(INSTALL) -f $?.map $@.map
 	
 $(DEST_LIBAFSIAUTH): $(LIBAFSIAUTH)
@@ -122,29 +163,44 @@
 $(LIBAFSIAUTH): $(AFSAOBJS) $(AFSIAUTHOBJS)
 	${LD} ${LDSTUFF} -bloadmap:afs.ext.iauth.loadmap \
 		-bmap:afs.ext.iauth.map -o afs.ext.iauth \
-		${AFSAOBJS} ${AFSIAUTHOBJS} ${LIBS} ${LDFLAGS} 
+		${AFSAOBJS} ${AFSIAUTHOBJS} ${LIBS} ${LDFLAGS} ${IMPORTS32}
 
-$(LIBAFS): $(AFSAOBJS) $(AFSNOIAUTHOBJS)
-	${LD} ${LDSTUFF} -bloadmap:afs.ext.loadmap \
-	 	-bmap:afs.ext.map -o afs.ext \
-		${AFSAOBJS} ${AFSNOIAUTHOBJS} ${LIBS} ${LDFLAGS}
+afs.ext.32: $(AFSAOBJS) $(AFSNOIAUTHOBJS)
+	${LD} ${LDSTUFF} -bloadmap:afs.ext.32.loadmap \
+	 	-bmap:afs.ext.32.map -o afs.ext.32 \
+		${AFSAOBJS} ${AFSNOIAUTHOBJS} ${LIBS} \
+		${LDFLAGS} ${IMPORTS32}
+
+afs.ext.64: $(AFSAOBJS) $(AFSNOIAUTHOBJS)
+	${LD} ${LDSTUFF64} -b64 -bloadmap:afs.ext.64.loadmap \
+	 	-bmap:afs.ext.64.map -o afs.ext.64 \
+		${AFSAOBJS} ${AFSNOIAUTHOBJS} ${LIBS} \
+		${LDFLAGS} ${IMPORTS64}
 
-libafs: $(LIBAFS) $(LIBAFSIAUTH)
+libafs: $(LIBAFS) $(LIBAFS64) $(LIBAFSIAUTH)
 install_libafs: $(INST_LIBAFS) $(INST_LIBAFSIAUTH)
 dest_libafs: $(DEST_LIBAFS) $(DEST_LIBAFSIAUTH)
 
 
-osi_assem.o:	$(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_assem.s
-	${AS} -o osi_assem.o $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_assem.s
+osi_assem.o:	osi_assem.s
+	${AS} -a${KASOPTS} -o osi_assem.o osi_assem.s
+osi_assem.s: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_assem32.s $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_assem64.s
+	case bit${KASOPTS} in \
+		bit64 ) \
+			cp -p $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_assem64.s osi_assem.s ;; \
+		* ) \
+			cp -p $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_assem32.s osi_assem.s ;; \
+	esac
+
 
 # Build rules for iauth objects.
 afs_call_iauth.o:	$(AFS)/afs_call.c
-	$(CRULE_NOOPT) -DAFS_NONFSTRANS -DAFS_AIX_IAUTH_ENV -o afs_call_iauth.o
+	$(CRULE1) -DAFS_NONFSTRANS -DAFS_AIX_IAUTH_ENV -o afs_call_iauth.o
 afs_nfsclnt_iauth.o:	$(AFS)/afs_nfsclnt.c
-	$(CRULE_NOOPT) -DAFS_NONFSTRANS -DAFS_AIX_IAUTH_ENV -o afs_nfsclnt_iauth.o
+	$(CRULE1) -DAFS_NONFSTRANS -DAFS_AIX_IAUTH_ENV -o afs_nfsclnt_iauth.o
 afs_pioctl_iauth.o:	$(AFS)/afs_pioctl.c
-	$(CRULE_NOOPT) -DAFS_NONFSTRANS -DAFS_AIX_IAUTH_ENV -o afs_pioctl_iauth.o
-osi_vfsops_iauth.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_vnodeops.c
-	$(CRULE_NOOPT) -DAFS_NONFSTRANS  -DAFS_AIX_IAUTH_ENV -o osi_vfsops_iauth.o
-osi_vnodeops_iauth.o:	$(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_vnodeops.c
-	$(CRULE_NOOPT) -DAFS_NONFSTRANS -DAFS_AIX_IAUTH_ENV -o osi_vnodeops_iauth.o
+	$(CRULE1) -DAFS_NONFSTRANS -DAFS_AIX_IAUTH_ENV -o afs_pioctl_iauth.o
+osi_vfsops_iauth.o: $(AFS)/osi_vfsops.c
+	$(CRULE1) -DAFS_NONFSTRANS  -DAFS_AIX_IAUTH_ENV -o osi_vfsops_iauth.o
+osi_vnodeops_iauth.o:	$(AFS)/osi_vnodeops.c
+	$(CRULE1) -DAFS_NONFSTRANS -DAFS_AIX_IAUTH_ENV -o osi_vnodeops_iauth.o
Index: src/rx/rx.c
===================================================================
RCS file: /cvs/openafs/src/rx/rx.c,v
retrieving revision 1.50
diff -u -b -r1.50 rx.c
--- src/rx/rx.c	14 Mar 2003 19:47:38 -0000	1.50
+++ src/rx/rx.c	11 Jun 2003 08:36:01 -0000
@@ -34,6 +34,9 @@
 #include "netinet/in.h"
 #include "afs/afs_args.h"
 #include "afs/afs_osi.h"
+#ifdef RX_KERNEL_TRACE
+#include "rx_kcommon.h"
+#endif
 #if	(defined(AFS_AUX_ENV) || defined(AFS_AIX_ENV))
 #include "h/systm.h"
 #endif
@@ -314,6 +317,7 @@
 #define CLEAR_CALL_QUEUE_LOCK(C)
 #endif /* RX_ENABLE_LOCKS */
 struct rx_serverQueueEntry *rx_waitForPacket = 0;
+struct rx_serverQueueEntry *rx_waitingForPacket = 0;
 
 /* ------------Exported Interfaces------------- */
 
@@ -1497,6 +1501,8 @@
 	    queue_Append(&rx_idleServerQueue, sq);
 #ifndef AFS_AIX41_ENV
 	    rx_waitForPacket = sq;
+#else
+            rx_waitingForPacket = sq;
 #endif /* AFS_AIX41_ENV */
 	    do {
 		CV_WAIT(&sq->cv, &rx_serverPool_lock);
@@ -1525,6 +1531,19 @@
 	clock_GetTime(&call->startTime);
 	call->state = RX_STATE_ACTIVE;
 	call->mode = RX_MODE_RECEIVING;
+#ifdef RX_KERNEL_TRACE
+	if (ICL_SETACTIVE(afs_iclSetp)) {
+                int glockOwner = ISAFS_GLOCK();
+                if (!glockOwner)
+                        AFS_GLOCK();
+                afs_Trace3(afs_iclSetp, CM_TRACE_WASHERE,
+                        ICL_TYPE_STRING, __FILE__,
+                        ICL_TYPE_INT32, __LINE__,
+                        ICL_TYPE_POINTER, call);
+                if (!glockOwner)
+                        AFS_GUNLOCK();
+        }
+#endif
 
 	rxi_calltrace(RX_CALL_START, call);
 	dpf(("rx_GetCall(port=%d, service=%d) ==> call %x\n", 
@@ -1660,6 +1679,19 @@
 	clock_GetTime(&call->startTime);
 	call->state = RX_STATE_ACTIVE;
 	call->mode = RX_MODE_RECEIVING;
+#ifdef RX_KERNEL_TRACE
+	if (ICL_SETACTIVE(afs_iclSetp)) {
+                int glockOwner = ISAFS_GLOCK();
+                if (!glockOwner)
+                        AFS_GLOCK();
+                afs_Trace3(afs_iclSetp, CM_TRACE_WASHERE,
+                        ICL_TYPE_STRING, __FILE__,
+                        ICL_TYPE_INT32, __LINE__,
+                        ICL_TYPE_POINTER, call);
+                if (!glockOwner)
+                        AFS_GUNLOCK();
+        }
+#endif
 
 	rxi_calltrace(RX_CALL_START, call);
 	dpf(("rx_GetCall(port=%d, service=%d) ==> call %x\n", 
@@ -3894,6 +3926,19 @@
 	}
 	call->state = RX_STATE_ACTIVE;
 	call->mode = RX_MODE_RECEIVING;
+#ifdef RX_KERNEL_TRACE
+        {
+                int glockOwner = ISAFS_GLOCK();
+                if (!glockOwner)
+                        AFS_GLOCK();
+                afs_Trace3(afs_iclSetp, CM_TRACE_WASHERE,
+                        ICL_TYPE_STRING, __FILE__,
+                        ICL_TYPE_INT32, __LINE__,
+                        ICL_TYPE_POINTER, call);
+                if (!glockOwner)
+                        AFS_GUNLOCK();
+        }
+#endif
 	if (call->flags & RX_CALL_CLEARED) {
 	    /* send an ack now to start the packet flow up again */
 	    call->flags &= ~RX_CALL_CLEARED;
Index: src/rx/rx.h
===================================================================
RCS file: /cvs/openafs/src/rx/rx.h,v
retrieving revision 1.19
diff -u -b -r1.19 rx.h
--- src/rx/rx.h	13 Jan 2003 20:24:34 -0000	1.19
+++ src/rx/rx.h	11 Jun 2003 08:36:01 -0000
@@ -71,7 +71,11 @@
 /* Configurable parameters */
 #define	RX_IDLE_DEAD_TIME	60	/* default idle dead time */
 #define	RX_MAX_SERVICES		20	/* Maximum number of services that may be installed */
+#if defined(KERNEL) && defined(AFS_AIX51_ENV) && defined(__64__)
+#define RX_DEFAULT_STACK_SIZE   24000
+#else
 #define	RX_DEFAULT_STACK_SIZE	16000	/* Default process stack size; overriden by rx_SetStackSize */
+#endif
 
 /* This parameter should not normally be changed */
 #define	RX_PROCESS_PRIORITY	LWP_NORMAL_PRIORITY
Index: src/rx/rx_clock.h
===================================================================
RCS file: /cvs/openafs/src/rx/rx_clock.h,v
retrieving revision 1.11
diff -u -b -r1.11 rx_clock.h
--- src/rx/rx_clock.h	16 Oct 2002 03:58:49 -0000	1.11
+++ src/rx/rx_clock.h	11 Jun 2003 08:36:01 -0000
@@ -90,7 +90,17 @@
 #if defined(AFS_SGI61_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX_64BIT_KERNEL)
 #define clock_GetTime(cv) osi_GetTime((osi_timeval_t *)cv)
 #else
+#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
+#define        clock_GetTime(cv)                               \
+    BEGIN                                              \
+       struct timeval tv;                              \
+       osi_GetTime(&tv);                        \
+       (cv)->sec = (afs_int32)tv.tv_sec;               \
+       (cv)->usec = (afs_int32)tv.tv_usec;             \
+    END
+#else /* defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) */
 #define clock_GetTime(cv) osi_GetTime((struct timeval *)cv)
+#endif /* defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) */
 #endif
 #define clock_Sec() osi_Time()
 #define	clock_NewTime()    /* don't do anything; clock is fast enough in kernel */
Index: src/rx/rx_kcommon.c
===================================================================
RCS file: /cvs/openafs/src/rx/rx_kcommon.c,v
retrieving revision 1.34
diff -u -b -r1.34 rx_kcommon.c
--- src/rx/rx_kcommon.c	13 May 2003 21:22:19 -0000	1.34
+++ src/rx/rx_kcommon.c	11 Jun 2003 08:36:01 -0000
@@ -940,19 +940,23 @@
 
     nbytes = tlen + sizeof(afs_int32);
 #ifdef RX_KERNEL_TRACE
+    if (ICL_SETACTIVE(afs_iclSetp)) {
     AFS_GLOCK();
     afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP,
 		ICL_TYPE_STRING, "before osi_NetRecive()");
     AFS_GUNLOCK();
+    }
 #endif
     code = osi_NetReceive(rx_socket, &from, p->wirevec, p->niovecs,
 			    &nbytes);
 
 #ifdef RX_KERNEL_TRACE
+    if (ICL_SETACTIVE(afs_iclSetp)) {
     AFS_GLOCK();
     afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP,
 		ICL_TYPE_STRING, "after osi_NetRecive()");
     AFS_GUNLOCK();
+    }
 #endif
    /* restore the vec to its correct state */
     p->wirevec[p->niovecs-1].iov_len = savelen;
Index: src/rx/rx_kcommon.h
===================================================================
RCS file: /cvs/openafs/src/rx/rx_kcommon.h,v
retrieving revision 1.25
diff -u -b -r1.25 rx_kcommon.h
--- src/rx/rx_kcommon.h	20 May 2003 03:57:44 -0000	1.25
+++ src/rx/rx_kcommon.h	11 Jun 2003 08:36:01 -0000
@@ -131,7 +131,7 @@
 #include "afs/longc_procs.h"
 #include "afs/afs_stats.h"
 #include "h/errno.h"
-#if 0/*def KERNEL*/
+#ifdef KERNEL
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
 #endif
Index: src/rx/rx_packet.c
===================================================================
RCS file: /cvs/openafs/src/rx/rx_packet.c,v
retrieving revision 1.29
diff -u -b -r1.29 rx_packet.c
--- src/rx/rx_packet.c	10 Mar 2003 20:02:41 -0000	1.29
+++ src/rx/rx_packet.c	11 Jun 2003 08:36:02 -0000
@@ -25,6 +25,9 @@
 #include "rx/rx_queue.h"
 #include "rx/rx_packet.h"
 #else /* defined(UKERNEL) */
+#ifdef RX_KERNEL_TRACE
+#include "../rx/rx_kcommon.h"
+#endif
 #include "h/types.h"
 #ifndef AFS_LINUX20_ENV
 #include "h/systm.h"
@@ -1417,14 +1420,32 @@
     }
     AFS_RXGUNLOCK();
 #ifdef KERNEL
+#ifdef RX_KERNEL_TRACE
+    if (ICL_SETACTIVE(afs_iclSetp)) {
+        if (!waslocked) AFS_GLOCK();
+        afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP,
+                       ICL_TYPE_STRING, "before osi_NetSend()");
+        AFS_GUNLOCK();
+    } else
+#else
     if (waslocked) AFS_GUNLOCK();
 #endif
+#endif
     /* debug packets are not reliably delivered, hence the cast below. */
     (void) osi_NetSend(asocket, &taddr, apacket->wirevec, apacket->niovecs,
 		       apacket->length+RX_HEADER_SIZE, istack);
 #ifdef KERNEL
+#ifdef RX_KERNEL_TRACE
+    if (ICL_SETACTIVE(afs_iclSetp)) {
+        AFS_GLOCK();
+        afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP,
+                       ICL_TYPE_STRING, "after osi_NetSend()");
+        if (!waslocked) AFS_GUNLOCK();
+    } else
+#else
     if (waslocked) AFS_GLOCK();
 #endif
+#endif
     AFS_RXGLOCK();
     if (saven) {  /* means we truncated the packet above. */
       apacket->wirevec[i-1].iov_len = savelen;
@@ -1513,8 +1534,17 @@
 	AFS_RXGUNLOCK();
 #ifdef KERNEL
 	waslocked = ISAFS_GLOCK();
+#ifdef RX_KERNEL_TRACE
+        if (ICL_SETACTIVE(afs_iclSetp)) {
+            if (!waslocked) AFS_GLOCK();
+            afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP,
+                       ICL_TYPE_STRING, "before osi_NetSend()");
+            AFS_GUNLOCK();
+        } else
+#else
 	if (waslocked) AFS_GUNLOCK();
 #endif
+#endif
 	if ((code = osi_NetSend(socket, &addr, p->wirevec, p->niovecs, 
 				p->length+RX_HEADER_SIZE, istack)) != 0) {
 	  /* send failed, so let's hurry up the resend, eh? */
@@ -1535,7 +1565,16 @@
 #endif
 	}
 #ifdef KERNEL
+#ifdef RX_KERNEL_TRACE
+        if (ICL_SETACTIVE(afs_iclSetp)) {
+            AFS_GLOCK();
+            afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP,
+                       ICL_TYPE_STRING, "after osi_NetSend()");
+            if (!waslocked) AFS_GUNLOCK();
+        } else
+#else
 	if (waslocked) AFS_GLOCK();
+#endif
 #endif
 	AFS_RXGLOCK();
 #ifdef RXDEBUG    
Index: src/rx/rx_rdwr.c
===================================================================
RCS file: /cvs/openafs/src/rx/rx_rdwr.c,v
retrieving revision 1.19
diff -u -b -r1.19 rx_rdwr.c
--- src/rx/rx_rdwr.c	8 Feb 2003 08:40:03 -0000	1.19
+++ src/rx/rx_rdwr.c	11 Jun 2003 08:36:02 -0000
@@ -18,6 +18,9 @@
 
 #ifdef KERNEL
 #ifndef UKERNEL
+#ifdef RX_KERNEL_TRACE
+#include "rx_kcommon.h"
+#endif
 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #include "afs/sysincludes.h"
 #else
@@ -1233,6 +1236,20 @@
 
 	call->mode = (call->conn->type == RX_CLIENT_CONNECTION ?
 		                          RX_MODE_RECEIVING: RX_MODE_EOF);
+
+#ifdef RX_KERNEL_TRACE
+        {
+                int glockOwner = ISAFS_GLOCK();
+                if (!glockOwner)
+                        AFS_GLOCK();
+                afs_Trace3(afs_iclSetp, CM_TRACE_WASHERE,
+                        ICL_TYPE_STRING, __FILE__,
+                        ICL_TYPE_INT32, __LINE__,
+                        ICL_TYPE_POINTER, call);
+                if (!glockOwner)
+                        AFS_GUNLOCK();
+        }
+#endif
 
 #ifdef AFS_GLOBAL_RXLOCK_KERNEL
 	/* Wait until TQ_BUSY is reset before adding any
Index: src/rx/xdr_int64.c
===================================================================
RCS file: /cvs/openafs/src/rx/xdr_int64.c,v
retrieving revision 1.6
diff -u -b -r1.6 xdr_int64.c
--- src/rx/xdr_int64.c	16 Oct 2002 03:58:50 -0000	1.6
+++ src/rx/xdr_int64.c	11 Jun 2003 08:36:02 -0000
@@ -36,8 +36,8 @@
 
 bool_t xdr_afs_int64(register XDR *xdrs, afs_int64 *ulp)
 {
-        static afs_int32 high;
-        static afs_uint32 low;
+        afs_int32 high;
+        afs_uint32 low;
 
         if (xdrs->x_op == XDR_DECODE) {
                 if (!XDR_GETINT32(xdrs, (afs_int32 *) &high)) return (FALSE);
@@ -67,8 +67,8 @@
 }
 bool_t xdr_afs_uint64(register XDR *xdrs, afs_uint64 *ulp)
 {
-        static afs_uint32 high;
-        static afs_uint32 low;
+        afs_uint32 high;
+        afs_uint32 low;
 
         if (xdrs->x_op == XDR_DECODE) {
                 if (!XDR_GETINT32(xdrs, (afs_uint32 *) &high)) return (FALSE);
Index: src/rx/AIX/rx_kmutex.h
===================================================================
RCS file: /cvs/openafs/src/rx/AIX/rx_kmutex.h,v
retrieving revision 1.3
diff -u -b -r1.3 rx_kmutex.h
--- src/rx/AIX/rx_kmutex.h	5 Jul 2001 15:20:44 -0000	1.3
+++ src/rx/AIX/rx_kmutex.h	11 Jun 2003 08:36:02 -0000
@@ -44,7 +44,7 @@
 #define CV_SIGNAL(_cv)		e_wakeup_one(_cv)
 #define CV_BROADCAST(_cv)	e_wakeup(_cv)
 typedef simple_lock_data afs_kmutex_t;
-typedef int afs_kcondvar_t;
+typedef tid_t afs_kcondvar_t;
 #define	osi_rxWakeup(cv)	e_wakeup(cv)
 
 
Index: src/rx/AIX/rx_knet.c
===================================================================
RCS file: /cvs/openafs/src/rx/AIX/rx_knet.c,v
retrieving revision 1.9
diff -u -b -r1.9 rx_knet.c
--- src/rx/AIX/rx_knet.c	16 Oct 2002 03:58:51 -0000	1.9
+++ src/rx/AIX/rx_knet.c	11 Jun 2003 08:36:03 -0000
@@ -145,6 +145,15 @@
     tlen = ntohs((u_short)tvu->ui_ulen);
     if ((int)ti->ip_len != tlen) {
 	if (tlen > (int)ti->ip_len) {
+#ifdef RX_KERNEL_TRACE
+            int glockOwner = ISAFS_GLOCK();
+            if (!glockOwner) AFS_GLOCK();
+            afs_Trace3(afs_iclSetp, CM_TRACE_WASHERE,
+                        ICL_TYPE_STRING, __FILE__,
+                        ICL_TYPE_INT32, __LINE__,
+                        ICL_TYPE_INT32, tlen);
+            if (!glockOwner) AFS_GUNLOCK();
+#endif
 	    m_free(am);
 	    return;
 	}
@@ -163,18 +172,47 @@
 	 * underlying network (and interfaces and drivers and
 	 * DMA hardware, etc!) is error-free. First, fill
 	 * in entire virtual ip header. */
+#ifndef AFS_64BIT_KERNEL
 	tvu->ui_next = 0;
 	tvu->ui_prev = 0;
+#endif
 	tvu->ui_x1 = 0;
 	tvu->ui_len = tvu->ui_ulen;
 	am->m_flags |= M_PKTHDR;
 	am->m_pkthdr.len = tlen;
+#if !defined(AFS_AIX51_ENV) || !defined(AFS_64BIT_KERNEL)
 	if (in_cksum(am, sizeof(struct ip) + tlen)) {
 	    /* checksum, including cksum field, doesn't come out 0, so
 	       this packet is bad */
+#ifdef RX_KERNEL_TRACE
+            int glockOwner = ISAFS_GLOCK();
+            if (!glockOwner) AFS_GLOCK();
+            afs_Trace3(afs_iclSetp, CM_TRACE_WASHERE,
+                        ICL_TYPE_STRING, __FILE__,
+                        ICL_TYPE_INT32, __LINE__,
+                        ICL_TYPE_INT32, tlen);
+            if (!glockOwner) AFS_GUNLOCK();
+#endif
 	    m_freem(am);
 	    return;
 	}
+#else
+#ifdef notdef
+        { /* in_cksum() doesn't work correctly or the length is wrong? */
+                int cksum;
+                int glockOwner = ISAFS_GLOCK();
+                cksum = in_cksum(am, sizeof(struct ip) + tlen);
+                if (!glockOwner)
+                        AFS_GLOCK();
+                afs_Trace3(afs_iclSetp, CM_TRACE_WASHERE,
+                        ICL_TYPE_STRING, __FILE__,
+                        ICL_TYPE_INT32, __LINE__,
+                        ICL_TYPE_INT32, cksum);
+                if (!glockOwner)
+                        AFS_GUNLOCK();
+        }
+#endif
+#endif
     }
 
     /*
Index: src/sys/Makefile.in
===================================================================
RCS file: /cvs/openafs/src/sys/Makefile.in,v
retrieving revision 1.19
diff -u -b -r1.19 Makefile.in
--- src/sys/Makefile.in	11 Jan 2003 07:34:55 -0000	1.19
+++ src/sys/Makefile.in	11 Jun 2003 08:36:03 -0000
@@ -8,6 +8,7 @@
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 
+CFLAGS=-I. -I${srcdir} ${DBUG} -I${TOP_OBJDIR}/src/config -I${TOP_INCDIR}  ${XCFLAGS}
 SFLAGS=-P -I${TOP_INCDIR}
 LIBS=libsys.a ${TOP_LIBDIR}/librx.a libsys.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/util.a ${XLIBS}
 
@@ -22,9 +23,13 @@
 	${TOP_INCDIR}/afs/afs.exp \
 	${TOP_INCDIR}/afs/xfsattrs.h \
 	${TOP_LIBDIR}/afs.exp \
-	${TOP_LIBDIR}/libsys.a 
+	${TOP_LIBDIR}/libsys.a \
+	${KERNELDIR}/afs \
+	${KERNELDIR}/afs/xfsattrs.h \
+	${UKERNELDIR}/afs \
+	${UKERNELDIR}/afs/afsl.exp
 
-libsys.a: ${OBJECTS} ${RMTOBJS} AFS_component_version_number.o
+libsys.a: ${OBJECTS} ${RMTOBJS} afsl.exp AFS_component_version_number.o
 	-$(RM) -f $@
 	$(AR) crv $@ ${OBJECTS} ${RMTOBJS} \
 		AFS_component_version_number.o ${LIBSYS_AIX_EXP}
@@ -122,6 +127,22 @@
 		$(CC) -o xfsinode ${CFLAGS} ${srcdir}/xfsinode.c ${LIBS}
 	esac
 
+afs.exp: afs4.exp afs5.exp
+	case ${SYS_NAME} in \
+		rs_aix5* ) \
+			cp -p afs5.exp afs.exp ;; \
+		* ) \
+			cp -p afs4.exp afs.exp ;; \
+	esac
+
+afsl.exp: afsl4.exp afsl5.exp
+	case ${SYS_NAME} in \
+		rs_aix5* ) \
+			cp -p afsl5.exp afsl.exp ;; \
+		* ) \
+			cp -p afsl4.exp afsl.exp ;; \
+	esac
+
 #
 # Installation targets
 #
@@ -139,6 +160,18 @@
 	${INSTALL} $? $@
 
 ${TOP_LIBDIR}/libsys.a: libsys.a
+	${INSTALL} $? $@
+
+${UKERNELDIR}/afs:
+	mkdir -p $@
+
+${UKERNELDIR}/afs/afsl.exp: afsl.exp
+	${INSTALL} $? $@
+
+${KERNELDIR}/afs:
+	mkdir -p $@
+
+${KERNELDIR}/afs/xfsattrs.h: xfsattrs.h
 	${INSTALL} $? $@
 
 install: \
Index: src/tsm41/aix41_auth.c
===================================================================
RCS file: /cvs/openafs/src/tsm41/aix41_auth.c,v
retrieving revision 1.7
diff -u -b -r1.7 aix41_auth.c
--- src/tsm41/aix41_auth.c	26 Sep 2002 07:01:28 -0000	1.7
+++ src/tsm41/aix41_auth.c	11 Jun 2003 08:36:03 -0000
@@ -10,7 +10,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header: /cvs/openafs/src/tsm41/aix41_auth.c,v 1.7 2002/09/26 07:01:28 shadow Exp $");
+RCSID("$Header: /cvs/openafs/src/tsm41/aix41_auth.c,v 1.5 2001/08/08 00:04:11 shadow Exp $");
 
 #if defined(AFS_AIX41_ENV)
 #include <sys/types.h>
@@ -34,7 +34,7 @@
     int code, unixauthneeded, password_expires = -1;
 
     *reenter = 0;
-    *message = NULL;
+    *message = (char *)0;
     if (response) {
 	pword = response;
     } else {
@@ -53,7 +53,7 @@
 	return AUTH_FAILURE;
     }
     if (code = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION + KA_USERAUTH_DOSETPAG, userName, 
-					  NULL, NULL, pword, 0, &password_expires, 0, &reason)) {
+					  (char *)0, (char *)0, pword, 0, &password_expires, 0, &reason)) {
 	if (code == KANOENT) 
 	    return AUTH_NOTFOUND;	
 	*message = (char *)malloc(1024);
@@ -83,6 +83,28 @@
 }
 
 struct group *afs_getgrgid (int id) {
+#ifdef AFS_AIX51_ENV
+    static char name[64];
+    static char passwd[64];
+    static struct group grp;
+    struct group *g;
+    char *mem = NULL;
+
+    while ((g = getgrent()) != NULL) {
+	if (g->gr_gid == id) {
+		strncpy(&name, g->gr_name, sizeof(name));
+		strncpy(&passwd, g->gr_passwd, sizeof(passwd));
+		grp.gr_name = &name;
+		grp.gr_passwd = &passwd;
+		grp.gr_gid = g->gr_gid;
+		grp.gr_mem = &mem;
+		break;
+	}
+    }
+    endgrent();
+    if (g)
+       return &grp;
+#endif
     return NULL;
 }
 
@@ -91,33 +113,34 @@
 }
 
 #ifdef AFS_AIX51_ENV
-/*
- *  This is a nasty hack. It seems getpwnam calls this routine and is not
- *  happy with NULL as result. Trying to call here getpwnam in order to get
- *  a reasonable result kills the whole program. So I tried to return
- *  a dummy pwd and it seems to work!
- */
 struct passwd *afs_getpwnam (char *user) {
-    char name[64];
-    char *passwd = "*";
-    char *gecos = "";
-    char *dir = "/";
-    char *shell = "/bin/sh";
-    char *nobody = "nobody";
-    struct passwd p;
-
-    strncpy((char *)&name, user, sizeof(name));
-    name[63] = 0;
-    p.pw_name = &name;
-    p.pw_name = nobody;
-    p.pw_passwd = passwd;
-    p.pw_uid = 4294967294;
-    p.pw_gid = 4294967294;
-    p.pw_gecos = gecos;
-    p.pw_dir = dir;
-    p.pw_shell = shell;
-
-    return &p;
+    static char name[64];
+    static char passwd[64];
+    static char gecos[256];
+    static char dir[256];
+    static char shell[256];
+    static struct passwd pwd;
+    struct passwd *p;
+
+    while ((p = getpwent()) != NULL) {
+	if (!strcmp(p->pw_name, user)) {
+		strncpy(&name, p->pw_name, sizeof(name));
+		strncpy(&passwd, p->pw_passwd, sizeof(passwd));
+		strncpy(&gecos, p->pw_gecos, sizeof(gecos));
+		strncpy(&dir, p->pw_dir, sizeof(dir));
+		strncpy(&shell, p->pw_shell, sizeof(shell));
+		pwd.pw_name = &name;
+		pwd.pw_passwd = &passwd;
+		pwd.pw_uid = p->pw_uid;
+		pwd.pw_gid = p->pw_gid;
+		pwd.pw_gecos = &gecos;
+		pwd.pw_dir = &dir;
+		pwd.pw_shell = &shell;
+		break;
+	}
+    }
+    endpwent();
+    return &pwd;
 }
 #else
 int afs_getpwnam(int id)
Index: src/venus/fstrace.c
===================================================================
RCS file: /cvs/openafs/src/venus/fstrace.c,v
retrieving revision 1.11
diff -u -b -r1.11 fstrace.c
--- src/venus/fstrace.c	14 May 2003 15:15:10 -0000	1.11
+++ src/venus/fstrace.c	11 Jun 2003 08:36:03 -0000
@@ -13,7 +13,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header: /cvs/openafs/src/venus/fstrace.c,v 1.11 2003/05/14 15:15:10 shadow Exp $");
+RCSID("$Header: /cvs/openafs/src/venus/fstrace.c,v 1.10 2002/08/21 18:14:26 shadow Exp $");
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -40,14 +40,14 @@
 #include <afs/icl.h>
 #include <afs/afsutil.h>
 
-#if defined(AFS_ALPHA_ENV) || defined(AFS_SGI61_ENV)
+#if defined(AFS_ALPHA_ENV) || defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 /* For SGI 6.2, this is changed to 1 if it's a 32 bit kernel. */
 int afs_icl_sizeofLong = 2;
 #else
 int afs_icl_sizeofLong = 1;
 #endif
 
-#ifdef AFS_SGI61_ENV
+#if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 int afs_64bit_kernel = 1;	/* Default for 6.2+, and always for 6.1 */
 extern int afs_icl_sizeofLong;	/* Used in ICL_SIZEHACK() */
 #ifdef AFS_SGI62_ENV
@@ -120,7 +120,7 @@
  * by typesp.  Also watch for prematurely running out of parameters
  * before the string is gone.
  */
-#ifdef AFS_SGI61_ENV
+#if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 static int CheckTypes(bufferp, typesp, typeCount, outMsgBuffer)
   char *bufferp;
   int *typesp;
@@ -257,7 +257,7 @@
   afs_int32 rsize;
 {
     char msgBuffer[1024];
-#ifdef AFS_SGI61_ENV
+#if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
     char outMsgBuffer[1024];
     uint64_t tempParam;
     uint64_t printfParms[ICL_MAXEXPANSION * /* max parms */ 4];
@@ -297,7 +297,7 @@
 	case ICL_TYPE_LONG:
 	case ICL_TYPE_POINTER:
 	    printfTypes[pftix++] = 0;
-#ifdef AFS_SGI61_ENV
+#if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 	    printfParms[pfpix] = alp[pix];
 	    printfParms[pfpix] &= 0xffffffff;
 	    if (afs_64bit_kernel) {
@@ -340,7 +340,7 @@
 #ifdef AFS_SGI64_ENV
             printfStrings[pfpix++] = (char*) &alp[pix];
 #else /* AFS_SGI64_ENV */
-#ifdef AFS_SGI61_ENV
+#if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 	    printfStrings[pfpix++] = (char *) &alp[pix];
 #else /* AFS_SGI61_ENV */
 	    printfParms[pfpix++] = (long) &alp[pix];
@@ -369,7 +369,7 @@
      */
     printed = 0;
     if (status == 0) {
-#ifdef AFS_SGI61_ENV
+#if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 	if (CheckTypes(msgBuffer, printfTypes, pftix, outMsgBuffer)) {
 	    /* we have a string to use, but it ends "(dfs / zcm)",
 	     * so we remove the extra gunk.
@@ -2592,7 +2592,8 @@
 }
 
 /* free a log entry, and drop its reference count */
-int icl_LogFree(register struct afs_icl_log *logp)
+icl_LogFree(logp)
+  register struct afs_icl_log *logp;
 {
     logp->states |= ICL_LOGF_DELETED;
     icl_LogRele(logp);

--------------090100060406080303000008--