viced-avoid-tying-up-all-threads-20070730
[openafs.git] / src / viced / afsfileprocs.c
index d44ca9e..bdbd142 100644 (file)
@@ -42,10 +42,11 @@ RCSID
 #else
 #include <sys/param.h>
 #include <sys/file.h>
-#include <netinet/in.h>
-#include <netdb.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
 
 #ifdef HAVE_STRING_H
 #include <string.h>
@@ -79,9 +80,10 @@ RCSID
 #include <afs/ihandle.h>
 #include <afs/vnode.h>
 #include <afs/volume.h>
-#include <afs/acl.h>
 #include <afs/ptclient.h>
+#include <afs/ptuser.h>
 #include <afs/prs_fs.h>
+#include <afs/acl.h>
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
 #include <sys/stat.h>
@@ -104,20 +106,35 @@ RCSID
 #include <afs/cellconfig.h>
 #include <afs/keys.h>
 
-#include <afs/auth.h>
 #include <signal.h>
 #include <afs/partition.h>
 #include "viced_prototypes.h"
 #include "viced.h"
 #include "host.h"
+#include "callback.h"
 #include <afs/unified_afs.h>
 #include <afs/audit.h>
 #include <afs/afsutil.h>
+#include <afs/dir.h>
+
+extern void SetDirHandle(register DirHandle * dir, register Vnode * vnode);
+extern void FidZap(DirHandle * file);
+extern void FidZero(DirHandle * file);
 
 #ifdef AFS_PTHREAD_ENV
 pthread_mutex_t fileproc_glock_mutex;
 #endif /* AFS_PTHREAD_ENV */
 
+#ifdef O_LARGEFILE
+#define afs_stat       stat64
+#define afs_fstat      fstat64
+#define afs_open       open64
+#else /* !O_LARGEFILE */
+#define afs_stat       stat
+#define afs_fstat      fstat
+#define afs_open       open
+#endif /* !O_LARGEFILE */
+
 
 /* Useful local defines used by this module */
 
@@ -192,28 +209,28 @@ extern afs_int32 readonlyServer;
 /*
  * Externals used by the xstat code.
  */
-extern int VolumeCacheSize, VolumeGets, VolumeReplacements;
+extern VolPkgStats VStats;
 extern int CEs, CEBlocks;
 
 extern int HTs, HTBlocks;
 
 afs_int32 FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
-                           register struct rx_call *Call, afs_int32 Pos,
-                           afs_int32 Len, afs_int32 Int64Mode,
+                           register struct rx_call *Call, afs_sfsize_t Pos,
+                           afs_sfsize_t Len, afs_int32 Int64Mode,
 #if FS_STATS_DETAILED
-                           afs_int32 * a_bytesToFetchP,
-                           afs_int32 * a_bytesFetchedP
+                           afs_sfsize_t * a_bytesToFetchP,
+                           afs_sfsize_t * a_bytesFetchedP
 #endif                         /* FS_STATS_DETAILED */
     );
 
 afs_int32 StoreData_RXStyle(Volume * volptr, Vnode * targetptr,
                            struct AFSFid *Fid, struct client *client,
-                           register struct rx_call *Call, afs_uint32 Pos,
-                           afs_uint32 Length, afs_uint32 FileLength,
+                           register struct rx_call *Call, afs_fsize_t Pos,
+                           afs_fsize_t Length, afs_fsize_t FileLength,
                            int sync,
 #if FS_STATS_DETAILED
-                           afs_int32 * a_bytesToStoreP,
-                           afs_int32 * a_bytesStoredP
+                           afs_sfsize_t * a_bytesToStoreP,
+                           afs_sfsize_t * a_bytesStoredP
 #endif                         /* FS_STATS_DETAILED */
     );
 
@@ -284,13 +301,17 @@ SetVolumeSync(register struct AFSVolSync *async, register Volume * avol)
  */
 static int
 CallPreamble(register struct rx_call *acall, int activecall,
-            struct rx_connection **tconn)
+            struct rx_connection **tconn, struct host **ahostp)
 {
     struct host *thost;
     struct client *tclient;
     int retry_flag = 1;
     int code = 0;
-    char hoststr[16];
+    char hoststr[16], hoststr2[16];
+    struct ubik_client *uclient;
+
+    *ahostp = NULL;
+
     if (!tconn) {
        ViceLog(0, ("CallPreamble: unexpected null tconn!\n"));
        return -1;
@@ -300,9 +321,16 @@ CallPreamble(register struct rx_call *acall, int activecall,
     H_LOCK;
   retry:
     tclient = h_FindClient_r(*tconn);
+    if (!tclient) {
+       ViceLog(0, ("CallPreamble: Couldn't get CPS. Too many lockers\n"));
+       H_UNLOCK;
+       return VBUSY;
+    }
+    thost = tclient->host;
     if (tclient->prfail == 1) {        /* couldn't get the CPS */
        if (!retry_flag) {
            h_ReleaseClient_r(tclient);
+           h_Release_r(thost);
            ViceLog(0, ("CallPreamble: Couldn't get CPS. Fail\n"));
            H_UNLOCK;
            return -1001;
@@ -312,11 +340,23 @@ CallPreamble(register struct rx_call *acall, int activecall,
        /* Take down the old connection and re-read the key file */
        ViceLog(0,
                ("CallPreamble: Couldn't get CPS. Reconnect to ptserver\n"));
+#ifdef AFS_PTHREAD_ENV
+       uclient = (struct ubik_client *)pthread_getspecific(viced_uclient_key);
+
+       /* Is it still necessary to drop this? We hit the net, we should... */
        H_UNLOCK;
-       code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0);
+       if (uclient) 
+           hpr_End(uclient);
+       code = hpr_Initialize(&uclient);
+
+       assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0);
        H_LOCK;
+#else
+       code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0);
+#endif
        if (code) {
            h_ReleaseClient_r(tclient);
+           h_Release_r(thost);
            H_UNLOCK;
            ViceLog(0, ("CallPreamble: couldn't reconnect to ptserver\n"));
            return -1001;
@@ -324,26 +364,27 @@ CallPreamble(register struct rx_call *acall, int activecall,
 
        tclient->prfail = 2;    /* Means re-eval client's cps */
        h_ReleaseClient_r(tclient);
+       h_Release_r(thost);
        goto retry;
     }
 
-    thost = tclient->host;
     tclient->LastCall = thost->LastCall = FT_ApproxTime();
-    if (activecall)            /* For all but "GetTime" calls */
+    if (activecall)            /* For all but "GetTime", "GetStats", and "GetCaps" calls */
        thost->ActiveCall = thost->LastCall;
 
     h_Lock_r(thost);
     if (thost->hostFlags & HOSTDELETED) {
        ViceLog(3,
-               ("Discarded a packet for deleted host %s\n",
-                afs_inet_ntoa_r(thost->host, hoststr)));
+               ("Discarded a packet for deleted host %s:%d\n",
+                afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port)));
        code = VBUSY;           /* raced, so retry */
     } else if ((thost->hostFlags & VENUSDOWN)
               || (thost->hostFlags & HFE_LATER)) {
        if (BreakDelayedCallBacks_r(thost)) {
            ViceLog(0,
-                   ("BreakDelayedCallbacks FAILED for host %s which IS UP.  Possible network or routing failure.\n",
-                    afs_inet_ntoa_r(thost->host, hoststr)));
+                   ("BreakDelayedCallbacks FAILED for host %s:%d which IS UP.  Connection from %s:%d.  Possible network or routing failure.\n",
+                    afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), afs_inet_ntoa_r(rxr_HostOf(*tconn), hoststr2), 
+                    ntohs(rxr_PortOf(*tconn))));
            if (MultiProbeAlternateAddress_r(thost)) {
                ViceLog(0,
                        ("MultiProbe failed to find new address for host %s:%d\n",
@@ -357,8 +398,9 @@ CallPreamble(register struct rx_call *acall, int activecall,
                         ntohs(thost->port)));
                if (BreakDelayedCallBacks_r(thost)) {
                    ViceLog(0,
-                           ("BreakDelayedCallbacks FAILED AGAIN for host %s which IS UP.  Possible network or routing failure.\n",
-                            afs_inet_ntoa_r(thost->host, hoststr)));
+                           ("BreakDelayedCallbacks FAILED AGAIN for host %s:%d which IS UP.  Connection from %s:%d.  Possible network or routing failure.\n",
+                             afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), afs_inet_ntoa_r(rxr_HostOf(*tconn), hoststr2), 
+                             ntohs(rxr_PortOf(*tconn))));
                    code = -1;
                }
            }
@@ -370,25 +412,47 @@ CallPreamble(register struct rx_call *acall, int activecall,
     h_ReleaseClient_r(tclient);
     h_Unlock_r(thost);
     H_UNLOCK;
+    *ahostp = thost;
     return code;
 
 }                              /*CallPreamble */
 
 
 static afs_int32
-CallPostamble(register struct rx_connection *aconn, afs_int32 ret)
+CallPostamble(register struct rx_connection *aconn, afs_int32 ret,
+             struct host *ahost)
 {
     struct host *thost;
     struct client *tclient;
     int translate = 0;
+    int held;
 
     H_LOCK;
     tclient = h_FindClient_r(aconn);
+    if (!tclient) 
+       goto busyout;
     thost = tclient->host;
     if (thost->hostFlags & HERRORTRANS)
        translate = 1;
     h_ReleaseClient_r(tclient);
-    h_Release_r(thost);
+    held = h_Held_r(thost);
+    if (held)
+       h_Release_r(thost);
+    if (ahost && ahost != thost) {
+       char hoststr[16], hoststr2[16]; 
+       ViceLog(0, ("CallPostamble: ahost %s:%d (%x) != thost %s:%d (%x)\n",
+               afs_inet_ntoa_r(ahost->host, hoststr), ntohs(ahost->port),
+               ahost, 
+               afs_inet_ntoa_r(thost->host, hoststr2), ntohs(thost->port),
+               thost));
+       h_Release_r(ahost);
+    } else if (!ahost) {
+       char hoststr[16];       
+       ViceLog(0, ("CallPostamble: null ahost for thost %s:%d (%x)\n",
+               afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port),
+               thost));
+    }
+ busyout:
     H_UNLOCK;
     return (translate ? sys_error_to_et(ret) : ret);
 }                              /*CallPostamble */
@@ -402,7 +466,7 @@ static afs_int32
 CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock)
 {
     int fileCode = 0;
-    int errorCode = -1;
+    afs_int32 local_errorCode, errorCode = -1;
     static struct timeval restartedat = { 0, 0 };
 
     if (fid->Volume == 0 || fid->Vnode == 0)   /* not: || fid->Unique == 0) */
@@ -412,7 +476,7 @@ CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock)
 
        while (1) {
            errorCode = 0;
-           *volptr = VGetVolume(&errorCode, (afs_int32) fid->Volume);
+           *volptr = VGetVolume(&local_errorCode, &errorCode, (afs_int32) fid->Volume);
            if (!errorCode) {
                assert(*volptr);
                break;
@@ -468,19 +532,31 @@ CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock)
                    /* I'm not really worried about when we restarted, I'm   */
                    /* just worried about when the first VBUSY was returned. */
                    TM_GetTimeOfDay(&restartedat, 0);
+                   if (busyonrst) {
+                       FS_LOCK;
+                       afs_perfstats.fs_nBusies++;
+                       FS_UNLOCK;
+                   }
                    return (busyonrst ? VBUSY : VRESTARTING);
                } else {
                    struct timeval now;
                    TM_GetTimeOfDay(&now, 0);
                    if ((now.tv_sec - restartedat.tv_sec) < (11 * 60)) {
+                       if (busyonrst) {
+                           FS_LOCK;
+                           afs_perfstats.fs_nBusies++;
+                           FS_UNLOCK;
+                       }
                        return (busyonrst ? VBUSY : VRESTARTING);
                    } else {
                        return (VRESTARTING);
                    }
                }
            }
