2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afs/param.h>
20 #include <afs/unified_afs.h>
21 #include <afs/vlserver.h>
22 #include <WINNT/afsreg.h>
24 osi_rwlock_t cm_connLock;
26 DWORD RDRtimeout = CM_CONN_DEFAULTRDRTIMEOUT;
27 unsigned short ConnDeadtimeout = CM_CONN_CONNDEADTIME;
28 unsigned short HardDeadtimeout = CM_CONN_HARDDEADTIME;
29 unsigned short IdleDeadtimeout = CM_CONN_IDLEDEADTIME;
30 unsigned short NatPingInterval = CM_CONN_NATPINGINTERVAL;
32 #define LANMAN_WKS_PARAM_KEY "SYSTEM\\CurrentControlSet\\Services\\lanmanworkstation\\parameters"
33 #define LANMAN_WKS_SESSION_TIMEOUT "SessTimeout"
34 #define LANMAN_WKS_EXT_SESSION_TIMEOUT "ExtendedSessTimeout"
36 afs_uint32 cryptall = 0;
37 afs_uint32 cm_anonvldb = 0;
39 void cm_PutConn(cm_conn_t *connp)
41 afs_int32 refCount = InterlockedDecrement(&connp->refCount);
42 osi_assertx(refCount >= 0, "cm_conn_t refcount underflow");
45 void cm_InitConn(void)
47 static osi_once_t once;
53 if (osi_Once(&once)) {
54 lock_InitializeRWLock(&cm_connLock, "connection global lock",
55 LOCK_HIERARCHY_CONN_GLOBAL);
57 /* keisa - read timeout value for lanmanworkstation service.
59 * http://support.microsoft.com:80/support/kb/articles/Q102/0/67.asp&NoWebContent=1
60 * the SessTimeout is a minimum timeout not a maximum timeout. Therefore,
61 * I believe that the default should not be short. Instead, we should wait until
62 * RX times out before reporting a timeout to the SMB client.
64 code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, LANMAN_WKS_PARAM_KEY,
65 0, KEY_QUERY_VALUE, &parmKey);
66 if (code == ERROR_SUCCESS)
68 BOOL extTimeouts = msftSMBRedirectorSupportsExtendedTimeouts();
72 * The default value is 1000 seconds. However, this default
73 * will not apply to "\\AFS" unless "AFS" is listed in
74 * ServersWithExtendedSessTimeout which we will add when we
75 * create the ExtendedSessTimeout value in smb_Init()
77 dummyLen = sizeof(DWORD);
78 code = RegQueryValueEx(parmKey,
79 LANMAN_WKS_EXT_SESSION_TIMEOUT,
81 (BYTE *) &dwValue, &dummyLen);
82 if (code == ERROR_SUCCESS) {
84 afsi_log("lanmanworkstation : ExtSessTimeout %u", RDRtimeout);
87 if (!extTimeouts || code != ERROR_SUCCESS) {
88 dummyLen = sizeof(DWORD);
89 code = RegQueryValueEx(parmKey,
90 LANMAN_WKS_SESSION_TIMEOUT,
92 (BYTE *) &dwValue, &dummyLen);
93 if (code == ERROR_SUCCESS) {
95 afsi_log("lanmanworkstation : SessTimeout %u", RDRtimeout);
101 code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
102 0, KEY_QUERY_VALUE, &parmKey);
103 if (code == ERROR_SUCCESS) {
104 dummyLen = sizeof(DWORD);
105 code = RegQueryValueEx(parmKey, "ConnDeadTimeout", NULL, NULL,
106 (BYTE *) &dwValue, &dummyLen);
107 if (code == ERROR_SUCCESS) {
108 ConnDeadtimeout = (unsigned short)dwValue;
109 afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
111 dummyLen = sizeof(DWORD);
112 code = RegQueryValueEx(parmKey, "HardDeadTimeout", NULL, NULL,
113 (BYTE *) &dwValue, &dummyLen);
114 if (code == ERROR_SUCCESS) {
115 HardDeadtimeout = (unsigned short)dwValue;
116 afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
118 dummyLen = sizeof(DWORD);
119 code = RegQueryValueEx(parmKey, "IdleDeadTimeout", NULL, NULL,
120 (BYTE *) &dwValue, &dummyLen);
121 if (code == ERROR_SUCCESS) {
122 IdleDeadtimeout = (unsigned short)dwValue;
123 afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
125 dummyLen = sizeof(DWORD);
126 code = RegQueryValueEx(parmKey, "NatPingInterval", NULL, NULL,
127 (BYTE *) &dwValue, &dummyLen);
128 if (code == ERROR_SUCCESS) {
129 NatPingInterval = (unsigned short)dwValue;
131 afsi_log("NatPingInterval is %d", NatPingInterval);
132 RegCloseKey(parmKey);
136 * If these values were not set via cpp macro or obtained
137 * from the registry, we use a value that is derived from
138 * the smb redirector session timeout (RDRtimeout).
140 * The UNIX cache manager uses 120 seconds for the hard dead
141 * timeout and 50 seconds for the connection and idle timeouts.
143 * We base our values on those while making sure we leave
144 * enough time for overhead.
146 if (ConnDeadtimeout == 0) {
147 ConnDeadtimeout = (unsigned short) ((RDRtimeout / 2) < 50 ? (RDRtimeout / 2) : 50);
148 afsi_log("ConnDeadTimeout is %d", ConnDeadtimeout);
150 if (HardDeadtimeout == 0) {
151 HardDeadtimeout = (unsigned short) (RDRtimeout > 125 ? 120 : (RDRtimeout - 5));
152 afsi_log("HardDeadTimeout is %d", HardDeadtimeout);
154 if (IdleDeadtimeout == 0) {
155 IdleDeadtimeout = (unsigned short) ConnDeadtimeout;
156 afsi_log("IdleDeadTimeout is %d", IdleDeadtimeout);
162 void cm_InitReq(cm_req_t *reqp)
164 memset(reqp, 0, sizeof(cm_req_t));
165 reqp->startTime = GetTickCount();
168 static long cm_GetServerList(struct cm_fid *fidp, struct cm_user *userp,
169 struct cm_req *reqp, cm_serverRef_t ***serversppp)
172 cm_volume_t *volp = NULL;
173 cm_cell_t *cellp = NULL;
177 return CM_ERROR_INVAL;
180 cellp = cm_FindCellByID(fidp->cell, 0);
182 return CM_ERROR_NOSUCHCELL;
184 code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, CM_GETVOL_FLAG_CREATE, &volp);
188 *serversppp = cm_GetVolServers(volp, fidp->volume, userp, reqp);
190 lock_ObtainRead(&cm_volumeLock);
192 lock_ReleaseRead(&cm_volumeLock);
193 return (*serversppp ? 0 : CM_ERROR_NOSUCHVOLUME);
197 * Analyze the error return from an RPC. Determine whether or not to retry,
198 * and if we're going to retry, determine whether failover is appropriate,
199 * and whether timed backoff is appropriate.
201 * If the error code is from cm_ConnFromFID() or friends, it will be a CM_ERROR code.
202 * Otherwise it will be an RPC code. This may be a UNIX code (e.g. EDQUOT), or
203 * it may be an RX code, or it may be a special code (e.g. VNOVOL), or it may
204 * be a security code (e.g. RXKADEXPIRED).
206 * If the error code is from cm_ConnFromFID() or friends, connp will be NULL.
208 * For VLDB calls, fidp will be NULL.
210 * volSyncp and/or cbrp may also be NULL.
213 cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
215 AFSVolSync *volSyncp,
216 cm_serverRef_t * serversp,
217 cm_callbackRequest_t *cbrp, long errorCode)
219 cm_server_t *serverp = NULL;
220 cm_serverRef_t **serverspp = NULL;
221 cm_serverRef_t *tsrp;
222 cm_cell_t *cellp = NULL;
224 cm_volume_t * volp = NULL;
225 cm_vol_state_t *statep = NULL;
227 int free_svr_list = 0;
229 long timeUsed, timeLeft;
231 char addr[16]="unknown";
236 osi_Log2(afsd_logp, "cm_Analyze connp 0x%p, code 0x%x",
239 /* no locking required, since connp->serverp never changes after
241 dead_session = (userp->cellInfop == NULL);
243 serverp = connp->serverp;
245 /* Update callback pointer */
246 if (cbrp && serverp && errorCode == 0) {
248 if ( cbrp->serverp != serverp ) {
249 lock_ObtainWrite(&cm_serverLock);
250 cm_PutServerNoLock(cbrp->serverp);
251 cm_GetServerNoLock(serverp);
252 lock_ReleaseWrite(&cm_serverLock);
255 cm_GetServer(serverp);
257 lock_ObtainWrite(&cm_callbackLock);
258 cbrp->serverp = serverp;
259 lock_ReleaseWrite(&cm_callbackLock);
262 /* if timeout - check that it did not exceed the HardDead timeout
265 /* timeleft - get it from reqp the same way as cm_ConnByMServers does */
266 timeUsed = (GetTickCount() - reqp->startTime) / 1000;
267 timeLeft = HardDeadtimeout - timeUsed;
269 /* get a pointer to the cell */
271 if (cellp == NULL && serverp)
272 cellp = serverp->cellp;
273 if (cellp == NULL && serversp) {
274 struct cm_serverRef * refp;
275 for ( refp=serversp ; cellp == NULL && refp != NULL; refp=refp->next) {
276 if (refp->status == srv_deleted)
279 cellp = refp->server->cellp;
282 if (cellp == NULL && fidp) {
283 cellp = cm_FindCellByID(fidp->cell, 0);
287 if (errorCode == CM_ERROR_TIMEDOUT) {
288 if ( timeLeft > 5 ) {
290 cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, cellp);
295 else if (errorCode == UAEWOULDBLOCK || errorCode == EWOULDBLOCK ||
296 errorCode == UAEAGAIN || errorCode == EAGAIN) {
297 osi_Log0(afsd_logp, "cm_Analyze passed EWOULDBLOCK or EAGAIN.");
298 if ( timeLeft > 5 ) {
304 /* if there is nosuchvolume, then we have a situation in which a
305 * previously known volume no longer has a set of servers
306 * associated with it. Either the volume has moved or
307 * the volume has been deleted. Try to find a new server list
308 * until the timeout period expires.
310 else if (errorCode == CM_ERROR_NOSUCHVOLUME) {
311 osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_NOSUCHVOLUME.");
313 * The VNOVOL or VL_NOENT error has already been translated
314 * to CM_ERROR_NOSUCHVOLUME. There is nothing for us to do.
318 else if (errorCode == CM_ERROR_ALLDOWN) {
319 /* Servers marked DOWN will be restored by the background daemon
320 * thread as they become available. The volume status is
321 * updated as the server state changes.
324 osi_Log2(afsd_logp, "cm_Analyze passed CM_ERROR_DOWN (FS cell %s vol 0x%x)",
325 cellp->name, fidp->volume);
326 msgID = MSG_ALL_SERVERS_DOWN;
327 format = "All servers are unreachable when accessing cell %s volume %d.";
328 LogEvent(EVENTLOG_WARNING_TYPE, msgID, cellp->name, fidp->volume);
330 osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLDOWN (VL Server)");
334 else if (errorCode == CM_ERROR_ALLOFFLINE) {
335 /* Volume instances marked offline will be restored by the
336 * background daemon thread as they become available
339 osi_Log2(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE (FS cell %s vol 0x%x)",
340 cellp->name, fidp->volume);
341 msgID = MSG_ALL_SERVERS_OFFLINE;
342 format = "All servers are offline when accessing cell %s volume %d.";
343 LogEvent(EVENTLOG_WARNING_TYPE, msgID, cellp->name, fidp->volume);
345 code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp,
346 CM_GETVOL_FLAG_NO_LRU_UPDATE,
352 /* cm_CheckOfflineVolume() resets the serverRef state */
353 if (cm_CheckOfflineVolume(volp, fidp->volume))
356 cm_UpdateVolumeStatus(volp, fidp->volume);
358 lock_ObtainRead(&cm_volumeLock);
360 lock_ReleaseRead(&cm_volumeLock);
364 osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE (VL Server)");
367 else if (errorCode == CM_ERROR_ALLBUSY) {
368 /* Volumes that are busy cannot be determined to be non-busy
369 * without actually attempting to access them.
371 if (fidp) { /* File Server query */
372 osi_Log2(afsd_logp, "cm_Analyze passed CM_ERROR_ALLBUSY (FS cell %s vol 0x%x)",
373 cellp->name, fidp->volume);
374 msgID = MSG_ALL_SERVERS_BUSY;
375 format = "All servers are busy when accessing cell %s volume %d.";
376 LogEvent(EVENTLOG_WARNING_TYPE, msgID, cellp->name, fidp->volume);
378 code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp,
379 CM_GETVOL_FLAG_NO_LRU_UPDATE,
385 statep = cm_VolumeStateByID(volp, fidp->volume);
386 if (statep->state != vl_offline &&
387 statep->state != vl_busy &&
388 statep->state != vl_unknown) {
392 code = cm_GetServerList(fidp, userp, reqp, &serverspp);
394 serversp = *serverspp;
398 lock_ObtainWrite(&cm_serverLock);
399 for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
400 if (tsrp->status == srv_deleted)
402 if (tsrp->status == srv_busy) {
403 tsrp->status = srv_not_busy;
406 lock_ReleaseWrite(&cm_serverLock);
408 cm_FreeServerList(serverspp, 0);
413 cm_UpdateVolumeStatus(volp, fidp->volume);
417 cm_UpdateVolumeStatus(volp, fidp->volume);
420 lock_ObtainRead(&cm_volumeLock);
422 lock_ReleaseRead(&cm_volumeLock);
425 } else { /* VL Server query */
426 osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLBUSY (VL Server).");
432 lock_ObtainWrite(&cm_serverLock);
433 for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
434 if (tsrp->status == srv_deleted)
436 if (tsrp->status == srv_busy) {
437 tsrp->status = srv_not_busy;
440 lock_ReleaseWrite(&cm_serverLock);
447 /* special codes: VBUSY and VRESTARTING */
448 else if (errorCode == VBUSY || errorCode == VRESTARTING) {
449 if (!serversp && fidp) {
450 code = cm_GetServerList(fidp, userp, reqp, &serverspp);
452 serversp = *serverspp;
457 switch ( errorCode ) {
459 msgID = MSG_SERVER_REPORTS_VBUSY;
460 format = "Server %s reported busy when accessing volume %d.";
463 msgID = MSG_SERVER_REPORTS_VRESTARTING;
464 format = "Server %s reported restarting when accessing volume %d.";
468 if (serverp && fidp) {
469 /* Log server being offline for this volume */
470 sprintf(addr, "%d.%d.%d.%d",
471 ((serverp->addr.sin_addr.s_addr & 0xff)),
472 ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
473 ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
474 ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
476 osi_Log2(afsd_logp, format, osi_LogSaveString(afsd_logp,addr), fidp->volume);
477 LogEvent(EVENTLOG_WARNING_TYPE, msgID, addr, fidp->volume);
480 lock_ObtainWrite(&cm_serverLock);
481 for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
482 if (tsrp->status == srv_deleted)
484 if (tsrp->server == serverp && tsrp->status == srv_not_busy) {
485 tsrp->status = srv_busy;
486 if (fidp) { /* File Server query */
487 lock_ReleaseWrite(&cm_serverLock);
488 code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp,
489 CM_GETVOL_FLAG_NO_LRU_UPDATE,
492 statep = cm_VolumeStateByID(volp, fidp->volume);
493 lock_ObtainWrite(&cm_serverLock);
498 lock_ReleaseWrite(&cm_serverLock);
501 cm_UpdateVolumeStatus(volp, statep->ID);
502 lock_ObtainRead(&cm_volumeLock);
504 lock_ReleaseRead(&cm_volumeLock);
509 cm_FreeServerList(serverspp, 0);
516 /* special codes: missing volumes */
517 else if (errorCode == VNOVOL || errorCode == VMOVED || errorCode == VOFFLINE ||
518 errorCode == VSALVAGE || errorCode == VNOSERVICE || errorCode == VIO)
520 /* In case of timeout */
521 reqp->volumeError = errorCode;
523 switch ( errorCode ) {
525 msgID = MSG_SERVER_REPORTS_VNOVOL;
526 format = "Server %s reported volume %d as not attached (does not exist).";
529 msgID = MSG_SERVER_REPORTS_VMOVED;
530 format = "Server %s reported volume %d as moved.";
533 msgID = MSG_SERVER_REPORTS_VOFFLINE;
534 format = "Server %s reported volume %d as offline.";
537 msgID = MSG_SERVER_REPORTS_VSALVAGE;
538 format = "Server %s reported volume %d as needs salvage.";
541 msgID = MSG_SERVER_REPORTS_VNOSERVICE;
542 format = "Server %s reported volume %d as not in service.";
545 msgID = MSG_SERVER_REPORTS_VIO;
546 format = "Server %s reported volume %d as temporarily unaccessible.";
550 if (serverp && fidp) {
551 /* Log server being offline for this volume */
552 sprintf(addr, "%d.%d.%d.%d",
553 ((serverp->addr.sin_addr.s_addr & 0xff)),
554 ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
555 ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
556 ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
558 osi_Log2(afsd_logp, format, osi_LogSaveString(afsd_logp,addr), fidp->volume);
559 LogEvent(EVENTLOG_WARNING_TYPE, msgID, addr, fidp->volume);
563 * Mark server offline for this volume or delete the volume
564 * from the server list if it was moved or is not present.
566 if (!serversp && fidp) {
567 code = cm_GetServerList(fidp, userp, reqp, &serverspp);
569 serversp = *serverspp;
574 lock_ObtainWrite(&cm_serverLock);
575 for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
576 if (tsrp->status == srv_deleted)
579 sprintf(addr, "%d.%d.%d.%d",
580 ((tsrp->server->addr.sin_addr.s_addr & 0xff)),
581 ((tsrp->server->addr.sin_addr.s_addr & 0xff00)>> 8),
582 ((tsrp->server->addr.sin_addr.s_addr & 0xff0000)>> 16),
583 ((tsrp->server->addr.sin_addr.s_addr & 0xff000000)>> 24));
585 if (tsrp->server == serverp) {
587 if (errorCode == VMOVED || errorCode == VNOVOL) {
588 osi_Log2(afsd_logp, "volume %d not present on server %s",
589 fidp->volume, osi_LogSaveString(afsd_logp,addr));
590 tsrp->status = srv_deleted;
592 cm_RemoveVolumeFromServer(serverp, fidp->volume);
594 osi_Log2(afsd_logp, "volume %d instance on server %s marked offline",
595 fidp->volume, osi_LogSaveString(afsd_logp,addr));
596 tsrp->status = srv_offline;
600 osi_Log3(afsd_logp, "volume %d exists on server %s with status %u",
601 fidp->volume, osi_LogSaveString(afsd_logp,addr), tsrp->status);
604 lock_ReleaseWrite(&cm_serverLock);
606 /* Free the server list before cm_ForceUpdateVolume is called */
608 cm_FreeServerList(serverspp, 0);
613 if (fidp) { /* File Server query */
614 code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp,
615 CM_GETVOL_FLAG_NO_LRU_UPDATE,
618 statep = cm_VolumeStateByID(volp, fidp->volume);
620 if ((errorCode == VMOVED || errorCode == VNOVOL) &&
621 !(reqp->flags & CM_REQ_VOLUME_UPDATED))
623 code = cm_ForceUpdateVolume(fidp, userp, reqp);
625 timeLeft = 0; /* prevent a retry on failure */
627 reqp->flags |= CM_REQ_VOLUME_UPDATED;
628 osi_Log3(afsd_logp, "cm_Analyze called cm_ForceUpdateVolume cell %u vol %u code 0x%x",
629 fidp->cell, fidp->volume, code);
633 cm_UpdateVolumeStatus(volp, statep->ID);
634 osi_Log3(afsd_logp, "cm_Analyze NewVolState cell %u vol %u state %u",
635 fidp->cell, fidp->volume, statep->state);
639 lock_ObtainRead(&cm_volumeLock);
641 lock_ReleaseRead(&cm_volumeLock);
648 } else if ( errorCode == VNOVNODE ) {
651 osi_Log4(afsd_logp, "cm_Analyze passed VNOVNODE cell %u vol %u vn %u uniq %u.",
652 fidp->cell, fidp->volume, fidp->vnode, fidp->unique);
654 scp = cm_FindSCache(fidp);
656 cm_scache_t *pscp = NULL;
658 if (scp->fileType != CM_SCACHETYPE_DIRECTORY)
659 pscp = cm_FindSCacheParent(scp);
661 lock_ObtainWrite(&scp->rw);
662 lock_ObtainWrite(&cm_scacheLock);
663 cm_RemoveSCacheFromHashTable(scp);
664 lock_ReleaseWrite(&cm_scacheLock);
665 cm_LockMarkSCacheLost(scp);
666 scp->flags |= CM_SCACHEFLAG_DELETED;
667 lock_ReleaseWrite(&scp->rw);
668 cm_ReleaseSCache(scp);
671 if (cm_HaveCallback(pscp)) {
672 lock_ObtainWrite(&pscp->rw);
673 cm_DiscardSCache(pscp);
674 lock_ReleaseWrite(&pscp->rw);
676 cm_ReleaseSCache(pscp);
680 osi_Log0(afsd_logp, "cm_Analyze passed VNOVNODE unknown fid.");
685 else if (errorCode == RX_CALL_TIMEOUT) {
686 /* RPC took longer than hardDeadTime or the server
687 * reported idle for longer than idleDeadTime
688 * don't mark server as down but don't retry
689 * this is to prevent the SMB session from timing out
690 * In addition, we log an event to the event log
694 sprintf(addr, "%d.%d.%d.%d",
695 ((serverp->addr.sin_addr.s_addr & 0xff)),
696 ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
697 ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
698 ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
700 LogEvent(EVENTLOG_WARNING_TYPE, MSG_RX_HARD_DEAD_TIME_EXCEEDED, addr);
701 osi_Log1(afsd_logp, "cm_Analyze: hardDeadTime or idleDeadtime exceeded addr[%s]",
702 osi_LogSaveString(afsd_logp,addr));
703 reqp->tokenIdleErrorServp = serverp;
707 if (!fidp) { /* vldb */
710 cm_volume_t *volp = cm_GetVolumeByFID(fidp);
712 if (fidp->volume == cm_GetROVolumeID(volp))
720 else if (errorCode >= -64 && errorCode < 0) {
721 /* mark server as down */
723 sprintf(addr, "%d.%d.%d.%d",
724 ((serverp->addr.sin_addr.s_addr & 0xff)),
725 ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
726 ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
727 ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
729 if (errorCode == RX_CALL_DEAD)
730 osi_Log2(afsd_logp, "cm_Analyze: Rx Call Dead addr[%s] forcedNew[%s]",
731 osi_LogSaveString(afsd_logp,addr),
732 (reqp->flags & CM_REQ_NEW_CONN_FORCED ? "yes" : "no"));
734 osi_Log3(afsd_logp, "cm_Analyze: Rx Misc Error[%d] addr[%s] forcedNew[%s]",
736 osi_LogSaveString(afsd_logp,addr),
737 (reqp->flags & CM_REQ_NEW_CONN_FORCED ? "yes" : "no"));
740 lock_ObtainMutex(&serverp->mx);
741 if (errorCode == RX_CALL_DEAD &&
742 (reqp->flags & CM_REQ_NEW_CONN_FORCED)) {
743 if (!(serverp->flags & CM_SERVERFLAG_DOWN)) {
744 serverp->flags |= CM_SERVERFLAG_DOWN;
745 serverp->downTime = time(NULL);
748 if (reqp->flags & CM_REQ_NEW_CONN_FORCED) {
749 reqp->tokenIdleErrorServp = serverp;
750 reqp->tokenError = errorCode;
752 reqp->flags |= CM_REQ_NEW_CONN_FORCED;
756 lock_ReleaseMutex(&serverp->mx);
757 cm_ForceNewConnections(serverp);
762 else if (errorCode == RXKADEXPIRED) {
763 osi_Log1(afsd_logp, "cm_Analyze: rxkad error code 0x%x (RXKADEXPIRED)",
766 lock_ObtainMutex(&userp->mx);
767 ucellp = cm_GetUCell(userp, serverp->cellp);
768 if (ucellp->ticketp) {
769 free(ucellp->ticketp);
770 ucellp->ticketp = NULL;
772 ucellp->flags &= ~CM_UCELLFLAG_RXKAD;
774 lock_ReleaseMutex(&userp->mx);
778 } else if (errorCode >= ERROR_TABLE_BASE_RXK && errorCode < ERROR_TABLE_BASE_RXK + 256) {
779 char * s = "unknown error";
780 switch ( errorCode ) {
781 case RXKADINCONSISTENCY: s = "RXKADINCONSISTENCY"; break;
782 case RXKADPACKETSHORT : s = "RXKADPACKETSHORT"; break;
783 case RXKADLEVELFAIL : s = "RXKADLEVELFAIL"; break;
784 case RXKADTICKETLEN : s = "RXKADTICKETLEN"; break;
785 case RXKADOUTOFSEQUENCE: s = "RXKADOUTOFSEQUENCE"; break;
786 case RXKADNOAUTH : s = "RXKADNOAUTH"; break;
787 case RXKADBADKEY : s = "RXKADBADKEY"; break;
788 case RXKADBADTICKET : s = "RXKADBADTICKET"; break;
789 case RXKADUNKNOWNKEY : s = "RXKADUNKNOWNKEY"; break;
790 case RXKADEXPIRED : s = "RXKADEXPIRED"; break;
791 case RXKADSEALEDINCON : s = "RXKADSEALEDINCON"; break;
792 case RXKADDATALEN : s = "RXKADDATALEN"; break;
793 case RXKADILLEGALLEVEL : s = "RXKADILLEGALLEVEL"; break;
795 osi_Log2(afsd_logp, "cm_Analyze: rxkad error code 0x%x (%s)",
799 reqp->tokenIdleErrorServp = serverp;
800 reqp->tokenError = errorCode;
803 } else if (errorCode >= ERROR_TABLE_BASE_U && errorCode < ERROR_TABLE_BASE_U + 256) {
805 * We received a ubik error. its possible that the server we are
806 * communicating with has a corrupted database or is partitioned
807 * from the rest of the servers and another server might be able
808 * to answer our query. Therefore, we will retry the request
809 * and force the use of another server.
812 reqp->tokenIdleErrorServp = serverp;
813 reqp->tokenError = errorCode;
816 } else if (errorCode == VICECONNBAD || errorCode == VICETOKENDEAD) {
817 cm_ForceNewConnections(serverp);
822 char * s = "unknown error";
823 switch ( errorCode ) {
824 case VSALVAGE : s = "VSALVAGE"; break;
825 case VNOVNODE : s = "VNOVNODE"; break;
826 case VNOVOL : s = "VNOVOL"; break;
827 case VVOLEXISTS : s = "VVOLEXISTS"; break;
828 case VNOSERVICE : s = "VNOSERVICE"; break;
829 case VOFFLINE : s = "VOFFLINE"; break;
830 case VONLINE : s = "VONLINE"; break;
831 case VDISKFULL : s = "VDISKFULL"; break;
832 case VOVERQUOTA : s = "VOVERQUOTA"; break;
833 case VBUSY : s = "VBUSY"; break;
834 case VMOVED : s = "VMOVED"; break;
835 case VIO : s = "VIO"; break;
836 case VRESTRICTED : s = "VRESTRICTED"; break;
837 case VRESTARTING : s = "VRESTARTING"; break;
838 case VREADONLY : s = "VREADONLY"; break;
839 case EAGAIN : s = "EAGAIN"; break;
840 case UAEAGAIN : s = "UAEAGAIN"; break;
841 case EINVAL : s = "EINVAL"; break;
842 case UAEINVAL : s = "UAEINVAL"; break;
843 case EACCES : s = "EACCES"; break;
844 case UAEACCES : s = "UAEACCES"; break;
845 case ENOENT : s = "ENOENT"; break;
846 case UAENOENT : s = "UAENOENT"; break;
847 case EEXIST : s = "EEXIST"; break;
848 case UAEEXIST : s = "UAEEXIST"; break;
849 case VICECONNBAD : s = "VICECONNBAD"; break;
850 case VICETOKENDEAD : s = "VICETOKENDEAD"; break;
851 case WSAEWOULDBLOCK : s = "WSAEWOULDBLOCK"; break;
852 case UAEWOULDBLOCK : s = "UAEWOULDBLOCK"; break;
853 case VL_IDEXIST : s = "VL_IDEXIST"; break;
854 case VL_IO : s = "VL_IO"; break;
855 case VL_NAMEEXIST : s = "VL_NAMEEXIST"; break;
856 case VL_CREATEFAIL : s = "VL_CREATEFAIL"; break;
857 case VL_NOENT : s = "VL_NOENT"; break;
858 case VL_EMPTY : s = "VL_EMPTY"; break;
859 case VL_ENTDELETED : s = "VL_ENTDELETED"; break;
860 case VL_BADNAME : s = "VL_BADNAME"; break;
861 case VL_BADINDEX : s = "VL_BADINDEX"; break;
862 case VL_BADVOLTYPE : s = "VL_BADVOLTYPE"; break;
863 case VL_BADSERVER : s = "VL_BADSERVER"; break;
864 case VL_BADPARTITION : s = "VL_BADPARTITION"; break;
865 case VL_REPSFULL : s = "VL_REPSFULL"; break;
866 case VL_NOREPSERVER : s = "VL_NOREPSERVER"; break;
867 case VL_DUPREPSERVER : s = "VL_DUPREPSERVER"; break;
868 case VL_RWNOTFOUND : s = "VL_RWNOTFOUND"; break;
869 case VL_BADREFCOUNT : s = "VL_BADREFCOUNT"; break;
870 case VL_SIZEEXCEEDED : s = "VL_SIZEEXCEEDED"; break;
871 case VL_BADENTRY : s = "VL_BADENTRY"; break;
872 case VL_BADVOLIDBUMP : s = "VL_BADVOLIDBUMP"; break;
873 case VL_IDALREADYHASHED: s = "VL_IDALREADYHASHED"; break;
874 case VL_ENTRYLOCKED : s = "VL_ENTRYLOCKED"; break;
875 case VL_BADVOLOPER : s = "VL_BADVOLOPER"; break;
876 case VL_BADRELLOCKTYPE : s = "VL_BADRELLOCKTYPE"; break;
877 case VL_RERELEASE : s = "VL_RERELEASE"; break;
878 case VL_BADSERVERFLAG : s = "VL_BADSERVERFLAG"; break;
879 case VL_PERM : s = "VL_PERM"; break;
880 case VL_NOMEM : s = "VL_NOMEM"; break;
881 case VL_BADVERSION : s = "VL_BADVERSION"; break;
882 case VL_INDEXERANGE : s = "VL_INDEXERANGE"; break;
883 case VL_MULTIPADDR : s = "VL_MULTIPADDR"; break;
884 case VL_BADMASK : s = "VL_BADMASK"; break;
885 case CM_ERROR_NOSUCHCELL : s = "CM_ERROR_NOSUCHCELL"; break;
886 case CM_ERROR_NOSUCHVOLUME : s = "CM_ERROR_NOSUCHVOLUME"; break;
887 case CM_ERROR_TIMEDOUT : s = "CM_ERROR_TIMEDOUT"; break;
888 case CM_ERROR_RETRY : s = "CM_ERROR_RETRY"; break;
889 case CM_ERROR_NOACCESS : s = "CM_ERROR_NOACCESS"; break;
890 case CM_ERROR_NOSUCHFILE : s = "CM_ERROR_NOSUCHFILE"; break;
891 case CM_ERROR_STOPNOW : s = "CM_ERROR_STOPNOW"; break;
892 case CM_ERROR_TOOBIG : s = "CM_ERROR_TOOBIG"; break;
893 case CM_ERROR_INVAL : s = "CM_ERROR_INVAL"; break;
894 case CM_ERROR_BADFD : s = "CM_ERROR_BADFD"; break;
895 case CM_ERROR_BADFDOP : s = "CM_ERROR_BADFDOP"; break;
896 case CM_ERROR_EXISTS : s = "CM_ERROR_EXISTS"; break;
897 case CM_ERROR_CROSSDEVLINK : s = "CM_ERROR_CROSSDEVLINK"; break;
898 case CM_ERROR_BADOP : s = "CM_ERROR_BADOP"; break;
899 case CM_ERROR_BADPASSWORD : s = "CM_ERROR_BADPASSWORD"; break;
900 case CM_ERROR_NOTDIR : s = "CM_ERROR_NOTDIR"; break;
901 case CM_ERROR_ISDIR : s = "CM_ERROR_ISDIR"; break;
902 case CM_ERROR_READONLY : s = "CM_ERROR_READONLY"; break;
903 case CM_ERROR_WOULDBLOCK : s = "CM_ERROR_WOULDBLOCK"; break;
904 case CM_ERROR_QUOTA : s = "CM_ERROR_QUOTA"; break;
905 case CM_ERROR_SPACE : s = "CM_ERROR_SPACE"; break;
906 case CM_ERROR_BADSHARENAME : s = "CM_ERROR_BADSHARENAME"; break;
907 case CM_ERROR_BADTID : s = "CM_ERROR_BADTID"; break;
908 case CM_ERROR_UNKNOWN : s = "CM_ERROR_UNKNOWN"; break;
909 case CM_ERROR_NOMORETOKENS : s = "CM_ERROR_NOMORETOKENS"; break;
910 case CM_ERROR_NOTEMPTY : s = "CM_ERROR_NOTEMPTY"; break;
911 case CM_ERROR_USESTD : s = "CM_ERROR_USESTD"; break;
912 case CM_ERROR_REMOTECONN : s = "CM_ERROR_REMOTECONN"; break;
913 case CM_ERROR_ATSYS : s = "CM_ERROR_ATSYS"; break;
914 case CM_ERROR_NOSUCHPATH : s = "CM_ERROR_NOSUCHPATH"; break;
915 case CM_ERROR_CLOCKSKEW : s = "CM_ERROR_CLOCKSKEW"; break;
916 case CM_ERROR_BADSMB : s = "CM_ERROR_BADSMB"; break;
917 case CM_ERROR_ALLBUSY : s = "CM_ERROR_ALLBUSY"; break;
918 case CM_ERROR_NOFILES : s = "CM_ERROR_NOFILES"; break;
919 case CM_ERROR_PARTIALWRITE : s = "CM_ERROR_PARTIALWRITE"; break;
920 case CM_ERROR_NOIPC : s = "CM_ERROR_NOIPC"; break;
921 case CM_ERROR_BADNTFILENAME : s = "CM_ERROR_BADNTFILENAME"; break;
922 case CM_ERROR_BUFFERTOOSMALL : s = "CM_ERROR_BUFFERTOOSMALL"; break;
923 case CM_ERROR_RENAME_IDENTICAL : s = "CM_ERROR_RENAME_IDENTICAL"; break;
924 case CM_ERROR_ALLOFFLINE : s = "CM_ERROR_ALLOFFLINE"; break;
925 case CM_ERROR_AMBIGUOUS_FILENAME: s = "CM_ERROR_AMBIGUOUS_FILENAME"; break;
926 case CM_ERROR_BADLOGONTYPE : s = "CM_ERROR_BADLOGONTYPE"; break;
927 case CM_ERROR_GSSCONTINUE : s = "CM_ERROR_GSSCONTINUE"; break;
928 case CM_ERROR_TIDIPC : s = "CM_ERROR_TIDIPC"; break;
929 case CM_ERROR_TOO_MANY_SYMLINKS : s = "CM_ERROR_TOO_MANY_SYMLINKS"; break;
930 case CM_ERROR_PATH_NOT_COVERED : s = "CM_ERROR_PATH_NOT_COVERED"; break;
931 case CM_ERROR_LOCK_CONFLICT : s = "CM_ERROR_LOCK_CONFLICT"; break;
932 case CM_ERROR_SHARING_VIOLATION : s = "CM_ERROR_SHARING_VIOLATION"; break;
933 case CM_ERROR_ALLDOWN : s = "CM_ERROR_ALLDOWN"; break;
934 case CM_ERROR_TOOFEWBUFS : s = "CM_ERROR_TOOFEWBUFS"; break;
935 case CM_ERROR_TOOMANYBUFS : s = "CM_ERROR_TOOMANYBUFS"; break;
937 osi_Log2(afsd_logp, "cm_Analyze: ignoring error code 0x%x (%s)",
943 /* If not allowed to retry, don't */
944 if (!forcing_new && (reqp->flags & CM_REQ_NORETRY))
946 else if (retry && dead_session)
950 /* drop this on the way out */
955 * clear the volume updated flag if we succeed.
956 * this way the flag will not prevent a subsequent volume
957 * from being updated if necessary.
961 reqp->flags &= ~CM_REQ_VOLUME_UPDATED;
964 /* retry until we fail to find a connection */
968 long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
969 cm_req_t *reqp, cm_conn_t **connpp)
972 cm_serverRef_t *tsrp;
975 int someBusy = 0, someOffline = 0, allOffline = 1, allBusy = 1, allDown = 1;
976 #ifdef SET_RX_TIMEOUTS_TO_TIMELEFT
977 long timeUsed, timeLeft, hardTimeLeft;
981 if (serversp == NULL) {
982 osi_Log1(afsd_logp, "cm_ConnByMServers returning 0x%x", CM_ERROR_ALLDOWN);
983 return CM_ERROR_ALLDOWN;
986 #ifdef SET_RX_TIMEOUTS_TO_TIMELEFT
987 timeUsed = (GetTickCount() - reqp->startTime) / 1000;
989 /* leave 5 seconds margin of safety */
990 timeLeft = ConnDeadtimeout - timeUsed - 5;
991 hardTimeLeft = HardDeadtimeout - timeUsed - 5;
994 lock_ObtainRead(&cm_serverLock);
995 for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
996 if (tsrp->status == srv_deleted)
1000 if (reqp->tokenIdleErrorServp) {
1002 * search the list until we find the server
1003 * that failed last time. When we find it
1004 * clear the error, skip it and try the one
1007 if (tsp == reqp->tokenIdleErrorServp)
1008 reqp->tokenIdleErrorServp = NULL;
1012 cm_GetServerNoLock(tsp);
1013 lock_ReleaseRead(&cm_serverLock);
1014 if (!(tsp->flags & CM_SERVERFLAG_DOWN)) {
1016 if (tsrp->status == srv_busy) {
1019 } else if (tsrp->status == srv_offline) {
1025 code = cm_ConnByServer(tsp, usersp, connpp);
1026 if (code == 0) { /* cm_CBS only returns 0 */
1028 #ifdef SET_RX_TIMEOUTS_TO_TIMELEFT
1029 /* Set RPC timeout */
1030 if (timeLeft > ConnDeadtimeout)
1031 timeLeft = ConnDeadtimeout;
1033 if (hardTimeLeft > HardDeadtimeout)
1034 hardTimeLeft = HardDeadtimeout;
1036 lock_ObtainMutex(&(*connpp)->mx);
1037 rx_SetConnDeadTime((*connpp)->rxconnp, timeLeft);
1038 rx_SetConnHardDeadTime((*connpp)->rxconnp, (u_short) hardTimeLeft);
1039 lock_ReleaseMutex(&(*connpp)->mx);
1044 /* therefore, this code is never executed */
1045 if (firstError == 0)
1049 lock_ObtainRead(&cm_serverLock);
1050 cm_PutServerNoLock(tsp);
1053 lock_ReleaseRead(&cm_serverLock);
1055 if (firstError == 0) {
1057 firstError = (reqp->tokenError ? reqp->tokenError :
1058 (reqp->idleError ? RX_CALL_TIMEOUT : CM_ERROR_ALLDOWN));
1060 * if we experienced either a token error or and idle dead time error
1061 * and now all of the servers are down, we have either tried them
1062 * all or lost connectivity. Clear the error we are returning so
1063 * we will not return it indefinitely if the request is retried.
1065 reqp->idleError = reqp->tokenError = 0;
1066 } else if (allBusy) {
1067 firstError = CM_ERROR_ALLBUSY;
1068 } else if (allOffline || (someBusy && someOffline)) {
1069 firstError = CM_ERROR_ALLOFFLINE;
1071 osi_Log0(afsd_logp, "cm_ConnByMServers returning impossible error TIMEDOUT");
1072 firstError = CM_ERROR_TIMEDOUT;
1076 osi_Log1(afsd_logp, "cm_ConnByMServers returning 0x%x", firstError);
1080 /* called with a held server to GC all bad connections hanging off of the server */
1081 void cm_GCConnections(cm_server_t *serverp)
1087 lock_ObtainWrite(&cm_connLock);
1088 lcpp = &serverp->connsp;
1089 for (tcp = *lcpp; tcp; tcp = *lcpp) {
1091 if (userp && tcp->refCount == 0 && (userp->vcRefs == 0)) {
1092 /* do the deletion of this guy */
1093 cm_PutServer(tcp->serverp);
1094 cm_ReleaseUser(userp);
1096 rx_SetConnSecondsUntilNatPing(tcp->rxconnp, 0);
1097 rx_DestroyConnection(tcp->rxconnp);
1098 lock_FinalizeMutex(&tcp->mx);
1102 /* just advance to the next */
1106 lock_ReleaseWrite(&cm_connLock);
1109 static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
1110 cm_server_t *serverp)
1112 unsigned short port;
1115 struct rx_securityClass *secObjp;
1117 port = serverp->addr.sin_port;
1118 switch (serverp->type) {
1119 case CM_SERVER_VLDB:
1124 case CM_SERVER_FILE:
1130 osi_panic("unknown server type", __FILE__, __LINE__);
1133 if (ucellp->flags & CM_UCELLFLAG_RXKAD) {
1137 tcp->cryptlevel = rxkad_clear;
1140 tcp->cryptlevel = rxkad_auth;
1143 tcp->cryptlevel = rxkad_crypt;
1145 secObjp = rxkad_NewClientSecurityObject(tcp->cryptlevel,
1146 &ucellp->sessionKey, ucellp->kvno,
1147 ucellp->ticketLen, ucellp->ticketp);
1151 tcp->cryptlevel = rxkad_clear;
1152 secObjp = rxnull_NewClientSecurityObject();
1154 osi_assertx(secObjp != NULL, "null rx_securityClass");
1155 tcp->rxconnp = rx_NewConnection(serverp->addr.sin_addr.s_addr,
1160 rx_SetConnDeadTime(tcp->rxconnp, ConnDeadtimeout);
1161 rx_SetConnHardDeadTime(tcp->rxconnp, HardDeadtimeout);
1162 rx_SetConnIdleDeadTime(tcp->rxconnp, IdleDeadtimeout);
1165 * Attempt to limit NAT pings to the anonymous file server connections.
1166 * Only file servers implement client callbacks and we only need one ping
1167 * to be sent to each server.
1169 if (NatPingInterval && serverp->type == CM_SERVER_FILE && secIndex == 0)
1170 rx_SetConnSecondsUntilNatPing(tcp->rxconnp, NatPingInterval);
1172 tcp->ucgen = ucellp->gen;
1174 rxs_Release(secObjp); /* Decrement the initial refCount */
1177 long cm_ConnByServer(cm_server_t *serverp, cm_user_t *userp, cm_conn_t **connpp)
1184 if (cm_anonvldb && serverp->type == CM_SERVER_VLDB)
1185 userp = cm_rootUserp;
1187 lock_ObtainMutex(&userp->mx);
1188 lock_ObtainRead(&cm_connLock);
1189 for (tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
1190 if (tcp->userp == userp)
1194 /* find ucell structure */
1195 ucellp = cm_GetUCell(userp, serverp->cellp);
1197 lock_ConvertRToW(&cm_connLock);
1198 for (tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
1199 if (tcp->userp == userp)
1203 lock_ReleaseWrite(&cm_connLock);
1206 cm_GetServer(serverp);
1207 tcp = malloc(sizeof(*tcp));
1208 memset(tcp, 0, sizeof(*tcp));
1209 tcp->nextp = serverp->connsp;
1210 serverp->connsp = tcp;
1213 lock_InitializeMutex(&tcp->mx, "cm_conn_t mutex", LOCK_HIERARCHY_CONN);
1214 lock_ObtainMutex(&tcp->mx);
1215 tcp->serverp = serverp;
1216 tcp->cryptlevel = rxkad_clear;
1217 cm_NewRXConnection(tcp, ucellp, serverp);
1219 lock_ReleaseMutex(&tcp->mx);
1220 lock_ReleaseWrite(&cm_connLock);
1222 lock_ReleaseRead(&cm_connLock);
1224 InterlockedIncrement(&tcp->refCount);
1226 lock_ObtainMutex(&tcp->mx);
1227 if ((tcp->flags & CM_CONN_FLAG_FORCE_NEW) ||
1228 (tcp->ucgen < ucellp->gen) ||
1229 (tcp->cryptlevel != (ucellp->flags & CM_UCELLFLAG_RXKAD ? (cryptall == 1 ? rxkad_crypt : (cryptall == 2 ? rxkad_auth : rxkad_clear)) : rxkad_clear)))
1231 if (tcp->ucgen < ucellp->gen)
1232 osi_Log0(afsd_logp, "cm_ConnByServer replace connection due to token update");
1234 osi_Log0(afsd_logp, "cm_ConnByServer replace connection due to crypt change");
1235 tcp->flags &= ~CM_CONN_FLAG_FORCE_NEW;
1236 rx_SetConnSecondsUntilNatPing(tcp->rxconnp, 0);
1237 rx_DestroyConnection(tcp->rxconnp);
1238 cm_NewRXConnection(tcp, ucellp, serverp);
1240 lock_ReleaseMutex(&tcp->mx);
1242 lock_ReleaseMutex(&userp->mx);
1244 /* return this pointer to our caller */
1245 osi_Log1(afsd_logp, "cm_ConnByServer returning conn 0x%p", tcp);
1251 long cm_ServerAvailable(struct cm_fid *fidp, struct cm_user *userp)
1255 cm_serverRef_t **serverspp;
1256 cm_serverRef_t *tsrp;
1258 int someBusy = 0, someOffline = 0, allOffline = 1, allBusy = 1, allDown = 1;
1262 code = cm_GetServerList(fidp, userp, &req, &serverspp);
1266 lock_ObtainRead(&cm_serverLock);
1267 for (tsrp = *serverspp; tsrp; tsrp=tsrp->next) {
1268 if (tsrp->status == srv_deleted)
1271 if (!(tsp->flags & CM_SERVERFLAG_DOWN)) {
1273 if (tsrp->status == srv_busy) {
1276 } else if (tsrp->status == srv_offline) {
1285 lock_ReleaseRead(&cm_serverLock);
1286 cm_FreeServerList(serverspp, 0);
1292 else if (allOffline || (someBusy && someOffline))
1299 * The returned cm_conn_t ** object is released in the subsequent call
1302 long cm_ConnFromFID(struct cm_fid *fidp, struct cm_user *userp, cm_req_t *reqp,
1306 cm_serverRef_t **serverspp;
1310 code = cm_GetServerList(fidp, userp, reqp, &serverspp);
1315 code = cm_ConnByMServers(*serverspp, userp, reqp, connpp);
1316 cm_FreeServerList(serverspp, 0);
1321 long cm_ConnFromVolume(struct cm_volume *volp, unsigned long volid, struct cm_user *userp, cm_req_t *reqp,
1325 cm_serverRef_t **serverspp;
1329 serverspp = cm_GetVolServers(volp, volid, userp, reqp);
1331 code = cm_ConnByMServers(*serverspp, userp, reqp, connpp);
1332 cm_FreeServerList(serverspp, 0);
1337 extern struct rx_connection *
1338 cm_GetRxConn(cm_conn_t *connp)
1340 struct rx_connection * rxconnp;
1341 lock_ObtainMutex(&connp->mx);
1342 rxconnp = connp->rxconnp;
1343 rx_GetConnection(rxconnp);
1344 lock_ReleaseMutex(&connp->mx);
1348 void cm_ForceNewConnections(cm_server_t *serverp)
1352 lock_ObtainWrite(&cm_connLock);
1353 for (tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
1354 lock_ObtainMutex(&tcp->mx);
1355 tcp->flags |= CM_CONN_FLAG_FORCE_NEW;
1356 lock_ReleaseMutex(&tcp->mx);
1358 lock_ReleaseWrite(&cm_connLock);