make-clearcallback-faster-20050524
[openafs.git] / src / afs / afs_callback.c
index 53611f7..05885e5 100644 (file)
  */
 
 #include <afsconfig.h>
-#include "../afs/param.h"
-
-RCSID("$Header$");
-
-#include "../afs/sysincludes.h" /*Standard vendor system headers*/
-#include "../afs/afsincludes.h" /*AFS-based standard headers*/
-#include "../afs/afs_stats.h"  /*Cache Manager stats*/
-#include "../afs/afs_args.h"
-
-extern struct volume *afs_volumes[NVOLS];   /* volume hash table */
-extern void afs_DequeueCallback();
-extern void afs_ComputePAGStats();
-afs_int32 afs_allCBs   = 0;            /*Break callbacks on all objects */
-afs_int32 afs_oddCBs   = 0;            /*Break callbacks on dirs*/
-afs_int32 afs_evenCBs = 0;             /*Break callbacks received on files*/
-afs_int32 afs_allZaps = 0;             /*Objects entries deleted */
-afs_int32 afs_oddZaps = 0;             /*Dir cache entries deleted*/
-afs_int32 afs_evenZaps = 0;            /*File cache entries deleted*/
+#include "afs/param.h"
+
+RCSID
+    ("$Header$");
+
+#include "afs/sysincludes.h"   /*Standard vendor system headers */
+#include "afsincludes.h"       /*AFS-based standard headers */
+#include "afs/afs_stats.h"     /*Cache Manager stats */
+#include "afs/afs_args.h"
+
+afs_int32 afs_allCBs = 0;      /*Break callbacks on all objects */
+afs_int32 afs_oddCBs = 0;      /*Break callbacks on dirs */
+afs_int32 afs_evenCBs = 0;     /*Break callbacks received on files */
+afs_int32 afs_allZaps = 0;     /*Objects entries deleted */
+afs_int32 afs_oddZaps = 0;     /*Dir cache entries deleted */
+afs_int32 afs_evenZaps = 0;    /*File cache entries deleted */
 afs_int32 afs_connectBacks = 0;
-extern struct rx_service *afs_server;
-
-extern afs_lock_t afs_xvcb, afs_xbrs, afs_xdcache;
-extern afs_rwlock_t afs_xvcache, afs_xserver,  afs_xcell,  afs_xuser;
-extern afs_rwlock_t afs_xvolume, afs_puttofileLock, afs_ftf, afs_xinterface;
-extern afs_rwlock_t afs_xconn;
-extern struct afs_lock afs_xaxs;
-extern afs_lock_t afs_xcbhash;
-extern struct srvAddr *afs_srvAddrs[NSERVERS];
-extern struct afs_q CellLRU;
-extern struct cm_initparams cm_initParams;
 
 /*
  * Some debugging aids.
@@ -51,25 +38,32 @@ extern struct cm_initparams cm_initParams;
 static struct ltable {
     char *name;
     char *addr;
-} ltable []= {
-    "afs_xvcache", (char *)&afs_xvcache,
-    "afs_xdcache", (char *)&afs_xdcache,
-    "afs_xserver", (char *)&afs_xserver,
-    "afs_xvcb",    (char *)&afs_xvcb,
-    "afs_xbrs",    (char *)&afs_xbrs,
-    "afs_xcell",   (char *)&afs_xcell,
-    "afs_xconn",   (char *)&afs_xconn,
-    "afs_xuser",   (char *)&afs_xuser,
-    "afs_xvolume", (char *)&afs_xvolume,
-    "puttofile",   (char *)&afs_puttofileLock,
-    "afs_ftf",     (char *)&afs_ftf,
-    "afs_xcbhash", (char *)&afs_xcbhash,
-    "afs_xaxs",    (char *)&afs_xaxs,
-    "afs_xinterface", (char *)&afs_xinterface,
+} ltable[] = {
+    {
+    "afs_xvcache", (char *)&afs_xvcache}, {
+    "afs_xdcache", (char *)&afs_xdcache}, {
+    "afs_xserver", (char *)&afs_xserver}, {
+    "afs_xvcb", (char *)&afs_xvcb}, {
+    "afs_xbrs", (char *)&afs_xbrs}, {
+    "afs_xcell", (char *)&afs_xcell}, {
+    "afs_xconn", (char *)&afs_xconn}, {
+    "afs_xuser", (char *)&afs_xuser}, {
+    "afs_xvolume", (char *)&afs_xvolume}, {
+    "puttofile", (char *)&afs_puttofileLock}, {
+    "afs_ftf", (char *)&afs_ftf}, {
+    "afs_xcbhash", (char *)&afs_xcbhash}, {
+    "afs_xaxs", (char *)&afs_xaxs}, {
+    "afs_xinterface", (char *)&afs_xinterface},
+#ifndef UKERNEL
+    {
+    "afs_xosi", (char *)&afs_xosi},
+#endif
+    {
+    "afs_xsrvAddr", (char *)&afs_xsrvAddr}
 };
-unsigned long  lastCallBack_vnode;
-unsigned int   lastCallBack_dv;
-osi_timeval_t  lastCallBack_time;
+unsigned long lastCallBack_vnode;
+unsigned int lastCallBack_dv;
+osi_timeval_t lastCallBack_time;
 
 /* these are for storing alternate interface addresses */
 struct interfaceAddr afs_cb_interface;
@@ -97,21 +91,17 @@ struct interfaceAddr afs_cb_interface;
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_GetCE(a_call, a_index, a_result)
-    struct rx_call *a_call;
-    afs_int32 a_index;
-    struct AFSDBCacheEntry *a_result;
-
-{ /*SRXAFSCB_GetCE*/
+int
+SRXAFSCB_GetCE(struct rx_call *a_call, afs_int32 a_index,
+              struct AFSDBCacheEntry *a_result)
+{
 
-    register int i;                    /*Loop variable*/
-    register struct vcache *tvc;       /*Ptr to current cache entry*/
-    int code;                          /*Return code*/
+    register int i;            /*Loop variable */
+    register struct vcache *tvc;       /*Ptr to current cache entry */
+    int code;                  /*Return code */
     XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
 
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETCE);
 
@@ -121,12 +111,12 @@ int SRXAFSCB_GetCE(a_call, a_index, a_result)
            if (a_index == 0)
                goto searchDone;
            a_index--;
-       } /*Zip through current hash chain*/
-    } /*Zip through hash chains*/
+       }                       /*Zip through current hash chain */
+    }                          /*Zip through hash chains */
 
   searchDone:
