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; cm_initparams_v1 cm_initParams;
char *cm_sysName = 0; char *cm_sysName = 0;
int cm_sysNameCount = 0; unsigned int cm_sysNameCount = 0;
char *cm_sysNameList[MAXNUMSYSNAMES]; char *cm_sysNameList[MAXNUMSYSNAMES];
DWORD TraceOption = 0; DWORD TraceOption = 0;
@ -358,72 +358,72 @@ configureBackConnectionHostNames(void)
int afsd_InitCM(char **reasonP) int afsd_InitCM(char **reasonP)
{ {
osi_uid_t debugID; osi_uid_t debugID;
long cacheBlocks; long cacheBlocks;
long cacheSize; long cacheSize;
long logChunkSize; long logChunkSize;
long stats; long stats;
long traceBufSize; long traceBufSize;
long maxcpus; long maxcpus;
long ltt, ltto; long ltt, ltto;
long rx_mtu, rx_nojumbo; long rx_mtu, rx_nojumbo;
long virtualCache; long virtualCache;
char rootCellName[256]; char rootCellName[256];
struct rx_service *serverp; struct rx_service *serverp;
static struct rx_securityClass *nullServerSecurityClassp; static struct rx_securityClass *nullServerSecurityClassp;
struct hostent *thp; struct hostent *thp;
char *msgBuf; char *msgBuf;
char buf[200]; char buf[200];
HKEY parmKey; HKEY parmKey;
DWORD dummyLen; DWORD dummyLen;
DWORD regType; DWORD regType;
long code; long code;
/*int freelanceEnabled;*/ /*int freelanceEnabled;*/
WSADATA WSAjunk; WSADATA WSAjunk;
lana_number_t lanaNum; lana_number_t lanaNum;
int i; int i;
WSAStartup(0x0101, &WSAjunk); WSAStartup(0x0101, &WSAjunk);
afsd_initUpperCaseTable(); afsd_initUpperCaseTable();
/* setup osidebug server at RPC slot 1000 */ /* setup osidebug server at RPC slot 1000 */
osi_LongToUID(1000, &debugID); osi_LongToUID(1000, &debugID);
code = osi_InitDebug(&debugID); code = osi_InitDebug(&debugID);
afsi_log("osi_InitDebug code %d", code); afsi_log("osi_InitDebug code %d", code);
// osi_LockTypeSetDefault("stat"); /* comment this out for speed * // osi_LockTypeSetDefault("stat"); /* comment this out for speed *
if (code != 0) { if (code != 0) {
*reasonP = "unknown error"; *reasonP = "unknown error";
return -1; return -1;
} }
/* who are we ? */ /* who are we ? */
gethostname(cm_HostName, sizeof(cm_HostName)); gethostname(cm_HostName, sizeof(cm_HostName));
afsi_log("gethostname %s", cm_HostName); afsi_log("gethostname %s", cm_HostName);
thp = gethostbyname(cm_HostName); thp = gethostbyname(cm_HostName);
memcpy(&cm_HostAddr, thp->h_addr_list[0], 4); memcpy(&cm_HostAddr, thp->h_addr_list[0], 4);
/* seed random number generator */ /* seed random number generator */
srand(ntohl(cm_HostAddr)); srand(ntohl(cm_HostAddr));
/* Look up configuration parameters in Registry */ /* Look up configuration parameters in Registry */
code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName,
0, KEY_QUERY_VALUE, &parmKey); 0, KEY_QUERY_VALUE, &parmKey);
if (code != ERROR_SUCCESS) { if (code != ERROR_SUCCESS) {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER, | FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, code, 0, (LPTSTR)&msgBuf, 0, NULL); NULL, code, 0, (LPTSTR)&msgBuf, 0, NULL);
StringCbPrintfA(buf, sizeof(buf), StringCbPrintfA(buf, sizeof(buf),
"Failure in configuration while opening Registry: %s", "Failure in configuration while opening Registry: %s",
msgBuf); msgBuf);
osi_panic(buf, __FILE__, __LINE__); osi_panic(buf, __FILE__, __LINE__);
} }
dummyLen = sizeof(maxcpus); dummyLen = sizeof(maxcpus);
code = RegQueryValueEx(parmKey, "MaxCPUs", NULL, NULL, code = RegQueryValueEx(parmKey, "MaxCPUs", NULL, NULL,
(BYTE *) &maxcpus, &dummyLen); (BYTE *) &maxcpus, &dummyLen);
if (code == ERROR_SUCCESS) { if (code == ERROR_SUCCESS) {
HANDLE hProcess; HANDLE hProcess;
DWORD_PTR processAffinityMask, systemAffinityMask; DWORD_PTR processAffinityMask, systemAffinityMask;
@ -456,139 +456,139 @@ int afsd_InitCM(char **reasonP)
} }
} }
dummyLen = sizeof(TraceOption); dummyLen = sizeof(TraceOption);
code = RegQueryValueEx(parmKey, "TraceOption", NULL, NULL, code = RegQueryValueEx(parmKey, "TraceOption", NULL, NULL,
(BYTE *) &TraceOption, &dummyLen); (BYTE *) &TraceOption, &dummyLen);
afsi_log("Event Log Tracing = %lX", TraceOption); afsi_log("Event Log Tracing = %lX", TraceOption);
dummyLen = sizeof(traceBufSize); dummyLen = sizeof(traceBufSize);
code = RegQueryValueEx(parmKey, "TraceBufferSize", NULL, NULL, code = RegQueryValueEx(parmKey, "TraceBufferSize", NULL, NULL,
(BYTE *) &traceBufSize, &dummyLen); (BYTE *) &traceBufSize, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("Trace Buffer size %d", traceBufSize); afsi_log("Trace Buffer size %d", traceBufSize);
else { else {
traceBufSize = CM_CONFIGDEFAULT_TRACEBUFSIZE; traceBufSize = CM_CONFIGDEFAULT_TRACEBUFSIZE;
afsi_log("Default trace buffer size %d", traceBufSize); afsi_log("Default trace buffer size %d", traceBufSize);
} }
/* setup and enable debug log */ /* setup and enable debug log */
afsd_logp = osi_LogCreate("afsd", traceBufSize); afsd_logp = osi_LogCreate("afsd", traceBufSize);
afsi_log("osi_LogCreate log addr %x", (int)afsd_logp); afsi_log("osi_LogCreate log addr %x", (int)afsd_logp);
osi_LogEnable(afsd_logp); osi_LogEnable(afsd_logp);
logReady = 1; logReady = 1;
osi_Log0(afsd_logp, "Log init"); osi_Log0(afsd_logp, "Log init");
dummyLen = sizeof(cacheSize); dummyLen = sizeof(cacheSize);
code = RegQueryValueEx(parmKey, "CacheSize", NULL, NULL, code = RegQueryValueEx(parmKey, "CacheSize", NULL, NULL,
(BYTE *) &cacheSize, &dummyLen); (BYTE *) &cacheSize, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("Cache size %d", cacheSize); afsi_log("Cache size %d", cacheSize);
else { else {
cacheSize = CM_CONFIGDEFAULT_CACHESIZE; cacheSize = CM_CONFIGDEFAULT_CACHESIZE;
afsi_log("Default cache size %d", cacheSize); afsi_log("Default cache size %d", cacheSize);
} }
dummyLen = sizeof(logChunkSize); dummyLen = sizeof(logChunkSize);
code = RegQueryValueEx(parmKey, "ChunkSize", NULL, NULL, code = RegQueryValueEx(parmKey, "ChunkSize", NULL, NULL,
(BYTE *) &logChunkSize, &dummyLen); (BYTE *) &logChunkSize, &dummyLen);
if (code == ERROR_SUCCESS) { if (code == ERROR_SUCCESS) {
if (logChunkSize < 12 || logChunkSize > 30) { if (logChunkSize < 12 || logChunkSize > 30) {
afsi_log("Invalid chunk size %d, using default", afsi_log("Invalid chunk size %d, using default",
logChunkSize); logChunkSize);
logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE; logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE;
} }
afsi_log("Chunk size %d", logChunkSize); afsi_log("Chunk size %d", logChunkSize);
} else { } else {
logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE; logChunkSize = CM_CONFIGDEFAULT_CHUNKSIZE;
afsi_log("Default chunk size %d", logChunkSize); afsi_log("Default chunk size %d", logChunkSize);
} }
cm_logChunkSize = logChunkSize; cm_logChunkSize = logChunkSize;
cm_chunkSize = 1 << logChunkSize; cm_chunkSize = 1 << logChunkSize;
dummyLen = sizeof(numBkgD); dummyLen = sizeof(numBkgD);
code = RegQueryValueEx(parmKey, "Daemons", NULL, NULL, code = RegQueryValueEx(parmKey, "Daemons", NULL, NULL,
(BYTE *) &numBkgD, &dummyLen); (BYTE *) &numBkgD, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("%d background daemons", numBkgD); afsi_log("%d background daemons", numBkgD);
else { else {
numBkgD = CM_CONFIGDEFAULT_DAEMONS; numBkgD = CM_CONFIGDEFAULT_DAEMONS;
afsi_log("Defaulting to %d background daemons", numBkgD); afsi_log("Defaulting to %d background daemons", numBkgD);
} }
dummyLen = sizeof(numSvThreads); dummyLen = sizeof(numSvThreads);
code = RegQueryValueEx(parmKey, "ServerThreads", NULL, NULL, code = RegQueryValueEx(parmKey, "ServerThreads", NULL, NULL,
(BYTE *) &numSvThreads, &dummyLen); (BYTE *) &numSvThreads, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("%d server threads", numSvThreads); afsi_log("%d server threads", numSvThreads);
else { else {
numSvThreads = CM_CONFIGDEFAULT_SVTHREADS; numSvThreads = CM_CONFIGDEFAULT_SVTHREADS;
afsi_log("Defaulting to %d server threads", numSvThreads); afsi_log("Defaulting to %d server threads", numSvThreads);
} }
dummyLen = sizeof(stats); dummyLen = sizeof(stats);
code = RegQueryValueEx(parmKey, "Stats", NULL, NULL, code = RegQueryValueEx(parmKey, "Stats", NULL, NULL,
(BYTE *) &stats, &dummyLen); (BYTE *) &stats, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("Status cache size %d", stats); afsi_log("Status cache size %d", stats);
else { else {
stats = CM_CONFIGDEFAULT_STATS; stats = CM_CONFIGDEFAULT_STATS;
afsi_log("Default status cache size %d", stats); afsi_log("Default status cache size %d", stats);
} }
dummyLen = sizeof(ltt); dummyLen = sizeof(ltt);
code = RegQueryValueEx(parmKey, "LogoffTokenTransfer", NULL, NULL, code = RegQueryValueEx(parmKey, "LogoffTokenTransfer", NULL, NULL,
(BYTE *) &ltt, &dummyLen); (BYTE *) &ltt, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("Logoff token transfer %s", (ltt ? "on" : "off")); afsi_log("Logoff token transfer %s", (ltt ? "on" : "off"));
else { else {
ltt = 1; ltt = 1;
afsi_log("Logoff token transfer on by default"); afsi_log("Logoff token transfer on by default");
} }
smb_LogoffTokenTransfer = ltt; smb_LogoffTokenTransfer = ltt;
afsi_log("Logoff token transfer is currently ignored"); afsi_log("Logoff token transfer is currently ignored");
if (ltt) { if (ltt) {
dummyLen = sizeof(ltto); dummyLen = sizeof(ltto);
code = RegQueryValueEx(parmKey, "LogoffTokenTransferTimeout", code = RegQueryValueEx(parmKey, "LogoffTokenTransferTimeout",
NULL, NULL, (BYTE *) &ltto, &dummyLen); NULL, NULL, (BYTE *) &ltto, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("Logoff token tranfer timeout %d seconds", ltto); afsi_log("Logoff token tranfer timeout %d seconds", ltto);
else { else {
ltto = 10; ltto = 10;
afsi_log("Default logoff token transfer timeout 10 seconds"); afsi_log("Default logoff token transfer timeout 10 seconds");
} }
} else { } else {
ltto = 0; ltto = 0;
} }
smb_LogoffTransferTimeout = ltto; smb_LogoffTransferTimeout = ltto;
afsi_log("Default logoff token is currently ignored"); afsi_log("Default logoff token is currently ignored");
dummyLen = sizeof(cm_rootVolumeName); dummyLen = sizeof(cm_rootVolumeName);
code = RegQueryValueEx(parmKey, "RootVolume", NULL, NULL, code = RegQueryValueEx(parmKey, "RootVolume", NULL, NULL,
cm_rootVolumeName, &dummyLen); cm_rootVolumeName, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("Root volume %s", cm_rootVolumeName); afsi_log("Root volume %s", cm_rootVolumeName);
else { else {
StringCbCopyA(cm_rootVolumeName, sizeof(cm_rootVolumeName), "root.afs"); StringCbCopyA(cm_rootVolumeName, sizeof(cm_rootVolumeName), "root.afs");
afsi_log("Default root volume name root.afs"); afsi_log("Default root volume name root.afs");
} }
cm_mountRootLen = sizeof(cm_mountRoot); cm_mountRootLen = sizeof(cm_mountRoot);
code = RegQueryValueEx(parmKey, "MountRoot", NULL, NULL, code = RegQueryValueEx(parmKey, "MountRoot", NULL, NULL,
cm_mountRoot, &cm_mountRootLen); cm_mountRoot, &cm_mountRootLen);
if (code == ERROR_SUCCESS) { if (code == ERROR_SUCCESS) {
afsi_log("Mount root %s", cm_mountRoot); afsi_log("Mount root %s", cm_mountRoot);
cm_mountRootLen = strlen(cm_mountRoot); cm_mountRootLen = strlen(cm_mountRoot);
} else { } else {
StringCbCopyA(cm_mountRoot, sizeof(cm_mountRoot), "/afs"); StringCbCopyA(cm_mountRoot, sizeof(cm_mountRoot), "/afs");
cm_mountRootLen = 4; cm_mountRootLen = 4;
/* Don't log */ /* Don't log */
} }
dummyLen = sizeof(buf); dummyLen = sizeof(buf);
code = RegQueryValueEx(parmKey, "CachePath", NULL, &regType, code = RegQueryValueEx(parmKey, "CachePath", NULL, &regType,
buf, &dummyLen); buf, &dummyLen);
if (code == ERROR_SUCCESS && buf[0]) { if (code == ERROR_SUCCESS && buf[0]) {
if (regType == REG_EXPAND_SZ) { if (regType == REG_EXPAND_SZ) {
dummyLen = ExpandEnvironmentStrings(buf, cm_CachePath, sizeof(cm_CachePath)); dummyLen = ExpandEnvironmentStrings(buf, cm_CachePath, sizeof(cm_CachePath));
@ -599,17 +599,17 @@ int afsd_InitCM(char **reasonP)
} else { } else {
StringCbCopyA(cm_CachePath, sizeof(cm_CachePath), buf); StringCbCopyA(cm_CachePath, sizeof(cm_CachePath), buf);
} }
afsi_log("Cache path %s", cm_CachePath); afsi_log("Cache path %s", cm_CachePath);
} else { } else {
GetWindowsDirectory(cm_CachePath, sizeof(cm_CachePath)); GetWindowsDirectory(cm_CachePath, sizeof(cm_CachePath));
cm_CachePath[2] = 0; /* get drive letter only */ cm_CachePath[2] = 0; /* get drive letter only */
StringCbCatA(cm_CachePath, sizeof(cm_CachePath), "\\AFSCache"); StringCbCatA(cm_CachePath, sizeof(cm_CachePath), "\\AFSCache");
afsi_log("Default cache path %s", cm_CachePath); afsi_log("Default cache path %s", cm_CachePath);
} }
dummyLen = sizeof(virtualCache); dummyLen = sizeof(virtualCache);
code = RegQueryValueEx(parmKey, "NonPersistentCaching", NULL, NULL, code = RegQueryValueEx(parmKey, "NonPersistentCaching", NULL, NULL,
&virtualCache, &dummyLen); &virtualCache, &dummyLen);
if (code == ERROR_SUCCESS && virtualCache) { if (code == ERROR_SUCCESS && virtualCache) {
buf_cacheType = CM_BUF_CACHETYPE_VIRTUAL; buf_cacheType = CM_BUF_CACHETYPE_VIRTUAL;
} else { } else {
@ -617,27 +617,27 @@ int afsd_InitCM(char **reasonP)
} }
afsi_log("Cache type is %s", ((buf_cacheType == CM_BUF_CACHETYPE_FILE)?"FILE":"VIRTUAL")); afsi_log("Cache type is %s", ((buf_cacheType == CM_BUF_CACHETYPE_FILE)?"FILE":"VIRTUAL"));
dummyLen = sizeof(traceOnPanic); dummyLen = sizeof(traceOnPanic);
code = RegQueryValueEx(parmKey, "TrapOnPanic", NULL, NULL, code = RegQueryValueEx(parmKey, "TrapOnPanic", NULL, NULL,
(BYTE *) &traceOnPanic, &dummyLen); (BYTE *) &traceOnPanic, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("Set to %s on panic", afsi_log("Set to %s on panic",
traceOnPanic ? "trap" : "not trap"); traceOnPanic ? "trap" : "not trap");
else { else {
traceOnPanic = 0; traceOnPanic = 0;
/* Don't log */ /* Don't log */
} }
dummyLen = sizeof(reportSessionStartups); dummyLen = sizeof(reportSessionStartups);
code = RegQueryValueEx(parmKey, "ReportSessionStartups", NULL, NULL, code = RegQueryValueEx(parmKey, "ReportSessionStartups", NULL, NULL,
(BYTE *) &reportSessionStartups, &dummyLen); (BYTE *) &reportSessionStartups, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("Session startups %s be recorded in the Event Log", afsi_log("Session startups %s be recorded in the Event Log",
reportSessionStartups ? "will" : "will not"); reportSessionStartups ? "will" : "will not");
else { else {
reportSessionStartups = 0; reportSessionStartups = 0;
/* Don't log */ /* Don't log */
} }
for ( i=0; i < MAXNUMSYSNAMES; i++ ) { for ( i=0; i < MAXNUMSYSNAMES; i++ ) {
cm_sysNameList[i] = osi_Alloc(MAXSYSNAME); cm_sysNameList[i] = osi_Alloc(MAXSYSNAME);
@ -645,53 +645,53 @@ int afsd_InitCM(char **reasonP)
} }
cm_sysName = cm_sysNameList[0]; cm_sysName = cm_sysNameList[0];
dummyLen = MAXSYSNAME; dummyLen = MAXSYSNAME;
code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, cm_sysName, &dummyLen); code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, cm_sysName, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS)
afsi_log("Sys name %s", cm_sysName); afsi_log("Sys name %s", cm_sysName);
else { else {
StringCbCopyA(cm_sysName, MAXSYSNAME, "i386_nt40"); StringCbCopyA(cm_sysName, MAXSYSNAME, "i386_nt40");
afsi_log("Default sys name %s", cm_sysName); afsi_log("Default sys name %s", cm_sysName);
} }
cm_sysNameCount = 1; cm_sysNameCount = 1;
dummyLen = sizeof(cryptall); dummyLen = sizeof(cryptall);
code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL, code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL,
(BYTE *) &cryptall, &dummyLen); (BYTE *) &cryptall, &dummyLen);
if (code == ERROR_SUCCESS) if (code == ERROR_SUCCESS) {
afsi_log("SecurityLevel is %s", cryptall?"crypt":"clear"); afsi_log("SecurityLevel is %s", cryptall?"crypt":"clear");
else { } else {
cryptall = rxkad_clear; cryptall = 0;
afsi_log("Default SecurityLevel is clear"); afsi_log("Default SecurityLevel is clear");
} }
#ifdef AFS_AFSDB_ENV #ifdef AFS_AFSDB_ENV
dummyLen = sizeof(cm_dnsEnabled); dummyLen = sizeof(cm_dnsEnabled);
code = RegQueryValueEx(parmKey, "UseDNS", NULL, NULL, code = RegQueryValueEx(parmKey, "UseDNS", NULL, NULL,
(BYTE *) &cm_dnsEnabled, &dummyLen); (BYTE *) &cm_dnsEnabled, &dummyLen);
if (code == ERROR_SUCCESS) { if (code == ERROR_SUCCESS) {
afsi_log("DNS %s be used to find AFS cell servers", afsi_log("DNS %s be used to find AFS cell servers",
cm_dnsEnabled ? "will" : "will not"); cm_dnsEnabled ? "will" : "will not");
} }
else { else {
cm_dnsEnabled = 1; /* default on */ cm_dnsEnabled = 1; /* default on */
afsi_log("Default to use DNS to find AFS cell servers"); afsi_log("Default to use DNS to find AFS cell servers");
} }
#else /* AFS_AFSDB_ENV */ #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 */ #endif /* AFS_AFSDB_ENV */
#ifdef AFS_FREELANCE_CLIENT #ifdef AFS_FREELANCE_CLIENT
dummyLen = sizeof(cm_freelanceEnabled); dummyLen = sizeof(cm_freelanceEnabled);
code = RegQueryValueEx(parmKey, "FreelanceClient", NULL, NULL, code = RegQueryValueEx(parmKey, "FreelanceClient", NULL, NULL,
(BYTE *) &cm_freelanceEnabled, &dummyLen); (BYTE *) &cm_freelanceEnabled, &dummyLen);
if (code == ERROR_SUCCESS) { if (code == ERROR_SUCCESS) {
afsi_log("Freelance client feature %s activated", afsi_log("Freelance client feature %s activated",
cm_freelanceEnabled ? "is" : "is not"); cm_freelanceEnabled ? "is" : "is not");
} }
else { else {
cm_freelanceEnabled = 0; /* default off */ cm_freelanceEnabled = 0; /* default off */
} }
#endif /* AFS_FREELANCE_CLIENT */ #endif /* AFS_FREELANCE_CLIENT */
#ifdef COMMENT #ifdef COMMENT
@ -738,15 +738,15 @@ int afsd_InitCM(char **reasonP)
} }
afsi_log("Maximum number of VCs per server is %d", smb_maxVCPerServer); afsi_log("Maximum number of VCs per server is %d", smb_maxVCPerServer);
dummyLen = sizeof(smb_authType); dummyLen = sizeof(smb_authType);
code = RegQueryValueEx(parmKey, "SMBAuthType", NULL, NULL, code = RegQueryValueEx(parmKey, "SMBAuthType", NULL, NULL,
(BYTE *) &smb_authType, &dummyLen); (BYTE *) &smb_authType, &dummyLen);
if (code != ERROR_SUCCESS || if (code != ERROR_SUCCESS ||
(smb_authType != SMB_AUTH_EXTENDED && smb_authType != SMB_AUTH_NTLM && smb_authType != SMB_AUTH_NONE)) { (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 */ 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"))); afsi_log("SMB authentication type is %s", ((smb_authType == SMB_AUTH_NONE)?"NONE":((smb_authType == SMB_AUTH_EXTENDED)?"EXTENDED":"NTLM")));
dummyLen = sizeof(rx_nojumbo); dummyLen = sizeof(rx_nojumbo);
code = RegQueryValueEx(parmKey, "RxNoJumbo", NULL, NULL, code = RegQueryValueEx(parmKey, "RxNoJumbo", NULL, NULL,
@ -754,7 +754,7 @@ int afsd_InitCM(char **reasonP)
if (code != ERROR_SUCCESS) { if (code != ERROR_SUCCESS) {
rx_nojumbo = 0; rx_nojumbo = 0;
} }
if(rx_nojumbo) if (rx_nojumbo)
afsi_log("RX Jumbograms are disabled"); afsi_log("RX Jumbograms are disabled");
dummyLen = sizeof(rx_mtu); dummyLen = sizeof(rx_mtu);
@ -763,7 +763,7 @@ int afsd_InitCM(char **reasonP)
if (code != ERROR_SUCCESS || !rx_mtu) { if (code != ERROR_SUCCESS || !rx_mtu) {
rx_mtu = -1; rx_mtu = -1;
} }
if(rx_mtu != -1) if (rx_mtu != -1)
afsi_log("RX maximum MTU is %d", rx_mtu); afsi_log("RX maximum MTU is %d", rx_mtu);
dummyLen = sizeof(ConnDeadtimeout); dummyLen = sizeof(ConnDeadtimeout);
@ -776,18 +776,18 @@ int afsd_InitCM(char **reasonP)
(BYTE *) &HardDeadtimeout, &dummyLen); (BYTE *) &HardDeadtimeout, &dummyLen);
afsi_log("HardDeadTimeout is %d", HardDeadtimeout); afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
RegCloseKey (parmKey); RegCloseKey (parmKey);
/* Call lanahelper to get Netbios name, lan adapter number and gateway flag */ /* 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))) { if(SUCCEEDED(code = lana_GetUncServerNameEx(cm_NetbiosName, &lanaNum, &isGateway, LANA_NETBIOS_NAME_FULL))) {
LANadapter = (lanaNum == LANA_INVALID)? -1: lanaNum; LANadapter = (lanaNum == LANA_INVALID)? -1: lanaNum;
if(LANadapter != -1) if (LANadapter != -1)
afsi_log("LAN adapter number %d", LANadapter); afsi_log("LAN adapter number %d", LANadapter);
else else
afsi_log("LAN adapter number not determined"); afsi_log("LAN adapter number not determined");
if(isGateway) if (isGateway)
afsi_log("Set for gateway service"); afsi_log("Set for gateway service");
afsi_log("Using >%s< as SMB server name", cm_NetbiosName); afsi_log("Using >%s< as SMB server name", cm_NetbiosName);
@ -797,38 +797,38 @@ int afsd_InitCM(char **reasonP)
osi_panic(buf, __FILE__, __LINE__); osi_panic(buf, __FILE__, __LINE__);
} }
/* setup early variables */ /* setup early variables */
/* These both used to be configurable. */ /* These both used to be configurable. */
smb_UseV3 = 1; smb_UseV3 = 1;
buf_bufferSize = CM_CONFIGDEFAULT_BLOCKSIZE; 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; cacheBlocks = (cacheSize * 1024) / buf_bufferSize;
/* get network related info */ /* get network related info */
cm_noIPAddr = CM_MAXINTERFACE_ADDR; cm_noIPAddr = CM_MAXINTERFACE_ADDR;
code = syscfg_GetIFInfo(&cm_noIPAddr, code = syscfg_GetIFInfo(&cm_noIPAddr,
cm_IPAddr, cm_SubnetMask, cm_IPAddr, cm_SubnetMask,
cm_NetMtu, cm_NetFlags); cm_NetMtu, cm_NetFlags);
if ( (cm_noIPAddr <= 0) || (code <= 0 ) ) if ( (cm_noIPAddr <= 0) || (code <= 0 ) )
afsi_log("syscfg_GetIFInfo error code %d", code); afsi_log("syscfg_GetIFInfo error code %d", code);
else else
afsi_log("First Network address %x SubnetMask %x", afsi_log("First Network address %x SubnetMask %x",
cm_IPAddr[0], cm_SubnetMask[0]); cm_IPAddr[0], cm_SubnetMask[0]);
/* /*
* Save client configuration for GetCacheConfig requests * Save client configuration for GetCacheConfig requests
*/ */
cm_initParams.nChunkFiles = 0; cm_initParams.nChunkFiles = 0;
cm_initParams.nStatCaches = stats; cm_initParams.nStatCaches = stats;
cm_initParams.nDataCaches = 0; cm_initParams.nDataCaches = 0;
cm_initParams.nVolumeCaches = 0; cm_initParams.nVolumeCaches = 0;
cm_initParams.firstChunkSize = cm_chunkSize; cm_initParams.firstChunkSize = cm_chunkSize;
cm_initParams.otherChunkSize = cm_chunkSize; cm_initParams.otherChunkSize = cm_chunkSize;
cm_initParams.cacheSize = cacheSize; cm_initParams.cacheSize = cacheSize;
cm_initParams.setTime = 0; cm_initParams.setTime = 0;
cm_initParams.memCache = 0; cm_initParams.memCache = 0;
/* Set RX parameters before initializing RX */ /* Set RX parameters before initializing RX */
if ( rx_nojumbo ) { if ( rx_nojumbo ) {
@ -847,48 +847,48 @@ int afsd_InitCM(char **reasonP)
/* Ensure the AFS Netbios Name is registered to allow loopback access */ /* Ensure the AFS Netbios Name is registered to allow loopback access */
configureBackConnectionHostNames(); 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. * callback RPC messages.
*/ */
code = rx_Init(htons(7001)); code = rx_Init(htons(7001));
afsi_log("rx_Init code %x", code); afsi_log("rx_Init code %x", code);
if (code != 0) { if (code != 0) {
*reasonP = "afsd: failed to init rx client on port 7001"; *reasonP = "afsd: failed to init rx client on port 7001";
return -1; return -1;
} }
/* Initialize the RPC server for session keys */ /* Initialize the RPC server for session keys */
RpcInit(); RpcInit();
/* create an unauthenticated service #1 for callbacks */ /* create an unauthenticated service #1 for callbacks */
nullServerSecurityClassp = rxnull_NewServerSecurityObject(); nullServerSecurityClassp = rxnull_NewServerSecurityObject();
serverp = rx_NewService(0, 1, "AFS", &nullServerSecurityClassp, 1, serverp = rx_NewService(0, 1, "AFS", &nullServerSecurityClassp, 1,
RXAFSCB_ExecuteRequest); RXAFSCB_ExecuteRequest);
afsi_log("rx_NewService addr %x", (int)serverp); afsi_log("rx_NewService addr %x", (int)serverp);
if (serverp == NULL) { if (serverp == NULL) {
*reasonP = "unknown error"; *reasonP = "unknown error";
return -1; return -1;
} }
nullServerSecurityClassp = rxnull_NewServerSecurityObject(); nullServerSecurityClassp = rxnull_NewServerSecurityObject();
serverp = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", serverp = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats",
&nullServerSecurityClassp, 1, RXSTATS_ExecuteRequest); &nullServerSecurityClassp, 1, RXSTATS_ExecuteRequest);
afsi_log("rx_NewService addr %x", (int)serverp); afsi_log("rx_NewService addr %x", (int)serverp);
if (serverp == NULL) { if (serverp == NULL) {
*reasonP = "unknown error"; *reasonP = "unknown error";
return -1; return -1;
} }
/* start server threads, *not* donating this one to the pool */ /* start server threads, *not* donating this one to the pool */
rx_StartServer(0); rx_StartServer(0);
afsi_log("rx_StartServer"); afsi_log("rx_StartServer");
/* init user daemon, and other packages */ /* init user daemon, and other packages */
cm_InitUser(); cm_InitUser();
cm_InitACLCache(2*stats); cm_InitACLCache(2*stats);
cm_InitConn(); cm_InitConn();
cm_InitCell(); cm_InitCell();
@ -905,28 +905,28 @@ int afsd_InitCM(char **reasonP)
cm_InitSCache(stats); cm_InitSCache(stats);
code = cm_InitDCache(0, cacheBlocks); code = cm_InitDCache(0, cacheBlocks);
afsi_log("cm_InitDCache code %x", code); afsi_log("cm_InitDCache code %x", code);
if (code != 0) { if (code != 0) {
*reasonP = "error initializing cache"; *reasonP = "error initializing cache";
return -1; return -1;
} }
#ifdef AFS_AFSDB_ENV #ifdef AFS_AFSDB_ENV
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500) #if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
if (cm_InitDNS(cm_dnsEnabled) == -1) if (cm_InitDNS(cm_dnsEnabled) == -1)
cm_dnsEnabled = 0; /* init failed, so deactivate */ cm_dnsEnabled = 0; /* init failed, so deactivate */
afsi_log("cm_InitDNS %d", cm_dnsEnabled); afsi_log("cm_InitDNS %d", cm_dnsEnabled);
#endif #endif
#endif #endif
code = cm_GetRootCellName(rootCellName); code = cm_GetRootCellName(rootCellName);
afsi_log("cm_GetRootCellName code %d, cm_freelanceEnabled= %d, rcn= %s", afsi_log("cm_GetRootCellName code %d, cm_freelanceEnabled= %d, rcn= %s",
code, cm_freelanceEnabled, (code ? "<none>" : rootCellName)); code, cm_freelanceEnabled, (code ? "<none>" : rootCellName));
if (code != 0 && !cm_freelanceEnabled) if (code != 0 && !cm_freelanceEnabled)
{ {
*reasonP = "can't find root cell name in afsd.ini"; *reasonP = "can't find root cell name in afsd.ini";
return -1; return -1;
} }
else if (cm_freelanceEnabled) else if (cm_freelanceEnabled)
cm_rootCellp = NULL; cm_rootCellp = NULL;
@ -939,14 +939,13 @@ int afsd_InitCM(char **reasonP)
*reasonP = "can't find root cell in afsdcell.ini"; *reasonP = "can't find root cell in afsdcell.ini";
return -1; return -1;
} }
} }
#ifdef AFS_FREELANCE_CLIENT #ifdef AFS_FREELANCE_CLIENT
if (cm_freelanceEnabled) if (cm_freelanceEnabled)
cm_InitFreelance(); cm_InitFreelance();
#endif #endif
return 0; return 0;
} }
int afsd_InitDaemons(char **reasonP) 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) 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", osi_Log3(afsd_logp, "RecordRacingRevoke Volume %d Flags %lX activeCalls %d",
fidp->volume, cancelFlags, cm_activeCallbackGrantingCalls); fidp->volume, cancelFlags, cm_activeCallbackGrantingCalls);
if (cm_activeCallbackGrantingCalls > 0) { if (cm_activeCallbackGrantingCalls > 0) {
rp = malloc(sizeof(*rp)); rp = malloc(sizeof(*rp));
memset(rp, 0, sizeof(*rp)); memset(rp, 0, sizeof(*rp));
osi_QAdd((osi_queue_t **) &cm_racingRevokesp, &rp->q); osi_QAdd((osi_queue_t **) &cm_racingRevokesp, &rp->q);
rp->flags |= (cancelFlags & CM_RACINGFLAG_ALL); rp->flags |= (cancelFlags & CM_RACINGFLAG_ALL);
if (fidp) rp->fid = *fidp; if (fidp) rp->fid = *fidp;
rp->callbackCount = ++cm_callbackCount; rp->callbackCount = ++cm_callbackCount;
} }
lock_ReleaseWrite(&cm_callbackLock); lock_ReleaseWrite(&cm_callbackLock);
} }
/* /*
@ -128,50 +128,50 @@ void cm_CallbackNotifyChange(cm_scache_t *scp)
*/ */
void cm_RevokeCallback(struct rx_call *callp, AFSFid *fidp) void cm_RevokeCallback(struct rx_call *callp, AFSFid *fidp)
{ {
cm_fid_t tfid; cm_fid_t tfid;
cm_scache_t *scp; cm_scache_t *scp;
long hash; long hash;
/* don't bother setting cell, since we won't be checking it (to aid /* 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 * in working with multi-homed servers: we don't know the cell if we
* don't recognize the IP address). * don't recognize the IP address).
*/ */
tfid.cell = 0; tfid.cell = 0;
tfid.volume = fidp->Volume; tfid.volume = fidp->Volume;
tfid.vnode = fidp->Vnode; tfid.vnode = fidp->Vnode;
tfid.unique = fidp->Unique; tfid.unique = fidp->Unique;
hash = CM_SCACHE_HASH(&tfid); hash = CM_SCACHE_HASH(&tfid);
osi_Log3(afsd_logp, "RevokeCallback vol %d vn %d un %d", 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 /* 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, * 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 * it could complete while we're doing the scan below, and get missed
* by both the scan and by this code. * by both the scan and by this code.
*/ */
cm_RecordRacingRevoke(&tfid, 0); cm_RecordRacingRevoke(&tfid, 0);
lock_ObtainWrite(&cm_scacheLock); lock_ObtainWrite(&cm_scacheLock);
/* do all in the hash bucket, since we don't know how many we'll find with /* do all in the hash bucket, since we don't know how many we'll find with
* varying cells. * varying cells.
*/ */
for(scp = cm_hashTablep[hash]; scp; scp=scp->nextp) { for (scp = cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (scp->fid.volume == tfid.volume && if (scp->fid.volume == tfid.volume &&
scp->fid.vnode == tfid.vnode && scp->fid.vnode == tfid.vnode &&
scp->fid.unique == tfid.unique) { scp->fid.unique == tfid.unique) {
scp->refCount++; scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock); lock_ReleaseWrite(&cm_scacheLock);
osi_Log1(afsd_logp, "Discarding SCache scp %x", scp); osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
lock_ObtainMutex(&scp->mx); lock_ObtainMutex(&scp->mx);
cm_DiscardSCache(scp); cm_DiscardSCache(scp);
lock_ReleaseMutex(&scp->mx); lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp); cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock); lock_ObtainWrite(&cm_scacheLock);
scp->refCount--; scp->refCount--;
}
} }
lock_ReleaseWrite(&cm_scacheLock); }
lock_ReleaseWrite(&cm_scacheLock);
} }
/* called to revoke a volume callback, which is typically issued when a volume /* 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) void cm_RevokeVolumeCallback(struct rx_call *callp, AFSFid *fidp)
{ {
long hash; long hash;
cm_scache_t *scp; cm_scache_t *scp;
cm_fid_t tfid; cm_fid_t tfid;
osi_Log1(afsd_logp, "RevokeVolumeCallback %d", fidp->Volume); osi_Log1(afsd_logp, "RevokeVolumeCallback %d", fidp->Volume);
/* do this first, so that if we're executing a callback granting call /* 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, * 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 * it could complete while we're doing the scan below, and get missed
* by both the scan and by this code. * by both the scan and by this code.
*/ */
tfid.cell = tfid.vnode = tfid.unique = 0; tfid.cell = tfid.vnode = tfid.unique = 0;
tfid.volume = fidp->Volume; tfid.volume = fidp->Volume;
cm_RecordRacingRevoke(&tfid, CM_RACINGFLAG_CANCELVOL); cm_RecordRacingRevoke(&tfid, CM_RACINGFLAG_CANCELVOL);
lock_ObtainWrite(&cm_scacheLock); lock_ObtainWrite(&cm_scacheLock);
for(hash = 0; hash < cm_hashTableSize; hash++) { for (hash = 0; hash < cm_hashTableSize; hash++) {
for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) { for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (scp->fid.volume == fidp->Volume) { if (scp->fid.volume == fidp->Volume) {
scp->refCount++; scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock); lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainMutex(&scp->mx); lock_ObtainMutex(&scp->mx);
osi_Log1(afsd_logp, "Discarding SCache scp %x", scp); osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
cm_DiscardSCache(scp); cm_DiscardSCache(scp);
lock_ReleaseMutex(&scp->mx); lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp); cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock); lock_ObtainWrite(&cm_scacheLock);
scp->refCount--; scp->refCount--;
} }
} /* search one hash bucket */ } /* search one hash bucket */
} /* search all hash buckets */ } /* search all hash buckets */
lock_ReleaseWrite(&cm_scacheLock); lock_ReleaseWrite(&cm_scacheLock);
} }
/* handle incoming RPC callback breaking message. /* 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) SRXAFSCB_CallBack(struct rx_call *callp, AFSCBFids *fidsArrayp, AFSCBs *cbsArrayp)
{ {
int i; int i;
AFSFid *tfidp; AFSFid *tfidp;
osi_Log0(afsd_logp, "SRXAFSCB_CallBack"); osi_Log0(afsd_logp, "SRXAFSCB_CallBack");
for(i=0; i < (long) fidsArrayp->AFSCBFids_len; i++) { for (i=0; i < (long) fidsArrayp->AFSCBFids_len; i++) {
tfidp = &fidsArrayp->AFSCBFids_val[i]; tfidp = &fidsArrayp->AFSCBFids_val[i];
if (tfidp->Volume == 0) if (tfidp->Volume == 0)
continue; /* means don't do anything */ continue; /* means don't do anything */
else if (tfidp->Vnode == 0) else if (tfidp->Vnode == 0)
cm_RevokeVolumeCallback(callp, tfidp); cm_RevokeVolumeCallback(callp, tfidp);
else else
cm_RevokeCallback(callp, tfidp); cm_RevokeCallback(callp, tfidp);
} }
return 0; return 0;
} }
/* called with no locks by RPC system when a server indicates that it has never /* 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. * are "rare," hopefully this won't be a problem.
*/ */
lock_ObtainWrite(&cm_scacheLock); lock_ObtainWrite(&cm_scacheLock);
for(hash = 0; hash < cm_hashTableSize; hash++) { for (hash = 0; hash < cm_hashTableSize; hash++) {
for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) { for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
scp->refCount++; scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock); lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainMutex(&scp->mx); lock_ObtainMutex(&scp->mx);
discarded = 0; discarded = 0;
if (scp->cbServerp != NULL) { if (scp->cbServerp != NULL) {
/* we have a callback, now decide if we should clear it */ /* we have a callback, now decide if we should clear it */
if (scp->cbServerp == tsp || tsp == NULL) { if (scp->cbServerp == tsp || tsp == NULL) {
osi_Log1(afsd_logp, "Discarding SCache scp %x", scp); osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
cm_DiscardSCache(scp); cm_DiscardSCache(scp);
discarded = 1; discarded = 1;
} }
} }
lock_ReleaseMutex(&scp->mx); lock_ReleaseMutex(&scp->mx);
if (discarded) if (discarded)
cm_CallbackNotifyChange(scp); cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock); lock_ObtainWrite(&cm_scacheLock);
scp->refCount--; scp->refCount--;
} /* search one hash bucket */ } /* search one hash bucket */
} /* search all hash buckets */ } /* search all hash buckets */
lock_ReleaseWrite(&cm_scacheLock); lock_ReleaseWrite(&cm_scacheLock);
/* we're done with the server structure */ /* we're done with the server structure */
if (tsp) cm_PutServer(tsp); if (tsp)
cm_PutServer(tsp);
} }
return 0; return 0;
@ -323,7 +324,7 @@ SRXAFSCB_InitCallBackState(struct rx_call *callp)
SRXAFSCB_Probe(struct rx_call *callp) SRXAFSCB_Probe(struct rx_call *callp)
{ {
osi_Log0(afsd_logp, "SRXAFSCB_Probe - not implemented"); osi_Log0(afsd_logp, "SRXAFSCB_Probe - not implemented");
return 0; return 0;
} }
/* debug interface: not implemented */ /* debug interface: not implemented */
@ -337,67 +338,67 @@ SRXAFSCB_GetCE64(struct rx_call *callp, long index, AFSDBCacheEntry *cep)
/* debug interface: not implemented */ /* debug interface: not implemented */
SRXAFSCB_GetLock(struct rx_call *callp, long index, AFSDBLock *lockp) SRXAFSCB_GetLock(struct rx_call *callp, long index, AFSDBLock *lockp)
{ {
/* XXXX */ /* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_GetLock - not implemented"); osi_Log0(afsd_logp, "SRXAFSCB_GetLock - not implemented");
return RXGEN_OPCODE; return RXGEN_OPCODE;
} }
/* debug interface: not implemented */ /* debug interface: not implemented */
SRXAFSCB_GetCE(struct rx_call *callp, long index, AFSDBCacheEntry *cep) SRXAFSCB_GetCE(struct rx_call *callp, long index, AFSDBCacheEntry *cep)
{ {
/* XXXX */ /* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_GetCE - not implemented"); osi_Log0(afsd_logp, "SRXAFSCB_GetCE - not implemented");
return RXGEN_OPCODE; return RXGEN_OPCODE;
} }
/* debug interface: not implemented */ /* debug interface: not implemented */
SRXAFSCB_XStatsVersion(struct rx_call *callp, long *vp) SRXAFSCB_XStatsVersion(struct rx_call *callp, long *vp)
{ {
/* XXXX */ /* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_XStatsVersion - not implemented"); osi_Log0(afsd_logp, "SRXAFSCB_XStatsVersion - not implemented");
*vp = -1; *vp = -1;
return RXGEN_OPCODE; return RXGEN_OPCODE;
} }
/* debug interface: not implemented */ /* debug interface: not implemented */
SRXAFSCB_GetXStats(struct rx_call *callp, long cvn, long coln, long *srvp, long *timep, SRXAFSCB_GetXStats(struct rx_call *callp, long cvn, long coln, long *srvp, long *timep,
AFSCB_CollData *datap) AFSCB_CollData *datap)
{ {
/* XXXX */ /* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_GetXStats - not implemented"); osi_Log0(afsd_logp, "SRXAFSCB_GetXStats - not implemented");
return RXGEN_OPCODE; return RXGEN_OPCODE;
} }
/* debug interface: not implemented */ /* debug interface: not implemented */
SRXAFSCB_InitCallBackState2(struct rx_call *callp, struct interfaceAddr* addr) SRXAFSCB_InitCallBackState2(struct rx_call *callp, struct interfaceAddr* addr)
{ {
/* XXXX */ /* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_InitCallBackState2 - not implemented"); osi_Log0(afsd_logp, "SRXAFSCB_InitCallBackState2 - not implemented");
return RXGEN_OPCODE; return RXGEN_OPCODE;
} }
/* debug interface: not implemented */ /* debug interface: not implemented */
SRXAFSCB_WhoAreYou(struct rx_call *callp, struct interfaceAddr* addr) SRXAFSCB_WhoAreYou(struct rx_call *callp, struct interfaceAddr* addr)
{ {
/* XXXX */ /* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_WhoAreYou - not implemented"); osi_Log0(afsd_logp, "SRXAFSCB_WhoAreYou - not implemented");
return RXGEN_OPCODE; return RXGEN_OPCODE;
} }
/* debug interface: not implemented */ /* debug interface: not implemented */
SRXAFSCB_InitCallBackState3(struct rx_call *callp, afsUUID* serverUuid) SRXAFSCB_InitCallBackState3(struct rx_call *callp, afsUUID* serverUuid)
{ {
/* XXXX */ /* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_InitCallBackState3 - not implemented"); osi_Log0(afsd_logp, "SRXAFSCB_InitCallBackState3 - not implemented");
return RXGEN_OPCODE; return RXGEN_OPCODE;
} }
/* debug interface: not implemented */ /* debug interface: not implemented */
SRXAFSCB_ProbeUuid(struct rx_call *callp, afsUUID* clientUuid) SRXAFSCB_ProbeUuid(struct rx_call *callp, afsUUID* clientUuid)
{ {
/* XXXX */ /* XXXX */
osi_Log0(afsd_logp, "SRXAFSCB_ProbeUuid - not implemented"); 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 */ /* called by afsd without any locks to initialize this module */
void cm_InitCallback(void) void cm_InitCallback(void)
{ {
lock_InitializeRWLock(&cm_callbackLock, "cm_callbackLock"); lock_InitializeRWLock(&cm_callbackLock, "cm_callbackLock");
cm_activeCallbackGrantingCalls = 0; cm_activeCallbackGrantingCalls = 0;
} }
/* called with locked scp; tells us whether we've got a callback. /* 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. // 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 // 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. // good shape and we simply return true, provided no change is detected.
int fdc, fgc; int fdc, fgc;
if (cm_freelanceEnabled && if (cm_freelanceEnabled &&
scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) { 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) void cm_StartCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp)
{ {
lock_ObtainWrite(&cm_callbackLock); lock_ObtainWrite(&cm_callbackLock);
cbrp->callbackCount = cm_callbackCount; cbrp->callbackCount = cm_callbackCount;
cm_activeCallbackGrantingCalls++; cm_activeCallbackGrantingCalls++;
cbrp->startTime = osi_Time(); cbrp->startTime = osi_Time();
cbrp->serverp = NULL; cbrp->serverp = NULL;
lock_ReleaseWrite(&cm_callbackLock); lock_ReleaseWrite(&cm_callbackLock);
} }
/* Called at the end of a callback-granting call, to remove the callback /* 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. * this locking hierarchy.
*/ */
void cm_EndCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp, 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 *revp; /* where we are */
cm_racingRevokes_t *nrevp; /* where we'll be next */ cm_racingRevokes_t *nrevp; /* where we'll be next */
int freeFlag; int freeFlag;
cm_server_t * serverp = 0; cm_server_t * serverp = 0;
lock_ObtainWrite(&cm_callbackLock); lock_ObtainWrite(&cm_callbackLock);
if (flags & CM_CALLBACK_MAINTAINCOUNT) { if (flags & CM_CALLBACK_MAINTAINCOUNT) {
osi_assert(cm_activeCallbackGrantingCalls > 0); osi_assert(cm_activeCallbackGrantingCalls > 0);
} }
else { else {
osi_assert(cm_activeCallbackGrantingCalls-- > 0); osi_assert(cm_activeCallbackGrantingCalls-- > 0);
} }
if (cm_activeCallbackGrantingCalls == 0) if (cm_activeCallbackGrantingCalls == 0)
freeFlag = 1; freeFlag = 1;
else else
freeFlag = 0; 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 (cbrp) {
if (scp) { if (scp) {
if (scp->cbServerp != cbrp->serverp) { if (scp->cbServerp != cbrp->serverp) {
serverp = scp->cbServerp; serverp = scp->cbServerp;
} }
scp->cbServerp = cbrp->serverp; scp->cbServerp = cbrp->serverp;
scp->cbExpires = cbrp->startTime + cbp->ExpirationTime; scp->cbExpires = cbrp->startTime + cbp->ExpirationTime;
} else { } else {
serverp = cbrp->serverp; serverp = cbrp->serverp;
} }
cbrp->serverp = NULL; cbrp->serverp = NULL;
} }
/* a callback was actually revoked during our granting call, so /* a callback was actually revoked during our granting call, so
* run down the list of revoked fids, looking for ours. * run down the list of revoked fids, looking for ours.
* If activeCallbackGrantingCalls is zero, free the elements, too. * If activeCallbackGrantingCalls is zero, free the elements, too.
* *
* May need to go through entire list just to do the freeing. * May need to go through entire list just to do the freeing.
*/ */
for(revp = cm_racingRevokesp; revp; revp = nrevp) { for (revp = cm_racingRevokesp; revp; revp = nrevp) {
nrevp = (cm_racingRevokes_t *) osi_QNext(&revp->q); nrevp = (cm_racingRevokes_t *) osi_QNext(&revp->q);
/* if this callback came in later than when we started the /* if this callback came in later than when we started the
* callback-granting call, and if this fid is the right fid, * callback-granting call, and if this fid is the right fid,
* then clear the callback. * then clear the callback.
*/ */
if (scp && cbrp && cbrp->callbackCount != cm_callbackCount if (scp && cbrp && cbrp->callbackCount != cm_callbackCount
&& revp->callbackCount > cbrp->callbackCount && revp->callbackCount > cbrp->callbackCount
&& (( scp->fid.volume == revp->fid.volume && && (( scp->fid.volume == revp->fid.volume &&
scp->fid.vnode == revp->fid.vnode && scp->fid.vnode == revp->fid.vnode &&
scp->fid.unique == revp->fid.unique) scp->fid.unique == revp->fid.unique)
|| ||
((revp->flags & CM_RACINGFLAG_CANCELVOL) && ((revp->flags & CM_RACINGFLAG_CANCELVOL) &&
scp->fid.volume == revp->fid.volume) scp->fid.volume == revp->fid.volume)
|| ||
(revp->flags & CM_RACINGFLAG_CANCELALL))) { (revp->flags & CM_RACINGFLAG_CANCELALL))) {
/* this one matches */ /* this one matches */
osi_Log4(afsd_logp, osi_Log4(afsd_logp,
"Racing revoke scp %x old cbc %d rev cbc %d cur cbc %d", "Racing revoke scp %x old cbc %d rev cbc %d cur cbc %d",
scp, scp,
cbrp->callbackCount, revp->callbackCount, cbrp->callbackCount, revp->callbackCount,
cm_callbackCount); cm_callbackCount);
cm_DiscardSCache(scp); cm_DiscardSCache(scp);
/* /*
* Since we don't have a callback to preserve, it's * Since we don't have a callback to preserve, it's
* OK to drop the lock and re-obtain it. * OK to drop the lock and re-obtain it.
*/ */
lock_ReleaseMutex(&scp->mx); lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp); cm_CallbackNotifyChange(scp);
lock_ObtainMutex(&scp->mx); lock_ObtainMutex(&scp->mx);
}
if (freeFlag) free(revp);
} }
if (freeFlag) free(revp);
}
/* if we freed the list, zap the pointer to it */ /* if we freed the list, zap the pointer to it */
if (freeFlag) cm_racingRevokesp = NULL; if (freeFlag) cm_racingRevokesp = NULL;
lock_ReleaseWrite(&cm_callbackLock); lock_ReleaseWrite(&cm_callbackLock);
if ( serverp ) { if ( serverp ) {
lock_ObtainWrite(&cm_serverLock); 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. * called with locked scp; returns with same.
*/ */
long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp, 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; cm_conn_t *connp;
AFSFetchStatus afsStatus; AFSFetchStatus afsStatus;
AFSVolSync volSync; 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); osi_Log2(afsd_logp, "GetCallback scp %x flags %lX", scp, flags);
#ifdef AFS_FREELANCE_CLIENT #ifdef AFS_FREELANCE_CLIENT
// The case where a callback is needed on /afs is handled // The case where a callback is needed on /afs is handled
// specially. We need to fetch the status by calling // specially. We need to fetch the status by calling
// cm_MergeStatus and mark that cm_fakeDirCallback is 2 // cm_MergeStatus and mark that cm_fakeDirCallback is 2
if (cm_freelanceEnabled) { if (cm_freelanceEnabled) {
if (scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && if (scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
scp->fid.volume==AFS_FAKE_ROOT_VOL_ID && scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
scp->fid.unique==0x1 && scp->fid.unique==0x1 &&
@ -849,41 +850,42 @@ long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
} }
#endif /* AFS_FREELANCE_CLIENT */ #endif /* AFS_FREELANCE_CLIENT */
mustCall = (flags & 1); mustCall = (flags & 1);
cm_AFSFidFromFid(&tfid, &scp->fid); cm_AFSFidFromFid(&tfid, &scp->fid);
while (1) { while (1) {
if (!mustCall && cm_HaveCallback(scp)) return 0; if (!mustCall && cm_HaveCallback(scp)) return 0;
/* turn off mustCall, since it has now forced us past the check above */ /* turn off mustCall, since it has now forced us past the check above */
mustCall = 0; mustCall = 0;
/* otherwise, we have to make an RPC to get the status */ /* 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_SyncOp(scp, NULL, NULL, NULL, 0, sflags);
cm_StartCallbackGrantingCall(scp, &cbr); cm_StartCallbackGrantingCall(scp, &cbr);
sfid = scp->fid; sfid = scp->fid;
lock_ReleaseMutex(&scp->mx); lock_ReleaseMutex(&scp->mx);
/* now make the RPC */ /* now make the RPC */
osi_Log1(afsd_logp, "CALL FetchStatus vp %x", (long) scp); osi_Log1(afsd_logp, "CALL FetchStatus vp %x", (long) scp);
do { do {
code = cm_Conn(&sfid, userp, reqp, &connp); code = cm_Conn(&sfid, userp, reqp, &connp);
if (code) continue; if (code) continue;
lock_ObtainMutex(&connp->mx);
code = RXAFS_FetchStatus(connp->callp, &tfid, code = RXAFS_FetchStatus(connp->callp, &tfid,
&afsStatus, &callback, &volSync); &afsStatus, &callback, &volSync);
lock_ReleaseMutex(&connp->mx);
} while (cm_Analyze(connp, userp, reqp, &sfid, &volSync, NULL, } while (cm_Analyze(connp, userp, reqp, &sfid, &volSync, NULL,
&cbr, code)); &cbr, code));
code = cm_MapRPCError(code, reqp); 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); cm_SyncOpDone(scp, NULL, sflags);
if (code == 0) { if (code == 0) {
cm_EndCallbackGrantingCall(scp, &cbr, &callback, 0); cm_EndCallbackGrantingCall(scp, &cbr, &callback, 0);
cm_MergeStatus(scp, &afsStatus, &volSync, userp, 0); cm_MergeStatus(scp, &afsStatus, &volSync, userp, 0);
} }
else else
cm_EndCallbackGrantingCall(NULL, &cbr, NULL, 0); cm_EndCallbackGrantingCall(NULL, &cbr, NULL, 0);
@ -903,8 +905,8 @@ void cm_CheckCBExpiration(void)
now = osi_Time(); now = osi_Time();
lock_ObtainWrite(&cm_scacheLock); lock_ObtainWrite(&cm_scacheLock);
for(i=0; i<cm_hashTableSize; i++) { for (i=0; i<cm_hashTableSize; i++) {
for(scp = cm_hashTablep[i]; scp; scp=scp->nextp) { for (scp = cm_hashTablep[i]; scp; scp=scp->nextp) {
scp->refCount++; scp->refCount++;
lock_ReleaseWrite(&cm_scacheLock); lock_ReleaseWrite(&cm_scacheLock);
if (scp->cbExpires > 0 && (scp->cbServerp == NULL || now > scp->cbExpires)) { 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 */ /* called with a held server to GC all bad connections hanging off of the server */
void cm_GCConnections(cm_server_t *serverp) void cm_GCConnections(cm_server_t *serverp)
{ {
cm_conn_t *tcp; cm_conn_t *tcp;
cm_conn_t **lcpp; cm_conn_t **lcpp;
cm_user_t *userp; cm_user_t *userp;
lock_ObtainWrite(&cm_connLock); lock_ObtainWrite(&cm_connLock);
lcpp = &serverp->connsp; lcpp = &serverp->connsp;
for(tcp = *lcpp; tcp; tcp = *lcpp) { for (tcp = *lcpp; tcp; tcp = *lcpp) {
userp = tcp->userp; userp = tcp->userp;
if (userp && tcp->refCount == 0 && (userp->vcRefs == 0)) { if (userp && tcp->refCount == 0 && (userp->vcRefs == 0)) {
/* do the deletion of this guy */ /* do the deletion of this guy */
cm_PutServer(tcp->serverp); cm_PutServer(tcp->serverp);
cm_ReleaseUser(userp); cm_ReleaseUser(userp);
*lcpp = tcp->nextp; *lcpp = tcp->nextp;
rx_DestroyConnection(tcp->callp); rx_DestroyConnection(tcp->callp);
lock_FinalizeMutex(&tcp->mx); lock_FinalizeMutex(&tcp->mx);
free(tcp); free(tcp);
} }
else { else {
/* just advance to the next */ /* just advance to the next */
lcpp = &tcp->nextp; lcpp = &tcp->nextp;
} }
} }
lock_ReleaseWrite(&cm_connLock); lock_ReleaseWrite(&cm_connLock);
} }
static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp, 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 serviceID;
int secIndex; int secIndex;
struct rx_securityClass *secObjp; struct rx_securityClass *secObjp;
afs_int32 level; afs_int32 level;
if (serverp->type == CM_SERVER_VLDB) { if (serverp->type == CM_SERVER_VLDB) {
port = htons(7003); port = htons(7003);
serviceID = 52; serviceID = 52;
} }
else { else {
osi_assert(serverp->type == CM_SERVER_FILE); osi_assert(serverp->type == CM_SERVER_FILE);
port = htons(7000); port = htons(7000);
serviceID = 1; serviceID = 1;
} }
if (ucellp->flags & CM_UCELLFLAG_RXKAD) { if (ucellp->flags & CM_UCELLFLAG_RXKAD) {
secIndex = 2; secIndex = 2;
if (cryptall) { if (cryptall) {
level = rxkad_crypt; level = tcp->cryptlevel = rxkad_crypt;
tcp->cryptlevel = rxkad_crypt; } else {
} else { level = tcp->cryptlevel = rxkad_clear;
level = rxkad_clear; }
}
secObjp = rxkad_NewClientSecurityObject(level, secObjp = rxkad_NewClientSecurityObject(level,
&ucellp->sessionKey, ucellp->kvno, &ucellp->sessionKey, ucellp->kvno,
ucellp->ticketLen, ucellp->ticketp); ucellp->ticketLen, ucellp->ticketp);
@ -523,61 +522,65 @@ static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
secIndex = 0; secIndex = 0;
secObjp = rxnull_NewClientSecurityObject(); secObjp = rxnull_NewClientSecurityObject();
} }
osi_assert(secObjp != NULL); osi_assert(secObjp != NULL);
tcp->callp = rx_NewConnection(serverp->addr.sin_addr.s_addr, tcp->callp = rx_NewConnection(serverp->addr.sin_addr.s_addr,
port, port,
serviceID, serviceID,
secObjp, secObjp,
secIndex); secIndex);
rx_SetConnDeadTime(tcp->callp, ConnDeadtimeout); rx_SetConnDeadTime(tcp->callp, ConnDeadtimeout);
rx_SetConnHardDeadTime(tcp->callp, HardDeadtimeout); rx_SetConnHardDeadTime(tcp->callp, HardDeadtimeout);
tcp->ucgen = ucellp->gen; tcp->ucgen = ucellp->gen;
if (secObjp) if (secObjp)
rxs_Release(secObjp); /* Decrement the initial refCount */ rxs_Release(secObjp); /* Decrement the initial refCount */
} }
long cm_ConnByServer(cm_server_t *serverp, cm_user_t *userp, cm_conn_t **connpp) 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; cm_ucell_t *ucellp;
lock_ObtainMutex(&userp->mx); lock_ObtainMutex(&userp->mx);
lock_ObtainWrite(&cm_connLock); lock_ObtainWrite(&cm_connLock);
for(tcp = serverp->connsp; tcp; tcp=tcp->nextp) { for (tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
if (tcp->userp == userp) if (tcp->userp == userp)
break; break;
} }
/* find ucell structure */ /* find ucell structure */
ucellp = cm_GetUCell(userp, serverp->cellp); ucellp = cm_GetUCell(userp, serverp->cellp);
if (!tcp) { if (!tcp) {
cm_GetServer(serverp); cm_GetServer(serverp);
tcp = malloc(sizeof(*tcp)); tcp = malloc(sizeof(*tcp));
memset(tcp, 0, sizeof(*tcp)); memset(tcp, 0, sizeof(*tcp));
tcp->nextp = serverp->connsp; tcp->nextp = serverp->connsp;
serverp->connsp = tcp; serverp->connsp = tcp;
cm_HoldUser(userp); cm_HoldUser(userp);
tcp->userp = userp; tcp->userp = userp;
lock_InitializeMutex(&tcp->mx, "cm_conn_t mutex"); lock_InitializeMutex(&tcp->mx, "cm_conn_t mutex");
lock_ObtainMutex(&tcp->mx);
tcp->serverp = serverp; tcp->serverp = serverp;
tcp->cryptlevel = rxkad_clear; tcp->cryptlevel = rxkad_clear;
cm_NewRXConnection(tcp, ucellp, serverp); cm_NewRXConnection(tcp, ucellp, serverp);
tcp->refCount = 1; tcp->refCount = 1;
} lock_ReleaseMutex(&tcp->mx);
else { } else {
if ((tcp->ucgen < ucellp->gen) || (tcp->cryptlevel != cryptall)) if ((tcp->ucgen < ucellp->gen) ||
{ (tcp->cryptlevel != (cryptall ? rxkad_crypt : rxkad_clear)))
rx_DestroyConnection(tcp->callp); {
cm_NewRXConnection(tcp, ucellp, serverp); lock_ObtainMutex(&tcp->mx);
} rx_DestroyConnection(tcp->callp);
cm_NewRXConnection(tcp, ucellp, serverp);
lock_ReleaseMutex(&tcp->mx);
}
tcp->refCount++; tcp->refCount++;
} }
lock_ReleaseWrite(&cm_connLock); lock_ReleaseWrite(&cm_connLock);
lock_ReleaseMutex(&userp->mx); 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); osi_Log1(afsd_logp, "cm_ConnByServer returning conn 0x%x", (long) tcp);
*connpp = tcp; *connpp = tcp;
return 0; 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 MAXNUMSYSNAMES 16 /* max that current constants allow */
#define MAXSYSNAME 128 /* max sysname (i.e. @sys) size */ #define MAXSYSNAME 128 /* max sysname (i.e. @sys) size */
extern char *cm_sysName; extern char * cm_sysName;
extern int cm_sysNameCount; extern unsigned int cm_sysNameCount;
extern char *cm_sysNameList[MAXNUMSYSNAMES]; extern char * cm_sysNameList[MAXNUMSYSNAMES];
#ifndef __CM_IOCTL_INTERFACES_ONLY__ #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) void cm_CheckServers(long flags, cm_cell_t *cellp)
{ {
/* ping all file servers, up or down, with unauthenticated connection, /* ping all file servers, up or down, with unauthenticated connection,
* to find out whether we have all our callbacks from the server still. * to find out whether we have all our callbacks from the server still.
* Also, ping down VLDBs. * 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; if ((cellp == NULL || cellp == tsp->cellp) &&
long code; ((wasDown && (flags & CM_FLAG_CHECKDOWNSERVERS)) ||
long secs; (!wasDown && (flags & CM_FLAG_CHECKUPSERVERS)))) {
long usecs;
int doPing; doPing = 1;
int serverType; } /* we're supposed to check this up/down server */
long now; lock_ReleaseMutex(&tsp->mx);
int wasDown;
cm_conn_t *connp; /* 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); 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); cm_PutServerNoLock(tsp);
} }
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
} }
void cm_InitServer(void) void cm_InitServer(void)
{ {
static osi_once_t once; static osi_once_t once;
if (osi_Once(&once)) { if (osi_Once(&once)) {
lock_InitializeRWLock(&cm_serverLock, "cm_serverLock"); lock_InitializeRWLock(&cm_serverLock, "cm_serverLock");
osi_EndOnce(&once); osi_EndOnce(&once);
} }
} }
void cm_GetServer(cm_server_t *serverp) 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) void cm_PutServer(cm_server_t *serverp)
{ {
lock_ObtainWrite(&cm_serverLock); lock_ObtainWrite(&cm_serverLock);
osi_assert(serverp->refCount-- > 0); osi_assert(serverp->refCount-- > 0);
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
} }
void cm_PutServerNoLock(cm_server_t *serverp) void cm_PutServerNoLock(cm_server_t *serverp)
{ {
osi_assert(serverp->refCount-- > 0); osi_assert(serverp->refCount-- > 0);
} }
void cm_SetServerPrefs(cm_server_t * serverp) void cm_SetServerPrefs(cm_server_t * serverp)
{ {
unsigned long serverAddr; /* in host byte order */ unsigned long serverAddr; /* in host byte order */
unsigned long myAddr, myNet, mySubnet;/* in host byte order */ unsigned long myAddr, myNet, mySubnet;/* in host byte order */
unsigned long netMask; unsigned long netMask;
int i; int i;
/* implement server prefs for fileservers only */ /* implement server prefs for fileservers only */
if ( serverp->type == CM_SERVER_FILE ) if ( serverp->type == CM_SERVER_FILE )
{ {
serverAddr = ntohl(serverp->addr.sin_addr.s_addr); serverAddr = ntohl(serverp->addr.sin_addr.s_addr);
serverp->ipRank = CM_IPRANK_LOW; /* default setings */ serverp->ipRank = CM_IPRANK_LOW; /* default setings */
for ( i=0; i < cm_noIPAddr; i++) for ( i=0; i < cm_noIPAddr; i++)
{ {
/* loop through all the client's IP address and compare /* loop through all the client's IP address and compare
** each of them against the server's IP address */ ** each of them against the server's IP address */
myAddr = cm_IPAddr[i]; myAddr = cm_IPAddr[i];
if ( IN_CLASSA(myAddr) ) if ( IN_CLASSA(myAddr) )
netMask = IN_CLASSA_NET; netMask = IN_CLASSA_NET;
else if ( IN_CLASSB(myAddr) ) else if ( IN_CLASSB(myAddr) )
netMask = IN_CLASSB_NET; netMask = IN_CLASSB_NET;
else if ( IN_CLASSC(myAddr) ) else if ( IN_CLASSC(myAddr) )
netMask = IN_CLASSC_NET; netMask = IN_CLASSC_NET;
else else
netMask = 0; netMask = 0;
myNet = myAddr & netMask; myNet = myAddr & netMask;
mySubnet = myAddr & cm_SubnetMask[i]; mySubnet = myAddr & cm_SubnetMask[i];
if ( (serverAddr & netMask) == myNet ) if ( (serverAddr & netMask) == myNet )
{ {
if ( (serverAddr & cm_SubnetMask[i]) == mySubnet) if ( (serverAddr & cm_SubnetMask[i]) == mySubnet)
{ {
if ( serverAddr == myAddr ) if ( serverAddr == myAddr )
serverp->ipRank = min(serverp->ipRank, serverp->ipRank = min(serverp->ipRank,
CM_IPRANK_TOP);/* same machine */ CM_IPRANK_TOP);/* same machine */
else serverp->ipRank = min(serverp->ipRank, else serverp->ipRank = min(serverp->ipRank,
CM_IPRANK_HI); /* same subnet */ CM_IPRANK_HI); /* same subnet */
} }
else serverp->ipRank = min(serverp->ipRank,CM_IPRANK_MED); else serverp->ipRank = min(serverp->ipRank,CM_IPRANK_MED);
/* same net */ /* same net */
} }
/* random between 0..15*/ /* random between 0..15*/
serverp->ipRank += min(serverp->ipRank, rand() % 0x000f); serverp->ipRank += min(serverp->ipRank, rand() % 0x000f);
} /* and of for loop */ } /* and of for loop */
} }
else else
serverp->ipRank = 10000 + (rand() % 0x00ff); /* VL server */ 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 *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)); memset(tsp, 0, sizeof(*tsp));
tsp->type = type; tsp->type = type;
tsp->cellp = cellp; tsp->cellp = cellp;
tsp->refCount = 1; tsp->refCount = 1;
lock_InitializeMutex(&tsp->mx, "cm_server_t mutex"); lock_InitializeMutex(&tsp->mx, "cm_server_t mutex");
tsp->addr = *socketp; tsp->addr = *socketp;
cm_SetServerPrefs(tsp); cm_SetServerPrefs(tsp);
lock_ObtainWrite(&cm_serverLock); /* get server lock */ lock_ObtainWrite(&cm_serverLock); /* get server lock */
tsp->allNextp = cm_allServersp; tsp->allNextp = cm_allServersp;
cm_allServersp = tsp; cm_allServersp = tsp;
lock_ReleaseWrite(&cm_serverLock); /* release server lock */ 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 */ /* find a server based on its properties */
cm_server_t *cm_FindServer(struct sockaddr_in *addrp, int type) 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); lock_ObtainWrite(&cm_serverLock);
for(tsp = cm_allServersp; tsp; tsp=tsp->allNextp) { for (tsp = cm_allServersp; tsp; tsp=tsp->allNextp) {
if (tsp->type == type && if (tsp->type == type &&
tsp->addr.sin_addr.s_addr == addrp->sin_addr.s_addr) break; 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) if (tsp)
cm_GetServerNoLock(tsp); cm_GetServerNoLock(tsp);
/* drop big table lock */ /* drop big table lock */
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
/* return what we found */ /* return what we found */
return tsp; return tsp;
} }
cm_serverRef_t *cm_NewServerRef(cm_server_t *serverp) cm_serverRef_t *cm_NewServerRef(cm_server_t *serverp)
{ {
cm_serverRef_t *tsrp; cm_serverRef_t *tsrp;
cm_GetServer(serverp); cm_GetServer(serverp);
tsrp = malloc(sizeof(*tsrp)); tsrp = malloc(sizeof(*tsrp));
tsrp->server = serverp; tsrp->server = serverp;
tsrp->status = not_busy; tsrp->status = not_busy;
tsrp->next = NULL; tsrp->next = NULL;
tsrp->refCount = 1; tsrp->refCount = 1;
return tsrp; return tsrp;
} }
long cm_ChecksumServerList(cm_serverRef_t *serversp) long cm_ChecksumServerList(cm_serverRef_t *serversp)
{ {
long sum = 0; long sum = 0;
int first = 1; int first = 1;
cm_serverRef_t *tsrp; cm_serverRef_t *tsrp;
lock_ObtainWrite(&cm_serverLock); lock_ObtainWrite(&cm_serverLock);
for (tsrp = serversp; tsrp; tsrp=tsrp->next) { for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
if (first) if (first)
first = 0; first = 0;
else else
sum <<= 1; sum <<= 1;
sum ^= (long) tsrp->server; sum ^= (long) tsrp->server;
} }
lock_ReleaseWrite(&cm_serverLock); 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) void cm_InsertServerList(cm_serverRef_t** list, cm_serverRef_t* element)
{ {
cm_serverRef_t *current=*list; cm_serverRef_t *current=*list;
unsigned short ipRank = element->server->ipRank; unsigned short ipRank = element->server->ipRank;
lock_ObtainWrite(&cm_serverLock); lock_ObtainWrite(&cm_serverLock);
element->refCount++; /* increase refCount */ element->refCount++; /* increase refCount */
/* insertion into empty list or at the beginning of the list */ /* insertion into empty list or at the beginning of the list */
if ( !current || (current->server->ipRank > ipRank) ) if ( !current || (current->server->ipRank > ipRank) )
{ {
element->next = *list; element->next = *list;
*list = element; *list = element;
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
return ; return ;
} }
while ( current->next ) /* find appropriate place to insert */ while ( current->next ) /* find appropriate place to insert */
{ {
if ( current->next->server->ipRank > ipRank ) if ( current->next->server->ipRank > ipRank )
break; break;
else current = current->next; else current = current->next;
} }
element->next = current->next; element->next = current->next;
current->next = element; current->next = element;
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
} }
/* /*
** Re-sort the server list with the modified rank ** Re-sort the server list with the modified rank
** returns 0 if element was changed successfully. ** 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) long cm_ChangeRankServer(cm_serverRef_t** list, cm_server_t* server)
{ {
cm_serverRef_t **current=list; cm_serverRef_t **current=list;
cm_serverRef_t *element=0; cm_serverRef_t *element=0;
/* if there is max of one element in the list, nothing to sort */ /* if there is max of one element in the list, nothing to sort */
if ( (!*current) || !((*current)->next) ) if ( (!*current) || !((*current)->next) )
return 1; /* list unchanged: return success */ return 1; /* list unchanged: return success */
lock_ObtainWrite(&cm_serverLock); lock_ObtainWrite(&cm_serverLock);
/* if the server is on the list, delete it from list */ /* if the server is on the list, delete it from list */
while ( *current ) while ( *current )
{ {
if ( (*current)->server == server) if ( (*current)->server == server)
{ {
element = (*current); element = (*current);
*current = (*current)->next; /* delete it */ *current = (*current)->next; /* delete it */
break; break;
} }
current = & ( (*current)->next); current = & ( (*current)->next);
} }
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
/* if this volume is not replicated on this server */ /* if this volume is not replicated on this server */
if (!element) if (!element)
return 1; /* server is not on list */ return 1; /* server is not on list */
/* re-insert deleted element into the list with modified rank*/ /* re-insert deleted element into the list with modified rank*/
cm_InsertServerList(list, element); cm_InsertServerList(list, element);
/* reduce refCount which was increased by cm_InsertServerList */ /* reduce refCount which was increased by cm_InsertServerList */
lock_ObtainWrite(&cm_serverLock); lock_ObtainWrite(&cm_serverLock);
element->refCount--; element->refCount--;
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
return 0; return 0;
} }
/* /*
** If there are more than one server on the list and the first n servers on ** 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) void cm_RandomizeServer(cm_serverRef_t** list)
{ {
int count, picked; int count, picked;
cm_serverRef_t* tsrp = *list, *lastTsrp; cm_serverRef_t* tsrp = *list, *lastTsrp;
unsigned short lowestRank; unsigned short lowestRank;
/* an empty list or a list with only one element */ /* an empty list or a list with only one element */
if ( !tsrp || ! tsrp->next ) if ( !tsrp || ! tsrp->next )
return ; return ;
lock_ObtainWrite(&cm_serverLock); lock_ObtainWrite(&cm_serverLock);
/* count the number of servers with the lowest rank */ /* count the number of servers with the lowest rank */
lowestRank = tsrp->server->ipRank; lowestRank = tsrp->server->ipRank;
for ( count=1, tsrp=tsrp->next; tsrp; tsrp=tsrp->next) for ( count=1, tsrp=tsrp->next; tsrp; tsrp=tsrp->next)
{ {
if ( tsrp->server->ipRank != lowestRank) if ( tsrp->server->ipRank != lowestRank)
break; break;
else else
count++; count++;
} }
/* if there is only one server with the lowest rank, we are done */ /* if there is only one server with the lowest rank, we are done */
if ( count <= 1 ) { if ( count <= 1 ) {
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
return ; return ;
} }
picked = rand() % count; picked = rand() % count;
if ( !picked ) { if ( !picked ) {
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
return ; return ;
} }
tsrp = *list; tsrp = *list;
while (--picked >= 0) while (--picked >= 0)
{ {
lastTsrp = tsrp; lastTsrp = tsrp;
tsrp = tsrp->next; tsrp = tsrp->next;
} }
lastTsrp->next = tsrp->next; /* delete random element from list*/ lastTsrp->next = tsrp->next; /* delete random element from list*/
tsrp->next = *list; /* insert element at the beginning of list */ tsrp->next = *list; /* insert element at the beginning of list */
*list = tsrp; *list = tsrp;
lock_ReleaseWrite(&cm_serverLock); lock_ReleaseWrite(&cm_serverLock);
} }
/* call cm_FreeServer while holding a write lock on cm_serverLock */ /* call cm_FreeServer while holding a write lock on cm_serverLock */
void cm_FreeServer(cm_server_t* serverp) 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 **current = list;
cm_serverRef_t **nextp = 0; cm_serverRef_t **nextp = 0;
cm_serverRef_t * next = 0; cm_serverRef_t * next = 0;
lock_ObtainWrite(&cm_serverLock); lock_ObtainWrite(&cm_serverLock);
@ -455,7 +457,7 @@ void cm_FreeServerList(cm_serverRef_t** list)
{ {
nextp = &(*current)->next; nextp = &(*current)->next;
if (--((*current)->refCount) == 0) { if (--((*current)->refCount) == 0) {
next = *nextp; next = *nextp;
cm_FreeServer((*current)->server); cm_FreeServer((*current)->server);
free(*current); free(*current);
*current = next; *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, extern long cm_Lookup(cm_scache_t *dscp, char *namep, long flags,
cm_user_t *userp, cm_req_t *reqp, cm_scache_t **outpScpp); 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, extern void cm_TryBulkStat(cm_scache_t *dscp, osi_hyper_t *offsetp,
cm_user_t *userp, cm_req_t *reqp); 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, 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); 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); 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; return 0;
} }
input = space; input = space;
memcpy(&setp, input, sizeof(afs_int32)); memcpy(&setp, input, sizeof(afs_int32));
input += sizeof(afs_int32); input += sizeof(afs_int32);
if (!setp) { if (!setp) {
fprintf(stderr,"No sysname name value was found\n"); fprintf(stderr,"No sysname name value was found\n");
return 1; return 1;
} }
printf("Current sysname%s", setp > 1 ? "s are" : " is"); printf("Current sysname%s", setp > 1 ? "s are" : " is");
for (; setp > 0; --setp ) { for (; setp > 0; --setp ) {
printf(" \'%s\'", input); printf(" \'%s\'", input);
input += strlen(input) + 1; input += strlen(input) + 1;
} }
printf("\n"); printf("\n");
return 0; return 0;
} }
@ -2943,7 +2943,7 @@ int argc;
char **argv; { char **argv; {
register afs_int32 code; register afs_int32 code;
register struct cmd_syndesc *ts; register struct cmd_syndesc *ts;
#ifdef AFS_AIX32_ENV #ifdef AFS_AIX32_ENV
/* /*
* The following signal action for AIX is necessary so that in case of a * 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"); cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
ts = cmd_CreateSyntax("sysname", SysNameCmd, 0, "get/set sysname (i.e. @sys) value"); 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"); ts = cmd_CreateSyntax("exportafs", ExportAfsCmd, 0, "enable/disable translators to AFS");
cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name"); cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "exporter name");