-           /* allow read operations on busy volume */
-           else if (errorCode == VBUSY && lock == READ_LOCK) {
+           /* allow read operations on busy volume. 
+            * must check local_errorCode because demand attach fs
+            * can have local_errorCode == VSALVAGING, errorCode == VBUSY */
+           else if (local_errorCode == VBUSY && lock == READ_LOCK) {
                errorCode = 0;
                break;
            } else if (errorCode)
@@ -548,6 +624,33 @@ SetAccessList(Vnode ** targetptr, Volume ** volume,
 
 }                              /*SetAccessList */
 
+/* Must not be called with H_LOCK held */
+static void
+client_CheckRights(struct client *client, struct acl_accessList *ACL, 
+                  afs_int32 *rights)
+{
+    *rights = 0;
+    ObtainReadLock(&client->lock);
+    if (client->CPS.prlist_len > 0 && !client->deleted &&
+       client->host && !(client->host->hostFlags & HOSTDELETED))
+       acl_CheckRights(ACL, &client->CPS, rights);
+    ReleaseReadLock(&client->lock);
+}
+
+/* Must not be called with H_LOCK held */
+static afs_int32
+client_HasAsMember(struct client *client, afs_int32 id)
+{
+    afs_int32 code = 0;
+
+    ObtainReadLock(&client->lock);
+    if (client->CPS.prlist_len > 0 && !client->deleted && 
+       client->host && !(client->host->hostFlags & HOSTDELETED))
+       code = acl_IsAMember(id, &client->CPS);
+    ReleaseReadLock(&client->lock);
+    return code;
+}
+
 /*
  * Compare the directory's ACL with the user's access rights in the client
  * connection and return the user's and everybody else's access permissions
@@ -559,15 +662,17 @@ GetRights(struct client *client, struct acl_accessList *ACL,
 {
     extern prlist SystemAnyUserCPS;
     afs_int32 hrights = 0;
+#ifndef AFS_PTHREAD_ENV
     int code;
+#endif
 
     if (acl_CheckRights(ACL, &SystemAnyUserCPS, anyrights) != 0) {
-
        ViceLog(0, ("CheckRights failed\n"));
        *anyrights = 0;
     }
     *rights = 0;
-    acl_CheckRights(ACL, &client->CPS, rights);
+
+    client_CheckRights(client, ACL, rights);
 
     /* wait if somebody else is already doing the getCPS call */
     H_LOCK;
@@ -582,16 +687,20 @@ GetRights(struct client *client, struct acl_accessList *ACL,
 #endif /* AFS_PTHREAD_ENV */
     }
 
-    if (client->host->hcps.prlist_len && !client->host->hcps.prlist_val) {
-       ViceLog(0,
-               ("CheckRights: len=%d, for host=0x%x\n",
-                client->host->hcps.prlist_len, client->host->host));
+    if (!client->host->hcps.prlist_len || !client->host->hcps.prlist_val) {
+       char hoststr[16];
+       ViceLog(5,
+               ("CheckRights: len=%u, for host=%s:%d\n",
+                client->host->hcps.prlist_len, 
+                afs_inet_ntoa_r(client->host->host, hoststr),
+                ntohs(client->host->port)));
     } else
        acl_CheckRights(ACL, &client->host->hcps, &hrights);
     H_UNLOCK;
     /* Allow system:admin the rights given with the -implicit option */
-    if (acl_IsAMember(SystemId, &client->CPS))
+    if (client_HasAsMember(client, SystemId))
        *rights |= implicitAdminRights;
+
     *rights |= hrights;
     *anyrights |= hrights;
 
@@ -606,7 +715,7 @@ GetRights(struct client *client, struct acl_accessList *ACL,
 static afs_int32
 VanillaUser(struct client *client)
 {
-    if (acl_IsAMember(SystemId, &client->CPS))
+    if (client_HasAsMember(client, SystemId))
        return (0);             /* not a system administrator, then you're "vanilla" */
     return (1);
 
@@ -645,11 +754,13 @@ GetVolumePackage(struct rx_connection *tcon, AFSFid * Fid, Volume ** volptr,
        return (errorCode);
     if (chkforDir == MustBeDIR)
        assert((*parent) == 0);
-    if ((errorCode = GetClient(tcon, client)) != 0)
-       return (errorCode);
-    if (!(*client))
-       return (EINVAL);
-    assert(GetRights(*client, aCL, rights, anyrights) == 0);
+    if (!(*client)) {
+       if ((errorCode = GetClient(tcon, client)) != 0)
+           return (errorCode);
+       if (!(*client))
+           return (EINVAL);
+    }
+    GetRights(*client, aCL, rights, anyrights);
     /* ok, if this is not a dir, set the PRSFS_ADMINISTER bit iff we're the owner */
     if ((*targetptr)->disk.type != vDirectory) {
        /* anyuser can't be owner, so only have to worry about rights, not anyrights */
@@ -674,7 +785,7 @@ GetVolumePackage(struct rx_connection *tcon, AFSFid * Fid, Volume ** volptr,
  */
 static void
 PutVolumePackage(Vnode * parentwhentargetnotdir, Vnode * targetptr,
-                Vnode * parentptr, Volume * volptr)
+                Vnode * parentptr, Volume * volptr, struct client **client)
 {
     int fileCode = 0;          /* Error code returned by the volume package */
 
@@ -693,6 +804,9 @@ PutVolumePackage(Vnode * parentwhentargetnotdir, Vnode * targetptr,
     if (volptr) {
        VPutVolume(volptr);
     }
+    if (*client) {
+       PutClient(client);
+    }
 }                              /*PutVolumePackage */
 
 static int
@@ -707,7 +821,7 @@ VolumeOwner(register struct client *client, register Vnode * targetptr)
         * We don't have to check for host's cps since only regular
         * viceid are volume owners.
         */
-       return (acl_IsAMember(owner, &client->CPS));
+       return (client_HasAsMember(client, owner));
     }
 
 }                              /*VolumeOwner */
@@ -761,7 +875,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                && targetptr->disk.type == vFile)
 #ifdef USE_GROUP_PERMS
                if (!OWNSp(client, targetptr)
-                   && !acl_IsAMember(targetptr->disk.owner, &client->CPS)) {
+                   && !client_HasAsMember(client, targetptr->disk.owner)) {
                    errorCode =
                        (((GROUPREAD | GROUPEXEC) & targetptr->disk.modeBits)
                         ? 0 : EACCES);
@@ -784,7 +898,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 #endif
        } else {                /*  !VanillaUser(client) && !FetchData */
 
-           osi_audit(PrivilegeEvent, 0, AUD_INT,
+           osi_audit(PrivilegeEvent, 0, AUD_ID,
                      (client ? client->ViceId : 0), AUD_INT, CallingRoutine,
                      AUD_END);
        }
@@ -802,13 +916,13 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                else if (VanillaUser(client))
                    return (EPERM);     /* Was EACCES */
                else
-                   osi_audit(PrivilegeEvent, 0, AUD_INT,
+                   osi_audit(PrivilegeEvent, 0, AUD_ID,
                              (client ? client->ViceId : 0), AUD_INT,
                              CallingRoutine, AUD_END);
            }
        } else {
            if (CallingRoutine != CHK_STOREDATA && !VanillaUser(client)) {
-               osi_audit(PrivilegeEvent, 0, AUD_INT,
+               osi_audit(PrivilegeEvent, 0, AUD_ID,
                          (client ? client->ViceId : 0), AUD_INT,
                          CallingRoutine, AUD_END);
            } else {
@@ -828,7 +942,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                        else if (VanillaUser(client))
                            return (EPERM);     /* Was EACCES */
                        else
-                           osi_audit(PrivilegeEvent, 0, AUD_INT,
+                           osi_audit(PrivilegeEvent, 0, AUD_ID,
                                      (client ? client->ViceId : 0), AUD_INT,
                                      CallingRoutine, AUD_END);
                    }
@@ -844,7 +958,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                        if (VanillaUser(client))
                            return (EACCES);
                        else
-                           osi_audit(PrivSetID, 0, AUD_INT,
+                           osi_audit(PrivSetID, 0, AUD_ID,
                                      (client ? client->ViceId : 0), AUD_INT,
                                      CallingRoutine, AUD_END);
                    }
@@ -865,8 +979,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                        if ((targetptr->disk.type == vFile)
                            && VanillaUser(client)) {
                            if (!OWNSp(client, targetptr)
-                               && !acl_IsAMember(targetptr->disk.owner,
-                                                 &client->CPS)) {
+                               && !client_HasAsMember(client, targetptr->disk.owner)) {
                                errorCode =
                                    ((GROUPWRITE & targetptr->disk.modeBits)
                                     ? 0 : EACCES);
@@ -884,7 +997,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                            if (VanillaUser(client))
                                return (EACCES);
                            else
-                               osi_audit(PrivilegeEvent, 0, AUD_INT,
+                               osi_audit(PrivilegeEvent, 0, AUD_ID,
                                          (client ? client->ViceId : 0),
                                          AUD_INT, CallingRoutine, AUD_END);
                        }
@@ -961,49 +1074,6 @@ RXStore_AccessList(Vnode * targetptr, struct AFSOpaque *AccessList)
 }                              /*RXStore_AccessList */
 
 
-static afs_int32
-Fetch_AccessList(Vnode * targetptr, Vnode * parentwhentargetnotdir,
-                struct AFSAccessList *AccessList)
-{
-    char *eACL;                        /* External access list placeholder */
-
-    assert(acl_Externalize
-          ((targetptr->disk.type ==
-            vDirectory ? VVnodeACL(targetptr) :
-            VVnodeACL(parentwhentargetnotdir)), &eACL) == 0);
-    if ((strlen(eACL) + 1) > AccessList->MaxSeqLen) {
-       acl_FreeExternalACL(&eACL);
-       return (E2BIG);
-    } else {
-       strcpy((char *)(AccessList->SeqBody), (char *)eACL);
-       AccessList->SeqLen = strlen(eACL) + 1;
-    }
-    acl_FreeExternalACL(&eACL);
-    return (0);
-
-}                              /*Fetch_AccessList */
-
-/*
- * The Access List information is converted from its external form in the
- * input AccessList structure to the internal representation and copied into
- * the target dir's vnode storage.
- */
-static afs_int32
-Store_AccessList(Vnode * targetptr, struct AFSAccessList *AccessList)
-{
-    struct acl_accessList *newACL;     /* PlaceHolder for new access list */
-
-    if (acl_Internalize(AccessList->SeqBody, &newACL) != 0)
-       return (EINVAL);
-    if ((newACL->size + 4) > VAclSize(targetptr))
-       return (E2BIG);
-    memcpy((char *)VVnodeACL(targetptr), (char *)newACL, (int)(newACL->size));
-    acl_FreeACL(&newACL);
-    return (0);
-
-}                              /*Store_AccessList */
-
-
 /* In our current implementation, each successive data store (new file
  * data version) creates a new inode. This function creates the new
  * inode, copies the old inode's contents to the new one, remove the old
@@ -1018,8 +1088,8 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
     Inode ino, nearInode;
     int rdlen;
     int wrlen;
-    register int size, length;
-    int ifd, ofd;
+    register afs_fsize_t size;
+    register int length;
     char *buff;
     int rc;                    /* return code */
     IHandle_t *newH;           /* Use until finished copying, then cp to vnode. */
@@ -1036,7 +1106,13 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
     }
 
     ino = VN_GET_INO(targetptr);
-    assert(VALID_INO(ino));
+    if (!VALID_INO(ino)) {
+       free(buff);
+       VTakeOffline(volptr);
+       ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                   volptr->hashid));
+       return EIO;
+    }    
     targFdP = IH_OPEN(targetptr->handle);
     if (targFdP == NULL) {
        rc = errno;
@@ -1072,7 +1148,7 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
            length = COPYBUFFSIZE;
            size -= COPYBUFFSIZE;
        } else {
-           length = size;
+           length = (int)size;
            size = 0;
        }
        rdlen = FDH_READ(targFdP, buff, length);
@@ -1112,10 +1188,10 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
                        ("CopyOnWrite failed: volume %u in partition %s  (tried reading %u, read %u, wrote %u, errno %u) volume needs salvage\n",
                         V_id(volptr), volptr->partition->name, length, rdlen,
                         wrlen, errno));
-#ifdef FAST_RESTART            /* if running in no-salvage, don't core the server */
+#if defined(AFS_DEMAND_ATTACH_FS)
+               ViceLog(0, ("CopyOnWrite failed: requesting salvage\n"));
+#else
                ViceLog(0, ("CopyOnWrite failed: taking volume offline\n"));
-#else /* Avoid further corruption and try to get a core. */
-               assert(0);
 #endif
                /* Decrement this inode so salvager doesn't find it. */
                FDH_REALLYCLOSE(newFdP);
@@ -1203,6 +1279,9 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
       */
     if ((*targetptr)->disk.uniquifier != fileFid->Unique) {
        VTakeOffline(volptr);
+       ViceLog(0,
+               ("Volume %u now offline, must be salvaged.\n",
+                volptr->hashid));
        errorCode = VSALVAGE;
        return errorCode;
     }
@@ -1228,16 +1307,12 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
                        ("DT: inode=%s, name=%s, errno=%d\n",
                         PrintInode(NULL, VN_GET_INO(*targetptr)), Name,
                         errno));
-#ifdef AFS_DEC_ENV
-               if ((errno != ENOENT) && (errno != EIO) && (errno != ENXIO))
-#else
                if (errno != ENOENT)
-#endif
                {
+                   VTakeOffline(volptr);
                    ViceLog(0,
                            ("Volume %u now offline, must be salvaged.\n",
                             volptr->hashid));
-                   VTakeOffline(volptr);
                    return (EIO);
                }
                DT1++;
@@ -1260,10 +1335,10 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
                ("Error %d deleting %s\n", code,
                 (((*targetptr)->disk.type ==
                   Directory) ? "directory" : "file")));
+       VTakeOffline(volptr);
        ViceLog(0,
                ("Volume %u now offline, must be salvaged.\n",
                 volptr->hashid));
-       VTakeOffline(volptr);
        if (!errorCode)
            errorCode = code;
     }
@@ -1298,7 +1373,7 @@ Update_ParentVnodeStatus(Vnode * parentptr, Volume * volptr, DirHandle * dir,
 #endif /* FS_STATS_DETAILED */
 
     parentptr->disk.dataVersion++;
-    newlength = Length(dir);
+    newlength = (afs_fsize_t) Length(dir);
     /* 
      * This is a called on both dir removals (i.e. remove, removedir, rename) but also in dir additions
      * (create, symlink, link, makedir) so we need to check if we have enough space
@@ -1476,12 +1551,12 @@ Update_TargetVnodeStatus(Vnode * targetptr, afs_uint32 Caller,
            targetptr->disk.modeBits = modebits;
            switch (Caller) {
            case TVS_SDATA:
-               osi_audit(PrivSetID, 0, AUD_INT, client->ViceId, AUD_INT,
+               osi_audit(PrivSetID, 0, AUD_ID, client->ViceId, AUD_INT,
                          CHK_STOREDATA, AUD_END);
                break;
            case TVS_CFILE:
            case TVS_SSTATUS:
-               osi_audit(PrivSetID, 0, AUD_INT, client->ViceId, AUD_INT,
+               osi_audit(PrivSetID, 0, AUD_ID, client->ViceId, AUD_INT,
                          CHK_STORESTATUS, AUD_END);
                break;
            default:
@@ -1525,7 +1600,8 @@ SetCallBackStruct(afs_uint32 CallBackTime, struct AFSCallBack *CallBack)
  * enough space before consuming some.
  */
 static afs_int32
-AdjustDiskUsage(Volume * volptr, afs_int32 length, afs_int32 checkLength)
+AdjustDiskUsage(Volume * volptr, afs_sfsize_t length,
+               afs_sfsize_t checkLength)
 {
     int rc;
     int nc;
@@ -1559,7 +1635,7 @@ AdjustDiskUsage(Volume * volptr, afs_int32 length, afs_int32 checkLength)
 static afs_int32
 Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
               Vnode ** targetptr, char *Name, struct AFSFid *OutFid,
-              int FileType, int BlocksPreallocatedForVnode)
+              int FileType, afs_sfsize_t BlocksPreallocatedForVnode)
 {
     int errorCode = 0;         /* Error code returned back */
     int temp;
@@ -1570,8 +1646,8 @@ Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
         AdjustDiskUsage(volptr, BlocksPreallocatedForVnode,
                         BlocksPreallocatedForVnode))) {
        ViceLog(25,
-               ("Insufficient space to allocate %d blocks\n",
-                BlocksPreallocatedForVnode));
+               ("Insufficient space to allocate %lld blocks\n",
+                (afs_intmax_t) BlocksPreallocatedForVnode));
        return (errorCode);
     }
 
