]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
windows-misc-20070619
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 19 Jun 2007 06:24:23 +0000 (06:24 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 19 Jun 2007 06:24:23 +0000 (06:24 +0000)
VMWare adapters have proven unreliable replacements for the Microsoft
loopback adapter.  Registering AFS often results in a name space collision.

Add cm_DumpCells() function and dump the cells as part of "fs memdump"

Dump all cm_scache_t and cm_volume_t regardless of reference counts

Fix cm_GetCell_Gen() to not allocate a new cm_cell_t when evaluating
mount points to aliases.  Instead, after looking up the alias successfully
search the allCellsp list for the fullname of the cell.  If found, use
the existing entry and cleanup the one we were about to allocate.

Use read locks whenever possible instead of write locks when searching
the allCellsp list.

src/WINNT/afsd/afsd_service.c
src/WINNT/afsd/cm_cell.c
src/WINNT/afsd/cm_cell.h
src/WINNT/afsd/cm_ioctl.c
src/WINNT/afsd/cm_scache.c
src/WINNT/afsd/cm_volume.c
src/WINNT/afsd/lanahelper.cpp

index e0bf53c5a49df2abb62a0437f9e194c6ed67ad7f..9b0fad485d59edb51aae7927227905c7592f95c2 100644 (file)
@@ -76,6 +76,8 @@ static void afsd_notifier(char *msgp, char *filep, long line)
     buf_ForceTrace(TRUE);
 
     afsi_log("--- begin dump ---");
+    cm_DumpCells(afsi_file, "a", 0);
+    cm_DumpVolumes(afsi_file, "a", 0);
     cm_DumpSCache(afsi_file, "a", 0);
 #ifdef keisa
     cm_dnlcDump(afsi_file, "a");
@@ -85,8 +87,8 @@ static void afsd_notifier(char *msgp, char *filep, long line)
     afsi_log("--- end   dump ---");
     
 #ifdef DEBUG
-       if (IsDebuggerPresent())
-               DebugBreak();   
+    if (IsDebuggerPresent())
+        DebugBreak();  
 #endif
 
     SetEvent(WaitToTerminate);
index 18742ddf56c5d7e5656cd18b452c07c945680da8..668d8ab1af433b8c20c6f070f8313aa07a8562de 100644 (file)
@@ -120,24 +120,42 @@ cm_cell_t *cm_GetCell(char *namep, long flags)
 
 cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags)
 {
-    cm_cell_t *cp;
+    cm_cell_t *cp, *cp2;
     long code;
     char fullname[200]="";
 
     if (!strcmp(namep,SMB_IOCTL_FILENAME_NOSLASH))
         return NULL;
 
-    lock_ObtainWrite(&cm_cellLock);
+    lock_ObtainRead(&cm_cellLock);
     for (cp = cm_data.allCellsp; cp; cp=cp->nextp) {
         if (stricmp(namep, cp->name) == 0) {
             strcpy(fullname, cp->name);
             break;
         }
     }   
+    lock_ReleaseRead(&cm_cellLock);    
 
     if (cp) {
         cp = cm_UpdateCell(cp);
     } else if (flags & CM_FLAG_CREATE) {
+        lock_ObtainWrite(&cm_cellLock);
+
+        /* when we dropped the lock the cell could have been added
+         * to the list so check again while holding the write lock 
+         */
+        for (cp = cm_data.allCellsp; cp; cp=cp->nextp) {
+            if (stricmp(namep, cp->name) == 0) {
+                strcpy(fullname, cp->name);
+                break;
+            }
+        }   
+
+        if (cp) {
+            lock_ReleaseWrite(&cm_cellLock);
+            goto done;
+        }
+
         if ( cm_data.currentCells >= cm_data.maxCells )
             osi_panic("Exceeded Max Cells", __FILE__, __LINE__);
 
@@ -179,6 +197,25 @@ cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags)
            cp->timeout = time(0) + 7200;       /* two hour timeout */
        }
 
+        /* we have now been given the fullname of the cell.  It may
+         * be that we already have a cell with that name.  If so,
+         * we should use it instead of completing the allocation
+         * of a new cm_cell_t 
+         */
+        for (cp2 = cm_data.allCellsp; cp2; cp2=cp2->nextp) {
+            if (stricmp(fullname, cp2->name) == 0) {
+                break;
+            }
+        }   
+
+        if (cp2) {
+            cm_FreeServerList(&cp->vlServersp, CM_FREESERVERLIST_DELETE);
+            cp = cp2;
+            lock_ReleaseWrite(&cm_cellLock);
+            goto done;
+        }
+
+
         /* randomise among those vlservers having the same rank*/ 
         cm_RandomizeServer(&cp->vlServersp);
 
@@ -195,6 +232,7 @@ cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags)
            
         /* the cellID cannot be 0 */
         cp->cellID = ++cm_data.currentCells;
+        lock_ReleaseWrite(&cm_cellLock);
     }
 
   done:
