Remove support for Solaris pre-8
[openafs.git] / src / afs / afs_volume.c
index 77121fa..f2148a5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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
@@ -18,8 +18,6 @@
 #include <afsconfig.h>
 #include "afs/param.h"
 
-RCSID
-    ("$Header$");
 
 #include "afs/stds.h"
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
@@ -33,7 +31,7 @@ RCSID
 #ifdef AFS_SGI62_ENV
 #include "h/hashing.h"
 #endif
-#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN60_ENV)
+#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
 #include <netinet/in_var.h>
 #endif /* ! AFS_HPUX110_ENV */
 #endif /* !defined(UKERNEL) */
@@ -42,12 +40,10 @@ RCSID
 #include "afs/afs_stats.h"     /* afs statistics */
 #include "afs/afs_dynroot.h"
 
-#if    defined(AFS_SUN56_ENV)
+#if    defined(AFS_SUN5_ENV)
 #include <inet/led.h>
 #include <inet/common.h>
-#if     defined(AFS_SUN58_ENV)
 #include <netinet/ip6.h>
-#endif
 #include <inet/ip.h>
 #endif
 
@@ -58,7 +54,7 @@ RCSID
 #endif /* vlserver error base define */
 
 /* Exported variables */
-ino_t volumeInode;             /** Inode for VolumeItems file */
+afs_dcache_id_t volumeInode;   /* Inode for VolumeItems file */
 afs_rwlock_t afs_xvolume;      /** allocation lock for volumes */
 struct volume *afs_freeVolList;
 struct volume *afs_volumes[NVOLS];
