This patch makes the kernel module for OpenAFS work properly on AIX.
Client (1.3.79) tested by me on: AIX 5.1, 32bit, both UP and MP.
and (1.3.80) by Michael Niksch on: rs_aix42 (as rs_aix43) on AIX 4330-11 bos.up 4.3.3.93 rs_aix51 on AIX 5100-07 bos.mp 5.1.0.64 rs_aix52 on AIX 5200-05 bos.mp 5.2.0.54 rs_aix52 on AIX 5200-05 bos.mp64 5.2.0.54
Horst Birthelmer has tested the server-stuff and found it still working.
Executive summary of the patch: * Removed memory allocation functions only used on AIX and ancient HPUX. If the performance penalty is noticeable, implement a wrapper at the osi-level in the same manner as LINUX/FBSD (ie not sprayed throughout the code). * Removed all remnants of splnet()-style locking, it was not sufficient for MP anyway which the real locks are. Affects only AIX and HPUX. * Drop the global locking in rxi_Alloc since the real locks do their jobs, affects only AIX41 and up (ie. MP capable OS). * Fix the non-kernel wrapper for osi_Alloc/Free on AIX to take void * in the same manner as the rest of the functions. IMO this wrapper shouldn't be necessary since you should never ever malloc() 0 bytes, but since it's there I'd guess someone made stupid assumptions somewhere... * Restores MAXKTCTICKETLEN to 12000 on AIX * Restores AFS_LWP_MINSTACKSIZE to 48k on AIX (might affect server-stuff)
This should be commited to the openafs-tree as soon as possible so we can get a bit wider testing and find out if there are more remaining problems on AIX than the following:
* -afsdb -dynroot doesn't seem to work (returns ENOENT immediately) * klog dumps core * login configured to use afs_dynamic_auth fails * Horst has problems with mysterious hangs
/Nikke
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se | [EMAIL PROTECTED]
---------------------------------------------------------------------------
*� *� <- Tribbles Snorkelling
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=diff -wru ../openafs-1.3.79.orig/src/afs/afs_daemons.c ./src/afs/afs_daemons.c
--- ../openafs-1.3.79.orig/src/afs/afs_daemons.c Tue Dec 7 07:12:11 2004
+++ ./src/afs/afs_daemons.c Mon Mar 14 10:28:29 2005
@@ -145,22 +145,6 @@
afs_FlushVCBs(1); /* flush queued callbacks */
afs_MaybeWakeupTruncateDaemon(); /* free cache space if have too
*/
rx_CheckPackets(); /* Does RX need more packets? */
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- /*
- * Hack: We always want to make sure there are plenty free
- * entries in the small free pool so that we don't have to
- * worry about rx (with disabled interrupts) to have to call
- * malloc). So we do the dummy call below...
- */
- if (((afs_stats_cmperf.SmallBlocksAlloced -
- afs_stats_cmperf.SmallBlocksActive)
- <= AFS_SALLOC_LOW_WATER))
- osi_FreeSmallSpace(osi_AllocSmallSpace(AFS_SMALLOCSIZ));
- if (((afs_stats_cmperf.MediumBlocksAlloced -
- afs_stats_cmperf.MediumBlocksActive)
- <= AFS_MALLOC_LOW_WATER + 50))
- osi_AllocMoreMSpace(AFS_MALLOC_LOW_WATER * 2);
-#endif
now = osi_Time();
if (lastCBSlotBump + CBHTSLOTLEN < now) { /* pretty
time-dependant */
diff -wru ../openafs-1.3.79.orig/src/afs/afs_init.c ./src/afs/afs_init.c
--- ../openafs-1.3.79.orig/src/afs/afs_init.c Tue Dec 7 07:12:11 2004
+++ ./src/afs/afs_init.c Mon Mar 14 15:44:54 2005
@@ -111,26 +111,6 @@
RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
osi_dnlc_init();
-
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- {
- afs_int32 preallocs;
-
- /*
- * We want to also reserve space for the gnode struct which is
associated
- * with each vnode (vcache) one; we want to use the pinned pool for
them
- * since they're referenced at interrupt level.
- */
- if (afs_stats_cmperf.SmallBlocksAlloced + astatSize < 3600)
- preallocs = astatSize;
- else {
- preallocs = 3600 - afs_stats_cmperf.SmallBlocksAlloced;
- if (preallocs <= 0)
- preallocs = 10;
- }
- osi_AllocMoreSSpace(preallocs);
- }
-#endif
/*
* create volume list structure
*/
@@ -492,9 +472,7 @@
RWLOCK_INIT(&afs_xinterface, "afs_xinterface");
LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
#ifndef AFS_FBSD_ENV
-#ifndef AFS_AIX32_ENV
LOCK_INIT(&osi_fsplock, "osi_fsplock");
-#endif
LOCK_INIT(&osi_flplock, "osi_flplock");
#endif
RWLOCK_INIT(&afs_xconn, "afs_xconn");
@@ -511,15 +489,6 @@
afs_sysname = afs_sysnamelist[0];
strcpy(afs_sysname, SYS_NAME);
afs_sysnamecount = 1;
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- {
-
- if ((preallocs > 256) && (preallocs < 3600))
- afs_preallocs = preallocs;
- osi_AllocMoreSSpace(afs_preallocs);
- osi_AllocMoreMSpace(100);
- }
-#endif
}
secobj = rxnull_NewServerSecurityObject();
diff -wru ../openafs-1.3.79.orig/src/afs/afs_osi_alloc.c
./src/afs/afs_osi_alloc.c
--- ../openafs-1.3.79.orig/src/afs/afs_osi_alloc.c Thu Mar 11 00:01:51 2004
+++ ./src/afs/afs_osi_alloc.c Mon Mar 14 15:45:19 2005
@@ -20,16 +20,17 @@
#include "afs/afs_stats.h" /* afs statistics */
#ifndef AFS_FBSD_ENV
+
#ifdef AFS_AIX41_ENV
#include "sys/lockl.h"
#include "sys/sleep.h"
#include "sys/syspest.h"
#include "sys/lock_def.h"
/*lock_t osi_fsplock = LOCK_AVAIL;*/
-#else
-afs_lock_t osi_fsplock;
#endif
+afs_lock_t osi_fsplock;
+
static struct osi_packet {
@@ -38,29 +39,6 @@
afs_lock_t osi_flplock;
-afs_int32 afs_preallocs = 512; /* Reserve space for all small allocs! */
-void
-osi_AllocMoreSSpace(register afs_int32 preallocs)
-{
- register int i;
- char *p;
-
- p = (char *)afs_osi_Alloc(AFS_SMALLOCSIZ * preallocs);
-#ifdef KERNEL_HAVE_PIN
- pin(p, AFS_SMALLOCSIZ * preallocs); /* XXXX */
-#endif
- for (i = 0; i < preallocs; i++, p += AFS_SMALLOCSIZ) {
-#ifdef AFS_AIX32_ENV
- *p = '\0'; /* page fault it in. */
-#endif
- osi_FreeSmallSpace((char *)p);
- }
- afs_stats_cmperf.SmallBlocksAlloced += preallocs;
- afs_stats_cmperf.SmallBlocksActive += preallocs;
-}
-
-
-
/* free space allocated by AllocLargeSpace. Also called by mclput when freeing
* a packet allocated by osi_NetReceive. */
@@ -82,98 +60,16 @@
osi_FreeSmallSpace(void *adata)
{
-#if defined(AFS_AIX32_ENV)
- int x;
-#endif
-#if defined(AFS_HPUX_ENV)
- ulong_t x;
-#endif
-
AFS_ASSERT_GLOCK();
AFS_STATCNT(osi_FreeSmallSpace);
afs_stats_cmperf.SmallBlocksActive--;
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT); */
-#else
MObtainWriteLock(&osi_fsplock, 323);
-#endif
((struct osi_packet *)adata)->next = freeSmallList;
freeSmallList = adata;
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- splx(x); /*unlockl(&osi_fsplock); */
-#else
MReleaseWriteLock(&osi_fsplock);
-#endif
}
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
-static struct osi_packet *freeMediumList;
-
-osi_AllocMoreMSpace(register afs_int32 preallocs)
-{
- register int i;
- char *p;
-
- p = (char *)afs_osi_Alloc(AFS_MDALLOCSIZ * preallocs);
-#ifdef KERNEL_HAVE_PIN
- pin(p, AFS_MDALLOCSIZ * preallocs); /* XXXX */
-#endif
- for (i = 0; i < preallocs; i++, p += AFS_MDALLOCSIZ) {
-#ifdef AFS_AIX32_ENV
- *p = '\0'; /* page fault it in. */
-#endif
- osi_FreeMediumSpace((char *)p);
- }
- afs_stats_cmperf.MediumBlocksAlloced += preallocs;
- afs_stats_cmperf.MediumBlocksActive += preallocs;
-}
-
-
-void *
-osi_AllocMediumSpace(size_t size)
-{
- register struct osi_packet *tp;
-#if defined(AFS_AIX32_ENV)
- int x;
-#endif
-#if defined(AFS_HPUX_ENV)
- ulong_t x;
-#endif
-
- afs_stats_cmperf.MediumBlocksActive++;
- retry:
- x = splnet();
- tp = freeMediumList;
- if (tp)
- freeMediumList = tp->next;
- splx(x);
- if (!tp) {
- osi_AllocMoreMSpace(AFS_MALLOC_LOW_WATER);
- goto retry;
- }
- return tp;
-}
-
-void
-osi_FreeMediumSpace(void *adata)
-{
-
-#if defined(AFS_AIX32_ENV)
- int x;
-#endif
-#if defined(AFS_HPUX_ENV)
- ulong_t x;
-#endif
-
- afs_stats_cmperf.MediumBlocksActive--;
- x = splnet();
- ((struct osi_packet *)adata)->next = freeMediumList;
- freeMediumList = adata;
- splx(x);
-}
-#endif /* defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) */
-
/* allocate space for sender */
void *
@@ -210,129 +106,28 @@
return (char *)tp;
}
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
-/*
- * XXX We could have used a macro around osi_AllocSmallSpace but it's
- * probably better like this so that we can remove this at some point.
- */
-/* morespace 1 - means we called at splnet level */
-char *
-osi_AllocSmall(register afs_int32 size, register afs_int32 morespace)
-{
- register struct osi_packet *tp;
-#if defined(AFS_AIX32_ENV)
- int x;
-#endif
-#if defined(AFS_HPUX_ENV)
- ulong_t x;
-#endif
-
- AFS_ASSERT_GLOCK();
-
- AFS_STATCNT(osi_AllocSmallSpace);
- if (size > AFS_SMALLOCSIZ)
- osi_Panic("osi_AllocSmall, size=%d", size);
- if ((!morespace
- &&
- ((afs_stats_cmperf.SmallBlocksAlloced -
- afs_stats_cmperf.SmallBlocksActive)
- <= AFS_SALLOC_LOW_WATER))
- || !freeSmallList) {
- osi_AllocMoreSSpace(AFS_SALLOC_LOW_WATER * 2);
- }
- afs_stats_cmperf.SmallBlocksActive++;
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT); */
-#else
- MObtainWriteLock(&osi_fsplock, 325);
-#endif
- tp = freeSmallList;
- if (tp)
- freeSmallList = tp->next;
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- splx(x); /*unlockl(&osi_fsplock); */
-#else
- MReleaseWriteLock(&osi_fsplock);
-#endif
-
- return (char *)tp;
-}
-
-int
-osi_FreeSmall(register struct osi_packet *adata)
-{
-#if defined(AFS_AIX32_ENV)
- int x;
-#endif
-#if defined(AFS_HPUX_ENV)
- ulong_t x;
-#endif
-
- AFS_STATCNT(osi_FreeSmallSpace);
- afs_stats_cmperf.SmallBlocksActive--;
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT); */
-#else
- MObtainWriteLock(&osi_fsplock, 326);
-#endif
- adata->next = freeSmallList;
- freeSmallList = adata;
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- splx(x); /*unlockl(&osi_fsplock); */
-#else
- MReleaseWriteLock(&osi_fsplock);
-#endif
- return 0;
-}
-#endif /* AFS_AIX32_ENV || AFS_HPUX_ENV */
/* allocate space for sender */
void *
osi_AllocSmallSpace(size_t size)
{
register struct osi_packet *tp;
-#if defined(AFS_AIX32_ENV)
- int x;
-#endif
-#if defined(AFS_HPUX_ENV)
- ulong_t x;
-#endif
AFS_STATCNT(osi_AllocSmallSpace);
if (size > AFS_SMALLOCSIZ)
osi_Panic("osi_AllocSmallS: size=%d\n", size);
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- /*
- * We're running out of free blocks (< 50); get some more ourselves so that
- * when we don't run out of them when called under splnet() (from rx);
- */
- if (((afs_stats_cmperf.SmallBlocksAlloced -
- afs_stats_cmperf.SmallBlocksActive)
- <= AFS_SALLOC_LOW_WATER) || !freeSmallList) {
- osi_AllocMoreSSpace(AFS_SALLOC_LOW_WATER * 2);
- }
-#else
if (!freeSmallList) {
afs_stats_cmperf.SmallBlocksAlloced++;
afs_stats_cmperf.SmallBlocksActive++;
return afs_osi_Alloc(AFS_SMALLOCSIZ);
}
-#endif
afs_stats_cmperf.SmallBlocksActive++;
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT); */
-#else
MObtainWriteLock(&osi_fsplock, 327);
-#endif
tp = freeSmallList;
if (tp)
freeSmallList = tp->next;
-#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)
- splx(x); /*unlockl(&osi_fsplock); */
-#else
MReleaseWriteLock(&osi_fsplock);
-#endif
return (char *)tp;
}
@@ -362,10 +157,7 @@
unpin(tp, AFS_SMALLOCSIZ);
#endif
}
- afs_preallocs = 512;
-#ifndef AFS_AIX32_ENV
LOCK_INIT(&osi_fsplock, "osi_fsplock");
-#endif
LOCK_INIT(&osi_flplock, "osi_flplock");
}
}
diff -wru ../openafs-1.3.79.orig/src/afs/afs_prototypes.h
./src/afs/afs_prototypes.h
--- ../openafs-1.3.79.orig/src/afs/afs_prototypes.h Tue Dec 7 07:12:12 2004
+++ ./src/afs/afs_prototypes.h Mon Mar 14 10:28:29 2005
@@ -514,20 +514,13 @@
/* afs_osi_alloc.c */
#ifndef AFS_FBSD_ENV
-extern afs_int32 afs_preallocs;
extern afs_lock_t osi_fsplock;
extern afs_lock_t osi_flplock;
#endif
extern void osi_FreeLargeSpace(void *adata);
-extern void osi_FreeMediumSpace(void *adata);
extern void osi_FreeSmallSpace(void *adata);
extern void *osi_AllocLargeSpace(size_t size);
-extern void *osi_AllocMediumSpace(size_t size);
extern void *osi_AllocSmallSpace(size_t size);
-#ifndef osi_AllocSmall
-extern char *osi_AllocSmall(register afs_int32 size,
- register afs_int32 morespace);
-#endif
/* afs_osi_uio.c */
extern int afsio_copy(struct uio *ainuio, struct uio *aoutuio,
diff -wru ../openafs-1.3.79.orig/src/afs/sysincludes.h ./src/afs/sysincludes.h
--- ../openafs-1.3.79.orig/src/afs/sysincludes.h Mon Feb 21 02:13:58 2005
+++ ./src/afs/sysincludes.h Tue Mar 15 08:54:06 2005
@@ -328,10 +328,6 @@
#include "rpc/types.h"
#include "rx/xdr.h"
-#ifdef AFS_AIX32_ENV
-# include "net/spl.h"
-#endif
-
/* Miscellaneous headers */
#include "h/proc.h"
#if !defined(AFS_FBSD_ENV)
diff -wru ../openafs-1.3.79.orig/src/lwp/lwp.h ./src/lwp/lwp.h
--- ../openafs-1.3.79.orig/src/lwp/lwp.h Mon Feb 21 02:13:50 2005
+++ ./src/lwp/lwp.h Mon Mar 14 16:22:03 2005
@@ -298,16 +298,10 @@
*/
#if defined(USE_UCONTEXT) && defined(HAVE_UCONTEXT_H)
#define AFS_LWP_MINSTACKSIZE (288 * 1024)
-#else
-#if defined(AFS_LINUX22_ENV)
+#elif defined(AFS_LINUX22_ENV)
#define AFS_LWP_MINSTACKSIZE (192 * 1024)
#else
-#if defined(AFS_AIX52_ENV)
-#define AFS_LWP_MINSTACKSIZE (128 * 1024)
-#else
#define AFS_LWP_MINSTACKSIZE (48 * 1024)
-#endif
-#endif
#endif
/* Action to take on stack overflow. */
diff -wru ../openafs-1.3.79.orig/src/rx/rx.c ./src/rx/rx.c
--- ../openafs-1.3.79.orig/src/rx/rx.c Mon Jan 31 05:14:45 2005
+++ ./src/rx/rx.c Mon Mar 14 15:44:14 2005
@@ -2194,30 +2194,13 @@
{
register char *p;
-#if defined(AFS_AIX41_ENV) && defined(KERNEL)
- /* Grab the AFS filesystem lock. See afs/osi.h for the lock
- * implementation.
- */
- int glockOwner = ISAFS_GLOCK();
- if (!glockOwner)
- AFS_GLOCK();
-#endif
MUTEX_ENTER(&rx_stats_mutex);
rxi_Alloccnt++;
rxi_Allocsize += size;
MUTEX_EXIT(&rx_stats_mutex);
-#if (defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)) &&
!defined(AFS_HPUX100_ENV) && defined(KERNEL)
- if (size > AFS_SMALLOCSIZ) {
- p = (char *)osi_AllocMediumSpace(size);
- } else
- p = (char *)osi_AllocSmall(size, 1);
-#if defined(AFS_AIX41_ENV) && defined(KERNEL)
- if (!glockOwner)
- AFS_GUNLOCK();
-#endif
-#else
+
p = (char *)osi_Alloc(size);
-#endif
+
if (!p)
osi_Panic("rxi_Alloc error");
memset(p, 0, size);
@@ -2227,30 +2210,12 @@
void
rxi_Free(void *addr, register size_t size)
{
-#if defined(AFS_AIX41_ENV) && defined(KERNEL)
- /* Grab the AFS filesystem lock. See afs/osi.h for the lock
- * implementation.
- */
- int glockOwner = ISAFS_GLOCK();
- if (!glockOwner)
- AFS_GLOCK();
-#endif
MUTEX_ENTER(&rx_stats_mutex);
rxi_Alloccnt--;
rxi_Allocsize -= size;
MUTEX_EXIT(&rx_stats_mutex);
-#if (defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV)) &&
!defined(AFS_HPUX100_ENV) && defined(KERNEL)
- if (size > AFS_SMALLOCSIZ)
- osi_FreeMediumSpace(addr);
- else
- osi_FreeSmall(addr);
-#if defined(AFS_AIX41_ENV) && defined(KERNEL)
- if (!glockOwner)
- AFS_GUNLOCK();
-#endif
-#else
+
osi_Free(addr, size);
-#endif
}
/* Find the peer process represented by the supplied (host,port)
diff -wru ../openafs-1.3.79.orig/src/rx/rx_prototypes.h ./src/rx/rx_prototypes.h
--- ../openafs-1.3.79.orig/src/rx/rx_prototypes.h Mon Jan 31 05:34:46 2005
+++ ./src/rx/rx_prototypes.h Tue Mar 15 10:38:23 2005
@@ -551,12 +551,12 @@
extern int rx_getAllAddr(afs_int32 * buffer, int maxSize);
extern void osi_Panic(); /* leave without args till stdarg rewrite */
extern void rxi_InitPeerParams(struct rx_peer *pp);
-#ifdef AFS_AIX32_ENV
-#ifndef osi_Alloc
-extern char *osi_Alloc(afs_int32 x);
-extern void osi_Free(char *x, afs_int32 size);
-#endif
-#endif /* AFS_AIX32_ENV */
+
+#if defined(AFS_AIX32_ENV) && !defined(KERNEL)
+extern void *osi_Alloc(afs_int32 x);
+extern void osi_Free(void *x, afs_int32 size);
+#endif /* defined(AFS_AIX32_ENV) && !defined(KERNEL) */
+
extern void rx_GetIFInfo(void);
extern void rx_SetNoJumbo(void);
diff -wru ../openafs-1.3.79.orig/src/rx/rx_user.c ./src/rx/rx_user.c
--- ../openafs-1.3.79.orig/src/rx/rx_user.c Mon Oct 18 19:43:58 2004
+++ ./src/rx/rx_user.c Tue Mar 15 12:04:03 2005
@@ -233,30 +233,30 @@
(int)file, line);
}
-#ifdef AFS_AIX32_ENV
+#if defined(AFS_AIX32_ENV) && !defined(KERNEL)
#ifndef osi_Alloc
static const char memZero;
-char *
+void *
osi_Alloc(afs_int32 x)
{
/*
- * 0-length allocs may return NULL ptr from osi_kalloc, so we special-case
+ * 0-length allocs may return NULL ptr from malloc, so we special-case
* things so that NULL returned iff an error occurred
*/
if (x == 0)
- return &memZero;
- return ((char *)malloc(x));
+ return (void *)&memZero;
+ return(malloc(x));
}
void
-osi_Free(char *x, afs_int32 size)
+osi_Free(void *x, afs_int32 size)
{
if (x == &memZero)
return;
- free((char *)x);
+ free(x);
}
#endif
-#endif /* AFS_AIX32_ENV */
+#endif /* defined(AFS_AIX32_ENV) && !defined(KERNEL) */
#define ADDRSPERSITE 16
diff -wru ../openafs-1.3.79.orig/src/rxkad/rxkad.p.h ./src/rxkad/rxkad.p.h
--- ../openafs-1.3.79.orig/src/rxkad/rxkad.p.h Tue Dec 7 17:48:43 2004
+++ ./src/rxkad/rxkad.p.h Mon Mar 14 15:46:09 2005
@@ -16,16 +16,7 @@
/* no ticket good for longer than 30 days */
#define MAXKTCTICKETLIFETIME (30*24*3600)
#define MINKTCTICKETLEN 32
-
-#if defined(AFS_AIX52_ENV)
-#ifdef __XCOFF64__
#define MAXKTCTICKETLEN 12000 /* was 344 */
-#else
-#define MAXKTCTICKETLEN 344
-#endif
-#else
-#define MAXKTCTICKETLEN 12000 /* was 344 */
-#endif
#define MAXKTCNAMELEN 64 /* name & inst should be 256 */
#define MAXKTCREALMLEN 64 /* should be 256 */