@@ -202,7 +240,6 @@ cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags)
     if (cp && newnamep)
         strcpy(newnamep, fullname);
     
-    lock_ReleaseWrite(&cm_cellLock);
     return cp;
 }
 
@@ -210,16 +247,16 @@ cm_cell_t *cm_FindCellByID(afs_int32 cellID)
 {
     cm_cell_t *cp;
 
-    lock_ObtainWrite(&cm_cellLock);
+    lock_ObtainRead(&cm_cellLock);
     for (cp = cm_data.allCellsp; cp; cp=cp->nextp) {
         if (cellID == cp->cellID) 
             break;
     }
+    lock_ReleaseRead(&cm_cellLock);    
 
     if (cp)
         cp = cm_UpdateCell(cp);
 
-    lock_ReleaseWrite(&cm_cellLock);   
     return cp;
 }
 
@@ -329,3 +366,31 @@ void cm_ChangeRankCellVLServer(cm_server_t *tsp)
     }
 }       
 
+int cm_DumpCells(FILE *outputFile, char *cookie, int lock)
+{
+    cm_cell_t *cellp;
+    int zilch;
+    char output[1024];
+
+    if (lock)
+        lock_ObtainRead(&cm_cellLock);
+
+    sprintf(output, "%s - dumping cells - cm_data.currentCells=%d, cm_data.maxCells=%d\r\n", 
+            cookie, cm_data.currentCells, cm_data.maxCells);
+    WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
+
+    for (cellp = cm_data.allCellsp; cellp; cellp=cellp->nextp) {
+        sprintf(output, "%s cellp=0x%p,name=%s ID=%d flags=0x%x\r\n", 
+                cookie, cellp, cellp->name, cellp->cellID, cellp->flags);
+        WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
+    }
+
+    sprintf(output, "%s - Done dumping cells.\r\n", cookie);
+    WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
+
+    if (lock)
+        lock_ReleaseRead(&cm_cellLock);
+
+    return(0);
+}
+
index fd750a057dae8711802261c5486bd053c472dc8a..64eb03e04e4b5029662234a18abe70838f8d21b8 100644 (file)
@@ -52,4 +52,6 @@ extern osi_rwlock_t cm_cellLock;
 
 extern cm_cell_t *cm_allCellsp;
 
+extern int cm_DumpCells(FILE *, char *, int);
+
 #endif /* __CELL_H_ENV_ */
index daab721e08b71ae23fe4422890e9f1e6cca4ca29..318360ad3f543c9ceceea95d6275b1b750e61e8b 100644 (file)
@@ -2706,8 +2706,9 @@ long cm_IoctlMemoryDump(struct smb_ioctl *ioctlp, struct cm_user *userp)
 #endif
   
     /* dump all interesting data */
-    cm_DumpSCache(hLogFile, cookie, 1);
+    cm_DumpCells(hLogFile, cookie, 1);
     cm_DumpVolumes(hLogFile, cookie, 1);
+    cm_DumpSCache(hLogFile, cookie, 1);
     cm_DumpBufHashTable(hLogFile, cookie, 1);
     smb_DumpVCP(hLogFile, cookie, 1);
 
index d3646547adfd84a349bb57ed4a6afb3588745d3d..6863ba2aecb672e190f229e8022ac80db1421edb 100644 (file)
@@ -1594,13 +1594,10 @@ int cm_DumpSCache(FILE *outputFile, char *cookie, int lock)
   
     for (scp = cm_data.allSCachesp; scp; scp = scp->allNextp) 
     {
-        if (scp->refCount != 0)
-        {
-            sprintf(output, "%s scp=0x%p, fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%u\r\n", 
-                    cookie, scp, scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique, 
-                    scp->refCount);
-            WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
-        }
+        sprintf(output, "%s scp=0x%p, fid (cell=%d, volume=%d, vnode=%d, unique=%d) volp=0x%p flags=0x%x refCount=%u\r\n", 
+                cookie, scp, scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique, 
+                scp->volp, scp->flags, scp->refCount);
+        WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
     }
   
     sprintf(output, "%s - dumping cm_data.hashTable - cm_data.scacheHashTableSize=%d\r\n", cookie, cm_data.scacheHashTableSize);
@@ -1610,13 +1607,10 @@ int cm_DumpSCache(FILE *outputFile, char *cookie, int lock)
     {
         for(scp = cm_data.scacheHashTablep[i]; scp; scp=scp->nextp) 
         {
-            if (scp->refCount != 0)
-            {
-                sprintf(output, "%s scp=0x%p, hash=%d, fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%u\r\n", 
-                         cookie, scp, i, scp->fid.cell, scp->fid.volume, scp->fid.vnode, 
-                         scp->fid.unique, scp->refCount);
-                WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
-            }
+            sprintf(output, "%s scp=0x%p, hash=%d, fid (cell=%d, volume=%d, vnode=%d, unique=%d) volp=0x%p flags=0x%x refCount=%u\r\n", 
+                    cookie, scp, i, scp->fid.cell, scp->fid.volume, scp->fid.vnode, 
+                    scp->fid.unique, scp->volp, scp->flags, scp->refCount);
+            WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
         }
     }
 
