From a5ab24af71efe6b80eb0f78d1979c5ab1d1e594d Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Tue, 27 Aug 2002 23:18:50 +0000 Subject: [PATCH] pin-function-definition-and-ifdef-cleanup-20020827 define if kernel uses pin/unpin to pin memory; cleanup ifdef usage --- src/afs/afs_call.c | 37 ++++++++++++++++--------------------- src/afs/afs_dcache.c | 8 ++++---- src/afs/afs_osi_alloc.c | 10 +++++----- src/afs/afs_vcache.c | 6 +++--- src/config/param.rs_aix42.h | 1 + 5 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index 0fc8ba659..00648ef47 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -46,24 +46,28 @@ char afs_rootVolumeName[64]=""; struct afs_icl_set *afs_iclSetp = (struct afs_icl_set*)0; struct afs_icl_set *afs_iclLongTermSetp = (struct afs_icl_set*)0; -#if defined(AFS_GLOBAL_SUNLOCK) && !defined(AFS_HPUX_ENV) && !defined(AFS_AIX41_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV) - +#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) kmutex_t afs_global_lock; kmutex_t afs_rxglobal_lock; +#endif #if defined(AFS_SGI_ENV) && !defined(AFS_SGI64_ENV) long afs_global_owner; #endif -#endif #if defined(AFS_OSF_ENV) simple_lock_data_t afs_global_lock; -#elif defined(AFS_DARWIN_ENV) +#endif + +#if defined(AFS_DARWIN_ENV) struct lock__bsd__ afs_global_lock; -#elif defined(AFS_FBSD_ENV) +#endif + +#if defined(AFS_FBSD_ENV) struct lock afs_global_lock; struct proc *afs_global_owner; #endif + #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) thread_t afs_global_owner; #endif /* AFS_OSF_ENV */ @@ -560,15 +564,9 @@ long parm, parm2, parm3, parm4, parm5, parm6; } else afs_shutdown(); } - -#if ! defined(AFS_HPUX90_ENV) || defined(AFS_HPUX100_ENV) else if (parm == AFSOP_AFS_VFSMOUNT) { #ifdef AFS_HPUX_ENV -#if defined(AFS_HPUX100_ENV) vfsmount(parm2, parm3, parm4, parm5); -#else - afs_vfs_mount(parm2, parm3, parm4, parm5); -#endif /* AFS_HPUX100_ENV */ #else /* defined(AFS_HPUX_ENV) */ #if defined(KERNEL_HAVE_SETUERROR) setuerror(EINVAL); @@ -577,7 +575,6 @@ long parm, parm2, parm3, parm4, parm5, parm6; #endif #endif /* defined(AFS_HPUX_ENV) */ } -#endif else if (parm == AFSOP_CLOSEWAIT) { afs_SynchronousCloses = 'S'; } @@ -962,9 +959,7 @@ struct afssysa { }; #endif -Afs_syscall (uap, rvp) - register struct afssysa *uap; - rval_t *rvp; +Afs_syscall(register struct afssysa *uap, rval_t *rvp) { int *retval = &rvp->r_val1; #else /* AFS_SUN5_ENV */ @@ -2246,7 +2241,7 @@ int afs_icl_LogUse(register struct afs_icl_log *logp) logp->logSize = ICL_DEFAULT_LOGSIZE; } logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize); #endif } @@ -2262,7 +2257,7 @@ int afs_icl_LogFreeUse(register struct afs_icl_log *logp) if (--logp->setCount == 0) { /* no more users -- free it (but keep log structure around)*/ afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize); #endif logp->firstUsed = logp->firstFree = 0; @@ -2288,11 +2283,11 @@ int afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize) /* free and allocate a new one */ afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize); #endif logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin((char *)logp->datap, sizeof(afs_int32) * logSize); #endif logp->logSize = logSize; @@ -2464,7 +2459,7 @@ int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp, strcpy(setp->name, name); setp->nevents = ICL_DEFAULTEVENTS; setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS); #endif for(i=0; inextp; osi_FreeSmallSpace(setp->name); afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS); #endif for(i=0; i < ICL_LOGSPERSET; i++) { diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index b3033e8d3..2a1027e7d 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -2613,7 +2613,7 @@ struct dcache *afs_MemGetDSlot(register afs_int32 aslot, register struct dcache /* none free, making one is better than a panic */ afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */ tdc = (struct dcache *) afs_osi_Alloc(sizeof (struct dcache)); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin((char *)tdc, sizeof(struct dcache)); /* XXX */ #endif } else { @@ -2706,7 +2706,7 @@ struct dcache *afs_UFSGetDSlot(register afs_int32 aslot, register struct dcache /* none free, making one is better than a panic */ afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */ tdc = (struct dcache *) afs_osi_Alloc(sizeof (struct dcache)); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin((char *)tdc, sizeof(struct dcache)); /* XXX */ #endif } else { @@ -3105,7 +3105,7 @@ void afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, tdp = afs_Initial_freeDSList = (struct dcache *) afs_osi_Alloc(aDentries * sizeof(struct dcache)); memset((char *)tdp, 0, aDentries * sizeof(struct dcache)); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin((char *)afs_indexTable, sizeof(struct dcache *) * afiles);/* XXX */ pin((char *)afs_indexTimes, sizeof(afs_hyper_t) * afiles); /* XXX */ pin((char *)afs_indexFlags, sizeof(char) * afiles); /* XXX */ @@ -3146,7 +3146,7 @@ void shutdown_dcache(void) afs_osi_Free(afs_indexUnique, afs_cacheFiles * sizeof(afs_uint32)); afs_osi_Free(afs_indexFlags, afs_cacheFiles * sizeof(u_char)); afs_osi_Free(afs_Initial_freeDSList, afs_dcentries * sizeof(struct dcache)); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN unpin((char *)afs_dcnextTbl, afs_cacheFiles * sizeof(afs_int32)); unpin((char *)afs_dvnextTbl, afs_cacheFiles * sizeof(afs_int32)); unpin((char *)afs_indexTable, afs_cacheFiles * sizeof(struct dcache *)); diff --git a/src/afs/afs_osi_alloc.c b/src/afs/afs_osi_alloc.c index 8cb9d45ac..5303825a3 100644 --- a/src/afs/afs_osi_alloc.c +++ b/src/afs/afs_osi_alloc.c @@ -43,7 +43,7 @@ void osi_AllocMoreSSpace(register afs_int32 preallocs) char *p; p = (char *) afs_osi_Alloc(AFS_SMALLOCSIZ * preallocs); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin(p, AFS_SMALLOCSIZ * preallocs); /* XXXX */ #endif for (i=0; i < preallocs; i++, p += AFS_SMALLOCSIZ) { @@ -109,7 +109,7 @@ osi_AllocMoreMSpace(register afs_int32 preallocs) char *p; p = (char *) afs_osi_Alloc(AFS_MDALLOCSIZ * preallocs); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin(p, AFS_MDALLOCSIZ * preallocs); /* XXXX */ #endif for (i=0; i < preallocs; i++, p += AFS_MDALLOCSIZ) { @@ -181,7 +181,7 @@ void *osi_AllocLargeSpace(size_t size) afs_stats_cmperf.LargeBlocksAlloced++; p = (char *) afs_osi_Alloc(AFS_LRALLOCSIZ); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN /* * Need to pin this memory since under heavy conditions this memory * could be swapped out; the problem is that we could inside rx where @@ -327,7 +327,7 @@ void shutdown_osinet(void) while ((tp = freePacketList)) { freePacketList = tp->next; afs_osi_Free(tp, AFS_LRALLOCSIZ); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN unpin(tp, AFS_LRALLOCSIZ); #endif } @@ -335,7 +335,7 @@ void shutdown_osinet(void) while ((tp = freeSmallList)) { freeSmallList = tp->next; afs_osi_Free(tp, AFS_SMALLOCSIZ); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN unpin(tp, AFS_SMALLOCSIZ); #endif } diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 36a094f6a..8cee8b8ad 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -787,7 +787,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) /* none free, making one is better than a panic */ afs_stats_cmperf.vcacheXAllocs++; /* count in case we have a leak */ tvc = (struct vcache *) afs_osi_Alloc(sizeof (struct vcache)); -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin((char *)tvc, sizeof(struct vcache)); /* XXX */ #endif #ifdef AFS_MACH_ENV @@ -2652,7 +2652,7 @@ void afs_vcacheInit(int astatSize) tvp[i].nextfree = &(tvp[i+1]); } tvp[astatSize-1].nextfree = NULL; -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN pin((char *)tvp, astatSize * sizeof(struct vcache)); /* XXX */ #endif #endif @@ -2696,7 +2696,7 @@ void shutdown_vcache(void) #if !defined(AFS_OSF_ENV) afs_osi_Free(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache)); #endif -#ifdef AFS_AIX32_ENV +#ifdef KERNEL_HAVE_PIN unpin(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache)); #endif diff --git a/src/config/param.rs_aix42.h b/src/config/param.rs_aix42.h index 4a3f5fcbf..b290e588d 100644 --- a/src/config/param.rs_aix42.h +++ b/src/config/param.rs_aix42.h @@ -45,6 +45,7 @@ #endif #define KERNEL_HAVE_SETUERROR 1 +#define KERNEL_HAVE_PIN 1 /* Extra kernel definitions (from kdefs file) */ #ifdef _KERNEL -- 2.39.5