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
*/
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");
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();
#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 {
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. */
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 *
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;
}
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");
}
}
{
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);
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)