-    if (tvc == (struct vcache *) 0) {
-       /*Past EOF*/
+    if (tvc == NULL) {
+       /*Past EOF */
        code = 1;
        goto fcnDone;
     }
@@ -159,7 +149,7 @@ int SRXAFSCB_GetCE(a_call, a_index, a_result)
     a_result->Length = tvc->m.Length;
 #endif /* AFS_64BIT_CLIENT */
     a_result->DataVersion = hgetlo(tvc->m.DataVersion);
-    a_result->callback = afs_data_pointer_to_int32(tvc->callback);             /* XXXX Now a pointer; change it XXXX */
+    a_result->callback = afs_data_pointer_to_int32(tvc->callback);     /* XXXX Now a pointer; change it XXXX */
     a_result->cbExpires = tvc->cbExpires;
     a_result->refCount = VREFCOUNT(tvc);
     a_result->opens = tvc->opens;
@@ -171,32 +161,25 @@ int SRXAFSCB_GetCE(a_call, a_index, a_result)
     /*
      * Return our results.
      */
-fcnDone:
+  fcnDone:
     XSTATS_END_TIME;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
-
-    return(code);
+    RX_AFS_GUNLOCK();
 
-} /*SRXAFSCB_GetCE*/
+    return (code);
 
-int SRXAFSCB_GetCE64(a_call, a_index, a_result)
-    struct rx_call *a_call;
-    afs_int32 a_index;
-    struct AFSDBCacheEntry64 *a_result;
+}                              /*SRXAFSCB_GetCE */
 
-{ /*SRXAFSCB_GetCE64*/
-
-    register int i;                    /*Loop variable*/
-    register struct vcache *tvc;       /*Ptr to current cache entry*/
-    int code;                          /*Return code*/
+int
+SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index,
+                struct AFSDBCacheEntry64 *a_result)
+{
+    register int i;            /*Loop variable */
+    register struct vcache *tvc;       /*Ptr to current cache entry */
+    int code;                  /*Return code */
     XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
 
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETCE);
 
@@ -206,12 +189,12 @@ int SRXAFSCB_GetCE64(a_call, a_index, a_result)
            if (a_index == 0)
                goto searchDone;
            a_index--;
-       } /*Zip through current hash chain*/
-    } /*Zip through hash chains*/
+       }                       /*Zip through current hash chain */
+    }                          /*Zip through hash chains */
 
   searchDone:
-    if (tvc == (struct vcache *) 0) {
-       /*Past EOF*/
+    if (tvc == NULL) {
+       /*Past EOF */
        code = 1;
        goto fcnDone;
     }
@@ -238,18 +221,14 @@ int SRXAFSCB_GetCE64(a_call, a_index, a_result)
     a_result->lock.pid_writer = 0;
     a_result->lock.src_indicator = 0;
 #endif /* AFS_OSF20_ENV */
-#ifdef AFS_64BIT_ENV
-    a_result->Length = tvc->m.Length;
-#else /* AFS_64BIT_ENV */
-#ifdef AFS_64BIT_CLIENT
-    a_result->Length = tvc->m.Length;
-#else /* AFS_64BIT_CLIENT */
+#if !defined(AFS_64BIT_ENV) 
     a_result->Length.high = 0;
     a_result->Length.low = tvc->m.Length;
-#endif /* AFS_64BIT_CLIENT */
-#endif /* AFS_64BIT_ENV */
+#else
+    a_result->Length = tvc->m.Length;
+#endif
     a_result->DataVersion = hgetlo(tvc->m.DataVersion);
-    a_result->callback = afs_data_pointer_to_int32(tvc->callback);             /* XXXX Now a pointer; change it XXXX */
+    a_result->callback = afs_data_pointer_to_int32(tvc->callback);     /* XXXX Now a pointer; change it XXXX */
     a_result->cbExpires = tvc->cbExpires;
     a_result->refCount = VREFCOUNT(tvc);
     a_result->opens = tvc->opens;
@@ -261,16 +240,14 @@ int SRXAFSCB_GetCE64(a_call, a_index, a_result)
     /*
      * Return our results.
      */
-fcnDone:
+  fcnDone:
     XSTATS_END_TIME;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
-    return(code);
+    return (code);
 
-} /*SRXAFSCB_GetCE64*/
+}                              /*SRXAFSCB_GetCE64 */
 
 
 /*------------------------------------------------------------------------
@@ -297,57 +274,62 @@ fcnDone:
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_GetLock (a_call, a_index, a_result)
-    struct rx_call *a_call;
-    afs_int32 a_index;
-    struct AFSDBLock *a_result;
-
-{ /*SRXAFSCB_GetLock*/
-
-    struct ltable *tl;         /*Ptr to lock table entry*/
-    int nentries;              /*Num entries in table*/
-    int code;                  /*Return code*/
+int
+SRXAFSCB_GetLock(struct rx_call *a_call, afs_int32 a_index,
+                struct AFSDBLock *a_result)
+{
+    struct ltable *tl;         /*Ptr to lock table entry */
+    int nentries;              /*Num entries in table */
+    int code;                  /*Return code */
     XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
 
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETLOCK);
-    
+
     AFS_STATCNT(SRXAFSCB_GetLock);
