]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-windows-misc-20070619
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 19 Jun 2007 06:25:39 +0000 (06:25 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 19 Jun 2007 06:25:39 +0000 (06:25 +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.

(cherry picked from commit aed66fda2c2ba1758a69950a53d09efc82f8212d)

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 3fc4f79f636261889306eb31da3c2e260f660eb6..4bd2df637bece72dad34a1f5ceb4ac71ad851e00 100644 (file)
@@ -122,24 +122,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__);
 
@@ -181,6 +199,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);
 
@@ -197,6 +234,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:
@@ -204,7 +242,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;
 }
 
@@ -212,16 +249,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;
 }
 
@@ -331,3 +368,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 ab894375fdc9ebd7bafde647bd0b7c971dfd6cbd..363aa7315b56a9f5ca2d261b90010b0e7689425c 100644 (file)
@@ -2756,8 +2756,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 a0d67989292aca6156d9baaaacb2e632c5968fb9..644b472ea207afb8648a0754c8a370a8fdee330c 100644 (file)
@@ -1596,13 +1596,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);
@@ -1612,13 +1609,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 4d935293645ce7854dd2510514fc23ab75675aef..9e377d8594ea59a202eb84e8d55c5736148d50ef 100644 (file)
@@ -596,7 +596,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);
@@ -681,7 +681,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)) {
@@ -847,7 +847,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);
@@ -1221,23 +1221,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.