DEVEL15-windows-misc-20070619

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 aed66fda2c)
This commit is contained in:
Jeffrey Altman 2007-06-19 06:25:39 +00:00
parent 09e7e81d6e
commit 0ebd80e33b
7 changed files with 108 additions and 42 deletions

View 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);

View 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);
}

View 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_ */

View 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);

View 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);
}
}

View 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)
{
cm_scache_t *scp;
int scprefs = 0;
if (scp->volp == volp)
scprefs++;
}
for (scp = cm_data.allSCachesp; scp; scp = scp->allNextp)
{
if (scp->volp == volp)
scprefs++;
}
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);
}
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);

View 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.