-    nentries = sizeof(ltable)/sizeof(struct ltable);
+    nentries = sizeof(ltable) / sizeof(struct ltable);
     if (a_index < 0 || a_index >= nentries) {
        /*
-         * Past EOF
-         */
+        * Past EOF
+        */
        code = 1;
-    }
-    else {
+    } else {
        /*
         * Found it - copy out its contents.
         */
        tl = &ltable[a_index];
        strcpy(a_result->name, tl->name);
-       a_result->lock.waitStates = ((struct afs_lock *)(tl->addr))->wait_states;
-       a_result->lock.exclLocked = ((struct afs_lock *)(tl->addr))->excl_locked;
-       a_result->lock.readersReading = ((struct afs_lock *)(tl->addr))->readers_reading;
-       a_result->lock.numWaiting = ((struct afs_lock *)(tl->addr))->num_waiting;
-       a_result->lock.pid_last_reader = ((struct afs_lock *)(tl->addr))->pid_last_reader;
-       a_result->lock.pid_writer = ((struct afs_lock *)(tl->addr))->pid_writer;
-       a_result->lock.src_indicator = ((struct afs_lock *)(tl->addr))->src_indicator;
+       a_result->lock.waitStates =
+           ((struct afs_lock *)(tl->addr))->wait_states;
+       a_result->lock.exclLocked =
+           ((struct afs_lock *)(tl->addr))->excl_locked;
+       a_result->lock.readersReading =
+           ((struct afs_lock *)(tl->addr))->readers_reading;
+       a_result->lock.numWaiting =
+           ((struct afs_lock *)(tl->addr))->num_waiting;
+#ifdef INSTRUMENT_LOCKS
+       a_result->lock.pid_last_reader =
+           ((struct afs_lock *)(tl->addr))->pid_last_reader;
+       a_result->lock.pid_writer =
+           ((struct afs_lock *)(tl->addr))->pid_writer;
+       a_result->lock.src_indicator =
+           ((struct afs_lock *)(tl->addr))->src_indicator;
+#else
+       a_result->lock.pid_last_reader = 0;
+       a_result->lock.pid_writer = 0;
+       a_result->lock.src_indicator = 0;
+#endif
        code = 0;
     }
 
     XSTATS_END_TIME;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
-    return(code);
+    return (code);
 
-}  /*SRXAFSCB_GetLock*/
+}                              /*SRXAFSCB_GetLock */
 
 
 /*------------------------------------------------------------------------
@@ -371,21 +353,24 @@ int SRXAFSCB_GetLock (a_call, a_index, a_result)
  *
  * Side Effects:
  *     As advertised.
- *------------------------------------------------------------------------*/
 
-static ClearCallBack(a_conn, a_fid)
-    register struct rx_connection *a_conn;
-    register struct AFSFid *a_fid;
+Appears to need to be called with GLOCK held, as the icl_Event4 stuff asserts otherwise
 
-{ /*ClearCallBack*/
+ *------------------------------------------------------------------------*/
 
+static int
+ClearCallBack(register struct rx_connection *a_conn,
+             register struct AFSFid *a_fid)
+{
     register struct vcache *tvc;
     register int i;
     struct VenusFid localFid;
-    struct volume * tv;
+    struct volume *tv;
 
     AFS_STATCNT(ClearCallBack);
 
+    AFS_ASSERT_GLOCK();
+
     /*
      * XXXX Don't hold any server locks here because of callback protocol XXX
      */
@@ -395,38 +380,39 @@ static ClearCallBack(a_conn, a_fid)
     localFid.Fid.Unique = a_fid->Unique;
 
     /*
-      * Volume ID of zero means don't do anything.
-      */
+     * Volume ID of zero means don't do anything.
+     */
     if (a_fid->Volume != 0) {
        if (a_fid->Vnode == 0) {
            /*
             * Clear callback for the whole volume.  Zip through the
             * hash chain, nullifying entries whose volume ID matches.
             */
-           for (i = 0; i < VCSIZE; i++)
-               for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
+               i = VCHashV(&localFid);
+               for (tvc = afs_vhashTV[i]; tvc; tvc = tvc->vhnext) {
                    if (tvc->fid.Fid.Volume == a_fid->Volume) {
-                       tvc->callback = (struct server *)0;
-                       tvc->quick.stamp = 0; 
+                       tvc->callback = NULL;
+                       tvc->quick.stamp = 0;
                        if (!localFid.Cell)
                            localFid.Cell = tvc->fid.Cell;
-                       tvc->h1.dchint = NULL; /* invalidate hints */
+                       tvc->h1.dchint = NULL;  /* invalidate hints */
                        ObtainWriteLock(&afs_xcbhash, 449);
                        afs_DequeueCallback(tvc);
                        tvc->states &= ~(CStatd | CUnique | CBulkFetching);
                        afs_allCBs++;
                        if (tvc->fid.Fid.Vnode & 1)
-                         afs_oddCBs++; 
+                           afs_oddCBs++;
                        else
-                         afs_evenCBs++; 
+                           afs_evenCBs++;
                        ReleaseWriteLock(&afs_xcbhash);
                        if (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR))
                            osi_dnlc_purgedp(tvc);
                        afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK,
-                                  ICL_TYPE_POINTER, tvc, 
-                                  ICL_TYPE_INT32, tvc->states,
-                                  ICL_TYPE_INT32, a_fid->Volume);
-                   } else if ((tvc->states & CMValid) && (tvc->mvid->Fid.Volume == a_fid->Volume)) {
+                                  ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32,
+                                  tvc->states, ICL_TYPE_INT32,
+                                  a_fid->Volume);
+                   } else if ((tvc->states & CMValid)
+                              && (tvc->mvid->Fid.Volume == a_fid->Volume)) {
                        tvc->states &= ~CMValid;
                        if (!localFid.Cell)
                            localFid.Cell = tvc->mvid->Cell;
@@ -438,28 +424,28 @@ static ClearCallBack(a_conn, a_fid)
             */
            tv = afs_FindVolume(&localFid, 0);
            if (tv) {
-             afs_ResetVolumeInfo(tv);
-             afs_PutVolume(tv, 0);
-             /* invalidate mtpoint? */
+               afs_ResetVolumeInfo(tv);
+               afs_PutVolume(tv, 0);
+               /* invalidate mtpoint? */
            }
-       } /*Clear callbacks for whole volume*/
+       } /*Clear callbacks for whole volume */
        else {
            /*
             * Clear callbacks just for the one file.
             */
            afs_allCBs++;
            if (a_fid->Vnode & 1)
-               afs_oddCBs++;   /*Could do this on volume basis, too*/
+               afs_oddCBs++;   /*Could do this on volume basis, too */
            else
-               afs_evenCBs++; /*A particular fid was specified*/
+               afs_evenCBs++;  /*A particular fid was specified */
            i = VCHash(&localFid);
            for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
                if (tvc->fid.Fid.Vnode == a_fid->Vnode
                    && tvc->fid.Fid.Volume == a_fid->Volume
-                   && tvc->fid.Fid.Unique == a_fid->Unique ) {
-                   tvc->callback = (struct server *)0;
-                   tvc->quick.stamp = 0; 
-                   tvc->h1.dchint = NULL; /* invalidate hints */
+                   && tvc->fid.Fid.Unique == a_fid->Unique) {
+                   tvc->callback = NULL;
+                   tvc->quick.stamp = 0;
+                   tvc->h1.dchint = NULL;      /* invalidate hints */
                    ObtainWriteLock(&afs_xcbhash, 450);
                    afs_DequeueCallback(tvc);
                    tvc->states &= ~(CStatd | CUnique | CBulkFetching);
@@ -467,24 +453,25 @@ static ClearCallBack(a_conn, a_fid)
                    if (a_fid->Vnode & 1 || (vType(tvc) == VDIR))
                        osi_dnlc_purgedp(tvc);
                    afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK,
-                              ICL_TYPE_POINTER, tvc, 
-                              ICL_TYPE_INT32, tvc->states, ICL_TYPE_LONG, 0);
+                              ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32,
+                              tvc->states, ICL_TYPE_LONG, 0);
 #ifdef CBDEBUG
                    lastCallBack_vnode = afid->Vnode;
                    lastCallBack_dv = tvc->mstat.DataVersion.low;
                    osi_GetuTime(&lastCallBack_time);
 #endif /* CBDEBUG */
                }