@@ -1651,14 +1727,11 @@ Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
  * SAFS_ReleaseLock)
  */
 static afs_int32
-HandleLocking(Vnode * targetptr, afs_int32 rights, ViceLockType LockingType)
+HandleLocking(Vnode * targetptr, struct client *client, afs_int32 rights, ViceLockType LockingType)
 {
     int Time;                  /* Used for time */
     int writeVnode = targetptr->changed_oldTime;       /* save original status */
 
-    /* Does the caller has Lock priviledges; root extends locks, however */
-    if (LockingType != LockExtend && !(rights & PRSFS_LOCK))
-       return (EACCES);
     targetptr->changed_oldTime = 1;    /* locking doesn't affect any time stamp */
     Time = FT_ApproxTime();
     switch (LockingType) {
@@ -1669,12 +1742,22 @@ HandleLocking(Vnode * targetptr, afs_int32 rights, ViceLockType LockingType)
                0;
        Time += AFS_LOCKWAIT;
        if (LockingType == LockRead) {
+           if ( !(rights & PRSFS_LOCK) && 
+                 !(rights & PRSFS_WRITE) &&
+                 !(OWNSp(client, targetptr) && (rights & PRSFS_INSERT)) )
+                    return(EACCES);
+            return(EACCES);
+
            if (targetptr->disk.lock.lockCount >= 0) {
                ++(targetptr->disk.lock.lockCount);
                targetptr->disk.lock.lockTime = Time;
            } else
                return (EAGAIN);
-       } else {
+       } else if (LockingType == LockWrite) {
+           if ( !(rights & PRSFS_WRITE) && 
+                !(OWNSp(client, targetptr) && (rights & PRSFS_INSERT)) )
+               return(EACCES);
+
            if (targetptr->disk.lock.lockCount == 0) {
                targetptr->disk.lock.lockCount = -1;
                targetptr->disk.lock.lockTime = Time;
@@ -1753,80 +1836,6 @@ RXUpdate_VolumeStatus(Volume * volptr, AFSStoreVolumeStatus * StoreVolStatus,
 }                              /*RXUpdate_VolumeStatus */
 
 
-/* old interface */
-static afs_int32
-Update_VolumeStatus(Volume * volptr, VolumeStatus * StoreVolStatus,
-                   struct BBS *Name, struct BBS *OfflineMsg,
-                   struct BBS *Motd)
-{
-    Error errorCode = 0;
-
-    if (StoreVolStatus->MinQuota > -1)
-       V_minquota(volptr) = StoreVolStatus->MinQuota;
-    if (StoreVolStatus->MaxQuota > -1)
-       V_maxquota(volptr) = StoreVolStatus->MaxQuota;
-    if (OfflineMsg->SeqLen > 1)
-       strcpy(V_offlineMessage(volptr), OfflineMsg->SeqBody);
-    if (Name->SeqLen > 1)
-       strcpy(V_name(volptr), Name->SeqBody);
-#if OPENAFS_VOL_STATS
-    /*
-     * We don't overwrite the motd field, since it's now being used
-     * for stats
-     */
-#else
-    if (Motd->SeqLen > 1)
-       strcpy(V_motd(volptr), Motd->SeqBody);
-#endif /* FS_STATS_DETAILED */
-    VUpdateVolume(&errorCode, volptr);
-    return (errorCode);
-
-}                              /*Update_VolumeStatus */
-
-
-/*
- * Get internal volume-related statistics from the Volume disk label
- * structure and put it into the VolumeStatus structure, status; it's
- * used by both SAFS_GetVolumeStatus and SAFS_SetVolumeStatus to return
- * the volume status to the caller.
- */
-static afs_int32
-GetVolumeStatus(VolumeStatus * status, struct BBS *name, struct BBS *offMsg,
-               struct BBS *motd, Volume * volptr)
-{
-    status->Vid = V_id(volptr);
-    status->ParentId = V_parentId(volptr);
-    status->Online = V_inUse(volptr);
-    status->InService = V_inService(volptr);
-    status->Blessed = V_blessed(volptr);
-    status->NeedsSalvage = V_needsSalvaged(volptr);
-    if (VolumeWriteable(volptr))
-       status->Type = ReadWrite;
-    else
-       status->Type = ReadOnly;
-    status->MinQuota = V_minquota(volptr);
-    status->MaxQuota = V_maxquota(volptr);
-    status->BlocksInUse = V_diskused(volptr);
-    status->PartBlocksAvail = volptr->partition->free;
-    status->PartMaxBlocks = volptr->partition->totalUsable;
-    strncpy(name->SeqBody, V_name(volptr), (int)name->MaxSeqLen);
-    name->SeqLen = strlen(V_name(volptr)) + 1;
-    if (name->SeqLen > name->MaxSeqLen)
-       name->SeqLen = name->MaxSeqLen;
-    strncpy(offMsg->SeqBody, V_offlineMessage(volptr), (int)name->MaxSeqLen);
-    offMsg->SeqLen = strlen(V_offlineMessage(volptr)) + 1;
-    if (offMsg->SeqLen > offMsg->MaxSeqLen)
-       offMsg->SeqLen = offMsg->MaxSeqLen;
-#ifdef notdef
-    /*Don't do anything with the motd field */
-    strncpy(motd->SeqBody, nullString, (int)offMsg->MaxSeqLen);
-    motd->SeqLen = strlen(nullString) + 1;
-#endif
-    if (motd->SeqLen > motd->MaxSeqLen)
-       motd->SeqLen = motd->MaxSeqLen;
-
-}                              /*GetVolumeStatus */
-
 static afs_int32
 RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg,
                  char **motd, Volume * volptr)
@@ -1880,7 +1889,7 @@ RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg,
     }
     strcpy(*motd, V_motd(volptr));
 #endif /* FS_STATS_DETAILED */
-
+    return 0;
 }                              /*RXGetVolumeStatus */
 
 
@@ -1903,26 +1912,6 @@ FileNameOK(register char *aname)
 }                              /*FileNameOK */
 
 
-/* Debugging tool to print Volume Statu's contents */
-static void
-PrintVolumeStatus(VolumeStatus * status)
-{
-    ViceLog(5, ("Volume header contains:\n"));
-    ViceLog(5,
-           ("Vid = %u, Parent = %u, Online = %d, InService = %d, Blessed = %d, NeedsSalvage = %d\n",
-            status->Vid, status->ParentId, status->Online, status->InService,
-            status->Blessed, status->NeedsSalvage));
-    ViceLog(5,
-           ("MinQuota = %d, MaxQuota = %d\n", status->MinQuota,
-            status->MaxQuota));
-    ViceLog(5,
-           ("Type = %d, BlocksInUse = %d, PartBlocksAvail = %d, PartMaxBlocks = %d\n",
-            status->Type, status->BlocksInUse, status->PartBlocksAvail,
-            status->PartMaxBlocks));
-
-}                              /*PrintVolumeStatus */
-
-
 /*
  * This variant of symlink is expressly to support the AFS/DFS translator
  * and is not supported by the AFS fileserver. We just return EINVAL.
@@ -1946,6 +1935,7 @@ SRXAFS_ResidencyCmd(struct rx_call * acall, struct AFSFid * Fid,
     return EINVAL;
 }
 
+#ifdef AFS_NT40_ENV
 static struct afs_buffer {
     struct afs_buffer *next;
 } *freeBufferList = 0;
@@ -1987,6 +1977,7 @@ AllocSendBuffer()
     return (char *)tp;
 
 }                              /*AllocSendBuffer */
+#endif /* AFS_NT40_ENV */
 
 /*
  * This routine returns the status info associated with the targetptr vnode
@@ -2039,8 +2030,9 @@ GetStatus(Vnode * targetptr, AFSFetchStatus * status, afs_int32 rights,
 
 static
   afs_int32
-common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
-                  afs_int32 Len, struct AFSFetchStatus *OutStatus,
+common_FetchData64(struct rx_call *acall, struct AFSFid *Fid,
+                  afs_sfsize_t Pos, afs_sfsize_t Len,
+                  struct AFSFetchStatus *OutStatus,
                   struct AFSCallBack *CallBack, struct AFSVolSync *Sync,
                   int type)
 {
@@ -2050,10 +2042,11 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
     int errorCode = 0;         /* return code to caller */
     int fileCode = 0;          /* return code from vol package */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     struct rx_connection *tcon;        /* the connection we're part of */
+    struct host *thost;
     afs_int32 rights, anyrights;       /* rights for this and any user */
-    struct client *t_client;   /* tmp ptr to client data */
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
@@ -2061,8 +2054,8 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
     struct timeval xferStartTime, xferStopTime;        /* Start/stop times for xfer portion */
     struct timeval elapsedTime;        /* Transfer time */
-    afs_int32 bytesToXfer;     /* # bytes to xfer */
-    afs_int32 bytesXferred;    /* # bytes actually xferred */
+    afs_sfsize_t bytesToXfer;  /* # bytes to xfer */
+    afs_sfsize_t bytesXferred; /* # bytes actually xferred */
     int readIdx;               /* Index of read stats array to bump */
     static afs_int32 tot_bytesXferred; /* shared access protected by FS_LOCK */
 
@@ -2084,16 +2077,16 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
     FS_LOCK;
     AFSCallStats.FetchData++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_FetchData;
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(5,
-           ("SRXAFS_FetchData, Fid = %u.%u.%u, Host %s, Id %d\n",
+           ("SRXAFS_FetchData, Fid = %u.%u.%u, Host %s:%d, Id %d\n",
             Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     /*
      * Get volume/vnode for the fetched file; caller's access rights to
      * it are also returned
@@ -2238,9 +2231,9 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
   Bad_FetchData:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2, ("SRXAFS_FetchData returns %d\n", errorCode));
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -2260,7 +2253,9 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, FetchDataEvent, errorCode, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, FetchDataEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return (errorCode);
 
 }                              /*SRXAFS_FetchData */
@@ -2270,12 +2265,8 @@ SRXAFS_FetchData(struct rx_call * acall, struct AFSFid * Fid, afs_int32 Pos,
                 afs_int32 Len, struct AFSFetchStatus * OutStatus,
                 struct AFSCallBack * CallBack, struct AFSVolSync * Sync)
 {
-    int code;
-
-    code =
-       common_FetchData64(acall, Fid, Pos, Len, OutStatus, CallBack, Sync,
-                          0);
-    return code;
+    return common_FetchData64(acall, Fid, Pos, Len, OutStatus, CallBack, 
+                              Sync, 0);
 }
 
 afs_int32
@@ -2284,16 +2275,18 @@ SRXAFS_FetchData64(struct rx_call * acall, struct AFSFid * Fid, afs_int64 Pos,
                   struct AFSCallBack * CallBack, struct AFSVolSync * Sync)
 {
     int code;
-    afs_int32 tPos, tLen;
+    afs_sfsize_t tPos, tLen;
 
 #ifdef AFS_64BIT_ENV
+#ifndef AFS_LARGEFILE_ENV
     if (Pos + Len > 0x7fffffff)
-       return E2BIG;
-    tPos = Pos;
-    tLen = Len;
+       return EFBIG;
+#endif /* !AFS_LARGEFILE_ENV */
+    tPos = (afs_sfsize_t) Pos;
+    tLen = (afs_sfsize_t) Len;
 #else /* AFS_64BIT_ENV */
     if (Pos.high || Len.high)
-       return E2BIG;
+       return EFBIG;
     tPos = Pos.low;
     tLen = Len.low;
 #endif /* AFS_64BIT_ENV */
@@ -2313,10 +2306,11 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
     Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
     int errorCode = 0;         /* return error code to caller */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
-    struct client *t_client;   /* tmp ptr to client data */
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
@@ -2340,16 +2334,16 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
     FS_LOCK;
     AFSCallStats.FetchACL++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_FetchACL;
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(5,
-           ("SAFS_FetchACL, Fid = %u.%u.%u, Host %s, Id %d\n", Fid->Volume,
+           ("SAFS_FetchACL, Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
             Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
 
     AccessList->AFSOpaque_len = 0;
     AccessList->AFSOpaque_val = malloc(AFSOPAQUEMAX);
@@ -2387,11 +2381,11 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
   Bad_FetchACL:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2,
            ("SAFS_FetchACL returns %d (ACL=%s)\n", errorCode,
             AccessList->AFSOpaque_val));
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -2411,7 +2405,10 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, FetchACLEvent, errorCode, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, FetchACLEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, 
+               AUD_ACL, AccessList->AFSOpaque_val, AUD_END);
     return errorCode;
 }                              /*SRXAFS_FetchACL */
 
@@ -2430,19 +2427,19 @@ SAFSS_FetchStatus(struct rx_call *acall, struct AFSFid *Fid,
     Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
     int errorCode = 0;         /* return code to caller */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     afs_int32 rights, anyrights;       /* rights for this and any user */
-    struct client *t_client;   /* tmp ptr to client data */
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_FetchStatus,  Fid = %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_FetchStatus,  Fid = %u.%u.%u, Host %s:%d, Id %d\n",
             Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.FetchStatus++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -2487,7 +2484,7 @@ SAFSS_FetchStatus(struct rx_call *acall, struct AFSFid *Fid,
   Bad_FetchStatus:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2, ("SAFS_FetchStatus returns %d\n", errorCode));
     return errorCode;
 
@@ -2505,10 +2502,12 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
     int errorCode = 0;         /* return code to caller */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     register struct AFSFid *tfid;      /* file id we're dealing with now */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
+    struct host *thost;
+    struct client *t_client = NULL;     /* tmp pointer to the client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -2551,7 +2550,7 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     }
     CallBacks->AFSCBs_len = nfiles;
 
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_BulkStatus;
 
     tfid = Fids->AFSCBFids_val;
@@ -2598,17 +2597,20 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
 
        /* put back the file ID and volume */
        (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                              volptr);
+                              volptr, &client);
        parentwhentargetnotdir = (Vnode *) 0;
        targetptr = (Vnode *) 0;
        volptr = (Volume *) 0;
+       client = (struct client *)0;
     }
 
   Bad_BulkStatus:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
-    errorCode = CallPostamble(tcon, errorCode);
+                          volptr, &client);
+    errorCode = CallPostamble(tcon, errorCode, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -2630,8 +2632,9 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
 
   Audit_and_Return:
     ViceLog(2, ("SAFS_BulkStatus       returns %d\n", errorCode));
-    osi_auditU(acall, BulkFetchStatusEvent, errorCode, AUD_FIDS, Fids,
-              AUD_END);
+    osi_auditU(acall, BulkFetchStatusEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FIDS, Fids, AUD_END);
     return errorCode;
 
 }                              /*SRXAFS_BulkStatus */
@@ -2648,10 +2651,12 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
     int errorCode = 0;         /* return code to caller */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     register struct AFSFid *tfid;      /* file id we're dealing with now */
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     AFSFetchStatus *tstatus;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
@@ -2695,7 +2700,7 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     }
     CallBacks->AFSCBs_len = nfiles;
 
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon))) {
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost))) {
        goto Bad_InlineBulkStatus;
     }
 
