viced-rmdir-fid-leak-20080219
[openafs.git] / src / viced / afsfileprocs.c
index c02aa5a..8c60b13 100644 (file)
@@ -47,14 +47,7 @@ RCSID
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 
 #ifndef AFS_LINUX20_ENV
 #include <net/if.h>
@@ -106,7 +99,6 @@ RCSID
 #include <afs/cellconfig.h>
 #include <afs/keys.h>
 
-#include <afs/auth.h>
 #include <signal.h>
 #include <afs/partition.h>
 #include "viced_prototypes.h"
@@ -311,6 +303,8 @@ CallPreamble(register struct rx_call *acall, int activecall,
     char hoststr[16], hoststr2[16];
     struct ubik_client *uclient;
 
+    *ahostp = NULL;
+
     if (!tconn) {
        ViceLog(0, ("CallPreamble: unexpected null tconn!\n"));
        return -1;
@@ -320,6 +314,11 @@ 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) {
@@ -343,7 +342,8 @@ CallPreamble(register struct rx_call *acall, int activecall,
            hpr_End(uclient);
        code = hpr_Initialize(&uclient);
 
-       assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0);
+       if (!code)
+           assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0);
        H_LOCK;
 #else
        code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0);
@@ -377,7 +377,7 @@ CallPreamble(register struct rx_call *acall, int activecall,
        if (BreakDelayedCallBacks_r(thost)) {
            ViceLog(0,
                    ("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), rxr_AddrStringOf(*tconn), 
+                    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,
@@ -393,7 +393,7 @@ CallPreamble(register struct rx_call *acall, int activecall,
                if (BreakDelayedCallBacks_r(thost)) {
                    ViceLog(0,
                            ("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), rxr_AddrStringOf(*tconn), 
+                             afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), afs_inet_ntoa_r(rxr_HostOf(*tconn), hoststr2), 
                              ntohs(rxr_PortOf(*tconn))));
                    code = -1;
                }
@@ -423,6 +423,8 @@ CallPostamble(register struct rx_connection *aconn, afs_int32 ret,
 
     H_LOCK;
     tclient = h_FindClient_r(aconn);
+    if (!tclient) 
+       goto busyout;
     thost = tclient->host;
     if (thost->hostFlags & HERRORTRANS)
        translate = 1;
@@ -430,15 +432,21 @@ CallPostamble(register struct rx_connection *aconn, afs_int32 ret,
     held = h_Held_r(thost);
     if (held)
        h_Release_r(thost);
-    if (ahost != 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(thost->host, hoststr), ntohs(thost->port),
+               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 */
@@ -675,7 +683,7 @@ GetRights(struct client *client, struct acl_accessList *ACL,
 
     if (!client->host->hcps.prlist_len || !client->host->hcps.prlist_val) {
        char hoststr[16];
-       ViceLog(0,
+       ViceLog(5,
                ("CheckRights: len=%u, for host=%s:%d\n",
                 client->host->hcps.prlist_len, 
                 afs_inet_ntoa_r(client->host->host, hoststr),
@@ -1092,7 +1100,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;
@@ -1168,12 +1182,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 */
-               ViceLog(0, ("CopyOnWrite failed: taking volume offline\n"));
-#elif defined(AFS_DEMAND_ATTACH_FS)
+#if defined(AFS_DEMAND_ATTACH_FS)
                ViceLog(0, ("CopyOnWrite failed: requesting salvage\n"));
-#else /* Avoid further corruption and try to get a core. */
-               assert(0);
+#else
+               ViceLog(0, ("CopyOnWrite failed: taking volume offline\n"));
 #endif
                /* Decrement this inode so salvager doesn't find it. */
                FDH_REALLYCLOSE(newFdP);
@@ -1261,6 +1273,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;
     }
@@ -1270,6 +1285,7 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
        if (IsEmpty(&childdir) != 0)
            return (EEXIST);
        DZap(&childdir);
+       FidZap(&childdir);
        (*targetptr)->delete = 1;
     } else if ((--(*targetptr)->disk.linkCount) == 0)
        (*targetptr)->delete = 1;
@@ -1288,10 +1304,10 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
                         errno));
                if (errno != ENOENT)
                {
+                   VTakeOffline(volptr);
                    ViceLog(0,
                            ("Volume %u now offline, must be salvaged.\n",
                             volptr->hashid));
-                   VTakeOffline(volptr);
                    return (EIO);
                }
                DT1++;
@@ -1314,10 +1330,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;
     }
@@ -1721,8 +1737,11 @@ HandleLocking(Vnode * targetptr, struct client *client, afs_int32 rights, ViceLo
                0;
        Time += AFS_LOCKWAIT;
        if (LockingType == LockRead) {
-           if ( !(rights & PRSFS_LOCK) )
-               return(EACCES);
+           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);
@@ -2023,6 +2042,7 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid,
     struct host *thost;
     afs_int32 rights, anyrights;       /* rights for this and any user */
     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 */
     struct fs_stats_xferData *xferP;   /* Ptr to this op's byte size struct */
@@ -2057,9 +2077,10 @@ common_FetchData64(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 = rxr_HostOf(tcon);
     ViceLog(5,
            ("SRXAFS_FetchData, Fid = %u.%u.%u, Host %s:%d, Id %d\n",
-            Fid->Volume, Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
+            Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
             ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     /*
      * Get volume/vnode for the fetched file; caller's access rights to
@@ -2285,6 +2306,7 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
     struct rx_connection *tcon = rx_ConnectionOf(acall);
     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 */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -2312,9 +2334,10 @@ SRXAFS_FetchACL(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 = rxr_HostOf(tcon);
     ViceLog(5,
            ("SAFS_FetchACL, Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
-            Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
+            Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
             ntohs(rxr_PortOf(tcon)), t_client->ViceId));
 
     AccessList->AFSOpaque_len = 0;
@@ -2402,13 +2425,15 @@ SAFSS_FetchStatus(struct rx_call *acall, struct AFSFid *Fid,
     struct client *client = 0; /* pointer to the client data */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_FetchStatus,  Fid = %u.%u.%u, Host %s:%d, Id %d\n",
-            Fid->Volume, Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
+            Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
             ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.FetchStatus++, AFSCallStats.TotalCalls++;
@@ -2854,6 +2879,7 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
     struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     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
@@ -2889,9 +2915,10 @@ common_StoreData64(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 = rxr_HostOf(tcon);
     ViceLog(5,
            ("StoreData: Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
-            Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
+            Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
             ntohs(rxr_PortOf(tcon)), t_client->ViceId));
 
     /*
@@ -3120,6 +3147,7 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
     struct rx_connection *tcon;
     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 */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -3140,10 +3168,11 @@ SRXAFS_StoreACL(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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_StoreACL, Fid = %u.%u.%u, ACL=%s, Host %s:%d, Id %d\n",
             Fid->Volume, Fid->Vnode, Fid->Unique, AccessList->AFSOpaque_val,
-            rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.StoreACL++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -3236,13 +3265,15 @@ SAFSS_StoreStatus(struct rx_call *acall, struct AFSFid *Fid,
     struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_StoreStatus,  Fid    = %u.%u.%u, Host %s:%d, Id %d\n",
-            Fid->Volume, Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
+            Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
             ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.StoreStatus++, AFSCallStats.TotalCalls++;
@@ -3382,15 +3413,17 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     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 */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_RemoveFile %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.RemoveFile++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -3545,16 +3578,18 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     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 */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_CreateFile %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.CreateFile++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -3727,6 +3762,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
     int doDelete;              /* deleted the rename target (ref count now 0) */
     int code;
     struct client *t_client;   /* tmp ptr to client data */
+    struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     FidZero(&olddir);
@@ -3736,11 +3772,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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("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, rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+            NewDirFid->Unique, inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.Rename++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -3956,6 +3993,9 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
            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;
            }
@@ -4201,6 +4241,7 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     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;
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
@@ -4208,10 +4249,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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_Symlink %s to %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             LinkContents, DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.Symlink++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -4283,10 +4325,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);
+    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));
+    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
@@ -4404,17 +4454,19 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     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 */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("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,
-            rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.Link++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -4608,6 +4660,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     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 */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     FidZero(&dir);
@@ -4615,10 +4668,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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_MakeDir %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.MakeDir++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -4802,16 +4856,18 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     afs_int32 rights, anyrights;       /* rights for this and any user */
     Vnode debugvnode1, debugvnode2;
     struct client *t_client;   /* tmp ptr to client data */
+    struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_RemoveDir    %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.RemoveDir++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -4957,6 +5013,7 @@ SAFSS_SetLock(struct rx_call *acall, struct AFSFid *Fid, ViceLockType type,
     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[4] = { "LockRead", "LockWrite", "LockExtend", "LockRelease" };
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
@@ -4966,10 +5023,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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_SetLock type = %s Fid = %u.%u.%u, Host %s:%d, Id %d\n",
             locktype[(int)type], Fid->Volume, Fid->Vnode, Fid->Unique,
-            rxr_AddrStringOf(tcon), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.SetLock++, AFSCallStats.TotalCalls++;
     FS_UNLOCK;
@@ -5086,13 +5144,15 @@ SAFSS_ExtendLock(struct rx_call *acall, struct AFSFid *Fid,
     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 */
     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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_ExtendLock Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
-            Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
+            Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
             ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.ExtendLock++, AFSCallStats.TotalCalls++;
@@ -5211,13 +5271,15 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
     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 */
     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 = rxr_HostOf(tcon);
     ViceLog(1,
            ("SAFS_ReleaseLock Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
-            Fid->Vnode, Fid->Unique, rxr_AddrStringOf(tcon),
+            Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
             ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     FS_LOCK;
     AFSCallStats.ReleaseLock++, AFSCallStats.TotalCalls++;
@@ -5917,19 +5979,21 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
 
     if (!FidArray && !CallBackArray) {
        ViceLog(1,
-               ("SAFS_GiveUpAllCallBacks: host=%s\n",
-                (tcon->peer ? rx_AddrStringOf(tcon->peer) : "<unknown>")));
+               ("SAFS_GiveUpAllCallBacks: host=%x\n",
+                (tcon->peer ? tcon->peer->host : 0)));
        errorCode = GetClient(tcon, &client);
        if (!errorCode) {
+           H_LOCK;
            DeleteAllCallBacks_r(client->host, 1);
+           H_UNLOCK;
            PutClient(&client);
        }
     } else {
        if (FidArray->AFSCBFids_len < CallBackArray->AFSCBs_len) {
            ViceLog(0,
-                   ("GiveUpCallBacks: #Fids %d < #CallBacks %d, host=%s\n",
+                   ("GiveUpCallBacks: #Fids %d < #CallBacks %d, host=%x\n",
                     FidArray->AFSCBFids_len, CallBackArray->AFSCBs_len,
-                    (tcon->peer ? rx_AddrStringOf(tcon->peer) : "<unknown>")));
+                    (tcon->peer ? tcon->peer->host : 0)));
            errorCode = EINVAL;
            goto Bad_GiveUpCallBacks;
        }
@@ -6029,10 +6093,12 @@ SRXAFS_GetCapabilities(struct rx_call * acall, Capabilities * capabilities)
 
     dataBytes = 1 * sizeof(afs_int32);
     dataBuffP = (afs_int32 *) malloc(dataBytes);
-    dataBuffP[0] = VICED_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;
@@ -6764,6 +6830,8 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     fdP = IH_OPEN(ihP);
     if (fdP == NULL) {
        VTakeOffline(volptr);
+       ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                   volptr->hashid));
        return EIO;
     }
     optSize = sendBufSize;
@@ -6773,6 +6841,8 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     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) {
@@ -6811,6 +6881,8 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
            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, wlen);
@@ -6825,6 +6897,8 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
        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, wlen);
@@ -6957,6 +7031,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
     afs_sfsize_t adjustSize;   /* bytes to call VAdjust... with */
     int linkCount;             /* link count on inode */
     FdHandle_t *fdP;
+    struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 
 #if FS_STATS_DETAILED
     /*
@@ -6974,12 +7049,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 = rxr_HostOf(rx_ConnectionOf(Call));
        ViceLog(0,
                ("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), (afs_uintmax_t) Pos,
-                rxr_AddrStringOf(rx_ConnectionOf(Call)),
-                ntohs(rxr_PortOf(rx_ConnectionOf(Call)))));
+                inet_ntoa(logHostAddr), ntohs(rxr_PortOf(rx_ConnectionOf(Call)))));
        return ENOENT;          /* is this proper error code? */
     } else {
        /*
@@ -6996,6 +7071,8 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        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;
        }
 
@@ -7039,7 +7116,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;
@@ -7234,9 +7316,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;
@@ -7320,6 +7406,8 @@ init_sys_error_to_et(void)
     sys2et[EDQUOT] = UAEDQUOT;
     sys2et[ENOMEDIUM] = UAENOMEDIUM;
     sys2et[EMEDIUMTYPE] = UAEMEDIUMTYPE;
+
+    sys2et[EIO] = UAEIO;
 }
 
 /* NOTE:  2006-03-01                                                     
@@ -7357,17 +7445,19 @@ SRXAFS_CallBackRxConnAddr (struct rx_call * acall, afs_int32 *addr)
 #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 ) 
+    if ( thost->interface->numberOfInterfaces <= 1 ) 
        goto Bad_CallBackRxConnAddr;
     
     /* initialise a security object only once */