-           } /*Walk through hash table*/
-       } /*Clear callbacks for one file*/
-    } /*Fid has non-zero volume ID*/
+           }                   /*Walk through hash table */
+       }                       /*Clear callbacks for one file */
+    }
 
+    /*Fid has non-zero volume ID */
     /*
      * Always return a predictable value.
      */
-    return(0);
+    return (0);
 
-} /*ClearCallBack*/
+}                              /*ClearCallBack */
 
 
 /*------------------------------------------------------------------------
@@ -510,45 +497,39 @@ static ClearCallBack(a_conn, a_fid)
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_CallBack(a_call, a_fids, a_callbacks)
-    struct rx_call *a_call;
-    register struct AFSCBFids *a_fids;
-    struct AFSCBs *a_callbacks;
-    
-{ /*SRXAFSCB_CallBack*/
-
-    register int i;                        /*Loop variable*/
-    struct AFSFid *tfid;                   /*Ptr to current fid*/
-    register struct rx_connection *tconn;   /*Call's connection*/
-    int code=0;
+int
+SRXAFSCB_CallBack(struct rx_call *a_call, register struct AFSCBFids *a_fids,
+                 struct AFSCBs *a_callbacks)
+{
+    register int i;            /*Loop variable */
+    struct AFSFid *tfid;       /*Ptr to current fid */
+    register struct rx_connection *tconn;      /*Call's connection */
+    int code = 0;
     XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
 
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_CALLBACK);
 
     AFS_STATCNT(SRXAFSCB_CallBack);
-    if (!(tconn = rx_ConnectionOf(a_call))) return;
-    tfid = (struct AFSFid *) a_fids->AFSCBFids_val;
-    
+    if (!(tconn = rx_ConnectionOf(a_call)))
+       return (0);
+    tfid = (struct AFSFid *)a_fids->AFSCBFids_val;
+
     /*
      * For now, we ignore callbacks, since the File Server only *breaks*
      * callbacks at present.
      */
-    for (i = 0; i < a_fids->AFSCBFids_len; i++) 
+    for (i = 0; i < a_fids->AFSCBFids_len; i++)
        ClearCallBack(tconn, &tfid[i]);
 
     XSTATS_END_TIME;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
-    
-    return(0);
+    RX_AFS_GUNLOCK();
+
+    return (0);
 
-} /*SRXAFSCB_CallBack*/
+}                              /*SRXAFSCB_CallBack */
 
 
 /*------------------------------------------------------------------------
@@ -572,28 +553,23 @@ int SRXAFSCB_CallBack(a_call, a_fids, a_callbacks)
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_Probe(a_call)
-    struct rx_call *a_call;
-
-{ /*SRXAFSCB_Probe*/
+int
+SRXAFSCB_Probe(struct rx_call *a_call)
+{
     int code = 0;
     XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
     AFS_STATCNT(SRXAFSCB_Probe);
 
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_PROBE);
     XSTATS_END_TIME;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
-    return(0);
+    return (0);
 
-} /*SRXAFSCB_Probe*/
+}                              /*SRXAFSCB_Probe */
 
 
 /*------------------------------------------------------------------------
@@ -616,23 +592,18 @@ int SRXAFSCB_Probe(a_call)
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_InitCallBackState(a_call)
-    struct rx_call *a_call;
-
-{ /*SRXAFSCB_InitCallBackState*/
-
+int
+SRXAFSCB_InitCallBackState(struct rx_call *a_call)
+{
     register int i;
     register struct vcache *tvc;
     register struct rx_connection *tconn;
     register struct rx_peer *peer;
     struct server *ts;
     int code = 0;
-    extern int osi_dnlc_purge();
     XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
 
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_INITCALLBACKSTATE);
     AFS_STATCNT(SRXAFSCB_InitCallBackState);
@@ -643,49 +614,48 @@ int SRXAFSCB_InitCallBackState(a_call)
     if ((tconn = rx_ConnectionOf(a_call)) && (peer = rx_PeerOf(tconn))) {
 
        afs_allCBs++;
-       afs_oddCBs++;   /*Including any missed via create race*/
-       afs_evenCBs++;  /*Including any missed via create race*/
+       afs_oddCBs++;           /*Including any missed via create race */
+       afs_evenCBs++;          /*Including any missed via create race */
 
-       ts = afs_FindServer(rx_HostOf(peer), rx_PortOf(peer), (afsUUID *)0, 0);
+       ts = afs_FindServer(rx_HostOf(peer), rx_PortOf(peer), (afsUUID *) 0,
+                           0);
        if (ts) {
            for (i = 0; i < VCSIZE; i++)
                for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
                    if (tvc->callback == ts) {
                        ObtainWriteLock(&afs_xcbhash, 451);
                        afs_DequeueCallback(tvc);
-                       tvc->callback = (struct server *)0;
+                       tvc->callback = NULL;
                        tvc->states &= ~(CStatd | CUnique | CBulkFetching);
                        ReleaseWriteLock(&afs_xcbhash);
                    }
                }
        }
 