@@ -2711,9 +2716,12 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
                              &rights, &anyrights))) {
            tstatus = &OutStats->AFSBulkStats_val[i];
            tstatus->errorCode = errorCode;
+           PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, 
+                            volptr, &client);
            parentwhentargetnotdir = (Vnode *) 0;
            targetptr = (Vnode *) 0;
            volptr = (Volume *) 0;
+           client = (struct client *)0;
            continue;
        }
 
@@ -2729,10 +2737,11 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
                tstatus = &OutStats->AFSBulkStats_val[i];
                tstatus->errorCode = errorCode;
                (void)PutVolumePackage(parentwhentargetnotdir, targetptr,
-                                      (Vnode *) 0, volptr);
+                                      (Vnode *) 0, volptr, &client);
                parentwhentargetnotdir = (Vnode *) 0;
                targetptr = (Vnode *) 0;
                volptr = (Volume *) 0;
+               client = (struct client *)0;
                continue;
            }
        }
@@ -2756,17 +2765,20 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
 
        /* put back the file ID and volume */
        (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                              volptr);
+                              volptr, &client);
        parentwhentargetnotdir = (Vnode *) 0;
        targetptr = (Vnode *) 0;
        volptr = (Volume *) 0;
+       client = (struct client *)0;
     }
 
   Bad_InlineBulkStatus:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
-    errorCode = CallPostamble(tcon, errorCode);
+                          volptr, &client);
+    errorCode = CallPostamble(tcon, errorCode, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -2788,8 +2800,9 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
 
   Audit_and_Return:
     ViceLog(2, ("SAFS_InlineBulkStatus returns %d\n", errorCode));
-    osi_auditU(acall, InlineBulkFetchStatusEvent, errorCode, AUD_FIDS, Fids,
-              AUD_END);
+    osi_auditU(acall, InlineBulkFetchStatusEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FIDS, Fids, AUD_END);
     return 0;
 
 }                              /*SRXAFS_InlineBulkStatus */
@@ -2802,6 +2815,8 @@ SRXAFS_FetchStatus(struct rx_call * acall, struct AFSFid * Fid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -2818,13 +2833,15 @@ SRXAFS_FetchStatus(struct rx_call * acall, struct AFSFid * Fid,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_FetchStatus;
 
     code = SAFSS_FetchStatus(acall, Fid, OutStatus, CallBack, Sync);
 
   Bad_FetchStatus:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -2844,7 +2861,9 @@ SRXAFS_FetchStatus(struct rx_call * acall, struct AFSFid * Fid,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, FetchStatusEvent, code, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, FetchStatusEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return code;
 
 }                              /*SRXAFS_FetchStatus */
@@ -2852,8 +2871,8 @@ SRXAFS_FetchStatus(struct rx_call * acall, struct AFSFid * Fid,
 static
   afs_int32
 common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
-                  struct AFSStoreStatus *InStatus, afs_uint32 Pos,
-                  afs_uint32 Length, afs_uint32 FileLength,
+                  struct AFSStoreStatus *InStatus, afs_fsize_t Pos,
+                  afs_fsize_t Length, afs_fsize_t FileLength,
                   struct AFSFetchStatus *OutStatus, struct AFSVolSync *Sync)
 {
     Vnode *targetptr = 0;      /* pointer to input fid */
@@ -2862,19 +2881,20 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
     int errorCode = 0;         /* return code for caller */
     int fileCode = 0;          /* return code from vol package */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
-    struct client *t_client;   /* tmp ptr to client data */
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     struct rx_connection *tcon;
+    struct host *thost;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct fs_stats_xferData *xferP;   /* Ptr to this op's byte size struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
     struct timeval xferStartTime, xferStopTime;        /* Start/stop times for xfer portion */
     struct timeval elapsedTime;        /* Transfer time */
-    afs_int32 bytesToXfer;     /* # bytes to xfer */
-    afs_int32 bytesXferred;    /* # bytes actually xfer */
+    afs_sfsize_t bytesToXfer;  /* # bytes to xfer */
+    afs_sfsize_t bytesXferred; /* # bytes actually xfer */
     static afs_int32 tot_bytesXferred; /* shared access protected by FS_LOCK */
 
     /*
@@ -2895,16 +2915,16 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
     FS_LOCK;
     AFSCallStats.StoreData++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_StoreData;
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(5,
-           ("StoreData: Fid = %u.%u.%u, Host %s, Id %d\n", Fid->Volume,
+           ("StoreData: Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
             Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
 
     /*
      * Get associated volume/vnode for the stored file; caller's rights
@@ -3041,10 +3061,10 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
   Bad_StoreData:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2, ("SAFS_StoreData        returns %d\n", errorCode));
 
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -3063,10 +3083,10 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
        FS_UNLOCK;
     }
 #endif /* FS_STATS_DETAILED */
-
-    osi_auditU(acall, StoreDataEvent, errorCode, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, StoreDataEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return (errorCode);
-
 }                              /*common_StoreData64 */
 
 afs_int32
@@ -3075,13 +3095,12 @@ SRXAFS_StoreData(struct rx_call * acall, struct AFSFid * Fid,
                 afs_uint32 Length, afs_uint32 FileLength,
                 struct AFSFetchStatus * OutStatus, struct AFSVolSync * Sync)
 {
-    int code;
-
-    code =
-       common_StoreData64(acall, Fid, InStatus, Pos, Length, FileLength,
-                          OutStatus, Sync);
-    return code;
+    if (FileLength > 0x7fffffff || Pos > 0x7fffffff || 
+       (0x7fffffff - Pos) < Length)
+        return EFBIG;
 
+    return common_StoreData64(acall, Fid, InStatus, Pos, Length, FileLength,
+                             OutStatus, Sync);
 }                              /*SRXAFS_StoreData */
 
 afs_int32
@@ -3092,19 +3111,21 @@ SRXAFS_StoreData64(struct rx_call * acall, struct AFSFid * Fid,
                   struct AFSVolSync * Sync)
 {
     int code;
-    afs_int32 tPos;
-    afs_int32 tLength;
-    afs_int32 tFileLength;
+    afs_fsize_t tPos;
+    afs_fsize_t tLength;
+    afs_fsize_t tFileLength;
 
 #ifdef AFS_64BIT_ENV
+#ifndef AFS_LARGEFILE_ENV
     if (FileLength > 0x7fffffff)
-       return E2BIG;
-    tPos = Pos;
-    tLength = Length;
-    tFileLength = FileLength;
+       return EFBIG;
+#endif /* !AFS_LARGEFILE_ENV */
+    tPos = (afs_fsize_t) Pos;
+    tLength = (afs_fsize_t) Length;
+    tFileLength = (afs_fsize_t) FileLength;
 #else /* AFS_64BIT_ENV */
     if (FileLength.high)
-       return E2BIG;
+       return EFBIG;
     tPos = Pos.low;
     tLength = Length.low;
     tFileLength = FileLength.low;
@@ -3126,10 +3147,11 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
     int errorCode = 0;         /* return code for caller */
     struct AFSStoreStatus InStatus;    /* Input status for fid */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct rx_connection *tcon;
-    struct client *t_client;   /* tmp ptr to client data */
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
@@ -3146,16 +3168,16 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
     FS_UNLOCK;
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_StoreACL;
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_StoreACL, Fid = %u.%u.%u, ACL=%s, Host %s, Id %d\n",
+           ("SAFS_StoreACL, Fid = %u.%u.%u, ACL=%s, Host %s:%d, Id %d\n",
             Fid->Volume, Fid->Vnode, Fid->Unique, AccessList->AFSOpaque_val,
-            inet_ntoa(logHostAddr), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.StoreACL++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -3201,9 +3223,10 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
 
   Bad_StoreACL:
     /* Update and store volume/vnode and parent vnodes back */
-    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, volptr);
+    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, 
+                    volptr, &client);
     ViceLog(2, ("SAFS_StoreACL returns %d\n", errorCode));
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -3223,7 +3246,9 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, StoreACLEvent, errorCode, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, StoreACLEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_ACL, AccessList->AFSOpaque_val, AUD_END);
     return errorCode;
 
 }                              /*SRXAFS_StoreACL */
@@ -3242,19 +3267,19 @@ SAFSS_StoreStatus(struct rx_call *acall, struct AFSFid *Fid,
     Vnode *parentwhentargetnotdir = 0; /* parent of Fid to get ACL */
     int errorCode = 0;         /* return code for caller */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
-    struct client *t_client;   /* tmp ptr to client data */
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_StoreStatus,  Fid    = %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_StoreStatus,  Fid    = %u.%u.%u, Host %s:%d, Id %d\n",
             Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.StoreStatus++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -3305,7 +3330,8 @@ SAFSS_StoreStatus(struct rx_call *acall, struct AFSFid *Fid,
 
   Bad_StoreStatus:
     /* Update and store volume/vnode and parent vnodes back */
-    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, volptr);
+    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, 
+                    volptr, &client);
     ViceLog(2, ("SAFS_StoreStatus returns %d\n", errorCode));
     return errorCode;
 
@@ -3320,6 +3346,8 @@ SRXAFS_StoreStatus(struct rx_call * acall, struct AFSFid * Fid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -3336,13 +3364,15 @@ SRXAFS_StoreStatus(struct rx_call * acall, struct AFSFid * Fid,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_StoreStatus;
 
     code = SAFSS_StoreStatus(acall, Fid, InStatus, OutStatus, Sync);
 
   Bad_StoreStatus:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -3362,7 +3392,9 @@ SRXAFS_StoreStatus(struct rx_call * acall, struct AFSFid * Fid,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, StoreStatusEvent, code, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, StoreStatusEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return code;
 
 }                              /*SRXAFS_StoreStatus */
@@ -3383,7 +3415,7 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     AFSFid fileFid;            /* area for Fid from the directory */
     int errorCode = 0;         /* error code */
     DirHandle dir;             /* Handle for dir package I/O */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -3392,11 +3424,11 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     FidZero(&dir);
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_RemoveFile %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_RemoveFile %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.RemoveFile++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -3461,7 +3493,8 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
   Bad_RemoveFile:
     /* Update and store volume/vnode and parent vnodes back */
-    PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr, volptr);
+    PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr, 
+                    volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_RemoveFile returns %d\n", errorCode));
     return errorCode;
@@ -3476,6 +3509,8 @@ SRXAFS_RemoveFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -3492,13 +3527,15 @@ SRXAFS_RemoveFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_RemoveFile;
 
     code = SAFSS_RemoveFile(acall, DirFid, Name, OutDirStatus, Sync);
 
   Bad_RemoveFile:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -3518,8 +3555,9 @@ SRXAFS_RemoveFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, RemoveFileEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, RemoveFileEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name, AUD_END);
     return code;
 
 }                              /*SRXAFS_RemoveFile */