@@ -76,15 +72,15 @@ static int inVolList(struct VenusFid *fid, afs_int32 nvols, afs_int32 * vID,
 
 
 /**
- * Convert a volume name to a number; 
+ * Convert a volume name to a number;
  * @param aname Volume name.
  * @return return 0 if can't parse as a number.
  */
 static int
-afs_vtoi(register char *aname)
+afs_vtoi(char *aname)
 {
-    register afs_int32 temp;
-    register int tc;
+    afs_int32 temp;
+    int tc;
     temp = 0;
     AFS_STATCNT(afs_vtoi);
     while ((tc = *aname++)) {
@@ -108,18 +104,20 @@ afs_vtoi(register char *aname)
 static struct fvolume staticFVolume;
 afs_int32 afs_FVIndex = -1;
 
-/** 
- * UFS specific version of afs_GetVolSlot 
+/**
+ * UFS specific version of afs_GetVolSlot
  * @return
  */
 struct volume *
 afs_UFSGetVolSlot(void)
 {
-    register struct volume *tv, **lv;
+    struct volume *tv = NULL, **lv;
     struct osi_file *tfile;
-    register afs_int32 i, code;
+    afs_int32 i = -1, code;
     afs_int32 bestTime;
-    struct volume *bestVp, **bestLp;
+    struct volume *bestVp, *oldLp = NULL, **bestLp = NULL;
+    char *oldname = NULL;
+    afs_int32 oldvtix = -2; /* Initialize to a value that doesn't occur */
 
     AFS_STATCNT(afs_UFSGetVolSlot);
     if (!afs_freeVolList) {
@@ -139,13 +137,19 @@ afs_UFSGetVolSlot(void)
                }
            }
        }
-       if (!bestVp)
-           osi_Panic("getvolslot none");
+       if (!bestVp) {
+           afs_warn("afs_UFSGetVolSlot: no vol slots available\n");
+           goto error;
+       }
        tv = bestVp;
+
+       oldLp = *bestLp;
        *bestLp = tv->next;
-       if (tv->name)
-           afs_osi_Free(tv->name, strlen(tv->name) + 1);
+
+       oldname = tv->name;
        tv->name = NULL;
+
+       oldvtix = tv->vtix;
        /* now write out volume structure to file */
        if (tv->vtix < 0) {
            tv->vtix = afs_volCounter++;
@@ -159,13 +163,16 @@ afs_UFSGetVolSlot(void)
             * next chain
             */
            if (afs_FVIndex != tv->vtix) {
-               tfile = osi_UFSOpen(volumeInode);
+               tfile = osi_UFSOpen(&volumeInode);
                code =
                    afs_osi_Read(tfile, sizeof(struct fvolume) * tv->vtix,
                                 &staticFVolume, sizeof(struct fvolume));
-               if (code != sizeof(struct fvolume))
-                   osi_Panic("read volumeinfo");
                osi_UFSClose(tfile);
+               if (code != sizeof(struct fvolume)) {
+                   afs_warn("afs_UFSGetVolSlot: error %d reading volumeinfo\n",
+                            (int)code);
+                   goto error;
+               }
                afs_FVIndex = tv->vtix;
            }
        }
@@ -176,37 +183,68 @@ afs_UFSGetVolSlot(void)
        staticFVolume.dotdot = tv->dotdot;
        staticFVolume.rootVnode = tv->rootVnode;
        staticFVolume.rootUnique = tv->rootUnique;
-       tfile = osi_UFSOpen(volumeInode);
+       tfile = osi_UFSOpen(&volumeInode);
        code =
            afs_osi_Write(tfile, sizeof(struct fvolume) * afs_FVIndex,
                          &staticFVolume, sizeof(struct fvolume));
-       if (code != sizeof(struct fvolume))
-           osi_Panic("write volumeinfo");
        osi_UFSClose(tfile);
+       if (code != sizeof(struct fvolume)) {
+           afs_warn("afs_UFSGetVolSlot: error %d writing volumeinfo\n",
+                    (int)code);
+           goto error;
+       }
+       if (oldname) {
+           afs_osi_Free(oldname, strlen(oldname) + 1);
+           oldname = NULL;
+       }
     } else {
        tv = afs_freeVolList;
        afs_freeVolList = tv->next;
     }
     return tv;
 
+ error:
+    if (tv) {
+       if (oldvtix == -2) {
+           afs_warn("afs_UFSGetVolSlot: oldvtix is uninitialized\n");
+           return NULL;
+       }
+       if (oldname) {
+           tv->name = oldname;
+           oldname = NULL;
+       }
+       if (oldvtix < 0) {
+           afs_volCounter--;
+           fvTable[i] = staticFVolume.next;
+       }
+       if (bestLp) {
+           *bestLp = oldLp;
+       }
+       tv->vtix = oldvtix;
+       /* we messed with staticFVolume, so make sure someone else
+        * doesn't think it's fine to use */
+       afs_FVIndex = -1;
+    }
+    return NULL;
 }                              /*afs_UFSGetVolSlot */
 
 
 /**
- *   Get an available volume list slot. If the list does not exist, 
+ *   Get an available volume list slot. If the list does not exist,
  * create one containing a single element.
- * @return 
+ * @return
  */
 struct volume *
 afs_MemGetVolSlot(void)
 {
-    register struct volume *tv;
+    struct volume *tv;
 
     AFS_STATCNT(afs_MemGetVolSlot);
     if (!afs_freeVolList) {
        struct volume *newVp;
 
-       newVp = (struct volume *)afs_osi_Alloc(sizeof(struct volume));
+       newVp = afs_osi_Alloc(sizeof(struct volume));
+       osi_Assert(newVp != NULL);
 
        newVp->next = NULL;
        afs_freeVolList = newVp;
@@ -217,7 +255,7 @@ afs_MemGetVolSlot(void)
 
 }                              /*afs_MemGetVolSlot */
 
-/** 
+/**
  *   Reset volume information for all volume structs that
  * point to a speicific server.
  * @param srvp
@@ -231,7 +269,7 @@ afs_ResetVolumes(struct server *srvp)
     /* Find any volumes residing on this server and flush their state */
     for (j = 0; j < NVOLS; j++) {
        for (vp = afs_volumes[j]; vp; vp = vp->next) {
-           for (k = 0; k < MAXHOSTS; k++) {
+           for (k = 0; k < AFS_MAXHOSTS; k++) {
                if (!srvp || (vp->serverHost[k] == srvp)) {
                    vp->serverHost[k] = 0;
                    afs_ResetVolumeInfo(vp);
@@ -243,7 +281,7 @@ afs_ResetVolumes(struct server *srvp)
 }
 
 
-/** 
+/**
  *   Reset volume name to volume id mapping cache.
  * @param flags
  */
@@ -273,7 +311,7 @@ afs_CheckVolumeNames(int flags)
            for (tv = afs_volumes[i]; tv; tv = tv->next)
                ++vsize;
 
-       volumeID = (afs_int32 *) afs_osi_Alloc(2 * vsize * sizeof(*volumeID));
+       volumeID = afs_osi_Alloc(2 * vsize * sizeof(*volumeID));
        cellID = (volumeID) ? volumeID + vsize : 0;
     }
 
@@ -294,7 +332,7 @@ afs_CheckVolumeNames(int flags)
            }
            /* ??? */
            if (flags & (AFS_VOLCHECK_BUSY | AFS_VOLCHECK_FORCE)) {
-               for (j = 0; j < MAXHOSTS; j++)
+               for (j = 0; j < AFS_MAXHOSTS; j++)
                    tv->status[j] = not_busy;
            }
 
@@ -318,25 +356,25 @@ loop:
                if ((flags & (AFS_VOLCHECK_FORCE | AFS_VOLCHECK_MTPTS))
                    || (tvc->mvid
                        && inVolList(tvc->mvid, nvols, volumeID, cellID)))
-                   tvc->states &= ~CMValid;
+                   tvc->f.states &= ~CMValid;
 
                /* If the volume that this file belongs to was reset earlier,
                 * then we should remove its callback.
                 * Again, if forced, always do it.
                 */
-               if ((tvc->states & CRO)
-                   && (inVolList(&tvc->fid, nvols, volumeID, cellID)
+               if ((tvc->f.states & CRO)
+                   && (inVolList(&tvc->f.fid, nvols, volumeID, cellID)
                        || (flags & AFS_VOLCHECK_FORCE))) {
 
-                    if (tvc->states & CVInit) {
+                    if (tvc->f.states & CVInit) {
                         ReleaseReadLock(&afs_xvcache);
-                       afs_osi_Sleep(&tvc->states);
+                       afs_osi_Sleep(&tvc->f.states);
                         goto loop;
                     }
 #ifdef AFS_DARWIN80_ENV
-                    if (tvc->states & CDeadVnode) {
+                    if (tvc->f.states & CDeadVnode) {
                         ReleaseReadLock(&afs_xvcache);
-                       afs_osi_Sleep(&tvc->states);
+                       afs_osi_Sleep(&tvc->f.states);
                         goto loop;
                     }
                    tvp = AFSTOV(tvc);
@@ -357,9 +395,9 @@ loop:
                    ObtainWriteLock(&afs_xcbhash, 485);
                    /* LOCKXXX: We aren't holding tvc write lock? */
                    afs_DequeueCallback(tvc);
-                   tvc->states &= ~CStatd;
+                   tvc->f.states &= ~CStatd;
                    ReleaseWriteLock(&afs_xcbhash);
-                   if (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR))
+                   if (tvc->f.fid.Fid.Vnode & 1 || (vType(tvc) == VDIR))
                        osi_dnlc_purgedp(tvc);
 
 #ifdef AFS_DARWIN80_ENV
@@ -415,7 +453,7 @@ inVolList(struct VenusFid *fid, afs_int32 nvols, afs_int32 * vID,
 /* afs_PutVolume is now a macro in afs.h */
 
 
-/** 
+/**
  *    Return volume struct if we have it cached and it's up-to-date.
  *  Environment: Must be called with afs_xvolume unlocked.
  *  @param afid Volume FID.
@@ -478,12 +516,12 @@ afs_GetVolume(struct VenusFid *afid, struct vrequest *areq,
 
 
 /**
- * 
+ *
  * @param volid Volume ID. If it's 0, get it from the name.
  * @param aname Volume name.
  * @param ve Volume entry.
  * @param tcell The cell containing this volume.
- * @param agood 
+ * @param agood
  * @param type Type of volume.
  * @param areq Request.
  * @return Volume or NULL if failure.
@@ -520,7 +558,7 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell,
                volid = nve->volumeId[whichType];
            } else {
                volid = ove->volumeId[whichType];
-           } 
+           }
        } /* end of if (volid == 0) */
     } /* end of if (!volid) */
 
@@ -536,16 +574,20 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell,
        struct fvolume *tf = 0;
 
        tv = afs_GetVolSlot();
-       memset((char *)tv, 0, sizeof(struct volume));
+       if (!tv) {
+           ReleaseWriteLock(&afs_xvolume);
+           return NULL;
+       }
+       memset(tv, 0, sizeof(struct volume));
        tv->cell = tcell->cellNum;
-       RWLOCK_INIT(&tv->lock, "volume lock");
+       AFS_RWLOCK_INIT(&tv->lock, "volume lock");
        tv->next = afs_volumes[i];      /* thread into list */
        afs_volumes[i] = tv;
        tv->volume = volid;
        for (j = fvTable[FVHash(tv->cell, volid)]; j != 0; j = tf->next) {
            if (afs_FVIndex != j) {
                struct osi_file *tfile;
-               tfile = osi_UFSOpen(volumeInode);
+               tfile = osi_UFSOpen(&volumeInode);
                err =
                    afs_osi_Read(tfile, sizeof(struct fvolume) * j,
                                 &staticFVolume, sizeof(struct fvolume));
@@ -588,6 +630,7 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell,
     if (agood) {
        if (!tv->name) {
            tv->name = afs_osi_Alloc(strlen(aname) + 1);
+           osi_Assert(tv->name != NULL);
            strcpy(tv->name, aname);
        }
     }
@@ -603,14 +646,14 @@ afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell,
  * Seek volume by it's name and attributes.
  * If volume not found, try to add one.
  * @param aname Volume name.
- * @param acell Cell 
+ * @param acell Cell
  * @param agood
  * @param areq
  * @param locktype Type of lock to be used.
- * @return 
+ * @return
  */
 struct volume *
-afs_GetVolumeByName(register char *aname, afs_int32 acell, int agood,
+afs_GetVolumeByName(char *aname, afs_int32 acell, int agood,
                    struct vrequest *areq, afs_int32 locktype)
 {
     afs_int32 i;
@@ -640,7 +683,7 @@ afs_GetVolumeByName(register char *aname, afs_int32 acell, int agood,
 
 /**
  *   Init a new dynroot volume.
- * @param Volume FID. 
+ * @param Volume FID.
  * @return Volume or NULL if not found.
  */
 static struct volume *
@@ -655,6 +698,7 @@ afs_NewDynrootVolume(struct VenusFid *fid)
     if (!tcell)
        return NULL;
     tve = afs_osi_Alloc(sizeof(*tve));
+    osi_Assert(tve != NULL);
     if (!(tcell->states & CHasVolRef))
        tcell->states |= CHasVolRef;
 
@@ -675,7 +719,7 @@ int lastnvcode;
 /**
  * @param aname Volume name.
  * @param acell Cell id.
- * @param agood 
+ * @param agood
  * @param areq Request type.
  * @param locktype Type of lock to be used.
  * @return Volume or NULL if failure.
@@ -691,8 +735,9 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood,
     struct uvldbentry *utve;
     struct cell *tcell;
     char *tbuffer, *ve;
-    struct conn *tconn;
+    struct afs_conn *tconn;
     struct vrequest treq;
+    struct rx_connection *rxconn;
 
     if (strlen(aname) > VL_MAXNAMELEN) /* Invalid volume name */
        return NULL;
@@ -717,45 +762,45 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood,
     do {
        tconn =
            afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum,
-                            &treq, SHARED_LOCK);
+                            &treq, SHARED_LOCK, &rxconn);
        if (tconn) {
-           if (tconn->srvr->server->flags & SNO_LHOSTS) {
+           if (tconn->parent->srvr->server->flags & SNO_LHOSTS) {
                type = 0;
                RX_AFS_GUNLOCK();
-               code = VL_GetEntryByNameO(tconn->id, aname, tve);
+               code = VL_GetEntryByNameO(rxconn, aname, tve);
                RX_AFS_GLOCK();
-           } else if (tconn->srvr->server->flags & SYES_LHOSTS) {
+           } else if (tconn->parent->srvr->server->flags & SYES_LHOSTS) {
                type = 1;
                RX_AFS_GUNLOCK();
-               code = VL_GetEntryByNameN(tconn->id, aname, ntve);
+               code = VL_GetEntryByNameN(rxconn, aname, ntve);
                RX_AFS_GLOCK();
            } else {
                type = 2;
                RX_AFS_GUNLOCK();
-               code = VL_GetEntryByNameU(tconn->id, aname, utve);
+               code = VL_GetEntryByNameU(rxconn, aname, utve);
                RX_AFS_GLOCK();
-               if (!(tconn->srvr->server->flags & SVLSRV_UUID)) {
+               if (!(tconn->parent->srvr->server->flags & SVLSRV_UUID)) {
                    if (code == RXGEN_OPCODE) {
                        type = 1;
                        RX_AFS_GUNLOCK();
-                       code = VL_GetEntryByNameN(tconn->id, aname, ntve);
+                       code = VL_GetEntryByNameN(rxconn, aname, ntve);
                        RX_AFS_GLOCK();
                        if (code == RXGEN_OPCODE) {
                            type = 0;
-                           tconn->srvr->server->flags |= SNO_LHOSTS;
+                           tconn->parent->srvr->server->flags |= SNO_LHOSTS;
                            RX_AFS_GUNLOCK();
-                           code = VL_GetEntryByNameO(tconn->id, aname, tve);
+                           code = VL_GetEntryByNameO(rxconn, aname, tve);
                            RX_AFS_GLOCK();
                        } else if (!code)
-                           tconn->srvr->server->flags |= SYES_LHOSTS;
+                           tconn->parent->srvr->server->flags |= SYES_LHOSTS;
                    } else if (!code)
-                       tconn->srvr->server->flags |= SVLSRV_UUID;
+                       tconn->parent->srvr->server->flags |= SVLSRV_UUID;
                }
                lastnvcode = code;
            }
        } else
            code = -1;
-    } while (afs_Analyze(tconn, code, NULL, &treq, -1, /* no op code for this */
+    } while (afs_Analyze(tconn, rxconn, code, NULL, &treq, -1, /* no op code for this */
                         SHARED_LOCK, tcell));
 
     if (code) {
@@ -770,7 +815,7 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood,
            int i;
            struct server *sp;
            struct srvAddr *sap;
-           for (i = 0; i < MAXCELLHOSTS; i++) {
+           for (i = 0; i < AFS_MAXCELLHOSTS; i++) {
                if ((sp = tcell->cellHosts[i]) == NULL)
                    break;
                for (sap = sp->addr; sap; sap = sap->next_sa)
@@ -800,23 +845,27 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood,
        ve = (char *)ntve;
     else
        ve = (char *)tve;
-    tv = afs_SetupVolume(0, aname, ve, tcell, agood, type, areq);
-    if ((agood == 3) && tv->backVol) {
+    tv = afs_SetupVolume(0, aname, ve, tcell, agood, type, &treq);
+    if ((agood == 3) && tv && tv->backVol) {
        /*
         * This means that very soon we'll ask for the BK volume so
         * we'll prefetch it (well we did already.)
         */
        tv1 =
-           afs_SetupVolume(tv->backVol, (char *)0, ve, tcell, 0, type, areq);
-       tv1->refCount--;
+           afs_SetupVolume(tv->backVol, (char *)0, ve, tcell, 0, type, &treq);
+       if (tv1) {
+           tv1->refCount--;
+       }
     }
-    if ((agood >= 2) && tv->roVol) {
+    if ((agood >= 2) && tv && tv->roVol) {
        /*
         * This means that very soon we'll ask for the RO volume so
         * we'll prefetch it (well we did already.)
         */
-       tv1 = afs_SetupVolume(tv->roVol, NULL, ve, tcell, 0, type, areq);
-       tv1->refCount--;
+       tv1 = afs_SetupVolume(tv->roVol, NULL, ve, tcell, 0, type, &treq);
+       if (tv1) {
+           tv1->refCount--;
+       }
     }
     osi_FreeLargeSpace(tbuffer);
     afs_PutCell(tcell, READ_LOCK);
@@ -826,18 +875,18 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood,
 
 
 
-/** 
+/**
  *   Call this with the volume structure locked; used for new-style vldb requests.
- * @param av Volume 
+ * @param av Volume
  * @param ve
  * @param acell
  */
 void
 InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell)
 {
-    register struct server *ts;
+    struct server *ts;
     struct cell *cellp;
-    register int i, j;
+    int i, j;
     afs_int32 mask;
     afs_uint32 temp;
 
@@ -869,12 +918,12 @@ InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell)
 
     cellp = afs_GetCell(acell, 0);
 
-    /* This volume, av, is locked. Zero out the serverHosts[] array 
-     * so that if afs_GetServer() decides to replace the server 
+    /* This volume, av, is locked. Zero out the serverHosts[] array
+     * so that if afs_GetServer() decides to replace the server
      * struct, we don't deadlock trying to afs_ResetVolumeInfo()
      * this volume.
      */
-    for (j = 0; j < MAXHOSTS; j++) {
+    for (j = 0; j < AFS_MAXHOSTS; j++) {
        av->serverHost[j] = 0;
     }
 
@@ -903,19 +952,19 @@ InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell)
        afs_PutServer(ts, WRITE_LOCK);
        j++;
     }
-    if (j < MAXHOSTS) {
+    if (j < AFS_MAXHOSTS) {
        av->serverHost[j++] = 0;
     }
-    afs_SortServers(av->serverHost, MAXHOSTS);
+    afs_SortServers(av->serverHost, AFS_MAXHOSTS);
 }                              /*InstallVolumeEntry */
 
 
 void
 InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, int acell)
 {
-    register struct server *ts;
+    struct server *ts;
     struct cell *cellp;
-    register int i, j;
+    int i, j;
     afs_int32 mask;
     afs_uint32 temp;
 
@@ -947,12 +996,12 @@ InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, int acell)
 
     cellp = afs_GetCell(acell, 0);
 
-    /* This volume, av, is locked. Zero out the serverHosts[] array 
-     * so that if afs_GetServer() decides to replace the server 
+    /* This volume, av, is locked. Zero out the serverHosts[] array
+     * so that if afs_GetServer() decides to replace the server
      * struct, we don't deadlock trying to afs_ResetVolumeInfo()
      * this volume.
      */
-    for (j = 0; j < MAXHOSTS; j++) {
+    for (j = 0; j < AFS_MAXHOSTS; j++) {
        av->serverHost[j] = 0;
     }
 
@@ -980,10 +1029,10 @@ InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, int acell)
        afs_PutServer(ts, WRITE_LOCK);
        j++;
     }
-    if (j < MAXHOSTS) {
+    if (j < AFS_MAXHOSTS) {
        av->serverHost[j++] = 0;
     }
-    afs_SortServers(av->serverHost, MAXHOSTS);
+    afs_SortServers(av->serverHost, AFS_MAXHOSTS);
 }                              /*InstallNVolumeEntry */
 
 
@@ -991,10 +1040,10 @@ void
 InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell,
                    struct cell *tcell, struct vrequest *areq)
 {
-    register struct server *ts;
-    struct conn *tconn;
+    struct server *ts;
+    struct afs_conn *tconn;
     struct cell *cellp;
-    register int i, j;
+    int i, j;
     afs_uint32 serverid;
     afs_int32 mask;
     int k;
@@ -1027,12 +1076,12 @@ InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell,
 
     cellp = afs_GetCell(acell, 0);
 
-    /* This volume, av, is locked. Zero out the serverHosts[] array 
-     * so that if afs_GetServer() decides to replace the server 
+    /* This volume, av, is locked. Zero out the serverHosts[] array
+     * so that if afs_GetServer() decides to replace the server
      * struct, we don't deadlock trying to afs_ResetVolumeInfo()
      * this volume.
      */
-    for (j = 0; j < MAXHOSTS; j++) {
+    for (j = 0; j < AFS_MAXHOSTS; j++) {
        av->serverHost[j] = 0;
     }
 
@@ -1058,24 +1107,27 @@ InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell,
                && ts->addr) {
                /* uuid, uniquifier, and portal are the same */
            } else {
-               afs_uint32 *addrp, nentries, code, unique;
+               afs_uint32 *addrp, code;
+               afs_int32 nentries, unique;
                bulkaddrs addrs;
                ListAddrByAttributes attrs;
                afsUUID uuid;
+               struct rx_connection *rxconn;
 
-               memset((char *)&attrs, 0, sizeof(attrs));
+               memset(&attrs, 0, sizeof(attrs));
                attrs.Mask = VLADDR_UUID;
                attrs.uuid = ve->serverNumber[i];
-               memset((char *)&uuid, 0, sizeof(uuid));
-               memset((char *)&addrs, 0, sizeof(addrs));
+               memset(&uuid, 0, sizeof(uuid));
+               memset(&addrs, 0, sizeof(addrs));
                do {
                    tconn =
                        afs_ConnByMHosts(tcell->cellHosts, tcell->vlport,
-                                        tcell->cellNum, areq, SHARED_LOCK);
+                                        tcell->cellNum, areq, SHARED_LOCK,
+                                        &rxconn);
                    if (tconn) {
                        RX_AFS_GUNLOCK();
                        code =
-                           VL_GetAddrsU(tconn->id, &attrs, &uuid, &unique,
+                           VL_GetAddrsU(rxconn, &attrs, &uuid, &unique,
                                         &nentries, &addrs);
                        RX_AFS_GLOCK();
                    } else {
@@ -1087,7 +1139,7 @@ InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell,
                        code = VL_NOENT;
 
                } while (afs_Analyze
-                        (tconn, code, NULL, areq, -1, SHARED_LOCK, tcell));
+                        (tconn, rxconn, code, NULL, areq, -1, SHARED_LOCK, tcell));
                if (code) {
                    /* Better handing of such failures; for now we'll simply retry this call */
                    areq->volumeError = 1;
@@ -1101,8 +1153,7 @@ InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell,
                ts = afs_GetServer(addrp, nentries, acell, cellp->fsport,
                                   WRITE_LOCK, &ve->serverNumber[i],
                                   ve->serverUnique[i]);
-               afs_osi_Free(addrs.bulkaddrs_val,
-                            addrs.bulkaddrs_len * sizeof(*addrp));
+               xdr_free((xdrproc_t) xdr_bulkaddrs, &addrs);
            }
        }
        av->serverHost[j] = ts;
@@ -1120,14 +1171,14 @@ InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell,
        j++;
     }
 
-    afs_SortServers(av->serverHost, MAXHOSTS);
+    afs_SortServers(av->serverHost, AFS_MAXHOSTS);
 }                              /*InstallVolumeEntry */
 
 
 /**
- *   Reset volume info for the specified volume strecture. Mark volume 
+ *   Reset volume info for the specified volume strecture. Mark volume
  * to be rechecked next time.
- * @param tv 
+ * @param tv
  */
 void
 afs_ResetVolumeInfo(struct volume *tv)
@@ -1137,7 +1188,7 @@ afs_ResetVolumeInfo(struct volume *tv)
     AFS_STATCNT(afs_ResetVolumeInfo);
     ObtainWriteLock(&tv->lock, 117);
     tv->states |= VRecheck;
-    for (i = 0; i < MAXHOSTS; i++)
+    for (i = 0; i < AFS_MAXHOSTS; i++)
        tv->status[i] = not_busy;
     if (tv->name) {
        afs_osi_Free(tv->name, strlen(tv->name) + 1);