-      
+
+
        /* find any volumes residing on this server and flush their state */
        {
            register struct volume *tv;
            register int j;
-        
-           for (i=0;i<NVOLS;i++) 
-               for (tv = afs_volumes[i]; tv; tv=tv->next) {
-                   for (j=0; j<MAXHOSTS; j++)
+
+           for (i = 0; i < NVOLS; i++)
+               for (tv = afs_volumes[i]; tv; tv = tv->next) {
+                   for (j = 0; j < MAXHOSTS; j++)
                        if (tv->serverHost[j] == ts)
                            afs_ResetVolumeInfo(tv);
                }
        }
-       osi_dnlc_purge(); /* may be a little bit extreme */
+       osi_dnlc_purge();       /* may be a little bit extreme */
     }
 
     XSTATS_END_TIME;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
-    return(0);
+    return (0);
 
-} /*SRXAFSCB_InitCallBackState*/
+}                              /*SRXAFSCB_InitCallBackState */
 
 
 /*------------------------------------------------------------------------
@@ -709,30 +679,24 @@ int SRXAFSCB_InitCallBackState(a_call)
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_XStatsVersion(a_call, a_versionP)
-    struct rx_call *a_call;
-    afs_int32 *a_versionP;
-
-{ /*SRXAFSCB_XStatsVersion*/
-   int code=0;
+int
+SRXAFSCB_XStatsVersion(struct rx_call *a_call, afs_int32 * a_versionP)
+{
+    int code = 0;
 
     XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_XSTATSVERSION);
 
     *a_versionP = AFSCB_XSTAT_VERSION;
 
     XSTATS_END_TIME;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
-    return(0);
-}  /*SRXAFSCB_XStatsVersion*/
+    return (0);
+}                              /*SRXAFSCB_XStatsVersion */
 
 
 /*------------------------------------------------------------------------
@@ -762,24 +726,17 @@ int SRXAFSCB_XStatsVersion(a_call, a_versionP)
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVersionNumP, a_timeP, a_dataP)
-    struct rx_call *a_call;
-    afs_int32 a_clientVersionNum;
-    afs_int32 a_collectionNumber;
-    afs_int32 *a_srvVersionNumP;
-    afs_int32 *a_timeP;
-    AFSCB_CollData *a_dataP;
-
-{ /*SRXAFSCB_GetXStats*/
-
-    register int code;         /*Return value*/
-    afs_int32 *dataBuffP;              /*Ptr to data to be returned*/
-    afs_int32 dataBytes;               /*Bytes in data buffer*/
+int
+SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
+                  afs_int32 a_collectionNumber, afs_int32 * a_srvVersionNumP,
+                  afs_int32 * a_timeP, AFSCB_CollData * a_dataP)
+{
+    register int code;         /*Return value */
+    afs_int32 *dataBuffP;      /*Ptr to data to be returned */
+    afs_int32 dataBytes;       /*Bytes in data buffer */
     XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
 
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETXSTATS);
 
@@ -800,10 +757,10 @@ int SRXAFSCB_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVers
      * no data.
      */
     a_dataP->AFSCB_CollData_len = 0;
-    a_dataP->AFSCB_CollData_val = (afs_int32 *)0;
+    a_dataP->AFSCB_CollData_val = NULL;
 #else
-    switch(a_collectionNumber) {
-      case AFSCB_XSTATSCOLL_CALL_INFO:
+    switch (a_collectionNumber) {
+    case AFSCB_XSTATSCOLL_CALL_INFO:
        /*
         * Pass back all the call-count-related data.
         *
@@ -812,13 +769,13 @@ int SRXAFSCB_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVers
         * >>> will be freed at the tail end of the server stub code.
         */
        dataBytes = sizeof(struct afs_CMStats);
-       dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes);
+       dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
        memcpy((char *)dataBuffP, (char *)&afs_cmstats, dataBytes);
-       a_dataP->AFSCB_CollData_len = dataBytes>>2;
+       a_dataP->AFSCB_CollData_len = dataBytes >> 2;
        a_dataP->AFSCB_CollData_val = dataBuffP;
        break;
 
-      case AFSCB_XSTATSCOLL_PERF_INFO:
+    case AFSCB_XSTATSCOLL_PERF_INFO:
        /*
         * Update and then pass back all the performance-related data.
         * Note: the only performance fields that need to be computed
@@ -832,13 +789,13 @@ int SRXAFSCB_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVers
        afs_stats_cmperf.numPerfCalls++;
        afs_CountServers();
        dataBytes = sizeof(afs_stats_cmperf);
-       dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes);
+       dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
        memcpy((char *)dataBuffP, (char *)&afs_stats_cmperf, dataBytes);
-       a_dataP->AFSCB_CollData_len = dataBytes>>2;
+       a_dataP->AFSCB_CollData_len = dataBytes >> 2;
        a_dataP->AFSCB_CollData_val = dataBuffP;
        break;
 
-      case AFSCB_XSTATSCOLL_FULL_PERF_INFO:
+    case AFSCB_XSTATSCOLL_FULL_PERF_INFO:
        /*
         * Pass back the full range of performance and statistical
         * data available.  We have to bring the normal performance
@@ -851,35 +808,34 @@ int SRXAFSCB_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVers
         */
        afs_stats_cmperf.numPerfCalls++;
        afs_CountServers();
-       memcpy((char *)(&(afs_stats_cmfullperf.perf)), (char *)(&afs_stats_cmperf), sizeof(struct afs_stats_CMPerf));
+       memcpy((char *)(&(afs_stats_cmfullperf.perf)),
+              (char *)(&afs_stats_cmperf), sizeof(struct afs_stats_CMPerf));
        afs_stats_cmfullperf.numFullPerfCalls++;
 
        dataBytes = sizeof(afs_stats_cmfullperf);
-       dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes);
+       dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
        memcpy((char *)dataBuffP, (char *)(&afs_stats_cmfullperf), dataBytes);
-       a_dataP->AFSCB_CollData_len = dataBytes>>2;
+       a_dataP->AFSCB_CollData_len = dataBytes >> 2;
        a_dataP->AFSCB_CollData_val = dataBuffP;
        break;
 