@@ -3542,7 +3580,7 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Volume *volptr = 0;                /* pointer to the volume header */
     int errorCode = 0;         /* error code */
     DirHandle dir;             /* Handle for dir package I/O */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -3552,11 +3590,11 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_CreateFile %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_CreateFile %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.CreateFile++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -3604,8 +3642,8 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Update_TargetVnodeStatus(targetptr, TVS_CFILE, client, InStatus,
                             parentptr, volptr, 0);
 
-    /* set up the return status for the parent dir and the newly created file */
-    GetStatus(targetptr, OutFidStatus, rights, anyrights, parentptr);
+    /* set up the return status for the parent dir and the newly created file, and since the newly created file is owned by the creator, give it PRSFS_ADMINISTER to tell the client its the owner of the file */
+    GetStatus(targetptr, OutFidStatus, rights | PRSFS_ADMINISTER, anyrights, parentptr);
     GetStatus(parentptr, OutDirStatus, rights, anyrights, 0);
 
     /* convert the write lock to a read lock before breaking callbacks */
@@ -3621,7 +3659,7 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_CreateFile:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_CreateFile returns %d\n", errorCode));
     return errorCode;
@@ -3638,6 +3676,8 @@ SRXAFS_CreateFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -3654,7 +3694,9 @@ SRXAFS_CreateFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    memset(OutFid, 0, sizeof(struct AFSFid));
+
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_CreateFile;
 
     code =
@@ -3662,7 +3704,9 @@ SRXAFS_CreateFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
                         OutDirStatus, CallBack, Sync);
 
   Bad_CreateFile:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -3682,8 +3726,9 @@ SRXAFS_CreateFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, CreateFileEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, CreateFileEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name, AUD_FID, OutFid, AUD_END);
     return code;
 
 }                              /*SRXAFS_CreateFile */
@@ -3715,7 +3760,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
     DirHandle filedir;         /* Handle for dir package I/O */
     DirHandle newfiledir;      /* Handle for dir package I/O */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     afs_int32 newrights;       /* rights for this user */
     afs_int32 newanyrights;    /* rights for any user */
@@ -3732,12 +3777,12 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_Rename %s    to %s,  Fid = %u.%u.%u to %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_Rename %s    to %s,  Fid = %u.%u.%u to %u.%u.%u, Host %s:%d, Id %d\n",
             OldName, NewName, OldDirFid->Volume, OldDirFid->Vnode,
             OldDirFid->Unique, NewDirFid->Volume, NewDirFid->Vnode,
-            NewDirFid->Unique, inet_ntoa(logHostAddr), t_client->ViceId));
+            NewDirFid->Unique, inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.Rename++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -3926,7 +3971,13 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
      * directory structure.  This is to prevent removing a subtree alltogether
      */
     if ((oldvptr != newvptr) && (fileptr->disk.type == vDirectory)) {
-       for (testnode = newvptr->disk.parent; testnode != 0;) {
+        afs_int32 forpass = 0, vnum = 0, top = 0;
+       for (testnode = newvptr->disk.parent; testnode != 0; forpass++) {
+           if (testnode > vnum) vnum = testnode;
+           if (forpass > vnum) {
+               errorCode = FSERR_ELOOP;
+               goto Bad_Rename;
+           }
            if (testnode == oldvptr->vnodeNumber) {
                testnode = oldvptr->disk.parent;
                continue;
@@ -3940,10 +3991,19 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
                errorCode = FSERR_ELOOP;
                goto Bad_Rename;
            }
+           if (testnode == 1) top = 1;
            testvptr = VGetVnode(&errorCode, volptr, testnode, READ_LOCK);
            assert(errorCode == 0);
            testnode = testvptr->disk.parent;
            VPutVnode(&errorCode, testvptr);
+           if ((top == 1) && (testnode != 0)) {
+               VTakeOffline(volptr);
+               ViceLog(0,
+                       ("Volume %u now offline, must be salvaged.\n",
+                        volptr->hashid));
+               errorCode = EIO;
+               goto Bad_Rename;
+           }
            assert(errorCode == 0);
        }
     }
@@ -3968,7 +4028,8 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
        if (newfileptr->disk.linkCount == 0) {  /* Link count 0 - delete */
            afs_fsize_t newSize;
            VN_GET_LEN(newSize, newfileptr);
-           VAdjustDiskUsage(&errorCode, volptr, -nBlocks(newSize), 0);
+           VAdjustDiskUsage((Error *) & errorCode, volptr,
+                            (afs_sfsize_t) - nBlocks(newSize), 0);
            if (VN_GET_INO(newfileptr)) {
                IH_REALLYCLOSE(newfileptr->handle);
                errorCode =
@@ -4087,10 +4148,8 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
        VPutVnode(&fileCode, newfileptr);
        assert(fileCode == 0);
     }
-    (void)PutVolumePackage(fileptr,
-                          (newvptr
-                           && newvptr != oldvptr ? newvptr : 0), oldvptr,
-                          volptr);
+    (void)PutVolumePackage(fileptr, (newvptr && newvptr != oldvptr ? 
+                                    newvptr : 0), oldvptr, volptr, &client);
     FidZap(&olddir);
     FidZap(&newdir);
     FidZap(&filedir);
@@ -4110,6 +4169,8 @@ SRXAFS_Rename(struct rx_call * acall, struct AFSFid * OldDirFid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4126,7 +4187,7 @@ SRXAFS_Rename(struct rx_call * acall, struct AFSFid * OldDirFid,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_Rename;
 
     code =
@@ -4134,7 +4195,9 @@ SRXAFS_Rename(struct rx_call * acall, struct AFSFid * OldDirFid,
                     OutOldDirStatus, OutNewDirStatus, Sync);
 
   Bad_Rename:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -4154,8 +4217,10 @@ SRXAFS_Rename(struct rx_call * acall, struct AFSFid * OldDirFid,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, RenameFileEvent, code, AUD_FID, OldDirFid, AUD_STR,
-              OldName, AUD_FID, NewDirFid, AUD_STR, NewName, AUD_END);
+    osi_auditU(acall, RenameFileEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, OldDirFid, AUD_STR, OldName, 
+               AUD_FID, NewDirFid, AUD_STR, NewName, AUD_END);
     return code;
 
 }                              /*SRXAFS_Rename */
@@ -4175,11 +4240,11 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Vnode *targetptr = 0;      /* vnode of the new link */
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
     int errorCode = 0;         /* error code */
-    int code = 0;
+    int len, code = 0;
     DirHandle dir;             /* Handle for dir package I/O */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
-    afs_int32 rights, anyrights, fd;   /* rights for this and any user */
+    struct client *client = 0; /* pointer to client structure */
+    afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     FdHandle_t *fdP;
@@ -4189,11 +4254,11 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_Symlink %s to %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_Symlink %s to %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             LinkContents, DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.Symlink++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -4265,9 +4330,18 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Write the contents of the symbolic link name into the target inode */
     fdP = IH_OPEN(targetptr->handle);
-    assert(fdP != NULL);
-    assert(FDH_WRITE(fdP, (char *)LinkContents, strlen((char *)LinkContents))
-          == strlen((char *)LinkContents));
+    if (fdP == NULL) {
+       (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
+                              volptr, &client);
+       VTakeOffline(volptr);
+       ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                   volptr->hashid));
+       return EIO;
+    }    
+    len = strlen((char *) LinkContents);
+    code = (len == FDH_WRITE(fdP, (char *) LinkContents, len)) ? 0 : VDISKFULL;
+    if (code) 
+       ViceLog(0, ("SAFSS_Symlink FDH_WRITE failed for len=%d, Fid=%u.%d.%d\n", len, OutFid->Volume, OutFid->Vnode, OutFid->Unique));
     FDH_CLOSE(fdP);
     /*
      * Set up and return modified status for the parent dir and new symlink
@@ -4286,10 +4360,10 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_SymLink:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_Symlink returns %d\n", errorCode));
-    return errorCode;
+    return ( errorCode ? errorCode : code );
 
 }                              /*SAFSS_Symlink */
 
@@ -4310,6 +4384,8 @@ SRXAFS_Symlink(acall, DirFid, Name, LinkContents, InStatus, OutFid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4326,7 +4402,7 @@ SRXAFS_Symlink(acall, DirFid, Name, LinkContents, InStatus, OutFid,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_Symlink;
 
     code =
@@ -4334,7 +4410,9 @@ SRXAFS_Symlink(acall, DirFid, Name, LinkContents, InStatus, OutFid,
                      OutFidStatus, OutDirStatus, Sync);
 
   Bad_Symlink:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -4354,8 +4432,10 @@ SRXAFS_Symlink(acall, DirFid, Name, LinkContents, InStatus, OutFid,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, SymlinkEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, SymlinkEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0, 
+               AUD_FID, DirFid, AUD_STR, Name,
+              AUD_FID, OutFid, AUD_STR, LinkContents, AUD_END);
     return code;
 
 }                              /*SRXAFS_Symlink */
@@ -4376,7 +4456,7 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Volume *volptr = 0;                /* pointer to the volume header */
     int errorCode = 0;         /* error code */
     DirHandle dir;             /* Handle for dir package I/O */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -4386,12 +4466,12 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_Link %s,     Did = %u.%u.%u, Fid = %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_Link %s,     Did = %u.%u.%u, Fid = %u.%u.%u, Host %s:%d, Id %d\n",
             Name, DirFid->Volume, DirFid->Vnode, DirFid->Unique,
             ExistingFid->Volume, ExistingFid->Vnode, ExistingFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.Link++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -4490,7 +4570,7 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_Link:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_Link returns %d\n", errorCode));
     return errorCode;
@@ -4505,6 +4585,8 @@ SRXAFS_Link(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4521,7 +4603,7 @@ SRXAFS_Link(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_Link;
 
     code =
@@ -4529,7 +4611,9 @@ SRXAFS_Link(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
                   OutDirStatus, Sync);
 
   Bad_Link:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -4549,7 +4633,9 @@ SRXAFS_Link(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, LinkEvent, code, AUD_FID, DirFid, AUD_STR, Name,
+    osi_auditU(acall, LinkEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name,
               AUD_FID, ExistingFid, AUD_END);
     return code;
 
@@ -4576,7 +4662,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     int newACLSize;            /* Size of access list */
     DirHandle dir;             /* Handle for dir package I/O */
     DirHandle parentdir;       /* Handle for dir package I/O */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -4587,11 +4673,11 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_MakeDir %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_MakeDir %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.MakeDir++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -4663,7 +4749,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     SetDirHandle(&dir, targetptr);
     assert(!(MakeDir(&dir, OutFid, DirFid)));
     DFlush();
-    VN_SET_LEN(targetptr, Length(&dir));
+    VN_SET_LEN(targetptr, (afs_fsize_t) Length(&dir));
 
     /* set up return status */
     GetStatus(targetptr, OutFidStatus, rights, anyrights, parentptr);
@@ -4682,7 +4768,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_MakeDir:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     FidZap(&parentdir);
     ViceLog(2, ("SAFS_MakeDir returns %d\n", errorCode));
@@ -4700,6 +4786,8 @@ SRXAFS_MakeDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4715,7 +4803,7 @@ SRXAFS_MakeDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     FS_UNLOCK;
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_MakeDir;
 
     code =
@@ -4723,7 +4811,9 @@ SRXAFS_MakeDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
                      OutDirStatus, CallBack, Sync);
 
   Bad_MakeDir:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -4743,8 +4833,10 @@ SRXAFS_MakeDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, MakeDirEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, MakeDirEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name,
+              AUD_FID, OutFid, AUD_END);
     return code;
 
 }                              /*SRXAFS_MakeDir */
@@ -4765,7 +4857,7 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     int errorCode = 0;         /* error code */
     DirHandle dir;             /* Handle for dir package I/O */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     Vnode debugvnode1, debugvnode2;
     struct client *t_client;   /* tmp ptr to client data */
@@ -4776,11 +4868,11 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_RemoveDir    %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_RemoveDir    %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.RemoveDir++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -4842,7 +4934,7 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_RemoveDir:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_RemoveDir        returns %d\n", errorCode));
     return errorCode;
@@ -4857,6 +4949,8 @@ SRXAFS_RemoveDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4873,13 +4967,15 @@ SRXAFS_RemoveDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_RemoveDir;
 
     code = SAFSS_RemoveDir(acall, DirFid, Name, OutDirStatus, Sync);
 
   Bad_RemoveDir:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -4899,8 +4995,9 @@ SRXAFS_RemoveDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, RemoveDirEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, RemoveDirEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name, AUD_END);
     return code;
 
 }                              /*SRXAFS_RemoveDir */
