]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-post-1-3-70-windows-changes-20040816
authorJeffrey Altman <jaltman@mit.edu>
Tue, 17 Aug 2004 05:28:34 +0000 (05:28 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 17 Aug 2004 05:28:34 +0000 (05:28 +0000)
  * Fix aklog.exe to not add the AFS ID to the username

  * PTS registration of new users to foreign cells has been added to
     afscreds.exe

  * The cm_Daemon thread is used to perform checks for
    down servers, up servers, volumes, callback expirations,
    lock maintenance and token expiration.  Due to a gaff in
    larger integer division the thread never performed any
    work.  Instead the current time computation would always
    be less then the trigger times.  This had an adverse affect
    on the client's ability to maintain communication with servers,
    keep volumes up to date, and flush user tokens and acls
    when they have expired. This was broken when the 1.3 branch
    was modified to support VC7 which no longer included
    largeint.lib

  * An initialization problem with the Freelance code was
    detected while fixing the callbackRequest.  The cm_rootSCachep
    object is obtained during afsd_InitDaemons() but the callback
    information is incomplete.  The callback information will not
    be obtained until cm_MergeStatus is called from within
    cm_GetCallback.  Unfortunately, cm_SyncOp did not properly
    test for the conditions under which the callback information
    must be obtained.

  * Reports have been filed indicating that callbacks were
    being lost.  An examination of the code indicated that the
    cm_server_t objects were not being properly reference
    counted by the cm_scache_t and cm_callbackRequest_t objects.
    In particular, the cm_server_t objects may have been freed
    from beneath the cm_conn_t objects.

    All of the reference counting is now done via the functions:
        cm_GetServer
        cm_GetServerNoLock
        cm_PutServer
        cm_PutServerNoLock
    this improves the ability to track the referrals.

    Each cm_BeginCallbackGranting Call now allocates a reference
    to the cm_server_t.  The cm_EndCallbackGrantingCall either
    frees the reference or transfers it to the cm_scache_t
    cbServerp field.  These are then appropriately tracked
    through the cm_Analyze call.

  * Ensure that the dnlc hash table is the same size as the
    dir name hash table (as per original author's note).
    Increase the dnlc CM_AFSNCNAMESIZE to a multiple of 8
    for compatibility with 64-bit systems.

  * fix smb_ApplyV3DirListPatches to properly apply the hidden
     attribute to dotfiles when the infoLevel < 0x101 and
     cm_SyncOp has failed.

  * Fix the Freelance registry initialization code.  There
    was a possibility that some systems could end up with
    garbage in the registry during a clean install.

(cherry picked from commit 3dce18d2481ee07ac27af8bd691d640247526a5d)

28 files changed:
doc/txt/winnotes/afs-changes-since-1.2.txt
doc/txt/winnotes/afs-issues.txt
src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/afskfw.c
src/WINNT/afsd/cm_access.c
src/WINNT/afsd/cm_buf.c
src/WINNT/afsd/cm_buf.h
src/WINNT/afsd/cm_callback.c
src/WINNT/afsd/cm_callback.h
src/WINNT/afsd/cm_conn.c
src/WINNT/afsd/cm_daemon.c
src/WINNT/afsd/cm_dcache.c
src/WINNT/afsd/cm_dir.h
src/WINNT/afsd/cm_dnlc.c
src/WINNT/afsd/cm_dnlc.h
src/WINNT/afsd/cm_freelance.c
src/WINNT/afsd/cm_ioctl.c
src/WINNT/afsd/cm_scache.c
src/WINNT/afsd/cm_server.c
src/WINNT/afsd/cm_server.h
src/WINNT/afsd/cm_vnodeops.c
src/WINNT/afsd/cm_volume.c
src/WINNT/afsd/smb.h
src/WINNT/afsd/smb3.c
src/WINNT/aklog/aklog.c
src/WINNT/client_osi/osiutils.c
src/config/NTMakefile.i386_nt40
src/volser/vos.c

index e4210af32105aa08c5152c4db0bedcaf12cf63d9..e11c1968658aa0e4b0f348a1218f49ba18a948a1 100644 (file)
@@ -1,3 +1,63 @@
+Since 1.3.70:
+  * Fix aklog.exe to not add the AFS ID to the username
+
+  * PTS registration of new users to foreign cells has been added to 
+     afscreds.exe
+
+  * The cm_Daemon thread is used to perform checks for 
+    down servers, up servers, volumes, callback expirations, 
+    lock maintenance and token expiration.  Due to a gaff in
+    larger integer division the thread never performed any 
+    work.  Instead the current time computation would always
+    be less then the trigger times.  This had an adverse affect
+    on the client's ability to maintain communication with servers,
+    keep volumes up to date, and flush user tokens and acls
+    when they have expired. This was broken when the 1.3 branch
+    was modified to support VC7 which no longer included 
+    largeint.lib
+
+  * An initialization problem with the Freelance code was 
+    detected while fixing the callbackRequest.  The cm_rootSCachep
+    object is obtained during afsd_InitDaemons() but the callback 
+    information is incomplete.  The callback information will not
+    be obtained until cm_MergeStatus is called from within
+    cm_GetCallback.  Unfortunately, cm_SyncOp did not properly 
+    test for the conditions under which the callback information
+    must be obtained.  
+
+  * Reports have been filed indicating that callbacks were
+    being lost.  An examination of the code indicated that the
+    cm_server_t objects were not being properly reference
+    counted by the cm_scache_t and cm_callbackRequest_t objects.
+    In particular, the cm_server_t objects may have been freed
+    from beneath the cm_conn_t objects.
+
+    All of the reference counting is now done via the functions:
+        cm_GetServer
+        cm_GetServerNoLock
+        cm_PutServer
+        cm_PutServerNoLock
+    this improves the ability to track the referrals.  
+
+    Each cm_BeginCallbackGranting Call now allocates a reference
+    to the cm_server_t.  The cm_EndCallbackGrantingCall either
+    frees the reference or transfers it to the cm_scache_t
+    cbServerp field.  These are then appropriately tracked
+    through the cm_Analyze call.
+
+  * Ensure that the dnlc hash table is the same size as the
+    dir name hash table (as per original author's note).
+    Increase the dnlc CM_AFSNCNAMESIZE to a multiple of 8
+    for compatibility with 64-bit systems.
+
+  * fix smb_ApplyV3DirListPatches to properly apply the hidden
+     attribute to dotfiles when the infoLevel < 0x101 and 
+     cm_SyncOp has failed.
+
+  * Fix the Freelance registry initialization code.  There
+    was a possibility that some systems could end up with 
+    garbage in the registry during a clean install.
+
 Since 1.3.66:
    * file and directory names beginning with "." will now be given the
      hidden attribute when the volume access is anonymous.  this matches
index 8d4e27303a4e4344fe59a6009f3b7e7ebbec0906..c640aba056d6936eac766cea476011882cb39718 100644 (file)
@@ -196,3 +196,5 @@ List of unfunded projects:
       afsmap.exe <drive> <afs-path> [/PERSISTENT]
       afsmap.exe <drive> <unc-path> [/PERSISTENT]
       afsmap.exe <drive> /DELETE
+  23. Write-through caching appears to be unsupported.   Files copied to AFS
+      do not end up in the local cache.
index db6c3a54c74b44e27c35f21c06a0d3950712b3b9..faf11da1cccee4963d876c9b12980f20cf334344 100644 (file)
@@ -46,7 +46,7 @@ DWORD cm_rootVolumeNameLen;
 cm_volume_t *cm_rootVolumep = NULL;
 cm_cell_t *cm_rootCellp = NULL;
 cm_fid_t cm_rootFid;
-cm_scache_t *cm_rootSCachep;
+cm_scache_t *cm_rootSCachep = NULL;
 char cm_mountRoot[1024];
 DWORD cm_mountRootLen;
 int cm_logChunkSize;
@@ -71,7 +71,7 @@ long cm_HostAddr;
 
 char cm_NetbiosName[MAX_NB_NAME_LENGTH] = "";
 
-char cm_CachePath[200];
+char cm_CachePath[MAX_PATH];
 DWORD cm_CachePathLen;
 
 BOOL isGateway = FALSE;
@@ -553,8 +553,7 @@ int afsd_InitCM(char **reasonP)
                code = RegQueryValueEx(parmKey, "LogoffTokenTransferTimeout",
                                        NULL, NULL, (BYTE *) &ltto, &dummyLen);
                if (code == ERROR_SUCCESS)
-                       afsi_log("Logoff token tranfer timeout %d seconds",
-                                ltto);
+            afsi_log("Logoff token tranfer timeout %d seconds", ltto);
                else {
                        ltto = 10;
                        afsi_log("Default logoff token transfer timeout 10 seconds");
@@ -647,8 +646,7 @@ int afsd_InitCM(char **reasonP)
     cm_sysName = cm_sysNameList[0];
 
        dummyLen = MAXSYSNAME;
-       code = RegQueryValueEx(parmKey, "SysName", NULL, NULL,
-                               cm_sysName, &dummyLen);
+    code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, cm_sysName, &dummyLen);
        if (code == ERROR_SUCCESS)
                afsi_log("Sys name %s", cm_sysName);
        else {
@@ -943,11 +941,11 @@ int afsd_InitCM(char **reasonP)
         }
        }
 
+
 #ifdef AFS_FREELANCE_CLIENT
        if (cm_freelanceEnabled)
          cm_InitFreelance();
 #endif
-
        return 0;
 }
 
index fbf10568a24379d2b00fe15e6bf08928c3bf0d07..763dc19b113fe7ee204c244e64c8dbaadba33c93 100644 (file)
@@ -62,6 +62,7 @@
 
 #include <osilog.h>
 #include <rxkad_prototypes.h>   /* for life_to_time */
+#include <afs/ptserver.h>
 
 /*
  * TIMING _____________________________________________________________________
@@ -2378,6 +2379,114 @@ KFW_AFS_unlog(void)
     return(0);
 }
 
+
+#define ALLOW_REGISTER 1
+static int
+ViceIDToUsername(char *username, 
+                 char *realm_of_user, 
+                 char *realm_of_cell,
+                 char * cell_to_use,
+                 struct ktc_principal *aclient, 
+                 struct ktc_principal *aserver, 
+                 struct ktc_token *atoken)
+{
+    static char lastcell[MAXCELLCHARS+1] = { 0 };
+    static char confname[512] = { 0 };
+    char username_copy[BUFSIZ];
+    long viceId;                       /* AFS uid of user */
+    int  status = 0;
+#ifdef ALLOW_REGISTER
+    afs_int32 id;
+#endif /* ALLOW_REGISTER */
+
+    if (confname[0] == '\0') {
+        strncpy(confname, AFSDIR_CLIENT_ETC_DIRPATH, sizeof(confname));
+        confname[sizeof(confname) - 2] = '\0';
+    }
+
+    /*
+     * Talk about DUMB!  It turns out that there is a bug in
+     * pr_Initialize -- even if you give a different cell name
+     * to it, it still uses a connection to a previous AFS server
+     * if one exists.  The way to fix this is to change the
+     * _filename_ argument to pr_Initialize - that forces it to
+     * re-initialize the connection.  We do this by adding and
+     * removing a "/" on the end of the configuration directory name.
+     */
+
+    if (lastcell[0] != '\0' && (strcmp(lastcell, aserver->cell) != 0)) {
+        int i = strlen(confname);
+        if (confname[i - 1] == '/') {
+            confname[i - 1] = '\0';
+        } else {
+            confname[i] = '/';
+            confname[i + 1] = '\0';
+        }
+    }
+
+    strcpy(lastcell, aserver->cell);
+
+    if (!pr_Initialize (0, confname, aserver->cell))
+        status = pr_SNameToId (username, &viceId);
+
+    /*
+     * This is a crock, but it is Transarc's crock, so
+     * we have to play along in order to get the
+     * functionality.  The way the afs id is stored is
+     * as a string in the username field of the token.
+     * Contrary to what you may think by looking at
+     * the code for tokens, this hack (AFS ID %d) will
+     * not work if you change %d to something else.
+     */
+
+    /*
+     * This code is taken from cklog -- it lets people
+     * automatically register with the ptserver in foreign cells
+     */
+
+#ifdef ALLOW_REGISTER
+    if (status == 0) {
+        if (viceId != ANONYMOUSID) {
+#else /* ALLOW_REGISTER */
+            if ((status == 0) && (viceId != ANONYMOUSID))
+#endif /* ALLOW_REGISTER */
+            {
+#ifdef AFS_ID_TO_NAME
+                strncpy(username_copy, username, BUFSIZ);
+                snprintf (username, BUFSIZ, "%s (AFS ID %d)", username_copy, (int) viceId);
+#endif /* AFS_ID_TO_NAME */
+            }
+#ifdef ALLOW_REGISTER
+        } else if (strcmp(realm_of_user, realm_of_cell) != 0) {
+            id = 0;
+            strncpy(aclient->name, username, MAXKTCNAMELEN - 1);
+            strcpy(aclient->instance, "");
+            strncpy(aclient->cell, realm_of_user, MAXKTCREALMLEN - 1);
+            if (status = ktc_SetToken(aserver, atoken, aclient, 0))
+                return status;
+
+            /*                                    
+             * In case you're wondering, we don't need to change the
+             * filename here because we're still connecting to the
+             * same cell -- we're just using a different authentication
+             * level
+             */
+
+            if (status = pr_Initialize(1L, confname, aserver->cell, 0))
+                return status;
+            if (status = pr_CreateUser(username, &id))
+                return status;
+#ifdef AFS_ID_TO_NAME
+            strncpy(username_copy, username, BUFSIZ);
+            snprintf (username, BUFSIZ, "%s (AFS ID %d)", username_copy, (int) viceId);
+#endif /* AFS_ID_TO_NAME */
+        }
+    }
+#endif /* ALLOW_REGISTER */
+    return status;
+}
+
+
 int
 KFW_AFS_klog(
     krb5_context alt_ctx,
@@ -2717,6 +2826,9 @@ KFW_AFS_klog(
             p[len] = '\0';
         }
 
+        ViceIDToUsername(aclient.name, realm_of_user, realm_of_cell, CellName, 
+                         &aclient, &aserver, &atoken);
+
         if ( smbname ) {
             strncpy(aclient.smbname, smbname, sizeof(aclient.smbname));
             aclient.smbname[sizeof(aclient.smbname)-1] = '\0';
@@ -2835,6 +2947,9 @@ KFW_AFS_klog(
 
     strcpy(aclient.cell, CellName);
 
+    ViceIDToUsername(aclient.name, realm_of_user, realm_of_cell, CellName, 
+                      &aclient, &aserver, &atoken);
+
     if ( smbname ) {
         strncpy(aclient.smbname, smbname, sizeof(aclient.smbname));
         aclient.smbname[sizeof(aclient.smbname)-1] = '\0';
index 740ec3ec64b3603288b6491271873ead7b3a254b..ac4cc02a517fd5de2961bc57a81000b08a7fc228 100644 (file)
@@ -101,7 +101,8 @@ int cm_HaveAccessRights(struct cm_scache *scp, struct cm_user *up, long rights,
         /* fall through */
         
 done:
-       if (didLock) lock_ReleaseMutex(&aclScp->mx);
+    if (didLock) 
+        lock_ReleaseMutex(&aclScp->mx);
         cm_ReleaseSCache(aclScp);
         return code;
 }
index e8580339cdda66f08f84edb3f4a4163e3c3323a1..e0ee133fdd2a35d065648753801f132d40a29e91 100644 (file)
@@ -491,11 +491,14 @@ long buf_AddBuffers(long nbuffers)
  */
 long buf_SetNBuffers(long nbuffers)
 {
-       if (nbuffers < 10) return CM_ERROR_INVAL;
-        if (nbuffers == buf_nbuffers) return 0;
+    if (nbuffers < 10) 
+        return CM_ERROR_INVAL;
+    if (nbuffers == buf_nbuffers) 
+        return 0;
         else if (nbuffers > buf_nbuffers)
                return buf_AddBuffers(nbuffers - buf_nbuffers);
-        else return CM_ERROR_INVAL;
+    else 
+        return CM_ERROR_INVAL;
 }
 
 /* release a buffer.  Buffer must be referenced, but unlocked. */
@@ -652,8 +655,7 @@ void buf_Recycle(cm_buf_t *bp)
         * have any lock conflicts, so we can grab the buffer lock out of
         * order in the locking hierarchy.
         */
-       osi_Log2(buf_logp,
-               "buf_Recycle recycles 0x%x, off 0x%x",
+    osi_Log2( buf_logp, "buf_Recycle recycles 0x%x, off 0x%x",
                bp, bp->offset.LowPart);
 
        osi_assert(bp->refCount == 0);
@@ -1296,7 +1298,6 @@ long buf_Truncate(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp,
                        }
 
                         lock_ReleaseWrite(&buf_globalLock);
-
                 }
                
                 lock_ReleaseMutex(&scp->mx);
index 8840aae6607f0aab3462c80c91f143e3f6b0d6e8..8826e1d74d430a836d2d742544c5397bd6a56fb0 100644 (file)
@@ -72,7 +72,7 @@ typedef struct cm_buf {
                                 */
         struct cm_buf *allp;   /* next in all list */
        osi_mutex_t mx;         /* mutex protecting structure except refcount */
-        int refCount;          /* reference count */
+    int refCount;              /* reference count (buf_globalLock) */
         long idCounter;                /* counter for softrefs; bumped at each recycle */
         long dirtyCounter;     /* bumped at each dirty->clean transition */
 #ifdef notdef
index c84b367b3062177ba2be5fea99a7944aabbed95e..8b0fc50290503779cf26e27676311503d66cc229 100644 (file)
@@ -635,11 +635,13 @@ int cm_HaveCallback(cm_scache_t *scp)
   int fdc, fgc;
 
     if (cm_freelanceEnabled && 
-        scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
-        scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) {       // if it's something on /afs
-       if (!(scp->fid.vnode==0x1 && scp->fid.unique==0x1))     // if it's not root.afs
+         scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) {
+        /* if it's something on /afs */
+        if (!(scp->fid.vnode==0x1 && scp->fid.unique==0x1)) {
+            /* if it's not root.afs */
            return 1;
-       else {
+        }
+
            lock_ObtainMutex(&cm_Freelance_Lock);
            fdc = cm_fakeDirCallback;
            fgc = cm_fakeGettingCallback;
@@ -659,12 +661,12 @@ int cm_HaveCallback(cm_scache_t *scp)
            }
            return 0;
        }
-    }
 #endif
 
     if (scp->cbServerp != NULL)
        return 1;
-    else return 0;
+    else 
+        return 0;
 }
 
 /* need to detect a broken callback that races with our obtaining a callback.
@@ -708,6 +710,7 @@ void cm_EndCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp,
        cm_racingRevokes_t *revp;               /* where we are */
        cm_racingRevokes_t *nrevp;              /* where we'll be next */
         int freeFlag;
+    cm_server_t * serverp = 0;
 
        lock_ObtainWrite(&cm_callbackLock);
        if (flags & CM_CALLBACK_MAINTAINCOUNT) {
@@ -716,13 +719,23 @@ void cm_EndCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp,
        else {
                osi_assert(cm_activeCallbackGrantingCalls-- > 0);
        }
-        if (cm_activeCallbackGrantingCalls == 0) freeFlag = 1;
-        else freeFlag = 0;
+    if (cm_activeCallbackGrantingCalls == 0) 
+        freeFlag = 1;
+    else 
+        freeFlag = 0;
 
        /* record the callback; we'll clear it below if we really lose it */
+    if (cbrp) {
        if (scp) {
+            if (scp->cbServerp != cbrp->serverp) {
+                serverp = scp->cbServerp;
+            }
                scp->cbServerp = cbrp->serverp;
                scp->cbExpires = cbrp->startTime + cbp->ExpirationTime;
+        } else {
+            serverp = cbrp->serverp;
+        }
+        cbrp->serverp = NULL;
        }
 
        /* a callback was actually revoked during our granting call, so
@@ -737,7 +750,7 @@ void cm_EndCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp,
                  * callback-granting call, and if this fid is the right fid,
                  * then clear the callback.
                  */
-                if (scp && cbrp->callbackCount != cm_callbackCount
+        if (scp && cbrp && cbrp->callbackCount != cm_callbackCount
                                && revp->callbackCount > cbrp->callbackCount
              && (( scp->fid.volume == revp->fid.volume &&
                                  scp->fid.vnode == revp->fid.vnode &&
@@ -769,6 +782,12 @@ void cm_EndCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp,
        if (freeFlag) cm_racingRevokesp = NULL;
 
        lock_ReleaseWrite(&cm_callbackLock);
+
+    if ( serverp ) {
+        lock_ObtainWrite(&cm_serverLock);
+        cm_FreeServer(serverp);
+        lock_ReleaseWrite(&cm_serverLock);
+    }
 }
 
 /* if flags is 1, we want to force the code to make one call, anyway.
@@ -799,10 +818,11 @@ long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
              scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
              scp->fid.unique==0x1 &&
              scp->fid.vnode==0x1) {
+            
             // Start by indicating that we're in the process
             // of fetching the callback
-
             lock_ObtainMutex(&cm_Freelance_Lock);
+            osi_Log0(afsd_logp,"cm_getGetCallback fakeGettingCallback=1");
             cm_fakeGettingCallback = 1;
             lock_ReleaseMutex(&cm_Freelance_Lock);
 
@@ -811,8 +831,11 @@ long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
 
             // Indicate that the callback is not done
             lock_ObtainMutex(&cm_Freelance_Lock);
+            osi_Log0(afsd_logp,"cm_getGetCallback fakeDirCallback=2");
             cm_fakeDirCallback = 2;
+
             // Indicate that we're no longer fetching the callback
+            osi_Log0(afsd_logp,"cm_getGetCallback fakeGettingCallback=0");
             cm_fakeGettingCallback = 0;
             lock_ReleaseMutex(&cm_Freelance_Lock);
 
@@ -861,7 +884,7 @@ long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
             cm_MergeStatus(scp, &afsStatus, &volSync, userp, 0);
                }   
         else
-            cm_EndCallbackGrantingCall(NULL, NULL, NULL, 0);
+            cm_EndCallbackGrantingCall(NULL, &cbr, NULL, 0);
 
         /* now check to see if we got an error */
         if (code) return code;
@@ -884,8 +907,8 @@ void cm_CheckCBExpiration(void)
                        scp->refCount++;
                        lock_ReleaseWrite(&cm_scacheLock);
                        lock_ObtainMutex(&scp->mx);
-                       if (scp->cbServerp && now > scp->cbExpires) {
-                osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
+            if (scp->cbExpires > 0 && (scp->cbServerp == NULL || now > scp->cbExpires)) {
+                osi_Log1(afsd_logp, "Callback Expiration Discarding SCache scp %x", scp);
                                cm_DiscardSCache(scp);
                         }
                        lock_ReleaseMutex(&scp->mx);
index d556c9ea88382b24a3858112394e9c29f8d8db56..3acc6f19e5d50bd96b533536bd9c7622aff912c9 100644 (file)
@@ -64,4 +64,6 @@ extern long cm_GetCallback(struct cm_scache *, struct cm_user *,
 
 extern void cm_CheckCBExpiration(void);
 
+extern osi_rwlock_t cm_callbackLock;
+
 #endif /*  _CM_CALLBACK_H_ENV__ */
index 90542fdbd4118b066d3a9c5bb309942204c0b4ed..a7ee8c3864ccf800c022a8807728a3b92a357e79 100644 (file)
@@ -94,7 +94,6 @@ void cm_InitReq(cm_req_t *reqp)
 #else
         gettimeofday(&reqp->startTime, NULL);
 #endif
 }
 
 static long cm_GetServerList(struct cm_fid *fidp, struct cm_user *userp,
@@ -144,7 +143,7 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
        cm_serverRef_t * serversp,
        cm_callbackRequest_t *cbrp, long errorCode)
 {
-       cm_server_t *serverp;
+    cm_server_t *serverp = 0;
     cm_serverRef_t **serverspp = 0;
        cm_serverRef_t *tsrp;
        cm_ucell_t *ucellp;
@@ -163,8 +162,21 @@ cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
                serverp = connp->serverp;
 
        /* Update callback pointer */
-    if (cbrp && errorCode == 0) 
-        cbrp->serverp = connp->serverp;
+    if (cbrp && serverp && errorCode == 0) {
+        if (cbrp->serverp) {
+            if ( cbrp->serverp != serverp ) {
+                lock_ObtainWrite(&cm_serverLock);
+                cm_PutServerNoLock(cbrp->serverp);
+                cm_GetServerNoLock(serverp);
+                lock_ReleaseWrite(&cm_serverLock);
+            }
+        } else {
+            cm_GetServer(serverp);
+        }
+        lock_ObtainWrite(&cm_callbackLock);
+        cbrp->serverp = serverp;
+        lock_ReleaseWrite(&cm_callbackLock);
+    }
 
        /* If not allowed to retry, don't */
        if (reqp->flags & CM_REQ_NORETRY)
@@ -398,7 +410,7 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
        lock_ObtainWrite(&cm_serverLock);
     for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
         tsp = tsrp->server;
-        tsp->refCount++;
+        cm_GetServerNoLock(tsp);
         lock_ReleaseWrite(&cm_serverLock);
         if (!(tsp->flags & CM_SERVERFLAG_DOWN)) {
             allDown = 0;
@@ -422,7 +434,6 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
                     rx_SetConnDeadTime((*connpp)->callp, timeLeft);
                     rx_SetConnHardDeadTime((*connpp)->callp, (u_short) hardTimeLeft);
                     lock_ReleaseMutex(&(*connpp)->mx);
-
                     return 0;
                 }
                 if (firstError == 0) 
@@ -430,7 +441,7 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
             }
                } 
         lock_ObtainWrite(&cm_serverLock);
-        osi_assert(tsp->refCount-- > 0);
+        cm_PutServerNoLock(tsp);
     }   
 
        lock_ReleaseWrite(&cm_serverLock);
@@ -462,6 +473,7 @@ void cm_GCConnections(cm_server_t *serverp)
                userp = tcp->userp;
                if (userp && tcp->refCount == 0 && (userp->vcRefs == 0)) {
                        /* do the deletion of this guy */
+            cm_PutServer(tcp->serverp);
             cm_ReleaseUser(userp);
             *lcpp = tcp->nextp;
                        rx_DestroyConnection(tcp->callp);
@@ -532,11 +544,14 @@ long cm_ConnByServer(cm_server_t *serverp, cm_user_t *userp, cm_conn_t **connpp)
        lock_ObtainMutex(&userp->mx);
        lock_ObtainWrite(&cm_connLock);
        for(tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
-               if (tcp->userp == userp) break;
+        if (tcp->userp == userp) 
+            break;
     }
+    
        /* find ucell structure */
     ucellp = cm_GetUCell(userp, serverp->cellp);
        if (!tcp) {
+        cm_GetServer(serverp);
                tcp = malloc(sizeof(*tcp));
         memset(tcp, 0, sizeof(*tcp));
         tcp->nextp = serverp->connsp;
index 305aba53797950412a5dc602cbf65c3bd45a5d14..9ecb90c69bdd90bec449010fa4d8ab8e2f0c6154 100644 (file)
@@ -95,15 +95,15 @@ void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, long p1, long p2,
 /* periodic check daemon */
 void cm_Daemon(long parm)
 {
-    long now;
-       long lastLockCheck;
-    long lastVolCheck;
-    long lastCBExpirationCheck;
-       long lastDownServerCheck;
-       long lastUpServerCheck;
-       long lastTokenCacheCheck;
+    unsigned long now;
+       unsigned long lastLockCheck;
+    unsigned long lastVolCheck;
+    unsigned long lastCBExpirationCheck;
+       unsigned long lastDownServerCheck;
+       unsigned long lastUpServerCheck;
+       unsigned long lastTokenCacheCheck;
        char thostName[200];
-       long code;
+       unsigned long code;
        struct hostent *thp;
 
        /* ping all file servers, up or down, with unauthenticated connection,
index 512876930c788f198fce662fc7d16e892c7fe6f5..56400e8298268597dce5d1d7b716bf7de100f7f6 100644 (file)
@@ -15,7 +15,9 @@
 #include <winsock2.h>
 #include <nb30.h>
 #endif /* !DJGPP */
+#ifdef COMMENT
 #include <malloc.h>
+#endif
 #include <string.h>
 #include <stdlib.h>
 #include <osi.h>
@@ -407,8 +409,7 @@ long cm_CheckFetchRange(cm_scache_t *scp, osi_hyper_t *startBasep, long length,
     while(length > 0) {
                /* get callback so we can do a meaningful dataVersion comparison */
         code = cm_SyncOp(scp, NULL, up, reqp, 0,
-                         CM_SCACHESYNC_NEEDCALLBACK
-                         | CM_SCACHESYNC_GETSTATUS);
+                         CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
                if (code) {
                        scp->flags &= ~CM_SCACHEFLAG_PREFETCHING;
                        lock_ReleaseMutex(&scp->mx);
@@ -836,8 +837,8 @@ long cm_SetupFetchBIOD(cm_scache_t *scp, osi_hyper_t *offsetp,
        biop->reserved = 0;
 
        /* first lookup the file's length, so we know when to stop */
-    code = cm_SyncOp(scp, NULL, up, reqp, 0, CM_SCACHESYNC_NEEDCALLBACK
-                     | CM_SCACHESYNC_GETSTATUS);
+    code = cm_SyncOp(scp, NULL, up, reqp, 0, 
+                     CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
     if (code) 
         return code;
         
@@ -1073,8 +1074,7 @@ void cm_ReleaseBIOD(cm_bulkIO_t *biop, int isStore)
             if (bufp->flags & CM_BUF_WAITING) {
                                osi_Wakeup((long) bufp);
             }
-                       bufp->flags &= ~(CM_BUF_WAITING | CM_BUF_WRITING
-                             | CM_BUF_DIRTY);
+            bufp->flags &= ~(CM_BUF_WAITING | CM_BUF_WRITING | CM_BUF_DIRTY);
         }
 
         lock_ReleaseMutex(&bufp->mx);
index ce2f0b60e9dcba537c88479f1680d7c73d042a8e..1443b66778c17d1e06a2dc22be0e39f3b7c037cb 100644 (file)
@@ -11,7 +11,7 @@
 #define __CM_DIR_ENV__ 1
 
 #define CM_DIR_PAGESIZE                2048            /* bytes per page */
-#define CM_DIR_NHASHENT                128             /* entries in the hash tbl */
+#define CM_DIR_NHASHENT                256             /* entries in the hash tbl == NHSIZE */
 #define CM_DIR_MAXPAGES                128             /* max pages in a dir */
 #define CM_DIR_BIGMAXPAGES     1023            /* new big max pages */
 #define CM_DIR_EPP             64              /* dir entries per page */
@@ -63,6 +63,7 @@ typedef struct cm_dirEntry {
        char name[16];
 } cm_dirEntry_t;
 
+#ifdef UNUSED
 typedef struct cm_dirXEntry {
        /* A directory extension entry. */
        char name[32];
@@ -79,6 +80,7 @@ typedef struct cm_dirPage1 {
        cm_pageHeader_t header;
        cm_dirEntry_t entry[1];
 } cm_dirPage1_t;
+#endif /* UNUSED */
 
 extern int cm_NameEntries(char *namep, size_t *lenp);
 
index 5bfa220be0b99cddc807a347767c1a30774bb9bd..ea501caafc014120e6be9f6b81353964a69f3ec5 100644 (file)
 #include <osi.h>
 #include "afsd.h"
 
-osi_rwlock_t cm_dnlcLock;
+static osi_rwlock_t cm_dnlcLock;
 
-cm_dnlcstats_t dnlcstats;      /* dnlc statistics */
-int cm_useDnlc = 1;            /* yes, start using the dnlc */
-int cm_debugDnlc = 0;          /* debug dnlc */
+static cm_dnlcstats_t dnlcstats;       /* dnlc statistics */
+static int cm_useDnlc = 1;     /* yes, start using the dnlc */
+static int cm_debugDnlc = 0;   /* debug dnlc */
 
 
 /* Hash table invariants:
  *     1.  If nameHash[i] is NULL, list is empty
  *     2.  A single element in a hash bucket has itself as prev and next.
  */
-struct nc      *ncfreelist = (struct nc *)0;
+static struct nc *ncfreelist = (struct nc *)0;
 static struct nc nameCache[NCSIZE];
-struct nc*     nameHash[NHSIZE];
-
+static struct nc *nameHash[NHSIZE];
 
 #ifndef DJGPP
 #define dnlcNotify(x,debug){                    \
@@ -59,7 +58,6 @@ struct nc*    nameHash[NHSIZE];
 #define dnlcNotify(x,debug)
 #endif /* !DJGPP */
 
-
 static struct nc * 
 GetMeAnEntry() 
 {
index aadfb9c53243e8a7b9e62980805800eea59606f8..fcb9ee1dc3c3c2a6fe26303d10318790552fbf37 100644 (file)
@@ -9,9 +9,9 @@
 
 #include <ctype.h>
 
-#define        CM_AFSNCNAMESIZE        36 /* multiple of 4 */
-#define         NCSIZE                         300
-#define         NHSIZE                         256 /* must be power of 2== NHASHENT */
+#define        CM_AFSNCNAMESIZE        40  /* multiple of 8 (for 64-bit) */
+#define         NCSIZE                         512
+#define         NHSIZE                         256 /* must be power of 2 == CM_DIR_NHASHENT */
 
 
 struct nc {
index ddbd0e6a66ae384586dd59cbcbbbd6149825da35..f0caaf3db9f98bd5abf84a93caa53c03f1730522 100644 (file)
@@ -272,6 +272,7 @@ void cm_InitFakeRootDir() {
        }
        
        // we know the fakeDir is setup properly, so we claim that we have callback
+    osi_Log0(afsd_logp,"cm_InitFakeRootDir fakeDirCallback=1");
        cm_fakeDirCallback=1;
 
        // when we get here, we've set up everything! done!
@@ -512,7 +513,7 @@ long cm_InitLocalMountPoints() {
             fprintf(fp,"%s#%s:root.cell.\n",rootCellName,rootCellName);
             fprintf(fp,".%s%%%s:root.cell.\n",rootCellName,rootCellName);
             fclose(fp);
-            fopen(hdir, "r");
+            fp = fopen(hdir, "r");
         } else {
             fputs("0\n", fp);
             fclose(fp);
index 538a60c91ed9b1e1ed68ec2be5ab7ca6629a8d02..169861875c5050a8403ff862ccc0e373c40bd021 100644 (file)
@@ -1060,8 +1060,10 @@ long cm_IoctlGetCell(struct smb_ioctl *ioctlp, struct cm_user *userp)
                ioctlp->outDatap = cp;
        }
 
-       if (tcellp) return 0;
-       else return CM_ERROR_NOMORETOKENS;      /* mapped to EDOM */
+    if (tcellp) 
+        return 0;
+    else 
+        return CM_ERROR_NOMORETOKENS;  /* mapped to EDOM */
 }
 
 extern long cm_AddCellProc(void *rockp, struct sockaddr_in *addrp, char *namep);
index 54d6e75a7928aafb3b555c752966531d68aed18b..b1d29854c10647fae4b0257f682e339103bcb43f 100644 (file)
@@ -56,7 +56,8 @@ void cm_AdjustLRU(cm_scache_t *scp)
                cm_scacheLRULastp = (cm_scache_t *) osi_QPrev(&scp->q);
        osi_QRemove((osi_queue_t **) &cm_scacheLRUFirstp, &scp->q);
        osi_QAdd((osi_queue_t **) &cm_scacheLRUFirstp, &scp->q);
-       if (!cm_scacheLRULastp) cm_scacheLRULastp = scp;
+    if (!cm_scacheLRULastp) 
+        cm_scacheLRULastp = scp;
 }
 
 /* called with cm_scacheLock write-locked; find a vnode to recycle.
@@ -73,7 +74,8 @@ cm_scache_t *cm_GetNewSCache(void)
                for (scp = cm_scacheLRULastp;
                     scp;
                     scp = (cm_scache_t *) osi_QPrev(&scp->q)) {
-                 if (scp->refCount == 0) break;
+            if (scp->refCount == 0) 
+                break;
                }
                 
                 if (scp) {
@@ -85,7 +87,8 @@ cm_scache_t *cm_GetNewSCache(void)
                                for (tscp = *lscpp;
                                     tscp;
                                     lscpp = &tscp->nextp, tscp = *lscpp) {
-                                 if (tscp == scp) break;
+                    if (tscp == scp) 
+                        break;
                                 }
                                 osi_assertx(tscp, "afsd: scache hash screwup");
                                 *lscpp = scp->nextp;
@@ -108,7 +111,10 @@ cm_scache_t *cm_GetNewSCache(void)
                        scp->bulkStatProgress = hzero;
 
                         /* discard callback */
+            if (scp->cbServerp) {
+                cm_PutServer(scp->cbServerp);
                         scp->cbServerp = NULL;
+            }
                         scp->cbExpires = 0;
 
                        /* remove from dnlc */
@@ -164,7 +170,8 @@ cm_scache_t *cm_GetNewSCache(void)
        
         /* and put it in the LRU queue */
         osi_QAdd((osi_queue_t **) &cm_scacheLRUFirstp, &scp->q);
-        if (!cm_scacheLRULastp) cm_scacheLRULastp = scp;
+    if (!cm_scacheLRULastp) 
+        cm_scacheLRULastp = scp;
         cm_currentSCaches++;
        cm_dnlcPurgedp(scp); /* make doubly sure that this is not in dnlc */
        cm_dnlcPurgevp(scp); 
@@ -174,10 +181,14 @@ cm_scache_t *cm_GetNewSCache(void)
 /* like strcmp, only for fids */
 int cm_FidCmp(cm_fid_t *ap, cm_fid_t *bp)
 {
-        if (ap->vnode != bp->vnode) return 1;
-       if (ap->volume != bp->volume) return 1;
-        if (ap->unique != bp->unique) return 1;
-        if (ap->cell != bp->cell) return 1;
+    if (ap->vnode != bp->vnode) 
+        return 1;
+    if (ap->volume != bp->volume) 
+        return 1;
+    if (ap->unique != bp->unique) 
+        return 1;
+    if (ap->cell != bp->cell) 
+        return 1;
         return 0;
 }
 
@@ -240,16 +251,24 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
        long hash;
     cm_scache_t *scp;
     long code;
-    cm_volume_t *volp;
+    cm_volume_t *volp = 0;
     cm_cell_t *cellp;
-       char* mp;
+    char* mp = 0;
        int special; // yj: boolean variable to test if file is on root.afs
        int isRoot;
+    extern cm_fid_t cm_rootFid;
         
     hash = CM_SCACHE_HASH(fidp);
         
        osi_assert(fidp->cell != 0);
 
+    if (fidp->cell== cm_rootFid.cell && 
+         fidp->volume==cm_rootFid.volume &&
+         fidp->vnode==0x0 && fidp->unique==0x0)
+    {
+        osi_Log0(afsd_logp,"cm_getSCache called with root cell/volume and vnode=0 and unique=0");
+    }
+
        // yj: check if we have the scp, if so, we don't need
        // to do anything else
     lock_ObtainWrite(&cm_scacheLock);
@@ -281,16 +300,20 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
        if (cm_freelanceEnabled && isRoot) {
                osi_Log0(afsd_logp,"cm_getSCache Freelance and isRoot");
           /* freelance: if we are trying to get the root scp for the first
-             time, we will just put in a place holder entry. */
+         * time, we will just put in a place holder entry. 
+         */
                volp = NULL;
        }
          
        if (cm_freelanceEnabled && special) {
                osi_Log0(afsd_logp,"cm_getSCache Freelance and special");
+        if (fidp->vnode > 1) {
            lock_ObtainMutex(&cm_Freelance_Lock);
                mp =(cm_localMountPoints+fidp->vnode-2)->mountPointStringp;
                lock_ReleaseMutex(&cm_Freelance_Lock);
-               
+        } else {
+            mp = "";
+        }
                scp = cm_GetNewSCache();
                
                scp->fid = *fidp;
@@ -326,7 +349,6 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
                lock_ReleaseWrite(&cm_scacheLock);
                /*afsi_log("   getscache done");*/
                return 0;
-
        }
        // end of yj code
 #endif /* AFS_FREELANCE_CLIENT */
@@ -352,6 +374,7 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
                        scp->refCount++;
             cm_AdjustLRU(scp);
             lock_ReleaseWrite(&cm_scacheLock);
+            if (volp)
             cm_PutVolume(volp);
             *outScpp = scp;
                        return 0;
@@ -384,6 +407,13 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
        cm_hashTablep[hash] = scp;
     scp->flags |= CM_SCACHEFLAG_INHASH;
        scp->refCount = 1;
+
+       /* XXX - The following fields in the cm_scache are 
+        * uninitialized:
+        *   fileType
+        *   parentVnode
+        *   parentUnique
+        */
     lock_ReleaseWrite(&cm_scacheLock);
         
     /* now we have a held scache entry; just return it */
@@ -590,12 +620,14 @@ long cm_SyncOp(cm_scache_t *scp, cm_buf_t *bufp, cm_user_t *up, cm_req_t *reqp,
 
                // yj: modified this so that callback only checked if we're
                // not checking something on /afs
+        /* fix the conditional to match the one in cm_HaveCallback */
                if (  (flags & CM_SCACHESYNC_NEEDCALLBACK)
 #ifdef AFS_FREELANCE_CLIENT
-                       && (!cm_freelanceEnabled || !(!(scp->fid.vnode==0x1 &&
-                                                        scp->fid.unique==0x1) &&
-                                                        scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
-                                                        scp->fid.volume==AFS_FAKE_ROOT_VOL_ID))
+             && (!cm_freelanceEnabled || 
+                  !(scp->fid.vnode==0x1 && scp->fid.unique==0x1) ||
+                  scp->fid.cell!=AFS_FAKE_ROOT_CELL_ID ||
+                  scp->fid.volume!=AFS_FAKE_ROOT_VOL_ID ||
+                                 cm_fakeDirCallback < 2)
 #endif /* AFS_FREELANCE_CLIENT */
                    ) {
                        if (!cm_HaveCallback(scp)) {
@@ -656,7 +688,8 @@ sleep:
                if (bufLocked) lock_ReleaseMutex(&bufp->mx);
         osi_SleepM((long) &scp->flags, &scp->mx);
         osi_Log0(afsd_logp, "CM SyncOp woke!");
-        if (bufLocked) lock_ObtainMutex(&bufp->mx);
+        if (bufLocked) 
+            lock_ObtainMutex(&bufp->mx);
         lock_ObtainMutex(&scp->mx);
         } /* big while loop */
         
@@ -807,7 +840,7 @@ void cm_MergeStatus(cm_scache_t *scp, AFSFetchStatus *statusp, AFSVolSync *volp,
        if (cm_freelanceEnabled && scp == cm_rootSCachep) {
                osi_Log0(afsd_logp,"cm_MergeStatus Freelance cm_rootSCachep");
                statusp->InterfaceVersion = 0x1;
-               statusp->FileType = 0x2;
+        statusp->FileType = CM_SCACHETYPE_DIRECTORY;
                statusp->LinkCount = scp->linkCount;
                statusp->Length = cm_fakeDirSize;
                statusp->DataVersion = cm_fakeDirVersion;
@@ -900,8 +933,10 @@ void cm_MergeStatus(cm_scache_t *scp, AFSFetchStatus *statusp, AFSVolSync *volp,
                else
                        scp->fileType = CM_SCACHETYPE_SYMLINK;
         }
-        else scp->fileType = 0;        /* invalid */
-
+    else {
+        osi_Log1(afsd_logp, "Merge, Invalid File Type, scp %x", scp);
+        scp->fileType = 0;     /* invalid */
+    }
         /* and other stuff */
         scp->parentVnode = statusp->ParentVnode;
         scp->parentUnique = statusp->ParentUnique;
@@ -927,7 +962,10 @@ void cm_MergeStatus(cm_scache_t *scp, AFSFetchStatus *statusp, AFSVolSync *volp,
 void cm_DiscardSCache(cm_scache_t *scp)
 {
        lock_AssertMutex(&scp->mx);
+    if (scp->cbServerp) {
+        cm_PutServer(scp->cbServerp);
        scp->cbServerp = NULL;
+    }
         scp->cbExpires = 0;
        cm_dnlcPurgedp(scp);
         cm_FreeAllACLEnts(scp);
index fa1a72a6e3078f437aaa8901dc8a2a34da582300..7b2b86b6151bc8f44b2c5ac543210a97b4e7ba55 100644 (file)
@@ -53,7 +53,7 @@ void cm_CheckServers(long flags, cm_cell_t *cellp)
 
         lock_ObtainWrite(&cm_serverLock);
        for(tsp = cm_allServersp; tsp; tsp = tsp->allNextp) {
-               tsp->refCount++;
+        cm_GetServerNoLock(tsp);
                 lock_ReleaseWrite(&cm_serverLock);
 
                /* now process the server */
@@ -120,7 +120,7 @@ void cm_CheckServers(long flags, cm_cell_t *cellp)
                cm_GCConnections(tsp);
 
                 lock_ObtainWrite(&cm_serverLock);
-                osi_assert(tsp->refCount-- > 0);
+        cm_PutServerNoLock(tsp);
         }
         lock_ReleaseWrite(&cm_serverLock);
 }
@@ -135,15 +135,31 @@ void cm_InitServer(void)
         }
 }
 
+void cm_GetServer(cm_server_t *serverp)
+{
+    lock_ObtainWrite(&cm_serverLock);
+    serverp->refCount++;
+    afsi_log("cm_GetServer       serverp=%x count=%d", serverp, serverp->refCount);
+    lock_ReleaseWrite(&cm_serverLock);
+}
+
+void cm_GetServerNoLock(cm_server_t *serverp)
+{
+    serverp->refCount++;
+    afsi_log("cm_GetServerNoLock serverp=%x count=%d", serverp, serverp->refCount);
+}
+
 void cm_PutServer(cm_server_t *serverp)
 {
        lock_ObtainWrite(&cm_serverLock);
+    afsi_log("cm_PutServer       serverp=%x count=%d", serverp, serverp->refCount-1);
        osi_assert(serverp->refCount-- > 0);
        lock_ReleaseWrite(&cm_serverLock);
 }
 
 void cm_PutServerNoLock(cm_server_t *serverp)
 {
+    afsi_log("cm_PutServerNoLock serverp=%x count=%d", serverp, serverp->refCount-1);
        osi_assert(serverp->refCount-- > 0);
 }
 
@@ -195,7 +211,8 @@ void cm_SetServerPrefs(cm_server_t * serverp)
                serverp->ipRank += min(serverp->ipRank, rand() % 0x000f);
            } /* and of for loop */
        }
-       else    serverp->ipRank = 10000 + (rand() % 0x00ff); /* VL server */
+    else 
+        serverp->ipRank = 10000 + (rand() % 0x00ff); /* VL server */
 }
 
 cm_server_t *cm_NewServer(struct sockaddr_in *socketp, int type, cm_cell_t *cellp) {
@@ -235,7 +252,8 @@ cm_server_t *cm_FindServer(struct sockaddr_in *addrp, int type)
         }
 
        /* bump ref count if we found the server */
-       if (tsp) tsp->refCount++;
+    if (tsp) 
+        cm_GetServerNoLock(tsp);
 
        /* drop big table lock */
         lock_ReleaseWrite(&cm_serverLock);
@@ -248,9 +266,7 @@ cm_serverRef_t *cm_NewServerRef(cm_server_t *serverp)
 {
        cm_serverRef_t *tsrp;
 
-    lock_ObtainWrite(&cm_serverLock);
-       serverp->refCount++;
-    lock_ReleaseWrite(&cm_serverLock);
+    cm_GetServer(serverp);
        tsrp = malloc(sizeof(*tsrp));
        tsrp->server = serverp;
        tsrp->status = not_busy;
@@ -404,25 +420,26 @@ void cm_RandomizeServer(cm_serverRef_t** list)
 }
 
 /* call cm_FreeServer while holding a write lock on cm_serverLock */
-void cm_FreeServer(cm_server_t* server)
+void cm_FreeServer(cm_server_t* serverp)
 {
-    if (--(server->refCount) == 0)
+    cm_PutServerNoLock(serverp);
+    if (serverp->refCount == 0)
     {
         /* we need to check to ensure that all of the connections
          * for this server have a 0 refCount; otherwise, they will
          * not be garbage collected 
          */
-        cm_GCConnections(server);  /* connsp */
+        cm_GCConnections(serverp);  /* connsp */
 
-        lock_FinalizeMutex(&server->mx);
-        if ( cm_allServersp == server )
-            cm_allServersp = server->allNextp;
+        lock_FinalizeMutex(&serverp->mx);
+        if ( cm_allServersp == serverp )
+            cm_allServersp = serverp->allNextp;
         else {
             cm_server_t *tsp;
 
             for(tsp = cm_allServersp; tsp->allNextp; tsp=tsp->allNextp) {
-                if ( tsp->allNextp == server ) {
-                    tsp->allNextp = server->allNextp;
+                if ( tsp->allNextp == serverp ) {
+                    tsp->allNextp = serverp->allNextp;
                     break;
                 }
             }
index cabaf7c16846e1ae7cff536b1a8069c334392e37..fc766c3169562fdc9010487c06fdab83671dae12 100644 (file)
@@ -74,6 +74,10 @@ extern cm_serverRef_t *cm_NewServerRef(struct cm_server *serverp);
 
 extern long cm_ChecksumServerList(cm_serverRef_t *serversp);
 
+extern void cm_GetServer(cm_server_t *);
+
+extern void cm_GetServerNoLock(cm_server_t *);
+
 extern void cm_PutServer(cm_server_t *);
 
 extern void cm_PutServerNoLock(cm_server_t *);
index 9ef59eb2ff81925cddc1bf6700605aa8ae491c22..26b90fb16208b206e9127df47719c72c903eebcc 100644 (file)
@@ -1380,7 +1380,8 @@ long cm_NameI(cm_scache_t *rootSCachep, char *pathp, long flags,
                         psp = tempsp;
                         tp = psp->data;
                         cm_ReleaseSCache(tscp);
-                        tscp = linkScp;        /* already held
+                    tscp = linkScp;    
+                    /* already held
                                          * by AssembleLink */
                         /* now, if linkScp is null, that's
                          * AssembleLink's way of telling us that
@@ -1679,7 +1680,7 @@ void cm_TryBulkStat(cm_scache_t *dscp, osi_hyper_t *offsetp, cm_user_t *userp,
                 } /* all files in the response */
                /* now tell it to drop the count,
                 * after doing the vnode processing above */
-                cm_EndCallbackGrantingCall(NULL, NULL, NULL, 0);
+        cm_EndCallbackGrantingCall(NULL, &cbReq, NULL, 0);
                 
                 filex += filesThisCall;
         }      /* while there are still more files to process */
@@ -1959,7 +1960,7 @@ long cm_Create(cm_scache_t *dscp, char *namep, long flags, cm_attr_t *attrp,
        
         /* make sure we end things properly */
         if (!didEnd)
-               cm_EndCallbackGrantingCall(NULL, NULL, NULL, 0);
+               cm_EndCallbackGrantingCall(NULL, &cbReq, NULL, 0);
 
         return code;
 }
@@ -2075,7 +2076,7 @@ long cm_MakeDir(cm_scache_t *dscp, char *namep, long flags, cm_attr_t *attrp,
        
         /* make sure we end things properly */
         if (!didEnd)
-               cm_EndCallbackGrantingCall(NULL, NULL, NULL, 0);
+               cm_EndCallbackGrantingCall(NULL, &cbReq, NULL, 0);
        
         /* and return error code */
         return code;
index 2e35b362c2cfc59889c87c894f4bb53c964c375f..c784a354513d8d9a5f38f7cd09a9d55e695a265b 100644 (file)
@@ -175,7 +175,8 @@ long cm_GetVolumeByID(cm_cell_t *cellp, long volumeID, cm_user_t *userp,
         }
 
        /* hold the volume if we found it */
-        if (volp) volp->refCount++;
+    if (volp) 
+        volp->refCount++;
         lock_ReleaseWrite(&cm_volumeLock);
         
        /* return it held */
@@ -316,7 +317,8 @@ cm_serverRef_t **cm_GetVolServers(cm_volume_t *volp, unsigned long volume)
         serverspp = &volp->roServersp;
        else if (volume == volp->bkID)
         serverspp = &volp->bkServersp;
-       else osi_panic("bad volume ID in cm_GetVolServers", __FILE__, __LINE__);
+    else 
+        osi_panic("bad volume ID in cm_GetVolServers", __FILE__, __LINE__);
         
     for (current = *serverspp; current; current = current->next)
         current->refCount++;
@@ -370,7 +372,6 @@ void cm_CheckVolumes(void)
         lock_ReleaseWrite(&cm_volumeLock);
 
        /* We should also refresh cached mount points */
-
 }
 
 /*
index 0f72f37c265b984cadaca0d4fca5d214c0366eb0..d785c7dd6561735ca40fa8389c284258d10485e9 100644 (file)
@@ -339,8 +339,10 @@ typedef struct smb_dirListPatch {
 } smb_dirListPatch_t;
 
 /* dirListPatch Flags */
-#define SMB_DIRLISTPATCH_DOTFILE 1  /* the file referenced is a dot file 
-                                                                          Note: will not be set if smb_hideDotFiles is false */
+#define SMB_DIRLISTPATCH_DOTFILE 1  
+/* the file referenced is a dot file
+ * Note: will not be set if smb_hideDotFiles is false 
+ */
 
 /* waiting lock list elements */
 typedef struct smb_waitingLock {
index 3968598212844855c9e0a14cc296b3abec153203..d9a3f18500658f2f409bef31493342a129504dcc 100644 (file)
@@ -3029,7 +3029,6 @@ long smb_ApplyV3DirListPatches(cm_scache_t *dscp,
                                *((u_long *)dptr) = SMB_ATTR_HIDDEN;
                 }
                            dptr += 4;
-
             } else {
                 /* 1969-12-31 23:59:58 +00*/
                 dosTime = 0xEBBFBF7D;
@@ -3066,11 +3065,10 @@ long smb_ApplyV3DirListPatches(cm_scache_t *dscp,
 
                 /* merge in hidden (dot file) attribute */
                 if ( patchp->flags & SMB_DIRLISTPATCH_DOTFILE ) {
-                    attr == SMB_ATTR_HIDDEN;
+                    attr = SMB_ATTR_HIDDEN;
                                *dptr++ = attr & 0xff;
                                *dptr++ = (attr >> 8) & 0xff;
                 }
-
             }
                        continue;
         }
index e8409e92b1bd6d3223e0a3f503b3d7df96ec89fe..e9e1dc14a7b68da927ff883926be1d13fdd03e48 100644 (file)
@@ -181,6 +181,7 @@ void ViceIDToUsername(char *username, char *realm_of_user, char *realm_of_cell,
 {
     static char lastcell[MAXCELLCHARS+1] = { 0 };
     static char confname[512] = { 0 };
+    char username_copy[BUFSIZ];
        long viceId;                    /* AFS uid of user */
 #ifdef ALLOW_REGISTER
     afs_int32 id;
@@ -248,7 +249,12 @@ void ViceIDToUsername(char *username, char *realm_of_user, char *realm_of_cell,
 #else /* ALLOW_REGISTER */
             if ((*status == 0) && (viceId != ANONYMOUSID))
 #endif /* ALLOW_REGISTER */
-                sprintf (username, "AFS ID %d", (int) viceId);
+            {
+#ifdef AFS_ID_TO_NAME
+                strncpy(username_copy, username, BUFSIZ);
+                snprintf (username, BUFSIZ, "%s (AFS ID %d)", username_copy, (int) viceId);
+#endif /* AFS_ID_TO_NAME */
+            }
 #ifdef ALLOW_REGISTER
             } else if (strcmp(realm_of_user, realm_of_cell) != 0) {
                 if (dflag) {
@@ -263,6 +269,7 @@ void ViceIDToUsername(char *username, char *realm_of_user, char *realm_of_cell,
                     printf("%s: unable to obtain tokens for cell %s "
                             "(status: %d).\n", progname, cell_to_use, status);
                     *status = AKLOG_TOKEN;
+                return ;
                 }
 
                 /*
@@ -274,6 +281,7 @@ void ViceIDToUsername(char *username, char *realm_of_user, char *realm_of_cell,
 
                 if ((*status = pr_Initialize(1L, confname, aserver->cell, 0))) {
                     printf("Error %d\n", status);
+                return;
                 }
 
                 if ((*status = pr_CreateUser(username, &id))) {
@@ -283,7 +291,10 @@ void ViceIDToUsername(char *username, char *realm_of_user, char *realm_of_cell,
                 } else {
                     printf("created cross-cell entry for %s at %s\n",
                             username, cell_to_use);
-                    sprintf(username, "AFS ID %d", (int) id);
+#ifdef AFS_ID_TO_NAME
+                strncpy(username_copy, username, BUFSIZ);
+                snprintf (username, BUFSIZ, "%s (AFS ID %d)", username_copy, (int) viceId);
+#endif /* AFS_ID_TO_NAME */
                 }
             }
         }
@@ -432,7 +443,6 @@ static char *afs_realm_of_cell(struct afsconf_cell *cellconfig)
                        *s++ = c;
                }
                *s++ = 0;
-
        }
        return krbrlm;
 }
@@ -690,8 +700,7 @@ static int auth_to_cell(krb5_context context, char *cell, char *realm)
         memcpy(&atoken.sessionKey, v5cred->keyblock.contents, v5cred->keyblock.length);
         atoken.ticketLen = v5cred->ticket.length;
         memcpy(atoken.ticket, v5cred->ticket.data, atoken.ticketLen);
-    } else 
-    {
+    } else {
         strcpy (username, c.pname);
         if (c.pinst[0])
         {
@@ -734,8 +743,7 @@ static int auth_to_cell(krb5_context context, char *cell, char *realm)
                                        progname, status);
                                return(AKLOG_KERBEROS);
                        }
-               } else 
-               {
+        } else {
                        if ((status = krb_get_tf_realm(TKT_FILE, realm_of_user)) != KSUCCESS)
                        {
                                fprintf(stderr, "%s: Couldn't determine realm of user: %s)",
@@ -762,6 +770,7 @@ static int auth_to_cell(krb5_context context, char *cell, char *realm)
        */
        strncpy(aclient.name, username, MAXKTCNAMELEN - 1);
        strcpy(aclient.instance, "");
+    
     if (usev5) {
         int len = min(v5cred->client->realm.length,MAXKTCNAMELEN - 1);
         strncpy(aclient.cell, v5cred->client->realm.data, len);
@@ -1222,8 +1231,7 @@ int main(int argc, char *argv[])
                for (cur_node = cells.first; cur_node; cur_node = cur_node->next)
                {
                        memcpy(&cellinfo, cur_node->data, sizeof(cellinfo));
-                       if (status = auth_to_cell(
-                               context, 
+            if (status = auth_to_cell(context, 
                                cellinfo.cell, cellinfo.realm))
                                somethingswrong++;
                }
@@ -1231,8 +1239,7 @@ int main(int argc, char *argv[])
                /* Then, log to all paths in the paths list */
                for (cur_node = paths.first; cur_node; cur_node = cur_node->next)
                {
-                       if (status = auth_to_path(
-                               context, 
+            if (status = auth_to_path(context, 
                                cur_node->data))
                                somethingswrong++;
                }
index c37b74839aeecfa2b1f6abd14738ad121fd75827..8bc89c0a01723dc06eefdb782b6b4de47107436a 100644 (file)
@@ -104,7 +104,9 @@ LARGE_INTEGER ExtendedLargeIntegerDivide(LARGE_INTEGER a, unsigned long b, unsig
     if (b == 0) { return result; }
     if (b == 1) { *remainder = 0; return a; }
 
-       a1=(a.HighPart << 32) | a.LowPart;
+    a1 = a.HighPart;
+    a1 <<= 32;
+    a1 |= a.LowPart;
        q1=a1/b;
        r1=a1-(q1*b);
        if (r1 > ULONG_MAX) /*XXX */;
@@ -127,8 +129,12 @@ LARGE_INTEGER LargeIntegerDivide(LARGE_INTEGER a, LARGE_INTEGER b, LARGE_INTEGER
                return a; 
        }
 
-       a1=(a.HighPart << 32) | a.LowPart;
-       b1=(b.HighPart << 32) | a.LowPart;
+    a1 = a.HighPart;
+    a1 <<= 32;
+    a1 |= a.LowPart;
+    b1 = b.HighPart;
+    b1 <<= 32;
+    b1 |= b.LowPart;
        q1=a1/b1;
        r1=a1-(q1*b1);
        result.HighPart=q1 >> 32;
index 1bb9000a200d687c3f6aa5f03510f8e70f85b89f..541ad884966728505ad597ca3c556a040ab2844d 100644 (file)
@@ -79,7 +79,7 @@ LIB = $(AFSDEV_LIB)
 #define used in WinNT/2000 installation and program version display
 AFSPRODUCT_VER_MAJOR=1
 AFSPRODUCT_VER_MINOR=3
-AFSPRODUCT_VER_PATCH=7000
+AFSPRODUCT_VER_PATCH=7001
 AFSPRODUCT_VER_BUILD=0
 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
 AFSPRODUCT_FILE_VERSION=$(AFSPRODUCT_VER_MAJOR),$(AFSPRODUCT_VER_MINOR),$(AFSPRODUCT_VER_PATCH),$(AFSPRODUCT_VER_BUILD)
@@ -244,6 +244,7 @@ afscflags = $(afscflags) /GX
 
 !IF ("$(AFSVER_CL)"!="1200")
 afscdefs = $(afscdefs) /GT /GS
+#/Wp64
 !IF ("$(AFSVER_CL)"!="1400")
 afscdefs = $(afscdefs) /G7
 !ENDIF
index 1c3732f29c635582c01f8ebbb0bfc17d7bc55c5c..097ec1cd1312e39406c568f8a555c95c772159ad 100644 (file)
@@ -3356,7 +3356,7 @@ static
 SyncVldb(as)
      register struct cmd_syndesc *as;
 {
-    afs_int32 pnum, code;      /* part name */
+    afs_int32 pnum = 0, code;  /* part name */
     char part[10];
     int flags = 0;
     char *volname = 0;