-      default:
+    default:
        /*
         * Illegal collection number.
         */
        a_dataP->AFSCB_CollData_len = 0;
-       a_dataP->AFSCB_CollData_val = (afs_int32 *)0;
+       a_dataP->AFSCB_CollData_val = NULL;
        code = 1;
-    } /*Switch on collection number*/
+    }                          /*Switch on collection number */
 #endif /* AFS_NOSTATS */
 
     XSTATS_END_TIME;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
-    return(code);
+    return (code);
 
-} /*SRXAFSCB_GetXStats*/
+}                              /*SRXAFSCB_GetXStats */
 
 
 /*------------------------------------------------------------------------
@@ -901,9 +857,9 @@ int SRXAFSCB_GetXStats(a_call, a_clientVersionNum, a_collectionNumber, a_srvVers
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int afs_RXCallBackServer()
-
-{ /*afs_RXCallBackServer*/
+int
+afs_RXCallBackServer(void)
+{
     AFS_STATCNT(afs_RXCallBackServer);
 
     while (1) {
@@ -916,9 +872,9 @@ int afs_RXCallBackServer()
      * Donate this process to Rx.
      */
     rx_ServerProc();
-    return(0);
+    return (0);
 
-} /*afs_RXCallBackServer*/
+}                              /*afs_RXCallBackServer */
 
 
 /*------------------------------------------------------------------------
@@ -940,22 +896,19 @@ int afs_RXCallBackServer()
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int shutdown_CB() 
-
-{ /*shutdown_CB*/
-
-  extern int afs_cold_shutdown;
-
-  AFS_STATCNT(shutdown_CB);
+int
+shutdown_CB(void)
+{
+    AFS_STATCNT(shutdown_CB);
 
-  if (afs_cold_shutdown) {
-    afs_oddCBs = afs_evenCBs = afs_allCBs = afs_allZaps = afs_oddZaps = afs_evenZaps =
-       afs_connectBacks = 0;
-  }
+    if (afs_cold_shutdown) {
+       afs_oddCBs = afs_evenCBs = afs_allCBs = afs_allZaps = afs_oddZaps =
+           afs_evenZaps = afs_connectBacks = 0;
+    }
 
-  return(0);
+    return (0);
 
-} /*shutdown_CB*/
+}                              /*shutdown_CB */
 
 /*------------------------------------------------------------------------
  * EXPORTED SRXAFSCB_InitCallBackState2
@@ -977,11 +930,11 @@ int shutdown_CB()
  *      None
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_InitCallBackState2(a_call, addr)
-struct rx_call *a_call;
-struct interfaceAddr * addr;
+int
+SRXAFSCB_InitCallBackState2(struct rx_call *a_call,
+                           struct interfaceAddr *addr)
 {
-       return RXGEN_OPCODE;
+    return RXGEN_OPCODE;
 }
 
 /*------------------------------------------------------------------------
@@ -1008,26 +961,24 @@ struct interfaceAddr * addr;
  *      As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_WhoAreYou(a_call, addr)
-struct rx_call *a_call;
-struct interfaceAddr *addr;
+int
+SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr)
 {
     int i;
     int code = 0;
-    XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
 
     AFS_STATCNT(SRXAFSCB_WhoAreYou);
 
+    memset(addr, 0, sizeof(*addr));
+
     ObtainReadLock(&afs_xinterface);
 
     /* return all network interface addresses */
     addr->numberOfInterfaces = afs_cb_interface.numberOfInterfaces;
     addr->uuid = afs_cb_interface.uuid;
-    for ( i=0; i < afs_cb_interface.numberOfInterfaces; i++) {
+    for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) {
        addr->addr_in[i] = ntohl(afs_cb_interface.addr_in[i]);
        addr->subnetmask[i] = ntohl(afs_cb_interface.subnetmask[i]);
        addr->mtu[i] = ntohl(afs_cb_interface.mtu[i]);
@@ -1035,9 +986,7 @@ struct interfaceAddr *addr;
 
     ReleaseReadLock(&afs_xinterface);
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
     return code;
 }
@@ -1063,9 +1012,8 @@ struct interfaceAddr *addr;
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_InitCallBackState3(a_call, a_uuid)
-struct rx_call *a_call;
-afsUUID *a_uuid;
+int
+SRXAFSCB_InitCallBackState3(struct rx_call *a_call, afsUUID * a_uuid)
 {
     int code;
 
@@ -1076,7 +1024,7 @@ afsUUID *a_uuid;
 
     return code;
 }
+
 
 /*------------------------------------------------------------------------
  * EXPORTED SRXAFSCB_ProbeUuid
@@ -1101,30 +1049,25 @@ afsUUID *a_uuid;
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_ProbeUuid(a_call, a_uuid)
-struct rx_call *a_call;
-afsUUID *a_uuid;
+int
+SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID * a_uuid)
 {
     int code = 0;
     XSTATS_DECLS;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
     AFS_STATCNT(SRXAFSCB_Probe);
 
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_PROBE);
     if (!afs_uuid_equal(a_uuid, &afs_cb_interface.uuid))
-       code = 1; /* failure */
+       code = 1;               /* failure */
     XSTATS_END_TIME;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
     return code;
 }
+
 
 /*------------------------------------------------------------------------
  * EXPORTED SRXAFSCB_GetServerPrefs
@@ -1149,18 +1092,14 @@ afsUUID *a_uuid;
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_GetServerPrefs(
-    struct rx_call *a_call,
-    afs_int32 a_index,
-    afs_int32 *a_srvr_addr,
-    afs_int32 *a_srvr_rank)
+int
+SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index,
+                       afs_int32 * a_srvr_addr, afs_int32 * a_srvr_rank)
 {
     int i, j;
     struct srvAddr *sa;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
     AFS_STATCNT(SRXAFSCB_GetServerPrefs);
 
     ObtainReadLock(&afs_xserver);
@@ -1168,7 +1107,7 @@ int SRXAFSCB_GetServerPrefs(
     /* Search the hash table for the server with this index */
     *a_srvr_addr = 0xffffffff;
     *a_srvr_rank = 0xffffffff;
