windows-combined-20041010

* fix the Windows cache manager to prevent it from replacing the
    rx_connection object associated with the cm_conn_t object on each
    and every operation if "fs crypt" was set.  This explains the
    dramatic performance difference when crypt is used vs clear.
    The problem: 'cryptall', a boolean flag indicating whether or not
    "fs crypt" is set, was being compared to the rx_connection
    cryptlevel which is either rxkad_clear:0 or rxkad_crypt:2.
    1 != 2 and therefore the rx_connection was always destroyed
    and replaced on each and every operation.

    Lock the cm_conn_t object around every call to RXAFS_xxxx functions.
    It is not safe for the cm_conn_t object to not be locked because
    rx_DestroyConnection might be called from another thread if:
        - the user's tokens have changed or expired
        - the crypt mode has changed

  * Modify cm_Lookup to evaluate a list of possible values for @sys
    instead of just a single entry.  Re-write cm_ExpandSysname and
    add cm_LookupInternal.

  * Reformat affected files

  * Add cache file name to cache creation errors
This commit is contained in:
Jeffrey Altman 2004-10-11 00:50:37 +00:00 committed by Jeffrey Altman
parent 346f60b807
commit d8453a3f46
11 changed files with 5582 additions and 5433 deletions

View File

@ -81,7 +81,7 @@ BOOL reportSessionStartups = FALSE;
cm_initparams_v1 cm_initParams;
char *cm_sysName = 0;
int cm_sysNameCount = 0;
unsigned int cm_sysNameCount = 0;
char *cm_sysNameList[MAXNUMSYSNAMES];
DWORD TraceOption = 0;
@ -358,72 +358,72 @@ configureBackConnectionHostNames(void)
int afsd_InitCM(char **reasonP)
{
osi_uid_t debugID;
long cacheBlocks;
long cacheSize;
long logChunkSize;
long stats;
long traceBufSize;
osi_uid_t debugID;
long cacheBlocks;
long cacheSize;
long logChunkSize;
long stats;
long traceBufSize;
long maxcpus;
long ltt, ltto;
long ltt, ltto;
long rx_mtu, rx_nojumbo;
long virtualCache;
char rootCellName[256];
struct rx_service *serverp;
static struct rx_securityClass *nullServerSecurityClassp;
struct hostent *thp;
char *msgBuf;
char buf[200];
HKEY parmKey;
DWORD dummyLen;
char rootCellName[256];
struct rx_service *serverp;
static struct rx_securityClass *nullServerSecurityClassp;
struct hostent *thp;
char *msgBuf;
char buf[200];
HKEY parmKey;
DWORD dummyLen;
DWORD regType;
long code;
/*int freelanceEnabled;*/
WSADATA WSAjunk;
long code;
/*int freelanceEnabled;*/
WSADATA WSAjunk;
lana_number_t lanaNum;
int i;
WSAStartup(0x0101, &WSAjunk);
WSAStartup(0x0101, &WSAjunk);
afsd_initUpperCaseTable();
/* setup osidebug server at RPC slot 1000 */
osi_LongToUID(1000, &debugID);
code = osi_InitDebug(&debugID);
afsi_log("osi_InitDebug code %d", code);
/* setup osidebug server at RPC slot 1000 */
osi_LongToUID(1000, &debugID);
code = osi_InitDebug(&debugID);
afsi_log("osi_InitDebug code %d", code);
// osi_LockTypeSetDefault("stat"); /* comment this out for speed *
if (code != 0) {
*reasonP = "unknown error";
return -1;
}
if (code != 0) {
*reasonP = "unknown error";
return -1;
}
/* who are we ? */
gethostname(cm_HostName, sizeof(cm_HostName));
afsi_log("gethostname %s", cm_HostName);
thp = gethostbyname(cm_HostName);
memcpy(&cm_HostAddr, thp->h_addr_list[0], 4);
/* who are we ? */
gethostname(cm_HostName, sizeof(cm_HostName));
afsi_log("gethostname %s", cm_HostName);
thp = gethostbyname(cm_HostName);
memcpy(&cm_HostAddr, thp->h_addr_list[0], 4);
/* seed random number generator */
srand(ntohl(cm_HostAddr));
/* seed random number generator */
srand(ntohl(cm_HostAddr));
/* Look up configuration parameters in Registry */
code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName,
0, KEY_QUERY_VALUE, &parmKey);
if (code != ERROR_SUCCESS) {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, code, 0, (LPTSTR)&msgBuf, 0, NULL);
StringCbPrintfA(buf, sizeof(buf),
"Failure in configuration while opening Registry: %s",
msgBuf);
osi_panic(buf, __FILE__, __LINE__);
}
/* Look up configuration parameters in Registry */
code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName,
0, KEY_QUERY_VALUE, &parmKey);
if (code != ERROR_SUCCESS) {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, code, 0, (LPTSTR)&msgBuf, 0, NULL);
StringCbPrintfA(buf, sizeof(buf),
"Failure in configuration while opening Registry: %s",
msgBuf);
osi_panic(buf, __FILE__, __LINE__);
}
dummyLen = sizeof(maxcpus);
code = RegQueryValueEx(parmKey, "MaxCPUs", NULL, NULL,
(BYTE *) &maxcpus, &dummyLen);
if (code == ERROR_SUCCESS) {
code = RegQueryValueEx(parmKey, "MaxCPUs", NULL, NULL,
(BYTE *) &maxcpus, &dummyLen);
if (code == ERROR_SUCCESS) {
HANDLE hProcess;
DWORD_PTR processAffinityMask, systemAffinityMask;
@ -456,139 +456,139 @@ int afsd_InitCM(char **reasonP)
}
}
dummyLen = sizeof(TraceOption);
code = RegQueryValueEx(parmKey, "TraceOption", NULL, NULL,
(BYTE *) &TraceOption, &dummyLen);
dummyLen = sizeof(TraceOption);
code = RegQueryValueEx(parmKey, "TraceOption", NULL, NULL,
(BYTE *) &TraceOption, &dummyLen);
afsi_log("Event Log Tracing = %lX", TraceOption);
dummyLen = sizeof(traceBufSize);
code = RegQueryValueEx(parmKey, "TraceBufferSize", NULL, NULL,
(BYTE *) &traceBufSize, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Trace Buffer size %d", traceBufSize);
else {
traceBufSize = CM_CONFIGDEFAULT_TRACEBUFSIZE;
afsi_log("Default trace buffer size %d", traceBufSize);
}
dummyLen = sizeof(traceBufSize);
code = RegQueryValueEx(parmKey, "TraceBufferSize", NULL, NULL,
(BYTE *) &traceBufSize, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Trace Buffer size %d", traceBufSize);
else {
traceBufSize = CM_CONFIGDEFAULT_TRACEBUFSIZE;
afsi_log("Default trace buffer size %d", traceBufSize);
}
/* setup and enable debug log */
afsd_logp = osi_LogCreate("afsd", traceBufSize);
afsi_log("osi_LogCreate log addr %x", (int)afsd_logp);
/* setup and enable debug log */
afsd_logp = osi_LogCreate("afsd", traceBufSize);
afsi_log("osi_LogCreate log addr %x", (int)afsd_logp);
osi_LogEnable(afsd_logp);
logReady = 1;
logReady = 1;
osi_Log0(afsd_logp, "Log init");
dummyLen = sizeof(cacheSize);
code = RegQueryValueEx(parmKey, "CacheSize", NULL, NULL,
(BYTE *) &cacheSize, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Cache size %d", cacheSize);
else {
cacheSize = CM_CONFIGDEFAULT_CACHESIZE;
afsi_log("Default cache size %d", cacheSize);
}
dummyLen = sizeof(cacheSize);
code = RegQueryValueEx(parmKey, "CacheSize", NULL, NULL,
(BYTE *) &cacheSize, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Cache size %d", cacheSize);
else {
cacheSize = CM_CONFIGDEFAULT_CACHESIZE;
afsi_log("Default cache size %d", cacheSize);
}
dummyLen = sizeof(logChunkSize);
code = RegQueryValueEx(parmKey, "ChunkSize", NULL, NULL,
(BYTE *) &logChunkSize, &dummyLen);
if (code == ERROR_SUCCESS) {
if (logChunkSize < 12 || logChunkSize > 30) {
afsi_log("Invalid chunk size %d, using default",
logChunkSize);
logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE;
}
afsi_log("Chunk size %d", logChunkSize);
} else {
logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE;
afsi_log("Default chunk size %d", logChunkSize);
}
cm_logChunkSize = logChunkSize;
cm_chunkSize = 1 << logChunkSize;
dummyLen = sizeof(logChunkSize);
code = RegQueryValueEx(parmKey, "ChunkSize", NULL, NULL,
(BYTE *) &logChunkSize, &dummyLen);
if (code == ERROR_SUCCESS) {
if (logChunkSize < 12 || logChunkSize > 30) {
afsi_log("Invalid chunk size %d, using default",
logChunkSize);
logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE;
}
afsi_log("Chunk size %d", logChunkSize);
} else {
logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE;
afsi_log("Default chunk size %d", logChunkSize);
}
cm_logChunkSize = logChunkSize;
cm_chunkSize = 1 << logChunkSize;
dummyLen = sizeof(numBkgD);
code = RegQueryValueEx(parmKey, "Daemons", NULL, NULL,
(BYTE *) &numBkgD, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("%d background daemons", numBkgD);
else {
numBkgD = CM_CONFIGDEFAULT_DAEMONS;
afsi_log("Defaulting to %d background daemons", numBkgD);
}
dummyLen = sizeof(numBkgD);
code = RegQueryValueEx(parmKey, "Daemons", NULL, NULL,
(BYTE *) &numBkgD, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("%d background daemons", numBkgD);
else {
numBkgD = CM_CONFIGDEFAULT_DAEMONS;
afsi_log("Defaulting to %d background daemons", numBkgD);
}
dummyLen = sizeof(numSvThreads);
code = RegQueryValueEx(parmKey, "ServerThreads", NULL, NULL,
(BYTE *) &numSvThreads, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("%d server threads", numSvThreads);
else {
numSvThreads = CM_CONFIGDEFAULT_SVTHREADS;
afsi_log("Defaulting to %d server threads", numSvThreads);
}
dummyLen = sizeof(numSvThreads);
code = RegQueryValueEx(parmKey, "ServerThreads", NULL, NULL,
(BYTE *) &numSvThreads, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("%d server threads", numSvThreads);
else {
numSvThreads = CM_CONFIGDEFAULT_SVTHREADS;
afsi_log("Defaulting to %d server threads", numSvThreads);
}
dummyLen = sizeof(stats);
code = RegQueryValueEx(parmKey, "Stats", NULL, NULL,
(BYTE *) &stats, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Status cache size %d", stats);
else {
stats = CM_CONFIGDEFAULT_STATS;
afsi_log("Default status cache size %d", stats);
}
dummyLen = sizeof(stats);
code = RegQueryValueEx(parmKey, "Stats", NULL, NULL,
(BYTE *) &stats, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Status cache size %d", stats);
else {
stats = CM_CONFIGDEFAULT_STATS;
afsi_log("Default status cache size %d", stats);
}
dummyLen = sizeof(ltt);
code = RegQueryValueEx(parmKey, "LogoffTokenTransfer", NULL, NULL,
(BYTE *) &ltt, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Logoff token transfer %s", (ltt ? "on" : "off"));
else {
ltt = 1;
afsi_log("Logoff token transfer on by default");
}
dummyLen = sizeof(ltt);
code = RegQueryValueEx(parmKey, "LogoffTokenTransfer", NULL, NULL,
(BYTE *) &ltt, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Logoff token transfer %s", (ltt ? "on" : "off"));
else {
ltt = 1;
afsi_log("Logoff token transfer on by default");
}
smb_LogoffTokenTransfer = ltt;
afsi_log("Logoff token transfer is currently ignored");
if (ltt) {
dummyLen = sizeof(ltto);
code = RegQueryValueEx(parmKey, "LogoffTokenTransferTimeout",
NULL, NULL, (BYTE *) &ltto, &dummyLen);
if (code == ERROR_SUCCESS)
if (ltt) {
dummyLen = sizeof(ltto);
code = RegQueryValueEx(parmKey, "LogoffTokenTransferTimeout",
NULL, NULL, (BYTE *) &ltto, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Logoff token tranfer timeout %d seconds", ltto);
else {
ltto = 10;
afsi_log("Default logoff token transfer timeout 10 seconds");
}
} else {
else {
ltto = 10;
afsi_log("Default logoff token transfer timeout 10 seconds");
}
} else {
ltto = 0;
}
}
smb_LogoffTransferTimeout = ltto;
afsi_log("Default logoff token is currently ignored");
dummyLen = sizeof(cm_rootVolumeName);
code = RegQueryValueEx(parmKey, "RootVolume", NULL, NULL,
cm_rootVolumeName, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Root volume %s", cm_rootVolumeName);
else {
StringCbCopyA(cm_rootVolumeName, sizeof(cm_rootVolumeName), "root.afs");
afsi_log("Default root volume name root.afs");
}
dummyLen = sizeof(cm_rootVolumeName);
code = RegQueryValueEx(parmKey, "RootVolume", NULL, NULL,
cm_rootVolumeName, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Root volume %s", cm_rootVolumeName);
else {
StringCbCopyA(cm_rootVolumeName, sizeof(cm_rootVolumeName), "root.afs");
afsi_log("Default root volume name root.afs");
}
cm_mountRootLen = sizeof(cm_mountRoot);
code = RegQueryValueEx(parmKey, "MountRoot", NULL, NULL,
cm_mountRoot, &cm_mountRootLen);
if (code == ERROR_SUCCESS) {
afsi_log("Mount root %s", cm_mountRoot);
cm_mountRootLen = strlen(cm_mountRoot);
} else {
StringCbCopyA(cm_mountRoot, sizeof(cm_mountRoot), "/afs");
cm_mountRootLen = 4;
/* Don't log */
}
cm_mountRootLen = sizeof(cm_mountRoot);
code = RegQueryValueEx(parmKey, "MountRoot", NULL, NULL,
cm_mountRoot, &cm_mountRootLen);
if (code == ERROR_SUCCESS) {
afsi_log("Mount root %s", cm_mountRoot);
cm_mountRootLen = strlen(cm_mountRoot);
} else {
StringCbCopyA(cm_mountRoot, sizeof(cm_mountRoot), "/afs");
cm_mountRootLen = 4;
/* Don't log */
}
dummyLen = sizeof(buf);
code = RegQueryValueEx(parmKey, "CachePath", NULL, &regType,
buf, &dummyLen);
dummyLen = sizeof(buf);
code = RegQueryValueEx(parmKey, "CachePath", NULL, &regType,
buf, &dummyLen);
if (code == ERROR_SUCCESS && buf[0]) {
if (regType == REG_EXPAND_SZ) {
dummyLen = ExpandEnvironmentStrings(buf, cm_CachePath, sizeof(cm_CachePath));
@ -599,17 +599,17 @@ int afsd_InitCM(char **reasonP)
} else {
StringCbCopyA(cm_CachePath, sizeof(cm_CachePath), buf);
}
afsi_log("Cache path %s", cm_CachePath);
afsi_log("Cache path %s", cm_CachePath);
} else {
GetWindowsDirectory(cm_CachePath, sizeof(cm_CachePath));
cm_CachePath[2] = 0; /* get drive letter only */
StringCbCatA(cm_CachePath, sizeof(cm_CachePath), "\\AFSCache");
afsi_log("Default cache path %s", cm_CachePath);
}
GetWindowsDirectory(cm_CachePath, sizeof(cm_CachePath));
cm_CachePath[2] = 0; /* get drive letter only */
StringCbCatA(cm_CachePath, sizeof(cm_CachePath), "\\AFSCache");
afsi_log("Default cache path %s", cm_CachePath);
}
dummyLen = sizeof(virtualCache);
code = RegQueryValueEx(parmKey, "NonPersistentCaching", NULL, NULL,
&virtualCache, &dummyLen);
&virtualCache, &dummyLen);
if (code == ERROR_SUCCESS && virtualCache) {
buf_cacheType = CM_BUF_CACHETYPE_VIRTUAL;
} else {
@ -617,27 +617,27 @@ int afsd_InitCM(char **reasonP)
}
afsi_log("Cache type is %s", ((buf_cacheType == CM_BUF_CACHETYPE_FILE)?"FILE":"VIRTUAL"));
dummyLen = sizeof(traceOnPanic);
code = RegQueryValueEx(parmKey, "TrapOnPanic", NULL, NULL,
(BYTE *) &traceOnPanic, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Set to %s on panic",
traceOnPanic ? "trap" : "not trap");
else {
traceOnPanic = 0;
/* Don't log */
}
dummyLen = sizeof(traceOnPanic);
code = RegQueryValueEx(parmKey, "TrapOnPanic", NULL, NULL,
(BYTE *) &traceOnPanic, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Set to %s on panic",
traceOnPanic ? "trap" : "not trap");
else {
traceOnPanic = 0;
/* Don't log */
}
dummyLen = sizeof(reportSessionStartups);
code = RegQueryValueEx(parmKey, "ReportSessionStartups", NULL, NULL,
(BYTE *) &reportSessionStartups, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Session startups %s be recorded in the Event Log",
reportSessionStartups ? "will" : "will not");
else {
reportSessionStartups = 0;
/* Don't log */
}
dummyLen = sizeof(reportSessionStartups);
code = RegQueryValueEx(parmKey, "ReportSessionStartups", NULL, NULL,
(BYTE *) &reportSessionStartups, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Session startups %s be recorded in the Event Log",
reportSessionStartups ? "will" : "will not");
else {
reportSessionStartups = 0;
/* Don't log */
}
for ( i=0; i < MAXNUMSYSNAMES; i++ ) {
cm_sysNameList[i] = osi_Alloc(MAXSYSNAME);
@ -645,53 +645,53 @@ int afsd_InitCM(char **reasonP)
}
cm_sysName = cm_sysNameList[0];
dummyLen = MAXSYSNAME;
dummyLen = MAXSYSNAME;
code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, cm_sysName, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Sys name %s", cm_sysName);
else {
StringCbCopyA(cm_sysName, MAXSYSNAME, "i386_nt40");
afsi_log("Default sys name %s", cm_sysName);
}
if (code == ERROR_SUCCESS)
afsi_log("Sys name %s", cm_sysName);
else {
StringCbCopyA(cm_sysName, MAXSYSNAME, "i386_nt40");
afsi_log("Default sys name %s", cm_sysName);
}
cm_sysNameCount = 1;
dummyLen = sizeof(cryptall);
code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL,
(BYTE *) &cryptall, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("SecurityLevel is %s", cryptall?"crypt":"clear");
else {
cryptall = rxkad_clear;
afsi_log("Default SecurityLevel is clear");
}
dummyLen = sizeof(cryptall);
code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL,
(BYTE *) &cryptall, &dummyLen);
if (code == ERROR_SUCCESS) {
afsi_log("SecurityLevel is %s", cryptall?"crypt":"clear");
} else {
cryptall = 0;
afsi_log("Default SecurityLevel is clear");
}
#ifdef AFS_AFSDB_ENV
dummyLen = sizeof(cm_dnsEnabled);
code = RegQueryValueEx(parmKey, "UseDNS", NULL, NULL,
(BYTE *) &cm_dnsEnabled, &dummyLen);
if (code == ERROR_SUCCESS) {
afsi_log("DNS %s be used to find AFS cell servers",
cm_dnsEnabled ? "will" : "will not");
}
else {
cm_dnsEnabled = 1; /* default on */
afsi_log("Default to use DNS to find AFS cell servers");
}
dummyLen = sizeof(cm_dnsEnabled);
code = RegQueryValueEx(parmKey, "UseDNS", NULL, NULL,
(BYTE *) &cm_dnsEnabled, &dummyLen);
if (code == ERROR_SUCCESS) {
afsi_log("DNS %s be used to find AFS cell servers",
cm_dnsEnabled ? "will" : "will not");
}
else {
cm_dnsEnabled = 1; /* default on */
afsi_log("Default to use DNS to find AFS cell servers");
}
#else /* AFS_AFSDB_ENV */
afsi_log("AFS not built with DNS support to find AFS cell servers");
afsi_log("AFS not built with DNS support to find AFS cell servers");
#endif /* AFS_AFSDB_ENV */
#ifdef AFS_FREELANCE_CLIENT
dummyLen = sizeof(cm_freelanceEnabled);
code = RegQueryValueEx(parmKey, "FreelanceClient", NULL, NULL,
(BYTE *) &cm_freelanceEnabled, &dummyLen);
if (code == ERROR_SUCCESS) {
afsi_log("Freelance client feature %s activated",
cm_freelanceEnabled ? "is" : "is not");
}
else {
cm_freelanceEnabled = 0; /* default off */
}
dummyLen = sizeof(cm_freelanceEnabled);
code = RegQueryValueEx(parmKey, "FreelanceClient", NULL, NULL,
(BYTE *) &cm_freelanceEnabled, &dummyLen);
if (code == ERROR_SUCCESS) {
afsi_log("Freelance client feature %s activated",
cm_freelanceEnabled ? "is" : "is not");
}
else {
cm_freelanceEnabled = 0; /* default off */
}
#endif /* AFS_FREELANCE_CLIENT */
#ifdef COMMENT
@ -738,15 +738,15 @@ int afsd_InitCM(char **reasonP)
}
afsi_log("Maximum number of VCs per server is %d", smb_maxVCPerServer);
dummyLen = sizeof(smb_authType);
code = RegQueryValueEx(parmKey, "SMBAuthType", NULL, NULL,
(BYTE *) &smb_authType, &dummyLen);
dummyLen = sizeof(smb_authType);
code = RegQueryValueEx(parmKey, "SMBAuthType", NULL, NULL,
(BYTE *) &smb_authType, &dummyLen);
if (code != ERROR_SUCCESS ||
(smb_authType != SMB_AUTH_EXTENDED && smb_authType != SMB_AUTH_NTLM && smb_authType != SMB_AUTH_NONE)) {
smb_authType = SMB_AUTH_EXTENDED; /* default is to use extended authentication */
}
afsi_log("SMB authentication type is %s", ((smb_authType == SMB_AUTH_NONE)?"NONE":((smb_authType == SMB_AUTH_EXTENDED)?"EXTENDED":"NTLM")));
if (code != ERROR_SUCCESS ||
(smb_authType != SMB_AUTH_EXTENDED && smb_authType != SMB_AUTH_NTLM && smb_authType != SMB_AUTH_NONE)) {
smb_authType = SMB_AUTH_EXTENDED; /* default is to use extended authentication */
}
afsi_log("SMB authentication type is %s", ((smb_authType == SMB_AUTH_NONE)?"NONE":((smb_authType == SMB_AUTH_EXTENDED)?"EXTENDED":"NTLM")));
dummyLen = sizeof(rx_nojumbo);
code = RegQueryValueEx(parmKey, "RxNoJumbo", NULL, NULL,
@ -754,7 +754,7 @@ int afsd_InitCM(char **reasonP)
if (code != ERROR_SUCCESS) {
rx_nojumbo = 0;
}
if(rx_nojumbo)
if (rx_nojumbo)
afsi_log("RX Jumbograms are disabled");
dummyLen = sizeof(rx_mtu);
@ -763,7 +763,7 @@ int afsd_InitCM(char **reasonP)
if (code != ERROR_SUCCESS || !rx_mtu) {
rx_mtu = -1;
}
if(rx_mtu != -1)
if (rx_mtu != -1)
afsi_log("RX maximum MTU is %d", rx_mtu);
dummyLen = sizeof(ConnDeadtimeout);
@ -776,18 +776,18 @@ int afsd_InitCM(char **reasonP)
(BYTE *) &HardDeadtimeout, &dummyLen);
afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
RegCloseKey (parmKey);
RegCloseKey (parmKey);
/* Call lanahelper to get Netbios name, lan adapter number and gateway flag */
if(SUCCEEDED(code = lana_GetUncServerNameEx(cm_NetbiosName, &lanaNum, &isGateway, LANA_NETBIOS_NAME_FULL))) {
LANadapter = (lanaNum == LANA_INVALID)? -1: lanaNum;
if(LANadapter != -1)
if (LANadapter != -1)
afsi_log("LAN adapter number %d", LANadapter);
else
afsi_log("LAN adapter number not determined");
if(isGateway)
if (isGateway)
afsi_log("Set for gateway service");
afsi_log("Using >%s< as SMB server name", cm_NetbiosName);
@ -797,38 +797,38 @@ int afsd_InitCM(char **reasonP)
osi_panic(buf, __FILE__, __LINE__);
}
/* setup early variables */
/* These both used to be configurable. */
smb_UseV3 = 1;
/* setup early variables */
/* These both used to be configurable. */
smb_UseV3 = 1;
buf_bufferSize = CM_CONFIGDEFAULT_BLOCKSIZE;
/* turn from 1024 byte units into memory blocks */
/* turn from 1024 byte units into memory blocks */
cacheBlocks = (cacheSize * 1024) / buf_bufferSize;
/* get network related info */
cm_noIPAddr = CM_MAXINTERFACE_ADDR;
code = syscfg_GetIFInfo(&cm_noIPAddr,
cm_IPAddr, cm_SubnetMask,
cm_NetMtu, cm_NetFlags);
/* get network related info */
cm_noIPAddr = CM_MAXINTERFACE_ADDR;
code = syscfg_GetIFInfo(&cm_noIPAddr,
cm_IPAddr, cm_SubnetMask,
cm_NetMtu, cm_NetFlags);
if ( (cm_noIPAddr <= 0) || (code <= 0 ) )
afsi_log("syscfg_GetIFInfo error code %d", code);
else
afsi_log("First Network address %x SubnetMask %x",
cm_IPAddr[0], cm_SubnetMask[0]);
if ( (cm_noIPAddr <= 0) || (code <= 0 ) )
afsi_log("syscfg_GetIFInfo error code %d", code);
else
afsi_log("First Network address %x SubnetMask %x",
cm_IPAddr[0], cm_SubnetMask[0]);
/*
* Save client configuration for GetCacheConfig requests
*/
cm_initParams.nChunkFiles = 0;
cm_initParams.nStatCaches = stats;
cm_initParams.nDataCaches = 0;
cm_initParams.nVolumeCaches = 0;
cm_initParams.firstChunkSize = cm_chunkSize;
cm_initParams.otherChunkSize = cm_chunkSize;
cm_initParams.cacheSize = cacheSize;
cm_initParams.setTime = 0;
cm_initParams.memCache = 0;
/*
* Save client configuration for GetCacheConfig requests
*/
cm_initParams.nChunkFiles = 0;
cm_initParams.nStatCaches = stats;
cm_initParams.nDataCaches = 0;
cm_initParams.nVolumeCaches = 0;
cm_initParams.firstChunkSize = cm_chunkSize;
cm_initParams.otherChunkSize = cm_chunkSize;
cm_initParams.cacheSize = cacheSize;
cm_initParams.setTime = 0;
cm_initParams.memCache = 0;
/* Set RX parameters before initializing RX */
if ( rx_nojumbo ) {
@ -847,48 +847,48 @@ int afsd_InitCM(char **reasonP)
/* Ensure the AFS Netbios Name is registered to allow loopback access */
configureBackConnectionHostNames();
/* initialize RX, and tell it to listen to port 7001, which is used for
/* initialize RX, and tell it to listen to port 7001, which is used for
* callback RPC messages.
*/
code = rx_Init(htons(7001));
afsi_log("rx_Init code %x", code);
if (code != 0) {
*reasonP = "afsd: failed to init rx client on port 7001";
return -1;
}
code = rx_Init(htons(7001));
afsi_log("rx_Init code %x", code);
if (code != 0) {
*reasonP = "afsd: failed to init rx client on port 7001";
return -1;
}
/* Initialize the RPC server for session keys */
RpcInit();
/* Initialize the RPC server for session keys */
RpcInit();
/* create an unauthenticated service #1 for callbacks */
nullServerSecurityClassp = rxnull_NewServerSecurityObject();
/* create an unauthenticated service #1 for callbacks */
nullServerSecurityClassp = rxnull_NewServerSecurityObject();
serverp = rx_NewService(0, 1, "AFS", &nullServerSecurityClassp, 1,
RXAFSCB_ExecuteRequest);
afsi_log("rx_NewService addr %x", (int)serverp);
if (serverp == NULL) {
*reasonP = "unknown error";
return -1;
}
RXAFSCB_ExecuteRequest);
afsi_log("rx_NewService addr %x", (int)serverp);
if (serverp == NULL) {
*reasonP = "unknown error";
return -1;
}
nullServerSecurityClassp = rxnull_NewServerSecurityObject();
nullServerSecurityClassp = rxnull_NewServerSecurityObject();
serverp = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats",
&nullServerSecurityClassp, 1, RXSTATS_ExecuteRequest);
afsi_log("rx_NewService addr %x", (int)serverp);
if (serverp == NULL) {
*reasonP = "unknown error";
return -1;
}
&nullServerSecurityClassp, 1, RXSTATS_ExecuteRequest);
afsi_log("rx_NewService addr %x", (int)serverp);
if (serverp == NULL) {
*reasonP = "unknown error";
return -1;
}
/* start server threads, *not* donating this one to the pool */
rx_StartServer(0);
afsi_log("rx_StartServer");
afsi_log("rx_StartServer");
/* init user daemon, and other packages */
cm_InitUser();
/* init user daemon, and other packages */
cm_InitUser();
cm_InitACLCache(2*stats);
cm_InitACLCache(2*stats);
cm_InitConn();
cm_InitConn();
cm_InitCell();
@ -905,28 +905,28 @@ int afsd_InitCM(char **reasonP)
cm_InitSCache(stats);
code = cm_InitDCache(0, cacheBlocks);
afsi_log("cm_InitDCache code %x", code);
if (code != 0) {
*reasonP = "error initializing cache";
return -1;
}
afsi_log("cm_InitDCache code %x", code);
if (code != 0) {
*reasonP = "error initializing cache";
return -1;
}
#ifdef AFS_AFSDB_ENV
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
if (cm_InitDNS(cm_dnsEnabled) == -1)
cm_dnsEnabled = 0; /* init failed, so deactivate */
afsi_log("cm_InitDNS %d", cm_dnsEnabled);
if (cm_InitDNS(cm_dnsEnabled) == -1)
cm_dnsEnabled = 0; /* init failed, so deactivate */
afsi_log("cm_InitDNS %d", cm_dnsEnabled);
#endif
#endif
code = cm_GetRootCellName(rootCellName);
afsi_log("cm_GetRootCellName code %d, cm_freelanceEnabled= %d, rcn= %s",
code, cm_freelanceEnabled, (code ? "<none>" : rootCellName));
if (code != 0 && !cm_freelanceEnabled)
code = cm_GetRootCellName(rootCellName);
afsi_log("cm_GetRootCellName code %d, cm_freelanceEnabled= %d, rcn= %s",
code, cm_freelanceEnabled, (code ? "<none>" : rootCellName));
if (code != 0 && !cm_freelanceEnabled)
{
*reasonP = "can't find root cell name in afsd.ini";
return -1;
}
*reasonP = "can't find root cell name in afsd.ini";
return -1;
}
else if (cm_freelanceEnabled)
cm_rootCellp = NULL;
@ -939,14 +939,13 @@ int afsd_InitCM(char **reasonP)
*reasonP = "can't find root cell in afsdcell.ini";
return -1;
}
}
}
#ifdef AFS_FREELANCE_CLIENT
if (cm_freelanceEnabled)
cm_InitFreelance();
if (cm_freelanceEnabled)
cm_InitFreelance();
#endif
return 0;
return 0;
}
int afsd_InitDaemons(char **reasonP)

File diff suppressed because it is too large Load Diff

View File

@ -70,22 +70,22 @@ cm_racingRevokes_t *cm_racingRevokesp;
*/
void cm_RecordRacingRevoke(cm_fid_t *fidp, long cancelFlags)
{
cm_racingRevokes_t *rp;
cm_racingRevokes_t *rp;
lock_ObtainWrite(&cm_callbackLock);
lock_ObtainWrite(&cm_callbackLock);
osi_Log3(afsd_logp, "RecordRacingRevoke Volume %d Flags %lX activeCalls %d",
fidp->volume, cancelFlags, cm_activeCallbackGrantingCalls);
if (cm_activeCallbackGrantingCalls > 0) {
rp = malloc(sizeof(*rp));
memset(rp, 0, sizeof(*rp));
osi_QAdd((osi_queue_t **) &cm_racingRevokesp, &rp->q);
rp->flags |= (cancelFlags & CM_RACINGFLAG_ALL);
if (fidp) rp->fid = *fidp;
rp->callbackCount = ++cm_callbackCount;
}
lock_ReleaseWrite(&cm_callbackLock);
if (cm_activeCallbackGrantingCalls > 0) {
rp = malloc(sizeof(*rp));
memset(rp, 0, sizeof(*rp));
osi_QAdd((osi_queue_t **) &cm_racingRevokesp, &rp->q);
rp->flags |= (cancelFlags & CM_RACINGFLAG_ALL);
if (fidp) rp->fid = *fidp;
rp->callbackCount = ++cm_callbackCount;
}
lock_ReleaseWrite(&cm_callbackLock);
}
/*
@ -128,50 +128,50 @@ void cm_CallbackNotifyChange(cm_scache_t *scp)
*/
void cm_RevokeCallback(struct rx_call *callp, AFSFid *fidp)
{
cm_fid_t tfid;
cm_scache_t *scp;
long hash;
cm_fid_t tfid;
cm_scache_t *scp;
long hash;
/* don't bother setting cell, since we won't be checking it (to aid
* in working with multi-homed servers: we don't know the cell if we
* don't recognize the IP address).
*/
tfid.cell = 0;
tfid.volume = fidp->Volume;
tfid.vnode = fidp->Vnode;
tfid.unique = fidp->Unique;
hash = CM_SCACHE_HASH(&tfid);
/* don't bother setting cell, since we won't be checking it (to aid
* in working with multi-homed servers: we don't know the cell if we
* don't recognize the IP address).
*/
tfid.cell = 0;
tfid.volume = fidp->Volume;
tfid.vnode = fidp->Vnode;
tfid.unique = fidp->Unique;
hash = CM_SCACHE_HASH(&tfid);
osi_Log3(afsd_logp, "RevokeCallback vol %d vn %d un %d",
fidp->Volume, fidp->Vnode, fidp->Unique);
fidp->Volume, fidp->Vnode, fidp->Unique);
/* do this first, so that if we're executing a callback granting call
* at this moment, we kill it before it can be merged in. Otherwise,
* it could complete while we're doing the scan below, and get missed
* by both the scan and by this code.
*/
cm_RecordRacingRevoke(&tfid, 0);
/* do this first, so that if we're executing a callback granting call
* at this moment, we kill it before it can be merged in. Otherwise,
* it could complete while we're doing the scan below, and get missed
* by both the scan and by this code.
*/
cm_RecordRacingRevoke(&tfid, 0);
lock_ObtainWrite(&cm_scacheLock);
/* do all in the hash bucket, since we don't know how many we'll find with
* varying cells.
*/
for(scp = cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (scp->fid.volume == tfid.volume &&
scp->fid.vnode == tfid.vnode &&
scp->fid.unique == tfid.unique) {
scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainWrite(&cm_scacheLock);
/* do all in the hash bucket, since we don't know how many we'll find with
* varying cells.
*/
for (scp = cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (scp->fid.volume == tfid.volume &&
scp->fid.vnode == tfid.vnode &&
scp->fid.unique == tfid.unique) {
scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock);
osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
lock_ObtainMutex(&scp->mx);
cm_DiscardSCache(scp);
lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock);
scp->refCount--;
}
lock_ObtainMutex(&scp->mx);
cm_DiscardSCache(scp);
lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock);
scp->refCount--;
}
lock_ReleaseWrite(&cm_scacheLock);
}
lock_ReleaseWrite(&cm_scacheLock);
}
/* called to revoke a volume callback, which is typically issued when a volume
@ -181,40 +181,40 @@ void cm_RevokeCallback(struct rx_call *callp, AFSFid *fidp)
*/
void cm_RevokeVolumeCallback(struct rx_call *callp, AFSFid *fidp)
{
long hash;
cm_scache_t *scp;
cm_fid_t tfid;
long hash;
cm_scache_t *scp;
cm_fid_t tfid;
osi_Log1(afsd_logp, "RevokeVolumeCallback %d", fidp->Volume);
/* do this first, so that if we're executing a callback granting call
* at this moment, we kill it before it can be merged in. Otherwise,
* it could complete while we're doing the scan below, and get missed
* by both the scan and by this code.
*/
tfid.cell = tfid.vnode = tfid.unique = 0;
tfid.volume = fidp->Volume;
cm_RecordRacingRevoke(&tfid, CM_RACINGFLAG_CANCELVOL);
/* do this first, so that if we're executing a callback granting call
* at this moment, we kill it before it can be merged in. Otherwise,
* it could complete while we're doing the scan below, and get missed
* by both the scan and by this code.
*/
tfid.cell = tfid.vnode = tfid.unique = 0;
tfid.volume = fidp->Volume;
cm_RecordRacingRevoke(&tfid, CM_RACINGFLAG_CANCELVOL);
lock_ObtainWrite(&cm_scacheLock);
for(hash = 0; hash < cm_hashTableSize; hash++) {
for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (scp->fid.volume == fidp->Volume) {
scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainMutex(&scp->mx);
lock_ObtainWrite(&cm_scacheLock);
for (hash = 0; hash < cm_hashTableSize; hash++) {
for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (scp->fid.volume == fidp->Volume) {
scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainMutex(&scp->mx);
osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
cm_DiscardSCache(scp);
lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock);
scp->refCount--;
}
} /* search one hash bucket */
} /* search all hash buckets */
lock_ReleaseWrite(&cm_scacheLock);
cm_DiscardSCache(scp);
lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock);
scp->refCount--;
}
} /* search one hash bucket */
} /* search all hash buckets */
lock_ReleaseWrite(&cm_scacheLock);
}
/* handle incoming RPC callback breaking message.
@ -222,23 +222,23 @@ void cm_RevokeVolumeCallback(struct rx_call *callp, AFSFid *fidp)
*/
SRXAFSCB_CallBack(struct rx_call *callp, AFSCBFids *fidsArrayp, AFSCBs *cbsArrayp)
{
int i;
AFSFid *tfidp;
int i;
AFSFid *tfidp;
osi_Log0(afsd_logp, "SRXAFSCB_CallBack");
for(i=0; i < (long) fidsArrayp->AFSCBFids_len; i++) {
tfidp = &fidsArrayp->AFSCBFids_val[i];
for (i=0; i < (long) fidsArrayp->AFSCBFids_len; i++) {
tfidp = &fidsArrayp->AFSCBFids_val[i];
if (tfidp->Volume == 0)
continue; /* means don't do anything */
else if (tfidp->Vnode == 0)
cm_RevokeVolumeCallback(callp, tfidp);
else if (tfidp->Vnode == 0)
cm_RevokeVolumeCallback(callp, tfidp);
else
cm_RevokeCallback(callp, tfidp);
}
}
return 0;
return 0;
}
/* called with no locks by RPC system when a server indicates that it has never
@ -288,32 +288,33 @@ SRXAFSCB_InitCallBackState(struct rx_call *callp)
* are "rare," hopefully this won't be a problem.
*/
lock_ObtainWrite(&cm_scacheLock);
for(hash = 0; hash < cm_hashTableSize; hash++) {
for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainMutex(&scp->mx);
discarded = 0;
if (scp->cbServerp != NULL) {
/* we have a callback, now decide if we should clear it */
if (scp->cbServerp == tsp || tsp == NULL) {
for (hash = 0; hash < cm_hashTableSize; hash++) {
for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainMutex(&scp->mx);
discarded = 0;
if (scp->cbServerp != NULL) {
/* we have a callback, now decide if we should clear it */
if (scp->cbServerp == tsp || tsp == NULL) {
osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
cm_DiscardSCache(scp);
discarded = 1;
}
}
lock_ReleaseMutex(&scp->mx);
if (discarded)
cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock);
scp->refCount--;
} /* search one hash bucket */
} /* search all hash buckets */
cm_DiscardSCache(scp);
discarded = 1;
}
}
lock_ReleaseMutex(&scp->mx);
if (discarded)
cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock);
scp->refCount--;
} /* search one hash bucket */
} /* search all hash buckets */
lock_ReleaseWrite(&cm_scacheLock);
/* we're done with the server structure */
if (tsp) cm_PutServer(tsp);
if (tsp)
cm_PutServer(tsp);
}
return 0;
@ -323,7 +324,7 @@ SRXAFSCB_InitCallBackState(struct rx_call *callp)
SRXAFSCB_Probe(struct rx_call *callp)
{
osi_Log0(afsd_logp, "SRXAFSCB_Probe - not implemented");
return 0;
return 0;
}
/* debug interface: not implemented */
@ -337,67 +338,67 @@ SRXAFSCB_GetCE64(struct rx_call *callp, long index, AFSDBCacheEntry *cep)
/* debug interface: not implemented */
SRXAFSCB_GetLock(struct rx_call *callp, long index, AFSDBLock *lockp)
{
/* XXXX */
/* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_GetLock - not implemented");
return RXGEN_OPCODE;
return RXGEN_OPCODE;
}
/* debug interface: not implemented */
SRXAFSCB_GetCE(struct rx_call *callp, long index, AFSDBCacheEntry *cep)
{
/* XXXX */
/* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_GetCE - not implemented");
return RXGEN_OPCODE;
return RXGEN_OPCODE;
}
/* debug interface: not implemented */
SRXAFSCB_XStatsVersion(struct rx_call *callp, long *vp)
{
/* XXXX */
/* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_XStatsVersion - not implemented");
*vp = -1;
return RXGEN_OPCODE;
*vp = -1;
return RXGEN_OPCODE;
}
/* debug interface: not implemented */
SRXAFSCB_GetXStats(struct rx_call *callp, long cvn, long coln, long *srvp, long *timep,
AFSCB_CollData *datap)
{
/* XXXX */
/* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_GetXStats - not implemented");
return RXGEN_OPCODE;
return RXGEN_OPCODE;
}
/* debug interface: not implemented */
SRXAFSCB_InitCallBackState2(struct rx_call *callp, struct interfaceAddr* addr)
{
/* XXXX */
/* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_InitCallBackState2 - not implemented");
return RXGEN_OPCODE;
return RXGEN_OPCODE;
}
/* debug interface: not implemented */
SRXAFSCB_WhoAreYou(struct rx_call *callp, struct interfaceAddr* addr)
{
/* XXXX */
/* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_WhoAreYou - not implemented");
return RXGEN_OPCODE;
return RXGEN_OPCODE;
}
/* debug interface: not implemented */
SRXAFSCB_InitCallBackState3(struct rx_call *callp, afsUUID* serverUuid)
{
/* XXXX */
/* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_InitCallBackState3 - not implemented");
return RXGEN_OPCODE;
return RXGEN_OPCODE;
}
/* debug interface: not implemented */
SRXAFSCB_ProbeUuid(struct rx_call *callp, afsUUID* clientUuid)
{
/* XXXX */
/* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_ProbeUuid - not implemented");
return RXGEN_OPCODE;
return RXGEN_OPCODE;
}
/*------------------------------------------------------------------------
@ -608,8 +609,8 @@ cacheConfig *config;
/* called by afsd without any locks to initialize this module */
void cm_InitCallback(void)
{
lock_InitializeRWLock(&cm_callbackLock, "cm_callbackLock");
cm_activeCallbackGrantingCalls = 0;
lock_InitializeRWLock(&cm_callbackLock, "cm_callbackLock");
cm_activeCallbackGrantingCalls = 0;
}
/* called with locked scp; tells us whether we've got a callback.
@ -633,7 +634,7 @@ int cm_HaveCallback(cm_scache_t *scp)
// to be called because cm_GetCallback has some initialization work to do.
// If cm_fakeDirCallback is 2, then it means that the fake directory is in
// good shape and we simply return true, provided no change is detected.
int fdc, fgc;
int fdc, fgc;
if (cm_freelanceEnabled &&
scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) {
@ -691,12 +692,12 @@ int cm_HaveCallback(cm_scache_t *scp)
*/
void cm_StartCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp)
{
lock_ObtainWrite(&cm_callbackLock);
cbrp->callbackCount = cm_callbackCount;
cm_activeCallbackGrantingCalls++;
cbrp->startTime = osi_Time();
cbrp->serverp = NULL;
lock_ReleaseWrite(&cm_callbackLock);
lock_ObtainWrite(&cm_callbackLock);
cbrp->callbackCount = cm_callbackCount;
cm_activeCallbackGrantingCalls++;
cbrp->startTime = osi_Time();
cbrp->serverp = NULL;
lock_ReleaseWrite(&cm_callbackLock);
}
/* Called at the end of a callback-granting call, to remove the callback
@ -706,83 +707,83 @@ void cm_StartCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp)
* this locking hierarchy.
*/
void cm_EndCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp,
AFSCallBack *cbp, long flags)
AFSCallBack *cbp, long flags)
{
cm_racingRevokes_t *revp; /* where we are */
cm_racingRevokes_t *nrevp; /* where we'll be next */
int freeFlag;
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) {
osi_assert(cm_activeCallbackGrantingCalls > 0);
}
else {
osi_assert(cm_activeCallbackGrantingCalls-- > 0);
}
lock_ObtainWrite(&cm_callbackLock);
if (flags & CM_CALLBACK_MAINTAINCOUNT) {
osi_assert(cm_activeCallbackGrantingCalls > 0);
}
else {
osi_assert(cm_activeCallbackGrantingCalls-- > 0);
}
if (cm_activeCallbackGrantingCalls == 0)
freeFlag = 1;
else
freeFlag = 0;
/* record the callback; we'll clear it below if we really lose it */
/* 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;
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
* run down the list of revoked fids, looking for ours.
* If activeCallbackGrantingCalls is zero, free the elements, too.
*
* May need to go through entire list just to do the freeing.
*/
for(revp = cm_racingRevokesp; revp; revp = nrevp) {
nrevp = (cm_racingRevokes_t *) osi_QNext(&revp->q);
/* if this callback came in later than when we started the
* callback-granting call, and if this fid is the right fid,
* then clear the callback.
*/
/* a callback was actually revoked during our granting call, so
* run down the list of revoked fids, looking for ours.
* If activeCallbackGrantingCalls is zero, free the elements, too.
*
* May need to go through entire list just to do the freeing.
*/
for (revp = cm_racingRevokesp; revp; revp = nrevp) {
nrevp = (cm_racingRevokes_t *) osi_QNext(&revp->q);
/* if this callback came in later than when we started the
* callback-granting call, and if this fid is the right fid,
* then clear the callback.
*/
if (scp && cbrp && cbrp->callbackCount != cm_callbackCount
&& revp->callbackCount > cbrp->callbackCount
&& revp->callbackCount > cbrp->callbackCount
&& (( scp->fid.volume == revp->fid.volume &&
scp->fid.vnode == revp->fid.vnode &&
scp->fid.unique == revp->fid.unique)
||
((revp->flags & CM_RACINGFLAG_CANCELVOL) &&
scp->fid.volume == revp->fid.volume)
||
(revp->flags & CM_RACINGFLAG_CANCELALL))) {
/* this one matches */
osi_Log4(afsd_logp,
"Racing revoke scp %x old cbc %d rev cbc %d cur cbc %d",
scp,
cbrp->callbackCount, revp->callbackCount,
cm_callbackCount);
cm_DiscardSCache(scp);
/*
* Since we don't have a callback to preserve, it's
* OK to drop the lock and re-obtain it.
*/
lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp);
lock_ObtainMutex(&scp->mx);
}
if (freeFlag) free(revp);
scp->fid.vnode == revp->fid.vnode &&
scp->fid.unique == revp->fid.unique)
||
((revp->flags & CM_RACINGFLAG_CANCELVOL) &&
scp->fid.volume == revp->fid.volume)
||
(revp->flags & CM_RACINGFLAG_CANCELALL))) {
/* this one matches */
osi_Log4(afsd_logp,
"Racing revoke scp %x old cbc %d rev cbc %d cur cbc %d",
scp,
cbrp->callbackCount, revp->callbackCount,
cm_callbackCount);
cm_DiscardSCache(scp);
/*
* Since we don't have a callback to preserve, it's
* OK to drop the lock and re-obtain it.
*/
lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp);
lock_ObtainMutex(&scp->mx);
}
if (freeFlag) free(revp);
}
/* if we freed the list, zap the pointer to it */
if (freeFlag) cm_racingRevokesp = NULL;
/* if we freed the list, zap the pointer to it */
if (freeFlag) cm_racingRevokesp = NULL;
lock_ReleaseWrite(&cm_callbackLock);
lock_ReleaseWrite(&cm_callbackLock);
if ( serverp ) {
lock_ObtainWrite(&cm_serverLock);
@ -795,9 +796,9 @@ void cm_EndCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp,
* called with locked scp; returns with same.
*/
long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
struct cm_req *reqp, long flags)
struct cm_req *reqp, long flags)
{
long code;
long code;
cm_conn_t *connp;
AFSFetchStatus afsStatus;
AFSVolSync volSync;
@ -811,10 +812,10 @@ long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
osi_Log2(afsd_logp, "GetCallback scp %x flags %lX", scp, flags);
#ifdef AFS_FREELANCE_CLIENT
// The case where a callback is needed on /afs is handled
// specially. We need to fetch the status by calling
// cm_MergeStatus and mark that cm_fakeDirCallback is 2
if (cm_freelanceEnabled) {
// The case where a callback is needed on /afs is handled
// specially. We need to fetch the status by calling
// cm_MergeStatus and mark that cm_fakeDirCallback is 2
if (cm_freelanceEnabled) {
if (scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
scp->fid.unique==0x1 &&
@ -849,41 +850,42 @@ long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
}
#endif /* AFS_FREELANCE_CLIENT */
mustCall = (flags & 1);
cm_AFSFidFromFid(&tfid, &scp->fid);
while (1) {
if (!mustCall && cm_HaveCallback(scp)) return 0;
mustCall = (flags & 1);
cm_AFSFidFromFid(&tfid, &scp->fid);
while (1) {
if (!mustCall && cm_HaveCallback(scp)) return 0;
/* turn off mustCall, since it has now forced us past the check above */
mustCall = 0;
/* otherwise, we have to make an RPC to get the status */
sflags = CM_SCACHESYNC_FETCHSTATUS | CM_SCACHESYNC_GETCALLBACK;
sflags = CM_SCACHESYNC_FETCHSTATUS | CM_SCACHESYNC_GETCALLBACK;
cm_SyncOp(scp, NULL, NULL, NULL, 0, sflags);
cm_StartCallbackGrantingCall(scp, &cbr);
sfid = scp->fid;
lock_ReleaseMutex(&scp->mx);
lock_ReleaseMutex(&scp->mx);
/* now make the RPC */
osi_Log1(afsd_logp, "CALL FetchStatus vp %x", (long) scp);
/* now make the RPC */
osi_Log1(afsd_logp, "CALL FetchStatus vp %x", (long) scp);
do {
code = cm_Conn(&sfid, userp, reqp, &connp);
code = cm_Conn(&sfid, userp, reqp, &connp);
if (code) continue;
lock_ObtainMutex(&connp->mx);
code = RXAFS_FetchStatus(connp->callp, &tfid,
&afsStatus, &callback, &volSync);
} while (cm_Analyze(connp, userp, reqp, &sfid, &volSync, NULL,
lock_ReleaseMutex(&connp->mx);
} while (cm_Analyze(connp, userp, reqp, &sfid, &volSync, NULL,
&cbr, code));
code = cm_MapRPCError(code, reqp);
osi_Log0(afsd_logp, "CALL FetchStatus DONE");
osi_Log0(afsd_logp, "CALL FetchStatus DONE");
lock_ObtainMutex(&scp->mx);
lock_ObtainMutex(&scp->mx);
cm_SyncOpDone(scp, NULL, sflags);
if (code == 0) {
if (code == 0) {
cm_EndCallbackGrantingCall(scp, &cbr, &callback, 0);
cm_MergeStatus(scp, &afsStatus, &volSync, userp, 0);
}
}
else
cm_EndCallbackGrantingCall(NULL, &cbr, NULL, 0);
@ -903,8 +905,8 @@ void cm_CheckCBExpiration(void)
now = osi_Time();
lock_ObtainWrite(&cm_scacheLock);
for(i=0; i<cm_hashTableSize; i++) {
for(scp = cm_hashTablep[i]; scp; scp=scp->nextp) {
for (i=0; i<cm_hashTableSize; i++) {
for (scp = cm_hashTablep[i]; scp; scp=scp->nextp) {
scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock);
if (scp->cbExpires > 0 && (scp->cbServerp == NULL || now > scp->cbExpires)) {

View File

@ -463,29 +463,29 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
/* called with a held server to GC all bad connections hanging off of the server */
void cm_GCConnections(cm_server_t *serverp)
{
cm_conn_t *tcp;
cm_conn_t *tcp;
cm_conn_t **lcpp;
cm_user_t *userp;
lock_ObtainWrite(&cm_connLock);
lcpp = &serverp->connsp;
for(tcp = *lcpp; tcp; tcp = *lcpp) {
userp = tcp->userp;
if (userp && tcp->refCount == 0 && (userp->vcRefs == 0)) {
/* do the deletion of this guy */
lock_ObtainWrite(&cm_connLock);
lcpp = &serverp->connsp;
for (tcp = *lcpp; tcp; tcp = *lcpp) {
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);
rx_DestroyConnection(tcp->callp);
lock_FinalizeMutex(&tcp->mx);
free(tcp);
}
else {
/* just advance to the next */
/* just advance to the next */
lcpp = &tcp->nextp;
}
}
lock_ReleaseWrite(&cm_connLock);
lock_ReleaseWrite(&cm_connLock);
}
static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
@ -495,25 +495,24 @@ static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
int serviceID;
int secIndex;
struct rx_securityClass *secObjp;
afs_int32 level;
afs_int32 level;
if (serverp->type == CM_SERVER_VLDB) {
port = htons(7003);
if (serverp->type == CM_SERVER_VLDB) {
port = htons(7003);
serviceID = 52;
}
else {
osi_assert(serverp->type == CM_SERVER_FILE);
osi_assert(serverp->type == CM_SERVER_FILE);
port = htons(7000);
serviceID = 1;
}
if (ucellp->flags & CM_UCELLFLAG_RXKAD) {
secIndex = 2;
if (cryptall) {
level = rxkad_crypt;
tcp->cryptlevel = rxkad_crypt;
} else {
level = rxkad_clear;
}
if (ucellp->flags & CM_UCELLFLAG_RXKAD) {
secIndex = 2;
if (cryptall) {
level = tcp->cryptlevel = rxkad_crypt;
} else {
level = tcp->cryptlevel = rxkad_clear;
}
secObjp = rxkad_NewClientSecurityObject(level,
&ucellp->sessionKey, ucellp->kvno,
ucellp->ticketLen, ucellp->ticketp);
@ -523,61 +522,65 @@ static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
secIndex = 0;
secObjp = rxnull_NewClientSecurityObject();
}
osi_assert(secObjp != NULL);
osi_assert(secObjp != NULL);
tcp->callp = rx_NewConnection(serverp->addr.sin_addr.s_addr,
port,
serviceID,
secObjp,
secIndex);
rx_SetConnDeadTime(tcp->callp, ConnDeadtimeout);
rx_SetConnHardDeadTime(tcp->callp, HardDeadtimeout);
tcp->ucgen = ucellp->gen;
rx_SetConnDeadTime(tcp->callp, ConnDeadtimeout);
rx_SetConnHardDeadTime(tcp->callp, HardDeadtimeout);
tcp->ucgen = ucellp->gen;
if (secObjp)
rxs_Release(secObjp); /* Decrement the initial refCount */
}
long cm_ConnByServer(cm_server_t *serverp, cm_user_t *userp, cm_conn_t **connpp)
{
cm_conn_t *tcp;
cm_conn_t *tcp;
cm_ucell_t *ucellp;
lock_ObtainMutex(&userp->mx);
lock_ObtainWrite(&cm_connLock);
for(tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
lock_ObtainMutex(&userp->mx);
lock_ObtainWrite(&cm_connLock);
for (tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
if (tcp->userp == userp)
break;
}
/* find ucell structure */
/* find ucell structure */
ucellp = cm_GetUCell(userp, serverp->cellp);
if (!tcp) {
if (!tcp) {
cm_GetServer(serverp);
tcp = malloc(sizeof(*tcp));
tcp = malloc(sizeof(*tcp));
memset(tcp, 0, sizeof(*tcp));
tcp->nextp = serverp->connsp;
serverp->connsp = tcp;
cm_HoldUser(userp);
tcp->userp = userp;
lock_InitializeMutex(&tcp->mx, "cm_conn_t mutex");
lock_ObtainMutex(&tcp->mx);
tcp->serverp = serverp;
tcp->cryptlevel = rxkad_clear;
cm_NewRXConnection(tcp, ucellp, serverp);
tcp->refCount = 1;
}
else {
if ((tcp->ucgen < ucellp->gen) || (tcp->cryptlevel != cryptall))
{
rx_DestroyConnection(tcp->callp);
cm_NewRXConnection(tcp, ucellp, serverp);
}
tcp->cryptlevel = rxkad_clear;
cm_NewRXConnection(tcp, ucellp, serverp);
tcp->refCount = 1;
lock_ReleaseMutex(&tcp->mx);
} else {
if ((tcp->ucgen < ucellp->gen) ||
(tcp->cryptlevel != (cryptall ? rxkad_crypt : rxkad_clear)))
{
lock_ObtainMutex(&tcp->mx);
rx_DestroyConnection(tcp->callp);
cm_NewRXConnection(tcp, ucellp, serverp);
lock_ReleaseMutex(&tcp->mx);
}
tcp->refCount++;
}
lock_ReleaseWrite(&cm_connLock);
}
lock_ReleaseWrite(&cm_connLock);
lock_ReleaseMutex(&userp->mx);
/* return this pointer to our caller */
/* return this pointer to our caller */
osi_Log1(afsd_logp, "cm_ConnByServer returning conn 0x%x", (long) tcp);
*connpp = tcp;
*connpp = tcp;
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -43,9 +43,9 @@ typedef struct cm_SSetPref {
#define MAXNUMSYSNAMES 16 /* max that current constants allow */
#define MAXSYSNAME 128 /* max sysname (i.e. @sys) size */
extern char *cm_sysName;
extern int cm_sysNameCount;
extern char *cm_sysNameList[MAXNUMSYSNAMES];
extern char * cm_sysName;
extern unsigned int cm_sysNameCount;
extern char * cm_sysNameList[MAXNUMSYSNAMES];
#ifndef __CM_IOCTL_INTERFACES_ONLY__

View File

@ -37,102 +37,104 @@ int cm_NetFlags[CM_MAXINTERFACE_ADDR]; /* network flags */
void cm_CheckServers(long flags, cm_cell_t *cellp)
{
/* ping all file servers, up or down, with unauthenticated connection,
* to find out whether we have all our callbacks from the server still.
* Also, ping down VLDBs.
/* ping all file servers, up or down, with unauthenticated connection,
* to find out whether we have all our callbacks from the server still.
* Also, ping down VLDBs.
*/
cm_server_t *tsp;
long code;
long secs;
long usecs;
int doPing;
int serverType;
long now;
int wasDown;
cm_conn_t *connp;
lock_ObtainWrite(&cm_serverLock);
for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) {
cm_GetServerNoLock(tsp);
lock_ReleaseWrite(&cm_serverLock);
/* now process the server */
lock_ObtainMutex(&tsp->mx);
/* what time is it? */
now = osi_Time();
serverType = tsp->type;
doPing = 0;
wasDown = tsp->flags & CM_SERVERFLAG_DOWN;
/* only do the ping if the cell matches the requested cell, or we're
* matching all cells (cellp == NULL), and if we've requested to ping
* this type of {up, down} servers.
*/
cm_server_t *tsp;
long code;
long secs;
long usecs;
int doPing;
int serverType;
long now;
int wasDown;
cm_conn_t *connp;
if ((cellp == NULL || cellp == tsp->cellp) &&
((wasDown && (flags & CM_FLAG_CHECKDOWNSERVERS)) ||
(!wasDown && (flags & CM_FLAG_CHECKUPSERVERS)))) {
doPing = 1;
} /* we're supposed to check this up/down server */
lock_ReleaseMutex(&tsp->mx);
/* at this point, we've adjusted the server state, so do the ping and
* adjust things.
*/
if (doPing) {
code = cm_ConnByServer(tsp, cm_rootUserp, &connp);
if (code == 0) {
/* now call the appropriate ping call. Drop the timeout if
* the server is known to be down, so that we don't waste a
* lot of time retiming out down servers.
*/
if (wasDown)
rx_SetConnDeadTime(connp->callp, 10);
if (serverType == CM_SERVER_VLDB) {
code = VL_ProbeServer(connp->callp);
}
else {
/* file server */
lock_ObtainMutex(&connp->mx);
code = RXAFS_GetTime(connp->callp, &secs, &usecs);
lock_ReleaseMutex(&connp->mx);
}
if (wasDown)
rx_SetConnDeadTime(connp->callp, ConnDeadtimeout);
cm_PutConn(connp);
} /* got an unauthenticated connection to this server */
lock_ObtainMutex(&tsp->mx);
if (code == 0) {
/* mark server as up */
tsp->flags &= ~CM_SERVERFLAG_DOWN;
}
else {
/* mark server as down */
tsp->flags |= CM_SERVERFLAG_DOWN;
}
lock_ReleaseMutex(&tsp->mx);
}
/* also, run the GC function for connections on all of the
* server's connections.
*/
cm_GCConnections(tsp);
lock_ObtainWrite(&cm_serverLock);
for(tsp = cm_allServersp; tsp; tsp = tsp->allNextp) {
cm_GetServerNoLock(tsp);
lock_ReleaseWrite(&cm_serverLock);
/* now process the server */
lock_ObtainMutex(&tsp->mx);
/* what time is it? */
now = osi_Time();
serverType = tsp->type;
doPing = 0;
wasDown = tsp->flags & CM_SERVERFLAG_DOWN;
/* only do the ping if the cell matches the requested cell, or we're
* matching all cells (cellp == NULL), and if we've requested to ping
* this type of {up, down} servers.
*/
if ((cellp == NULL || cellp == tsp->cellp) &&
((wasDown && (flags & CM_FLAG_CHECKDOWNSERVERS)) ||
(!wasDown && (flags & CM_FLAG_CHECKUPSERVERS)))) {
doPing = 1;
} /* we're supposed to check this up/down server */
lock_ReleaseMutex(&tsp->mx);
/* at this point, we've adjusted the server state, so do the ping and
* adjust things.
*/
if (doPing) {
code = cm_ConnByServer(tsp, cm_rootUserp, &connp);
if (code == 0) {
/* now call the appropriate ping call. Drop the timeout if
* the server is known to be down, so that we don't waste a
* lot of time retiming out down servers.
*/
if (wasDown)
rx_SetConnDeadTime(connp->callp, 10);
if (serverType == CM_SERVER_VLDB) {
code = VL_ProbeServer(connp->callp);
}
else {
/* file server */
code = RXAFS_GetTime(connp->callp, &secs, &usecs);
}
if (wasDown)
rx_SetConnDeadTime(connp->callp, ConnDeadtimeout);
cm_PutConn(connp);
} /* got an unauthenticated connection to this server */
lock_ObtainMutex(&tsp->mx);
if (code == 0) {
/* mark server as up */
tsp->flags &= ~CM_SERVERFLAG_DOWN;
}
else {
/* mark server as down */
tsp->flags |= CM_SERVERFLAG_DOWN;
}
lock_ReleaseMutex(&tsp->mx);
}
/* also, run the GC function for connections on all of the
* server's connections.
*/
cm_GCConnections(tsp);
lock_ObtainWrite(&cm_serverLock);
cm_PutServerNoLock(tsp);
}
lock_ReleaseWrite(&cm_serverLock);
}
}
lock_ReleaseWrite(&cm_serverLock);
}
void cm_InitServer(void)
{
static osi_once_t once;
static osi_once_t once;
if (osi_Once(&once)) {
lock_InitializeRWLock(&cm_serverLock, "cm_serverLock");
osi_EndOnce(&once);
}
if (osi_Once(&once)) {
lock_InitializeRWLock(&cm_serverLock, "cm_serverLock");
osi_EndOnce(&once);
}
}
void cm_GetServer(cm_server_t *serverp)
@ -149,85 +151,85 @@ void cm_GetServerNoLock(cm_server_t *serverp)
void cm_PutServer(cm_server_t *serverp)
{
lock_ObtainWrite(&cm_serverLock);
osi_assert(serverp->refCount-- > 0);
lock_ReleaseWrite(&cm_serverLock);
lock_ObtainWrite(&cm_serverLock);
osi_assert(serverp->refCount-- > 0);
lock_ReleaseWrite(&cm_serverLock);
}
void cm_PutServerNoLock(cm_server_t *serverp)
{
osi_assert(serverp->refCount-- > 0);
osi_assert(serverp->refCount-- > 0);
}
void cm_SetServerPrefs(cm_server_t * serverp)
{
unsigned long serverAddr; /* in host byte order */
unsigned long myAddr, myNet, mySubnet;/* in host byte order */
unsigned long netMask;
int i;
unsigned long serverAddr; /* in host byte order */
unsigned long myAddr, myNet, mySubnet;/* in host byte order */
unsigned long netMask;
int i;
/* implement server prefs for fileservers only */
if ( serverp->type == CM_SERVER_FILE )
{
serverAddr = ntohl(serverp->addr.sin_addr.s_addr);
serverp->ipRank = CM_IPRANK_LOW; /* default setings */
/* implement server prefs for fileservers only */
if ( serverp->type == CM_SERVER_FILE )
{
serverAddr = ntohl(serverp->addr.sin_addr.s_addr);
serverp->ipRank = CM_IPRANK_LOW; /* default setings */
for ( i=0; i < cm_noIPAddr; i++)
{
/* loop through all the client's IP address and compare
** each of them against the server's IP address */
for ( i=0; i < cm_noIPAddr; i++)
{
/* loop through all the client's IP address and compare
** each of them against the server's IP address */
myAddr = cm_IPAddr[i];
if ( IN_CLASSA(myAddr) )
netMask = IN_CLASSA_NET;
else if ( IN_CLASSB(myAddr) )
netMask = IN_CLASSB_NET;
else if ( IN_CLASSC(myAddr) )
netMask = IN_CLASSC_NET;
else
netMask = 0;
myAddr = cm_IPAddr[i];
if ( IN_CLASSA(myAddr) )
netMask = IN_CLASSA_NET;
else if ( IN_CLASSB(myAddr) )
netMask = IN_CLASSB_NET;
else if ( IN_CLASSC(myAddr) )
netMask = IN_CLASSC_NET;
else
netMask = 0;
myNet = myAddr & netMask;
mySubnet = myAddr & cm_SubnetMask[i];
myNet = myAddr & netMask;
mySubnet = myAddr & cm_SubnetMask[i];
if ( (serverAddr & netMask) == myNet )
{
if ( (serverAddr & cm_SubnetMask[i]) == mySubnet)
{
if ( serverAddr == myAddr )
serverp->ipRank = min(serverp->ipRank,
CM_IPRANK_TOP);/* same machine */
else serverp->ipRank = min(serverp->ipRank,
CM_IPRANK_HI); /* same subnet */
}
else serverp->ipRank = min(serverp->ipRank,CM_IPRANK_MED);
/* same net */
}
/* random between 0..15*/
serverp->ipRank += min(serverp->ipRank, rand() % 0x000f);
} /* and of for loop */
}
if ( (serverAddr & netMask) == myNet )
{
if ( (serverAddr & cm_SubnetMask[i]) == mySubnet)
{
if ( serverAddr == myAddr )
serverp->ipRank = min(serverp->ipRank,
CM_IPRANK_TOP);/* same machine */
else serverp->ipRank = min(serverp->ipRank,
CM_IPRANK_HI); /* same subnet */
}
else serverp->ipRank = min(serverp->ipRank,CM_IPRANK_MED);
/* same net */
}
/* random between 0..15*/
serverp->ipRank += min(serverp->ipRank, rand() % 0x000f);
} /* and of for loop */
}
else
serverp->ipRank = 10000 + (rand() % 0x00ff); /* VL server */
}
cm_server_t *cm_NewServer(struct sockaddr_in *socketp, int type, cm_cell_t *cellp) {
cm_server_t *tsp;
cm_server_t *tsp;
osi_assert(socketp->sin_family == AF_INET);
osi_assert(socketp->sin_family == AF_INET);
tsp = malloc(sizeof(*tsp));
tsp = malloc(sizeof(*tsp));
memset(tsp, 0, sizeof(*tsp));
tsp->type = type;
tsp->type = type;
tsp->cellp = cellp;
tsp->refCount = 1;
lock_InitializeMutex(&tsp->mx, "cm_server_t mutex");
tsp->addr = *socketp;
lock_InitializeMutex(&tsp->mx, "cm_server_t mutex");
tsp->addr = *socketp;
cm_SetServerPrefs(tsp);
cm_SetServerPrefs(tsp);
lock_ObtainWrite(&cm_serverLock); /* get server lock */
tsp->allNextp = cm_allServersp;
tsp->allNextp = cm_allServersp;
cm_allServersp = tsp;
lock_ReleaseWrite(&cm_serverLock); /* release server lock */
@ -237,58 +239,58 @@ cm_server_t *cm_NewServer(struct sockaddr_in *socketp, int type, cm_cell_t *cell
/* find a server based on its properties */
cm_server_t *cm_FindServer(struct sockaddr_in *addrp, int type)
{
cm_server_t *tsp;
cm_server_t *tsp;
osi_assert(addrp->sin_family == AF_INET);
osi_assert(addrp->sin_family == AF_INET);
lock_ObtainWrite(&cm_serverLock);
for(tsp = cm_allServersp; tsp; tsp=tsp->allNextp) {
if (tsp->type == type &&
tsp->addr.sin_addr.s_addr == addrp->sin_addr.s_addr) break;
}
lock_ObtainWrite(&cm_serverLock);
for (tsp = cm_allServersp; tsp; tsp=tsp->allNextp) {
if (tsp->type == type &&
tsp->addr.sin_addr.s_addr == addrp->sin_addr.s_addr) break;
}
/* bump ref count if we found the server */
/* bump ref count if we found the server */
if (tsp)
cm_GetServerNoLock(tsp);
/* drop big table lock */
lock_ReleaseWrite(&cm_serverLock);
/* drop big table lock */
lock_ReleaseWrite(&cm_serverLock);
/* return what we found */
return tsp;
}
/* return what we found */
return tsp;
}
cm_serverRef_t *cm_NewServerRef(cm_server_t *serverp)
{
cm_serverRef_t *tsrp;
cm_serverRef_t *tsrp;
cm_GetServer(serverp);
tsrp = malloc(sizeof(*tsrp));
tsrp->server = serverp;
tsrp->status = not_busy;
tsrp->next = NULL;
tsrp = malloc(sizeof(*tsrp));
tsrp->server = serverp;
tsrp->status = not_busy;
tsrp->next = NULL;
tsrp->refCount = 1;
return tsrp;
return tsrp;
}
long cm_ChecksumServerList(cm_serverRef_t *serversp)
{
long sum = 0;
int first = 1;
cm_serverRef_t *tsrp;
long sum = 0;
int first = 1;
cm_serverRef_t *tsrp;
lock_ObtainWrite(&cm_serverLock);
for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
if (first)
first = 0;
else
sum <<= 1;
sum ^= (long) tsrp->server;
}
for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
if (first)
first = 0;
else
sum <<= 1;
sum ^= (long) tsrp->server;
}
lock_ReleaseWrite(&cm_serverLock);
return sum;
return sum;
}
/*
@ -299,31 +301,31 @@ long cm_ChecksumServerList(cm_serverRef_t *serversp)
*/
void cm_InsertServerList(cm_serverRef_t** list, cm_serverRef_t* element)
{
cm_serverRef_t *current=*list;
unsigned short ipRank = element->server->ipRank;
cm_serverRef_t *current=*list;
unsigned short ipRank = element->server->ipRank;
lock_ObtainWrite(&cm_serverLock);
element->refCount++; /* increase refCount */
/* insertion into empty list or at the beginning of the list */
if ( !current || (current->server->ipRank > ipRank) )
{
element->next = *list;
*list = element;
if ( !current || (current->server->ipRank > ipRank) )
{
element->next = *list;
*list = element;
lock_ReleaseWrite(&cm_serverLock);
return ;
}
return ;
}
while ( current->next ) /* find appropriate place to insert */
{
if ( current->next->server->ipRank > ipRank )
break;
else current = current->next;
}
element->next = current->next;
current->next = element;
while ( current->next ) /* find appropriate place to insert */
{
if ( current->next->server->ipRank > ipRank )
break;
else current = current->next;
}
element->next = current->next;
current->next = element;
lock_ReleaseWrite(&cm_serverLock);
}
}
/*
** Re-sort the server list with the modified rank
** returns 0 if element was changed successfully.
@ -331,39 +333,39 @@ void cm_InsertServerList(cm_serverRef_t** list, cm_serverRef_t* element)
*/
long cm_ChangeRankServer(cm_serverRef_t** list, cm_server_t* server)
{
cm_serverRef_t **current=list;
cm_serverRef_t *element=0;
cm_serverRef_t **current=list;
cm_serverRef_t *element=0;
/* if there is max of one element in the list, nothing to sort */
if ( (!*current) || !((*current)->next) )
return 1; /* list unchanged: return success */
/* if there is max of one element in the list, nothing to sort */
if ( (!*current) || !((*current)->next) )
return 1; /* list unchanged: return success */
lock_ObtainWrite(&cm_serverLock);
/* if the server is on the list, delete it from list */
while ( *current )
{
if ( (*current)->server == server)
{
element = (*current);
*current = (*current)->next; /* delete it */
break;
}
current = & ( (*current)->next);
}
/* if the server is on the list, delete it from list */
while ( *current )
{
if ( (*current)->server == server)
{
element = (*current);
*current = (*current)->next; /* delete it */
break;
}
current = & ( (*current)->next);
}
lock_ReleaseWrite(&cm_serverLock);
/* if this volume is not replicated on this server */
if (!element)
return 1; /* server is not on list */
if (!element)
return 1; /* server is not on list */
/* re-insert deleted element into the list with modified rank*/
cm_InsertServerList(list, element);
/* re-insert deleted element into the list with modified rank*/
cm_InsertServerList(list, element);
/* reduce refCount which was increased by cm_InsertServerList */
lock_ObtainWrite(&cm_serverLock);
element->refCount--;
lock_ReleaseWrite(&cm_serverLock);
return 0;
return 0;
}
/*
** If there are more than one server on the list and the first n servers on
@ -371,49 +373,49 @@ long cm_ChangeRankServer(cm_serverRef_t** list, cm_server_t* server)
*/
void cm_RandomizeServer(cm_serverRef_t** list)
{
int count, picked;
cm_serverRef_t* tsrp = *list, *lastTsrp;
unsigned short lowestRank;
int count, picked;
cm_serverRef_t* tsrp = *list, *lastTsrp;
unsigned short lowestRank;
/* an empty list or a list with only one element */
if ( !tsrp || ! tsrp->next )
return ;
/* an empty list or a list with only one element */
if ( !tsrp || ! tsrp->next )
return ;
lock_ObtainWrite(&cm_serverLock);
/* count the number of servers with the lowest rank */
lowestRank = tsrp->server->ipRank;
for ( count=1, tsrp=tsrp->next; tsrp; tsrp=tsrp->next)
{
if ( tsrp->server->ipRank != lowestRank)
break;
else
count++;
}
/* count the number of servers with the lowest rank */
lowestRank = tsrp->server->ipRank;
for ( count=1, tsrp=tsrp->next; tsrp; tsrp=tsrp->next)
{
if ( tsrp->server->ipRank != lowestRank)
break;
else
count++;
}
/* if there is only one server with the lowest rank, we are done */
if ( count <= 1 ) {
/* if there is only one server with the lowest rank, we are done */
if ( count <= 1 ) {
lock_ReleaseWrite(&cm_serverLock);
return ;
}
return ;
}
picked = rand() % count;
if ( !picked ) {
picked = rand() % count;
if ( !picked ) {
lock_ReleaseWrite(&cm_serverLock);
return ;
}
return ;
}
tsrp = *list;
while (--picked >= 0)
{
lastTsrp = tsrp;
tsrp = tsrp->next;
}
lastTsrp->next = tsrp->next; /* delete random element from list*/
tsrp->next = *list; /* insert element at the beginning of list */
*list = tsrp;
tsrp = *list;
while (--picked >= 0)
{
lastTsrp = tsrp;
tsrp = tsrp->next;
}
lastTsrp->next = tsrp->next; /* delete random element from list*/
tsrp->next = *list; /* insert element at the beginning of list */
*list = tsrp;
lock_ReleaseWrite(&cm_serverLock);
}
}
/* call cm_FreeServer while holding a write lock on cm_serverLock */
void cm_FreeServer(cm_server_t* serverp)
@ -447,7 +449,7 @@ void cm_FreeServerList(cm_serverRef_t** list)
{
cm_serverRef_t **current = list;
cm_serverRef_t **nextp = 0;
cm_serverRef_t * next = 0;
cm_serverRef_t * next = 0;
lock_ObtainWrite(&cm_serverLock);
@ -455,7 +457,7 @@ void cm_FreeServerList(cm_serverRef_t** list)
{
nextp = &(*current)->next;
if (--((*current)->refCount) == 0) {
next = *nextp;
next = *nextp;
cm_FreeServer((*current)->server);
free(*current);
*current = next;

File diff suppressed because it is too large Load Diff

View File

@ -70,6 +70,10 @@ extern long cm_NameI(cm_scache_t *rootSCachep, char *pathp, long flags,
extern long cm_Lookup(cm_scache_t *dscp, char *namep, long flags,
cm_user_t *userp, cm_req_t *reqp, cm_scache_t **outpScpp);
extern long cm_LookupInternal(cm_scache_t *dscp, char *namep, long flags,
cm_user_t *userp, cm_req_t *reqp,
cm_scache_t **outpScpp);
extern void cm_TryBulkStat(cm_scache_t *dscp, osi_hyper_t *offsetp,
cm_user_t *userp, cm_req_t *reqp);
@ -110,7 +114,8 @@ extern long cm_Link(cm_scache_t *dscp, char *namep, cm_scache_t *sscp,
extern long cm_SymLink(cm_scache_t *dscp, char *namep, char *contentsp,
long flags, cm_attr_t *attrp, cm_user_t *userp, cm_req_t *reqp);
extern int cm_ExpandSysName(char *inp, char *outp, long outSize);
extern int cm_ExpandSysName(char *inp, char *outp, long outSize,
unsigned int sysNameIndex);
extern long cm_Open(cm_scache_t *scp, int type, cm_user_t *userp);

View File

@ -2181,19 +2181,19 @@ register struct cmd_syndesc *as; {
return 0;
}
input = space;
memcpy(&setp, input, sizeof(afs_int32));
input += sizeof(afs_int32);
if (!setp) {
fprintf(stderr,"No sysname name value was found\n");
input = space;
memcpy(&setp, input, sizeof(afs_int32));
input += sizeof(afs_int32);
if (!setp) {
fprintf(stderr,"No sysname name value was found\n");
return 1;
}
}
printf("Current sysname%s", setp > 1 ? "s are" : " is");
for (; setp > 0; --setp ) {
printf(" \'%s\'", input);
input += strlen(input) + 1;
}
}
printf("\n");
return 0;
}
@ -2943,7 +2943,7 @@ int argc;
char **argv; {
register afs_int32 code;
register struct cmd_syndesc *ts;
#ifdef AFS_AIX32_ENV
/*
* The following signal action for AIX is necessary so that in case of a
@ -3141,7 +3141,7 @@ char **argv; {
cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
ts = cmd_CreateSyntax("sysname", SysNameCmd, 0, "get/set sysname (i.e. @sys) value");
cmd_AddParm(ts, "-newsys", CMD_SINGLE, CMD_OPTIONAL, "new sysname");
cmd_AddParm(ts, "-newsys", CMD_LIST, CMD_OPTIONAL, "new sysname");
ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, 0, "enable/disable translators to AFS");
cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");