@@ -4918,11 +5015,11 @@ SAFSS_SetLock(struct rx_call *acall, struct AFSFid *Fid, ViceLockType type,
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
     int errorCode = 0;         /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
-    static char *locktype[2] = { "LockRead", "LockWrite" };
+    static char *locktype[4] = { "LockRead", "LockWrite", "LockExtend", "LockRelease" };
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     if (type != LockRead && type != LockWrite) {
@@ -4931,11 +5028,11 @@ SAFSS_SetLock(struct rx_call *acall, struct AFSFid *Fid, ViceLockType type,
     }
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_SetLock type = %s Fid = %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_SetLock type = %s Fid = %u.%u.%u, Host %s:%d, Id %d\n",
             locktype[(int)type], Fid->Volume, Fid->Vnode, Fid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.SetLock++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -4954,12 +5051,12 @@ SAFSS_SetLock(struct rx_call *acall, struct AFSFid *Fid, ViceLockType type,
     SetVolumeSync(Sync, volptr);
 
     /* Handle the particular type of set locking, type */
-    errorCode = HandleLocking(targetptr, rights, type);
+    errorCode = HandleLocking(targetptr, client, rights, type);
 
   Bad_SetLock:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
 
     if ((errorCode == VREADONLY) && (type == LockRead))
        errorCode = 0;          /* allow read locks on RO volumes without saving state */
@@ -4975,7 +5072,6 @@ SRXAFS_OldSetLock(struct rx_call * acall, struct AFSFid * Fid,
                  ViceLockType type, struct AFSVolSync * Sync)
 {
     return SRXAFS_SetLock(acall, Fid, type, Sync);
-
 }                              /*SRXAFS_OldSetLock */
 
 
@@ -4985,6 +5081,8 @@ SRXAFS_SetLock(struct rx_call * acall, struct AFSFid * Fid, ViceLockType type,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5001,13 +5099,15 @@ SRXAFS_SetLock(struct rx_call * acall, struct AFSFid * Fid, ViceLockType type,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_SetLock;
 
     code = SAFSS_SetLock(acall, Fid, type, Sync);
 
   Bad_SetLock:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -5027,10 +5127,10 @@ SRXAFS_SetLock(struct rx_call * acall, struct AFSFid * Fid, ViceLockType type,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, SetLockEvent, code, AUD_FID, Fid, AUD_LONG, type,
-              AUD_END);
+    osi_auditU(acall, SetLockEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0, 
+               AUD_FID, Fid, AUD_LONG, type, AUD_END);
     return code;
-
 }                              /*SRXAFS_SetLock */
 
 
@@ -5046,7 +5146,7 @@ SAFSS_ExtendLock(struct rx_call *acall, struct AFSFid *Fid,
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
     int errorCode = 0;         /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -5054,11 +5154,11 @@ SAFSS_ExtendLock(struct rx_call *acall, struct AFSFid *Fid,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_ExtendLock Fid = %u.%u.%u, Host %s, Id %d\n", Fid->Volume,
+           ("SAFS_ExtendLock Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
             Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.ExtendLock++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -5077,12 +5177,12 @@ SAFSS_ExtendLock(struct rx_call *acall, struct AFSFid *Fid,
     SetVolumeSync(Sync, volptr);
 
     /* Handle the actual lock extension */
-    errorCode = HandleLocking(targetptr, rights, LockExtend);
+    errorCode = HandleLocking(targetptr, client, rights, LockExtend);
 
   Bad_ExtendLock:
     /* Put back file's vnode and volume */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
 
     if ((errorCode == VREADONLY))      /* presumably, we already granted this lock */
        errorCode = 0;          /* under our generous policy re RO vols */
@@ -5098,7 +5198,6 @@ SRXAFS_OldExtendLock(struct rx_call * acall, struct AFSFid * Fid,
                     struct AFSVolSync * Sync)
 {
     return SRXAFS_ExtendLock(acall, Fid, Sync);
-
 }                              /*SRXAFS_OldExtendLock */
 
 
@@ -5108,6 +5207,8 @@ SRXAFS_ExtendLock(struct rx_call * acall, struct AFSFid * Fid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5124,13 +5225,15 @@ SRXAFS_ExtendLock(struct rx_call * acall, struct AFSFid * Fid,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_ExtendLock;
 
     code = SAFSS_ExtendLock(acall, Fid, Sync);
 
   Bad_ExtendLock:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -5150,7 +5253,9 @@ SRXAFS_ExtendLock(struct rx_call * acall, struct AFSFid * Fid,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, ExtendLockEvent, code, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, ExtendLockEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return code;
 
 }                              /*SRXAFS_ExtendLock */
@@ -5168,7 +5273,7 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
     int errorCode = 0;         /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -5176,11 +5281,11 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_ReleaseLock Fid = %u.%u.%u, Host %s, Id %d\n", Fid->Volume,
+           ("SAFS_ReleaseLock Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
             Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.ReleaseLock++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -5199,7 +5304,7 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
     SetVolumeSync(Sync, volptr);
 
     /* Handle the actual lock release */
-    if ((errorCode = HandleLocking(targetptr, rights, LockRelease)))
+    if ((errorCode = HandleLocking(targetptr, client, rights, LockRelease)))
        goto Bad_ReleaseLock;
 
     /* if no more locks left, a callback would be triggered here */
@@ -5213,7 +5318,7 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
   Bad_ReleaseLock:
     /* Put back file's vnode and volume */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
 
     if ((errorCode == VREADONLY))      /* presumably, we already granted this lock */
        errorCode = 0;          /* under our generous policy re RO vols */
@@ -5229,7 +5334,6 @@ SRXAFS_OldReleaseLock(struct rx_call * acall, struct AFSFid * Fid,
                      struct AFSVolSync * Sync)
 {
     return SRXAFS_ReleaseLock(acall, Fid, Sync);
-
 }                              /*SRXAFS_OldReleaseLock */
 
 
@@ -5239,6 +5343,8 @@ SRXAFS_ReleaseLock(struct rx_call * acall, struct AFSFid * Fid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5255,13 +5361,15 @@ SRXAFS_ReleaseLock(struct rx_call * acall, struct AFSFid * Fid,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_ReleaseLock;
 
     code = SAFSS_ReleaseLock(acall, Fid, Sync);
 
   Bad_ReleaseLock:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -5281,7 +5389,9 @@ SRXAFS_ReleaseLock(struct rx_call * acall, struct AFSFid * Fid,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, ReleaseLockEvent, code, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, ReleaseLockEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0, 
+               AUD_FID, Fid, AUD_END);
     return code;
 
 }                              /*SRXAFS_ReleaseLock */
@@ -5367,7 +5477,9 @@ afs_int32
 SRXAFS_GetStatistics(struct rx_call *acall, struct ViceStatistics *Statistics)
 {
     afs_int32 code;
-    struct rx_connection *tcon;
+    struct rx_connection *tcon = rx_ConnectionOf(acall);
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5384,7 +5496,7 @@ SRXAFS_GetStatistics(struct rx_call *acall, struct ViceStatistics *Statistics)
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon, &thost)))
        goto Bad_GetStatistics;
 
     ViceLog(1, ("SAFS_GetStatistics Received\n"));
@@ -5397,7 +5509,9 @@ SRXAFS_GetStatistics(struct rx_call *acall, struct ViceStatistics *Statistics)
     SetSystemStats((struct AFSStatistics *)Statistics);
 
   Bad_GetStatistics:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -5417,8 +5531,9 @@ SRXAFS_GetStatistics(struct rx_call *acall, struct ViceStatistics *Statistics)
     }
 #endif /* FS_STATS_DETAILED */
 
+    osi_auditU(acall, GetStatisticsEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0, AUD_END);
     return code;
-
 }                              /*SRXAFS_GetStatistics */
 
 
@@ -5446,6 +5561,8 @@ afs_int32
 SRXAFS_XStatsVersion(struct rx_call * a_call, afs_int32 * a_versionP)
 {                              /*SRXAFS_XStatsVersion */
 
+    struct client *t_client = NULL;    /* tmp ptr to client data */
+    struct rx_connection *tcon = rx_ConnectionOf(a_call);
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5464,6 +5581,8 @@ SRXAFS_XStatsVersion(struct rx_call * a_call, afs_int32 * a_versionP)
 
     *a_versionP = AFS_XSTAT_VERSION;
 
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
     fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
@@ -5479,8 +5598,10 @@ SRXAFS_XStatsVersion(struct rx_call * a_call, afs_int32 * a_versionP)
     (opP->numSuccesses)++;
     FS_UNLOCK;
 #endif /* FS_STATS_DETAILED */
-    return (0);
 
+    osi_auditU(a_call, XStatsVersionEvent, 0, 
+               AUD_ID, t_client ? t_client->ViceId : 0, AUD_END);
+    return (0);
 }                              /*SRXAFS_XStatsVersion */
 
 
@@ -5507,7 +5628,7 @@ SRXAFS_XStatsVersion(struct rx_call * a_call, afs_int32 * a_versionP)
 static void
 FillPerfValues(struct afs_PerfStats *a_perfP)
 {                              /*FillPerfValues */
-
+    afs_uint32 hi, lo;
     int dir_Buffers;           /*# buffers in use by dir package */
     int dir_Calls;             /*# read calls in dir package */
     int dir_IOs;               /*# I/O ops in dir package */
@@ -5525,9 +5646,11 @@ FillPerfValues(struct afs_PerfStats *a_perfP)
     a_perfP->vcache_S_Gets = VnodeClassInfo[vSmall].gets;
     a_perfP->vcache_S_Reads = VnodeClassInfo[vSmall].reads;
     a_perfP->vcache_S_Writes = VnodeClassInfo[vSmall].writes;
-    a_perfP->vcache_H_Entries = VolumeCacheSize;
-    a_perfP->vcache_H_Gets = VolumeGets;
-    a_perfP->vcache_H_Replacements = VolumeReplacements;
+    a_perfP->vcache_H_Entries = VStats.hdr_cache_size;
+    SplitInt64(VStats.hdr_gets, hi, lo);
+    a_perfP->vcache_H_Gets = lo;
+    SplitInt64(VStats.hdr_loads, hi, lo);
+    a_perfP->vcache_H_Replacements = lo;
 
     /*
      * Directory section.
@@ -5603,7 +5726,8 @@ FillPerfValues(struct afs_PerfStats *a_perfP)
     a_perfP->host_ClientBlocks = CEBlocks;
 
     a_perfP->sysname_ID = afs_perfstats.sysname_ID;
-
+    a_perfP->rx_nBusies = (afs_int32) rx_stats.nBusies;
+    a_perfP->fs_nBusies = afs_perfstats.fs_nBusies;
 }                              /*FillPerfValues */
 
 
@@ -5759,6 +5883,36 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
 #endif
        break;
 
+    case AFS_XSTATSCOLL_CBSTATS:
+       afs_perfstats.numPerfCalls++;
+
+       dataBytes = sizeof(struct cbcounters);
+       dataBuffP = (afs_int32 *) malloc(dataBytes);
+       {
+           extern struct cbcounters cbstuff;
+           dataBuffP[0]=cbstuff.DeleteFiles;
+           dataBuffP[1]=cbstuff.DeleteCallBacks;
+           dataBuffP[2]=cbstuff.BreakCallBacks;
+           dataBuffP[3]=cbstuff.AddCallBacks;
+           dataBuffP[4]=cbstuff.GotSomeSpaces;
+           dataBuffP[5]=cbstuff.DeleteAllCallBacks;
+           dataBuffP[6]=cbstuff.nFEs;
+           dataBuffP[7]=cbstuff.nCBs;
+           dataBuffP[8]=cbstuff.nblks;
+           dataBuffP[9]=cbstuff.CBsTimedOut;
+           dataBuffP[10]=cbstuff.nbreakers;
+           dataBuffP[11]=cbstuff.GSS1;
+           dataBuffP[12]=cbstuff.GSS2;
+           dataBuffP[13]=cbstuff.GSS3;
+           dataBuffP[14]=cbstuff.GSS4;
+           dataBuffP[15]=cbstuff.GSS5;
+       }
+
+       a_dataP->AFS_CollData_len = dataBytes >> 2;
+       a_dataP->AFS_CollData_val = dataBuffP;
+       break;
+
+
     default:
        /*
         * Illegal collection number.
@@ -5797,8 +5951,9 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
 {
     afs_int32 errorCode = 0;
     register int i;
-    struct client *client;
+    struct client *client = 0;
     struct rx_connection *tcon;
+    struct host *thost;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5824,7 +5979,7 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
     FS_LOCK;
     AFSCallStats.GiveUpCallBacks++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_GiveUpCallBacks;
 
     if (!FidArray && !CallBackArray) {
@@ -5832,8 +5987,10 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
                ("SAFS_GiveUpAllCallBacks: host=%x\n",
                 (tcon->peer ? tcon->peer->host : 0)));
        errorCode = GetClient(tcon, &client);
-       if (!errorCode)
+       if (!errorCode) {
            DeleteAllCallBacks_r(client->host, 1);
+           PutClient(&client);
+       }
     } else {
        if (FidArray->AFSCBFids_len < CallBackArray->AFSCBs_len) {
            ViceLog(0,
@@ -5850,11 +6007,12 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
                register struct AFSFid *fid = &(FidArray->AFSCBFids_val[i]);
                DeleteCallBack(client->host, fid);
            }
+           PutClient(&client);
        }
     }
 
   Bad_GiveUpCallBacks:
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -5873,7 +6031,6 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
        FS_UNLOCK;
     }
 #endif /* FS_STATS_DETAILED */
-  out:
     return errorCode;
 
 }                              /*common_GiveUpCallBacks */
@@ -5922,16 +6079,37 @@ SRXAFS_Lookup(struct rx_call * call_p, struct AFSFid * afs_dfid_p,
 afs_int32
 SRXAFS_GetCapabilities(struct rx_call * acall, Capabilities * capabilities)
 {
+    afs_int32 code;
+    struct rx_connection *tcon;
+    struct host *thost;
     afs_int32 *dataBuffP;
-    afs_int32 *dataP;
     afs_int32 dataBytes;
 
+    FS_LOCK;
+    AFSCallStats.GetCapabilities++, AFSCallStats.TotalCalls++;
+    afs_FullPerfStats.overall.fs_nGetCaps++;
+    FS_UNLOCK;
+    ViceLog(2, ("SAFS_GetCapabilties\n"));
+
+    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon, &thost)))
+       goto Bad_GetCaps;
+
     dataBytes = 1 * sizeof(afs_int32);
     dataBuffP = (afs_int32 *) malloc(dataBytes);
-    dataBuffP[0] = CAPABILITY_ERRORTRANS;
+    dataBuffP[0] = VICED_CAPABILITY_ERRORTRANS | VICED_CAPABILITY_WRITELOCKACL;
+#if defined(AFS_64BIT_ENV) && defined(AFS_LARGEFILE_ENV)
+    dataBuffP[0] |= VICED_CAPABILITY_64BITFILES;
+#endif
+    if (saneacls)
+       dataBuffP[0] |= VICED_CAPABILITY_SANEACLS;
+
     capabilities->Capabilities_len = dataBytes / sizeof(afs_int32);
     capabilities->Capabilities_val = dataBuffP;
 
+  Bad_GetCaps:
+    code = CallPostamble(tcon, code, thost);
+
+
     return 0;
 }
 
@@ -5944,7 +6122,7 @@ SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids,
     afs_int32 nids, naddrs;
     afs_int32 *vd, *addr;
     int errorCode = 0;         /* return code to caller */
-    struct client *client;
+    struct client *client = 0;
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     ViceLog(1, ("SRXAFS_FlushCPS\n"));
@@ -5962,11 +6140,10 @@ SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids,
     for (i = 0; i < nids; i++, vd++) {
        if (!*vd)
            continue;
-       client = h_ID2Client(*vd);      /* returns client locked, or NULL */
+       client = h_ID2Client(*vd);      /* returns write locked and refCounted, or NULL */
        if (!client)
            continue;
 
-       BoostSharedLock(&client->lock);
        client->prfail = 2;     /* Means re-eval client's cps */
 #ifdef notdef
        if (client->tcon) {
@@ -5979,6 +6156,7 @@ SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids,
            client->CPS.prlist_len = 0;
        }
        ReleaseWriteLock(&client->lock);
+       PutClient(&client);
     }
 
     addr = addrs->IPAddrs_val;
@@ -6121,6 +6299,7 @@ SRXAFS_GetVolumeInfo(struct rx_call * acall, char *avolid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -6136,7 +6315,7 @@ SRXAFS_GetVolumeInfo(struct rx_call * acall, char *avolid,
     FS_UNLOCK;
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_GetVolumeInfo;
 
     FS_LOCK;
@@ -6150,7 +6329,7 @@ SRXAFS_GetVolumeInfo(struct rx_call * acall, char *avolid,
     avolinfo->Type4 = 0xabcd9999;      /* tell us to try new vldb */
 
   Bad_GetVolumeInfo:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -6184,10 +6363,12 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
     Vnode *parentwhentargetnotdir = 0; /* vnode of parent */
     int errorCode = 0;         /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client entry */
+    struct client *client = 0; /* pointer to client entry */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     AFSFid dummyFid;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -6206,7 +6387,7 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 #endif /* FS_STATS_DETAILED */
 
     ViceLog(1, ("SAFS_GetVolumeStatus for volume %u\n", avolid));
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_GetVolumeStatus;
 
     FS_LOCK;
@@ -6233,7 +6414,7 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 
   Bad_GetVolumeStatus:
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2, ("SAFS_GetVolumeStatus returns %d\n", errorCode));
     /* next is to guarantee out strings exist for stub */
     if (*Name == 0) {
@@ -6248,7 +6429,9 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
        *OfflineMsg = (char *)malloc(1);
        **OfflineMsg = 0;
     }
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -6267,6 +6450,10 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
        FS_UNLOCK;
     }
 #endif /* FS_STATS_DETAILED */
+
+    osi_auditU(acall, GetVolumeStatusEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_LONG, avolid, AUD_STR, *Name, AUD_END);
     return (errorCode);
 
 }                              /*SRXAFS_GetVolumeStatus */
@@ -6281,10 +6468,12 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
     Vnode *parentwhentargetnotdir = 0; /* vnode of parent */
     int errorCode = 0;         /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client entry */
+    struct client *client = 0; /* pointer to client entry */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     AFSFid dummyFid;
     struct rx_connection *tcon = rx_ConnectionOf(acall);
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -6303,7 +6492,7 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 #endif /* FS_STATS_DETAILED */
 
     ViceLog(1, ("SAFS_SetVolumeStatus for volume %u\n", avolid));
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_SetVolumeStatus;
 
     FS_LOCK;
@@ -6335,9 +6524,12 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
        RXUpdate_VolumeStatus(volptr, StoreVolStatus, Name, OfflineMsg, Motd);
 
   Bad_SetVolumeStatus:
-    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, volptr);
+    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, 
+                    volptr, &client);
     ViceLog(2, ("SAFS_SetVolumeStatus returns %d\n", errorCode));
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -6357,10 +6549,10 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
     }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, SetVolumeStatusEvent, errorCode, AUD_LONG, avolid,
-              AUD_STR, Name, AUD_END);
+    osi_auditU(acall, SetVolumeStatusEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_LONG, avolid, AUD_STR, Name, AUD_END);
     return (errorCode);
-
 }                              /*SRXAFS_SetVolumeStatus */
 
 #define        DEFAULTVOLUME   "root.afs"
@@ -6368,15 +6560,21 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 afs_int32
 SRXAFS_GetRootVolume(struct rx_call * acall, char **VolumeName)
 {
+#ifdef notdef
     int fd;
     int len;
     char *temp;
-    int errorCode = 0;         /* error code */
     struct rx_connection *tcon;
+    struct host *thost;
+#endif
+    int errorCode = 0;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
-    struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
+    struct timeval opStartTime;        /* Start time for RPC op */
+#ifdef notdef
+    struct timeval opStopTime;
     struct timeval elapsedTime;        /* Transfer time */
+#endif
 
     /*
      * Set our stats pointer, remember when the RPC operation started, and
@@ -6392,13 +6590,13 @@ SRXAFS_GetRootVolume(struct rx_call * acall, char **VolumeName)
     return FSERR_EOPNOTSUPP;
 
 #ifdef notdef
-    if (errorCode = CallPreamble(acall, ACTIVECALL, &tcon))
+    if (errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost))
        goto Bad_GetRootVolume;
     FS_LOCK;
     AFSCallStats.GetRootVolume++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
     temp = malloc(256);
-    fd = open(AFSDIR_SERVER_ROOTVOL_FILEPATH, O_RDONLY, 0666);
+    fd = afs_open(AFSDIR_SERVER_ROOTVOL_FILEPATH, O_RDONLY, 0666);
     if (fd <= 0)
        strcpy(temp, DEFAULTVOLUME);
     else {
@@ -6421,7 +6619,7 @@ SRXAFS_GetRootVolume(struct rx_call * acall, char **VolumeName)
     *VolumeName = temp;                /* freed by rx server-side stub */
 
   Bad_GetRootVolume:
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -6454,6 +6652,7 @@ SRXAFS_CheckToken(struct rx_call * acall, afs_int32 AfsId,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -6470,13 +6669,13 @@ SRXAFS_CheckToken(struct rx_call * acall, afs_int32 AfsId,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_CheckToken;
 
     code = FSERR_ECONNREFUSED;
 
   Bad_CheckToken:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -6506,6 +6705,7 @@ SRXAFS_GetTime(struct rx_call * acall, afs_uint32 * Seconds,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
     struct timeval tpl;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
@@ -6523,7 +6723,7 @@ SRXAFS_GetTime(struct rx_call * acall, afs_uint32 * Seconds,
     TM_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon, &thost)))
        goto Bad_GetTime;
 
     FS_LOCK;
@@ -6536,7 +6736,7 @@ SRXAFS_GetTime(struct rx_call * acall, afs_uint32 * Seconds,
     ViceLog(2, ("SAFS_GetTime returns %u, %u\n", *Seconds, *USeconds));
 
   Bad_GetTime:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
 
 #if FS_STATS_DETAILED
     TM_GetTimeOfDay(&opStopTime, 0);
@@ -6583,16 +6783,16 @@ SRXAFS_GetTime(struct rx_call * acall, afs_uint32 * Seconds,
 
 afs_int32
 FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
-                 register struct rx_call * Call, afs_int32 Pos,
-                 afs_int32 Len, afs_int32 Int64Mode,
+                 register struct rx_call * Call, afs_sfsize_t Pos,
+                 afs_sfsize_t Len, afs_int32 Int64Mode,
 #if FS_STATS_DETAILED
-                 afs_int32 * a_bytesToFetchP, afs_int32 * a_bytesFetchedP
+                 afs_sfsize_t * a_bytesToFetchP,
+                 afs_sfsize_t * a_bytesFetchedP
 #endif                         /* FS_STATS_DETAILED */
     )
 {
     struct timeval StartTime, StopTime;        /* used to calculate file  transfer rates */
     int errorCode = 0;         /* Returned error code to caller */
-    int code;
     IHandle_t *ihP;
     FdHandle_t *fdP;
 #ifdef AFS_NT40_ENV
@@ -6601,12 +6801,8 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     struct iovec tiov[RX_MAXIOVECS];
     int tnio;
 #endif /* AFS_NT40_ENV */
-    afs_int32 tlen;
+    afs_sfsize_t tlen;
     afs_int32 optSize;
-    struct stat tstat;
-#ifdef AFS_AIX_ENV
-    struct statfs tstatfs;
-#endif
 
 #if FS_STATS_DETAILED
     /*
@@ -6616,38 +6812,60 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     (*a_bytesFetchedP) = 0;
 #endif /* FS_STATS_DETAILED */
 
+
+    ViceLog(25,
+           ("FetchData_RXStyle: Pos %llu, Len %llu\n", (afs_uintmax_t) Pos,
+            (afs_uintmax_t) Len));
+
     if (!VN_GET_INO(targetptr)) {
+       afs_int32 zero = htonl(0);
        /*
         * This is used for newly created files; we simply send 0 bytes
         * back to make the cache manager happy...
         */
-       tlen = htonl(0);
        if (Int64Mode)
-           rx_Write(Call, (char *)&tlen, sizeof(afs_int32));   /* send 0-length  */
-       rx_Write(Call, (char *)&tlen, sizeof(afs_int32));       /* send 0-length  */
+           rx_Write(Call, (char *)&zero, sizeof(afs_int32));   /* send 0-length  */
+       rx_Write(Call, (char *)&zero, sizeof(afs_int32));       /* send 0-length  */
        return (0);
     }
     TM_GetTimeOfDay(&StartTime, 0);
     ihP = targetptr->handle;
     fdP = IH_OPEN(ihP);
-    if (fdP == NULL)
+    if (fdP == NULL) {
+       VTakeOffline(volptr);
+       ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                   volptr->hashid));
        return EIO;
+    }
     optSize = sendBufSize;
     tlen = FDH_SIZE(fdP);
+    ViceLog(25,
+           ("FetchData_RXStyle: file size %llu\n", (afs_uintmax_t) tlen));
     if (tlen < 0) {
        FDH_CLOSE(fdP);
+       VTakeOffline(volptr);
+       ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                   volptr->hashid));
        return EIO;
     }
+    if (Pos > tlen) {
+       Len = 0;
+    }
 
     if (Pos + Len > tlen)
        Len = tlen - Pos;       /* get length we should send */
     (void)FDH_SEEK(fdP, Pos, 0);
-    tlen = htonl(Len);
-    if (Int64Mode) {
-       afs_int32 zero = 0;
-       rx_Write(Call, (char *)&zero, sizeof(afs_int32));       /* High order bits */
+    {
+       afs_int32 high, low;
+       SplitOffsetOrSize(Len, high, low);
+       assert(Int64Mode || (Len >= 0 && high == 0) || Len < 0);
+       if (Int64Mode) {
+           high = htonl(high);
+           rx_Write(Call, (char *)&high, sizeof(afs_int32));   /* High order bits */
+       }
+       low = htonl(low);
+       rx_Write(Call, (char *)&low, sizeof(afs_int32));        /* send length on fetch */
     }
-    rx_Write(Call, (char *)&tlen, sizeof(afs_int32));  /* send length on fetch */
 #if FS_STATS_DETAILED
     (*a_bytesToFetchP) = Len;
 #endif /* FS_STATS_DETAILED */
@@ -6655,31 +6873,38 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     tbuffer = AllocSendBuffer();
 #endif /* AFS_NT40_ENV */
     while (Len > 0) {
+       int wlen;
        if (Len > optSize)
-           tlen = optSize;
+           wlen = optSize;
        else
-           tlen = Len;
+           wlen = (int)Len;
 #ifdef AFS_NT40_ENV
-       errorCode = FDH_READ(fdP, tbuffer, tlen);
-       if (errorCode != tlen) {
+       errorCode = FDH_READ(fdP, tbuffer, wlen);
+       if (errorCode != wlen) {
            FDH_CLOSE(fdP);
            FreeSendBuffer((struct afs_buffer *)tbuffer);
+           VTakeOffline(volptr);
+           ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                       volptr->hashid));
            return EIO;
        }
-       errorCode = rx_Write(Call, tbuffer, tlen);
+       errorCode = rx_Write(Call, tbuffer, wlen);
 #else /* AFS_NT40_ENV */
-       errorCode = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, tlen);
+       errorCode = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, wlen);
        if (errorCode <= 0) {
            FDH_CLOSE(fdP);
            return EIO;
        }