-    for (i=0, j=0; j < NSERVERS && i <= a_index; j++) {
+    for (i = 0, j = 0; j < NSERVERS && i <= a_index; j++) {
        for (sa = afs_srvAddrs[j]; sa && i <= a_index; sa = sa->next_bkt, i++) {
            if (i == a_index) {
                *a_srvr_addr = ntohl(sa->sa_ip);
@@ -1179,13 +1118,11 @@ int SRXAFSCB_GetServerPrefs(
 
     ReleaseReadLock(&afs_xserver);
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
     return 0;
 }
+
 
 /*------------------------------------------------------------------------
  * EXPORTED SRXAFSCB_GetCellServDB
@@ -1209,46 +1146,40 @@ int SRXAFSCB_GetServerPrefs(
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_GetCellServDB(
-    struct rx_call *a_call,
-    afs_int32 a_index,
-    char **a_name,
-    afs_int32 *a_hosts)
+int
+SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index,
+                      char **a_name, serverList * a_hosts)
 {
-    afs_int32 i, j;
+    afs_int32 i, j = 0;
     struct cell *tcell;
-    struct afs_q *cq, *tq;
     char *t_name, *p_name = NULL;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
     AFS_STATCNT(SRXAFSCB_GetCellServDB);
 
-    memset(a_hosts, 0, AFSMAXCELLHOSTS * sizeof(afs_int32));
-
-    /* search the list for the cell with this index */
-    ObtainReadLock(&afs_xcell);
-    for (i=0, cq = CellLRU.next; cq != &CellLRU && i<= a_index; cq = tq, i++) {
-        tq = QNext(cq);
-       if (i == a_index) {
-           tcell = QTOC(cq);
-           p_name = tcell->cellName;
-           for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++) {
-               a_hosts[j] = ntohl(tcell->cellHosts[j]->addr->sa_ip);
-           }
-       }
-    }
+    tcell = afs_GetCellByIndex(a_index, READ_LOCK);
 
-    if (p_name)
-       i = strlen(p_name);
-    else
+    if (!tcell) {
        i = 0;
-    t_name = (char *)rxi_Alloc(i+1);
+       a_hosts->serverList_val = 0;
+       a_hosts->serverList_len = 0;
+    } else {
+       p_name = tcell->cellName;
+       for (j = 0; j < AFSMAXCELLHOSTS && tcell->cellHosts[j]; j++);
+       i = strlen(p_name);
+       a_hosts->serverList_val =
+           (afs_int32 *) afs_osi_Alloc(j * sizeof(afs_int32));
+       a_hosts->serverList_len = j;
+       for (j = 0; j < AFSMAXCELLHOSTS && tcell->cellHosts[j]; j++)
+           a_hosts->serverList_val[j] =
+               ntohl(tcell->cellHosts[j]->addr->sa_ip);
+       afs_PutCell(tcell, READ_LOCK);
+    }
+
+    t_name = (char *)afs_osi_Alloc(i + 1);
     if (t_name == NULL) {
-#ifdef RX_ENABLE_LOCKS
-       AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+       afs_osi_Free(a_hosts->serverList_val, (j * sizeof(afs_int32)));
+       RX_AFS_GUNLOCK();
        return ENOMEM;
     }
 
@@ -1256,16 +1187,12 @@ int SRXAFSCB_GetCellServDB(
     if (p_name)
        memcpy(t_name, p_name, i);
 
-    ReleaseReadLock(&afs_xcell);
-
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
     *a_name = t_name;
     return 0;
 }
+
 
 /*------------------------------------------------------------------------
  * EXPORTED SRXAFSCB_GetLocalCell
@@ -1287,45 +1214,31 @@ int SRXAFSCB_GetCellServDB(
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_GetLocalCell(
-    struct rx_call *a_call,
-    char **a_name)
+int
+SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name)
 {
     int plen;
     struct cell *tcell;
-    struct afs_q *cq, *tq;
     char *t_name, *p_name = NULL;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
     AFS_STATCNT(SRXAFSCB_GetLocalCell);
 
     /* Search the list for the primary cell. Cell number 1 is only
      * the primary cell is when no other cell is explicitly marked as
      * the primary cell.  */
-    ObtainReadLock(&afs_xcell);
-    for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
-        tq = QNext(cq);
-       tcell = QTOC(cq);
-       if (tcell->states & CPrimary) {
-           p_name = tcell->cellName;
-           break;
-       }
-        if (tcell->cell == 1) {
-           p_name = tcell->cellName;
-       }
-    }
-
+    tcell = afs_GetPrimaryCell(READ_LOCK);
+    if (tcell)
+       p_name = tcell->cellName;
     if (p_name)
        plen = strlen(p_name);
     else
        plen = 0;
-    t_name = (char *)rxi_Alloc(plen+1);
+    t_name = (char *)afs_osi_Alloc(plen + 1);
     if (t_name == NULL) {
-#ifdef RX_ENABLE_LOCKS
-       AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+       if (tcell)
+           afs_PutCell(tcell, READ_LOCK);
+       RX_AFS_GUNLOCK();
        return ENOMEM;
     }
 
@@ -1333,13 +1246,11 @@ int SRXAFSCB_GetLocalCell(
     if (p_name)
        memcpy(t_name, p_name, plen);
 
-    ReleaseReadLock(&afs_xcell);
-
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
     *a_name = t_name;
+    if (tcell)
+       afs_PutCell(tcell, READ_LOCK);
     return 0;
 }
 
@@ -1359,10 +1270,9 @@ int SRXAFSCB_GetLocalCell(
  *
  * Returns void.
  */
-static void afs_MarshallCacheConfig(
-    afs_uint32 callerVersion,
-    cm_initparams_v1 *config,
-    afs_uint32 *ptr)
+static void
+afs_MarshallCacheConfig(afs_uint32 callerVersion, cm_initparams_v1 * config,
+                       afs_uint32 * ptr)
 {
     AFS_STATCNT(afs_MarshallCacheConfig);
     /*
@@ -1377,9 +1287,8 @@ static void afs_MarshallCacheConfig(
     *(ptr++) = config->cacheSize;
     *(ptr++) = config->setTime;
     *(ptr++) = config->memCache;
-
 }
+
 
 /*------------------------------------------------------------------------
  * EXPORTED SRXAFSCB_GetCacheConfig
@@ -1406,31 +1315,25 @@ static void afs_MarshallCacheConfig(
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-int SRXAFSCB_GetCacheConfig(
-    struct rx_call *a_call,
-    afs_uint32 callerVersion,
-    afs_uint32 *serverVersion,
-    afs_uint32 *configCount,
-    cacheConfig *config)
+int
+SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion,
+                       afs_uint32 * serverVersion, afs_uint32 * configCount,
+                       cacheConfig * config)
 {
     afs_uint32 *t_config;
     size_t allocsize;
     cm_initparams_v1 cm_config;
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GLOCK();
     AFS_STATCNT(SRXAFSCB_GetCacheConfig);
 
     /*
      * Currently only support version 1
      */
     allocsize = sizeof(cm_initparams_v1);
-    t_config = (afs_uint32 *)rxi_Alloc(allocsize);
+    t_config = (afs_uint32 *) afs_osi_Alloc(allocsize);
     if (t_config == NULL) {
-#ifdef RX_ENABLE_LOCKS
-       AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+       RX_AFS_GUNLOCK();
        return ENOMEM;
     }
 
@@ -1449,11 +1352,9 @@ int SRXAFSCB_GetCacheConfig(
     *serverVersion = AFS_CLIENT_RETRIEVAL_FIRST_EDITION;
     *configCount = allocsize;
     config->cacheConfig_val = t_config;
-    config->cacheConfig_len = allocsize/sizeof(afs_uint32);
+    config->cacheConfig_len = allocsize / sizeof(afs_uint32);
 
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+    RX_AFS_GUNLOCK();
 
     return 0;
 }
@@ -1482,13 +1383,10 @@ int SRXAFSCB_GetCacheConfig(
  *
  * Side Effects:
  *------------------------------------------------------------------------*/
-SRXAFSCB_FetchData(rxcall, Fid, Fd, Position, Length, TotalLength)
-    struct rx_call *rxcall;
-    struct AFSFid *Fid;
-    afs_int32 Fd;
-    afs_int64 Position;
-    afs_int64 Length;
-    afs_int64 *TotalLength;
+int
+SRXAFSCB_FetchData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd,
+                  afs_int64 Position, afs_int64 Length,
+                  afs_int64 * TotalLength)
 {
     return ENOSYS;
 }
@@ -1518,13 +1416,108 @@ SRXAFSCB_FetchData(rxcall, Fid, Fd, Position, Length, TotalLength)
  * Side Effects:
  *      As advertised.
  *------------------------------------------------------------------------*/
-SRXAFSCB_StoreData(rxcall, Fid, Fd, Position, Length, TotalLength)
-    struct rx_call *rxcall;
-    struct AFSFid *Fid;
-    afs_int32 Fd;
-    afs_int64 Position;
-    afs_int64 Length;
-    afs_int64 *TotalLength;
+int
+SRXAFSCB_StoreData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd,
+                  afs_int64 Position, afs_int64 Length,
+                  afs_int64 * TotalLength)
 {
     return ENOSYS;
 }
+
+/*------------------------------------------------------------------------
+ * EXPORTED SRXAFSCB_GetCellByNum
+ *
+ * Description:
+ *     Routine to get information about a cell specified by its
+ *     cell number (returned by GetCE/GetCE64).
+ *
+ * Arguments:
+ *     a_call    : Ptr to Rx call on which this request came in.
+ *     a_cellnum : Input cell number
+ *     a_name    : Output cell name (one zero byte when no such cell).
+ *     a_hosts   : Output cell database servers in host byte order.
+ *
+ * Returns:
+ *     0 on success
+ *
+ * Environment:
+ *     Nothing interesting.
+ *
+ * Side Effects:
+ *     As advertised.
+ *------------------------------------------------------------------------*/
+
+int
+SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
+                     char **a_name, serverList * a_hosts)
+{
+    afs_int32 i, sn;
+    struct cell *tcell;
+
+    RX_AFS_GLOCK();
+    AFS_STATCNT(SRXAFSCB_GetCellByNum);
+
+    a_hosts->serverList_val = 0;
+    a_hosts->serverList_len = 0;
+
+    tcell = afs_GetCellStale(a_cellnum, READ_LOCK);
+    if (!tcell) {
+       *a_name = afs_strdup("");
+       RX_AFS_GUNLOCK();
+       return 0;
+    }
+
+    ObtainReadLock(&tcell->lock);
+    *a_name = afs_strdup(tcell->cellName);
+
+    for (sn = 0; sn < AFSMAXCELLHOSTS && tcell->cellHosts[sn]; sn++);
+    a_hosts->serverList_len = sn;
+    a_hosts->serverList_val =
+       (afs_int32 *) afs_osi_Alloc(sn * sizeof(afs_int32));
+
+    for (i = 0; i < sn; i++)
+       a_hosts->serverList_val[i] = ntohl(tcell->cellHosts[i]->addr->sa_ip);
+    ReleaseReadLock(&tcell->lock);
+    afs_PutCell(tcell, READ_LOCK);
+
+    RX_AFS_GUNLOCK();
+    return 0;
+}
+
+int
+SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call,
+                            struct interfaceAddr *addr,
+                            Capabilities * capabilities)
+{
+    int i;
+    int code = 0;
+    afs_int32 *dataBuffP;
+    afs_int32 dataBytes;
+
+    RX_AFS_GLOCK();
+
+    AFS_STATCNT(SRXAFSCB_WhoAreYou);
+
+    ObtainReadLock(&afs_xinterface);
+
+    /* return all network interface addresses */
+    addr->numberOfInterfaces = afs_cb_interface.numberOfInterfaces;
+    addr->uuid = afs_cb_interface.uuid;
+    for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) {
+       addr->addr_in[i] = ntohl(afs_cb_interface.addr_in[i]);
+       addr->subnetmask[i] = ntohl(afs_cb_interface.subnetmask[i]);
+       addr->mtu[i] = ntohl(afs_cb_interface.mtu[i]);
+    }
+
+    ReleaseReadLock(&afs_xinterface);
+
+    RX_AFS_GUNLOCK();
+
+    dataBytes = 1 * sizeof(afs_int32);
+    dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
+    dataBuffP[0] = CAPABILITY_ERRORTRANS;
+    capabilities->Capabilities_len = dataBytes / sizeof(afs_int32);
+    capabilities->Capabilities_val = dataBuffP;
+
+    return code;
+}