index 6cd52f430f322f6e1e18e449248d2c130ebbc9cd..b56c33d2fa64ae49ea226ed9cfa21e919a6fc3f2 100644 (file)
@@ -592,7 +592,7 @@ long cm_GetVolumeByID(cm_cell_t *cellp, afs_uint32 volumeID, cm_user_t *userp,
     }
 
 #ifdef SEARCH_ALL_VOLUMES
-    assert(volp == volp2);
+    osi_assert(volp == volp2);
 #endif
 
     lock_ReleaseRead(&cm_volumeLock);
@@ -677,7 +677,7 @@ long cm_GetVolumeByName(struct cm_cell *cellp, char *volumeNamep,
     }
 
 #ifdef SEARCH_ALL_VOLUMES
-    assert(volp2 == volp);
+    osi_assert(volp2 == volp);
 #endif
 
     if (!volp && (flags & CM_GETVOL_FLAG_CREATE)) {
@@ -843,7 +843,7 @@ void cm_ForceUpdateVolume(cm_fid_t *fidp, cm_user_t *userp, cm_req_t *reqp)
     }
 
 #ifdef SEARCH_ALL_VOLUMES
-    assert(volp == volp2);
+    osi_assert(volp == volp2);
 #endif
 
     lock_ReleaseRead(&cm_volumeLock);
@@ -1217,23 +1217,20 @@ int cm_DumpVolumes(FILE *outputFile, char *cookie, int lock)
   
     for (volp = cm_data.allVolumesp; volp; volp=volp->allNextp)
     {
-        if (volp->refCount != 0)
-        {
-           cm_scache_t *scp;
-           int scprefs = 0;
-
-           for (scp = cm_data.allSCachesp; scp; scp = scp->allNextp) 
-           {
-               if (scp->volp == volp)
-                   scprefs++;
-           }
+        cm_scache_t *scp;
+        int scprefs = 0;
 
-            sprintf(output, "%s cell=%s name=%s rwID=%u roID=%u bkID=%u flags=0x%x fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%u scpRefs=%u\r\n", 
-                    cookie, volp->cellp->name, volp->namep, volp->rw.ID, volp->ro.ID, volp->bk.ID, volp->flags, 
-                   volp->dotdotFid.cell, volp->dotdotFid.volume, volp->dotdotFid.vnode, volp->dotdotFid.unique,
-                   volp->refCount, scprefs);
-            WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
-        }
+        for (scp = cm_data.allSCachesp; scp; scp = scp->allNextp) 
+        {
+            if (scp->volp == volp)
+                scprefs++;
+        }   
+
+        sprintf(output, "%s - volp=0x%p cell=%s name=%s rwID=%u roID=%u bkID=%u flags=0x%x fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%u scpRefs=%u\r\n", 
+                 cookie, volp, volp->cellp->name, volp->namep, volp->rw.ID, volp->ro.ID, volp->bk.ID, volp->flags, 
+                 volp->dotdotFid.cell, volp->dotdotFid.volume, volp->dotdotFid.vnode, volp->dotdotFid.unique,
+                 volp->refCount, scprefs);
+        WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
     }
     sprintf(output, "%s - Done dumping volumes.\r\n", cookie);
     WriteFile(outputFile, output, (DWORD)strlen(output), &zilch, NULL);
index e0b2eca237c616e36cb864f3c3702197463e53ce..8610b1d4151288ca7ede3cc6b165cc7db2d4b106 100644 (file)
@@ -439,7 +439,9 @@ extern "C" BOOL lana_IsLoopback(lana_number_t lana, BOOL reset)
     } astat;
     unsigned char kWLA_MAC[6] = { 0x02, 0x00, 0x4c, 0x4f, 0x4f, 0x50 };
     unsigned char kVista_WLA_MAC[6] = { 0x7F, 0x00, 0x00, 0x01, 0x4f, 0x50 };
+#ifdef USE_VMWARE
     unsigned char kVMWare_MAC[5] = { 0x00, 0x50, 0x56, 0xC0, 0x00 };
+#endif
     int status;
     HKEY hkConfig;
     LONG rv;
@@ -491,8 +493,11 @@ extern "C" BOOL lana_IsLoopback(lana_number_t lana, BOOL reset)
         return FALSE;
     }
     return (memcmp(astat.status.adapter_address, kWLA_MAC, 6) == 0 ||
-           memcmp(astat.status.adapter_address, kVista_WLA_MAC, 6) == 0 ||
-           memcmp(astat.status.adapter_address, kVMWare_MAC, 5) == 0);
+           memcmp(astat.status.adapter_address, kVista_WLA_MAC, 6) == 0 
+#ifdef USE_VMWARE
+             || memcmp(astat.status.adapter_address, kVMWare_MAC, 5) == 0
+#endif
+             );
 }
 
 // Get the netbios named used/to-be-used by the AFS SMB server.