-       tlen = errorCode;
+       wlen = errorCode;
        errorCode = FDH_READV(fdP, tiov, tnio);
-       if (errorCode != tlen) {
+       if (errorCode != wlen) {
            FDH_CLOSE(fdP);
+           VTakeOffline(volptr);
+           ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                       volptr->hashid));
            return EIO;
        }
-       errorCode = rx_Writev(Call, tiov, tnio, tlen);
+       errorCode = rx_Writev(Call, tiov, tnio, wlen);
 #endif /* AFS_NT40_ENV */
 #if FS_STATS_DETAILED
        /*
@@ -6688,14 +6913,14 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
         */
        (*a_bytesFetchedP) += errorCode;
 #endif /* FS_STATS_DETAILED */
-       if (errorCode != tlen) {
+       if (errorCode != wlen) {
            FDH_CLOSE(fdP);
 #ifdef AFS_NT40_ENV
            FreeSendBuffer((struct afs_buffer *)tbuffer);
 #endif /* AFS_NT40_ENV */
            return -31;
        }
-       Len -= tlen;
+       Len -= wlen;
     }
 #ifdef AFS_NT40_ENV
     FreeSendBuffer((struct afs_buffer *)tbuffer);
@@ -6730,7 +6955,8 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
 }                              /*FetchData_RXStyle */
 
 static int
-GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc, int *size)
+GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc,
+                   afs_sfsize_t * size)
 {
 #ifdef AFS_NAMEI_ENV
     FdHandle_t *lhp;
@@ -6748,9 +6974,9 @@ GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc, int *size)
     *size = OS_SIZE(fdP->fd_fd);
     return (*size == -1) ? -1 : 0;
 #else
-    struct stat status;
+    struct afs_stat status;
 
-    if (fstat(fdP->fd_fd, &status) < 0) {
+    if (afs_fstat(fdP->fd_fd, &status) < 0) {
        return -1;
     }
 
@@ -6782,14 +7008,15 @@ GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc, int *size)
 afs_int32
 StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
                  struct client * client, register struct rx_call * Call,
-                 afs_uint32 Pos, afs_uint32 Length, afs_uint32 FileLength,
+                 afs_fsize_t Pos, afs_fsize_t Length, afs_fsize_t FileLength,
                  int sync,
 #if FS_STATS_DETAILED
-                 afs_int32 * a_bytesToStoreP, afs_int32 * a_bytesStoredP
+                 afs_sfsize_t * a_bytesToStoreP,
+                 afs_sfsize_t * a_bytesStoredP
 #endif                         /* FS_STATS_DETAILED */
     )
 {
-    int bytesTransfered;       /* number of bytes actually transfered */
+    afs_sfsize_t bytesTransfered;      /* number of bytes actually transfered */
     struct timeval StartTime, StopTime;        /* Used to measure how long the store takes */
     int errorCode = 0;         /* Returned error code to caller */
 #ifdef AFS_NT40_ENV
@@ -6798,15 +7025,14 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
     struct iovec tiov[RX_MAXIOVECS];   /* no data copying with iovec */
     int tnio;                  /* temp for iovec size */
 #endif /* AFS_NT40_ENV */
-    int tlen;                  /* temp for xfr length */
+    afs_sfsize_t tlen;         /* temp for xfr length */
     Inode tinode;              /* inode for I/O */
     afs_int32 optSize;         /* optimal transfer size */
-    int DataLength;            /* size of inode */
-    afs_int32 TruncatedLength; /* size after ftruncate */
-    afs_uint32 NewLength;      /* size after this store completes */
-    afs_int32 adjustSize;      /* bytes to call VAdjust... with */
+    afs_sfsize_t DataLength;   /* size of inode */
+    afs_sfsize_t TruncatedLength;      /* size after ftruncate */
+    afs_fsize_t NewLength;     /* size after this store completes */
+    afs_sfsize_t adjustSize;   /* bytes to call VAdjust... with */
     int linkCount;             /* link count on inode */
-    int code;
     FdHandle_t *fdP;
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 
@@ -6826,12 +7052,12 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
 
     if (Pos == -1 || VN_GET_INO(targetptr) == 0) {
        /* the inode should have been created in Alloc_NewVnode */
-       logHostAddr.s_addr = rx_HostOf(rx_PeerOf(rx_ConnectionOf(Call)));
+       logHostAddr.s_addr = rxr_HostOf(rx_ConnectionOf(Call));
        ViceLog(0,
-               ("StoreData_RXStyle : Inode non-existent Fid = %u.%u.%u, inode = %llu, Pos %d Host %s\n",
+               ("StoreData_RXStyle : Inode non-existent Fid = %u.%u.%u, inode = %llu, Pos %llu Host %s:%d\n",
                 Fid->Volume, Fid->Vnode, Fid->Unique,
-                (afs_uintmax_t) VN_GET_INO(targetptr), Pos,
-                inet_ntoa(logHostAddr)));
+                (afs_uintmax_t) VN_GET_INO(targetptr), (afs_uintmax_t) Pos,
+                inet_ntoa(logHostAddr), ntohs(rxr_PortOf(rx_ConnectionOf(Call)))));
        return ENOENT;          /* is this proper error code? */
     } else {
        /*
@@ -6847,6 +7073,9 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
            return ENOENT;
        if (GetLinkCountAndSize(volptr, fdP, &linkCount, &DataLength) < 0) {
            FDH_CLOSE(fdP);
+           VTakeOffline(volptr);
+           ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                       volptr->hashid));
            return EIO;
        }
 
@@ -6890,7 +7119,12 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        }
        tinode = VN_GET_INO(targetptr);
     }
-    assert(VALID_INO(tinode));
+    if (!VALID_INO(tinode)) {
+       VTakeOffline(volptr);
+       ViceLog(0,("Volume %u now offline, must be salvaged.\n",
+                  volptr->hashid));
+       return EIO;
+    }
 
     /* compute new file length */
     NewLength = DataLength;
@@ -6921,6 +7155,10 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
     TM_GetTimeOfDay(&StartTime, 0);
 
     optSize = sendBufSize;
+    ViceLog(25,
+           ("StoreData_RXStyle: Pos %llu, DataLength %llu, FileLength %llu, Length %llu\n",
+            (afs_uintmax_t) Pos, (afs_uintmax_t) DataLength,
+            (afs_uintmax_t) FileLength, (afs_uintmax_t) Length));
 
     /* truncate the file iff it needs it (ftruncate is slow even when its a noop) */
     if (FileLength < DataLength)
@@ -6952,17 +7190,20 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        (*a_bytesToStoreP) = Length;
 #endif /* FS_STATS_DETAILED */
        while (1) {
+           int rlen;
            if (bytesTransfered >= Length) {
                errorCode = 0;
                break;
            }
            tlen = Length - bytesTransfered;    /* how much more to do */
            if (tlen > optSize)
-               tlen = optSize; /* bound by buffer size */
+               rlen = optSize; /* bound by buffer size */
+           else
+               rlen = (int)tlen;
 #ifdef AFS_NT40_ENV
-           errorCode = rx_Read(Call, tbuffer, tlen);
+           errorCode = rx_Read(Call, tbuffer, rlen);
 #else /* AFS_NT40_ENV */
-           errorCode = rx_Readv(Call, tiov, &tnio, RX_MAXIOVECS, tlen);
+           errorCode = rx_Readv(Call, tiov, &tnio, RX_MAXIOVECS, rlen);
 #endif /* AFS_NT40_ENV */
 #if FS_STATS_DETAILED
            (*a_bytesStoredP) += errorCode;
@@ -6971,17 +7212,17 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
                errorCode = -32;
                break;
            }
-           tlen = errorCode;
+           rlen = errorCode;
 #ifdef AFS_NT40_ENV
-           errorCode = FDH_WRITE(fdP, tbuffer, tlen);
+           errorCode = FDH_WRITE(fdP, tbuffer, rlen);
 #else /* AFS_NT40_ENV */
            errorCode = FDH_WRITEV(fdP, tiov, tnio);
 #endif /* AFS_NT40_ENV */
-           if (errorCode != tlen) {
+           if (errorCode != rlen) {
                errorCode = VDISKFULL;
                break;
            }
-           bytesTransfered += tlen;
+           bytesTransfered += rlen;
        }
     }
   done:
@@ -6992,7 +7233,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        FDH_SYNC(fdP);
     }
     if (errorCode) {
-       afs_fsize_t nfSize = FDH_SIZE(fdP);
+       afs_fsize_t nfSize = (afs_fsize_t) FDH_SIZE(fdP);
        /* something went wrong: adjust size and return */
        VN_SET_LEN(targetptr, nfSize);  /* set new file size. */
        /* changed_newTime is tested in StoreData to detemine if we
@@ -7002,7 +7243,8 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        FDH_CLOSE(fdP);
        /* set disk usage to be correct */
        VAdjustDiskUsage(&errorCode, volptr,
-                        (int)(nBlocks(nfSize) - nBlocks(NewLength)), 0);
+                        (afs_sfsize_t) (nBlocks(nfSize) -
+                                        nBlocks(NewLength)), 0);
        return errorCode;
     }
     FDH_CLOSE(fdP);
@@ -7077,9 +7319,13 @@ init_sys_error_to_et(void)
     sys2et[ENAMETOOLONG] = UAENAMETOOLONG;
     sys2et[ENOLCK] = UAENOLCK;
     sys2et[ENOSYS] = UAENOSYS;
+#if (ENOTEMPTY != EEXIST)
     sys2et[ENOTEMPTY] = UAENOTEMPTY;
+#endif
     sys2et[ELOOP] = UAELOOP;
+#if (EWOULDBLOCK != EAGAIN)
     sys2et[EWOULDBLOCK] = UAEWOULDBLOCK;
+#endif
     sys2et[ENOMSG] = UAENOMSG;
     sys2et[EIDRM] = UAEIDRM;
     sys2et[ECHRNG] = UAECHRNG;
@@ -7163,6 +7409,107 @@ init_sys_error_to_et(void)
     sys2et[EDQUOT] = UAEDQUOT;
     sys2et[ENOMEDIUM] = UAENOMEDIUM;
     sys2et[EMEDIUMTYPE] = UAEMEDIUMTYPE;
+
+    sys2et[EIO] = UAEIO;
+}
+
+/* NOTE:  2006-03-01                                                     
+ *  SRXAFS_CallBackRxConnAddr should be re-written as follows:           
+ *  - pass back the connection, client, and host from CallPreamble       
+ *  - keep a ref on the client, which we don't now                       
+ *  - keep a hold on the host, which we already do                       
+ *  - pass the connection, client, and host down into SAFSS_*, and use   
+ *    them instead of independently discovering them via rx_ConnectionOf 
+ *    (safe) and rx_GetSpecific (not so safe)                            
+ *  The idea being that we decide what client and host we're going to use
+ *  when CallPreamble is called, and stay consistent throughout the call.
+ *  This change is too invasive for 1.4.1 but should be made in 1.5.x.   
+ */                                                                      
+
+afs_int32
+SRXAFS_CallBackRxConnAddr (struct rx_call * acall, afs_int32 *addr)
+{
+    Error errorCode = 0;
+    struct rx_connection *tcon;
+    struct host *tcallhost;
+#ifdef __EXPERIMENTAL_CALLBACK_CONN_MOVING
+    struct host *thost;
+    struct client *tclient;
+    static struct rx_securityClass *sc = 0;
+    int i,j;
+    struct rx_connection *conn;
+#endif
+    
+    if (errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &tcallhost))
+           goto Bad_CallBackRxConnAddr1;
+    
+#ifndef __EXPERIMENTAL_CALLBACK_CONN_MOVING
+    errorCode = 1;
+#else
+    H_LOCK;
+    tclient = h_FindClient_r(tcon);
+    if (!tclient) {
+       errorCode = VBUSY;
+       goto Bad_CallBackRxConnAddr;
+    }
+    thost = tclient->host;
+    
+    /* nothing more can be done */
+    if ( !thost->interface ) 
+       goto Bad_CallBackRxConnAddr;
+    
+    assert(thost->interface->numberOfInterfaces > 0 );
+    
+    /* the only address is the primary interface */
+    /* can't change when there's only 1 address, anyway */
+    if ( thost->interface->numberOfInterfaces == 1 ) 
+       goto Bad_CallBackRxConnAddr;
+    
+    /* initialise a security object only once */
+    if ( !sc )
+       sc = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
+    
+    for ( i=0; i < thost->interface->numberOfInterfaces; i++)
+    {
+           if ( *addr == thost->interface->addr[i] ) {
+                   break;
+           }
+    }
+    
+    if ( *addr != thost->interface->addr[i] ) 
+       goto Bad_CallBackRxConnAddr;
+
+    conn = rx_NewConnection (thost->interface->addr[i],
+                            thost->port, 1, sc, 0);
+    rx_SetConnDeadTime(conn, 2); 
+    rx_SetConnHardDeadTime(conn, AFS_HARDDEADTIME); 
+    H_UNLOCK;
+    errorCode = RXAFSCB_Probe(conn);
+    H_LOCK;
+    if (!errorCode) {
+       if ( thost->callback_rxcon )
+           rx_DestroyConnection(thost->callback_rxcon);
+       thost->callback_rxcon = conn;
+       thost->host           = addr;
+       rx_SetConnDeadTime(thost->callback_rxcon, 50);
+       rx_SetConnHardDeadTime(thost->callback_rxcon, AFS_HARDDEADTIME);
+       h_ReleaseClient_r(tclient);
+       /* The hold on thost will be released by CallPostamble */
+       H_UNLOCK;
+       errorCode = CallPostamble(tcon, errorCode, tcallhost);
+       return errorCode;
+    } else {
+       rx_DestroyConnection(conn);
+    }      
+  Bad_CallBackRxConnAddr:
+    h_ReleaseClient_r(tclient);
+    /* The hold on thost will be released by CallPostamble */
+    H_UNLOCK;
+#endif
+
+    errorCode = CallPostamble(tcon, errorCode, tcallhost);
+ Bad_CallBackRxConnAddr1:
+    return errorCode;          /* failure */
 }
 
 afs_int32
@@ -7172,6 +7519,8 @@ sys_error_to_et(afs_int32 in)
        return 0;
     if (in < 0 || in > 511)
        return in;
+    if (in >= VICE_SPECIAL_ERRORS && in <= VIO || in == VRESTRICTED)
+       return in;
     if (sys2et[in] != 0)
        return sys2et[in];
     return in;