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>
11 #include <afs/afs_args.h>
18 #include <sys/socket.h>
28 /*extern void afsi_log(char *pattern, ...);*/
30 /* read/write lock for all global storage in this module */
31 osi_rwlock_t cm_callbackLock;
33 #ifdef AFS_FREELANCE_CLIENT
34 extern osi_mutex_t cm_Freelance_Lock;
37 /* count of # of callback breaking messages received by this CM so far. We use
38 * this count in determining whether there have been any callback breaks that
39 * apply to a call that returned a new callback. If the counter doesn't
40 * increase during a call, then we know that no callbacks were broken during
41 * that call, and thus that the callback that was just returned is still valid.
43 long cm_callbackCount;
45 /* count of number of RPCs potentially returning a callback executing now.
46 * When this counter hits zero, we can clear out the racing revokes list, since
47 * at that time, we know that none of the just-executed callback revokes will
48 * apply to any future call that returns a callback (since the latter hasn't
49 * even started execution yet).
51 long cm_activeCallbackGrantingCalls;
53 /* list of callbacks that have been broken recently. If a call returning a
54 * callback is executing and a callback revoke runs immediately after it at the
55 * server, the revoke may end up being processed before the response to the
56 * original callback granting call. We detect this by keeping a list of
57 * callback revokes that have been received since we *started* the callback
58 * granting call, and discarding any callbacks received for the same file ID,
59 * even if the callback revoke was received before the callback grant.
61 cm_racingRevokes_t *cm_racingRevokesp;
63 /* record a (potentially) racing revoke for this file ID; null means for all
64 * file IDs, and is used by InitCallBackState.
66 * The cancelFlags describe whether we're just discarding callbacks for the same
67 * file ID, the same volume, or all from the same server.
69 * Called with no locks held.
71 void cm_RecordRacingRevoke(cm_fid_t *fidp, long cancelFlags)
73 cm_racingRevokes_t *rp;
75 lock_ObtainWrite(&cm_callbackLock);
77 osi_Log3(afsd_logp, "RecordRacingRevoke Volume %d Flags %lX activeCalls %d",
78 fidp->volume, cancelFlags, cm_activeCallbackGrantingCalls);
80 if (cm_activeCallbackGrantingCalls > 0) {
81 rp = malloc(sizeof(*rp));
82 memset(rp, 0, sizeof(*rp));
83 osi_QAdd((osi_queue_t **) &cm_racingRevokesp, &rp->q);
84 rp->flags |= (cancelFlags & CM_RACINGFLAG_ALL);
85 if (fidp) rp->fid = *fidp;
86 rp->callbackCount = ++cm_callbackCount;
88 lock_ReleaseWrite(&cm_callbackLock);
92 * When we lose a callback, may have to send change notification replies.
94 void cm_CallbackNotifyChange(cm_scache_t *scp)
96 osi_Log2(afsd_logp, "CallbackNotifyChange FileType %d Flags %lX",
97 scp->fileType, scp->flags);
99 if (scp->fileType == CM_SCACHETYPE_DIRECTORY) {
100 if (scp->flags & CM_SCACHEFLAG_ANYWATCH)
102 FILE_NOTIFY_GENERIC_DIRECTORY_FILTER,
103 scp, NULL, NULL, TRUE);
108 tfid.cell = scp->fid.cell;
109 tfid.volume = scp->fid.volume;
110 tfid.vnode = scp->parentVnode;
111 tfid.unique = scp->parentUnique;
112 dscp = cm_FindSCache(&tfid);
114 dscp->flags & CM_SCACHEFLAG_ANYWATCH)
116 FILE_NOTIFY_GENERIC_FILE_FILTER,
117 dscp, NULL, NULL, TRUE);
118 if (dscp) cm_ReleaseSCache(dscp);
122 /* called with no locks held for every file ID that is revoked directly by
123 * a callback revoke call. Does not have to handle volume callback breaks,
124 * since those have already been split out.
126 * The callp parameter is currently unused.
128 void cm_RevokeCallback(struct rx_call *callp, AFSFid *fidp)
134 /* don't bother setting cell, since we won't be checking it (to aid
135 * in working with multi-homed servers: we don't know the cell if we
136 * don't recognize the IP address).
139 tfid.volume = fidp->Volume;
140 tfid.vnode = fidp->Vnode;
141 tfid.unique = fidp->Unique;
142 hash = CM_SCACHE_HASH(&tfid);
144 osi_Log3(afsd_logp, "RevokeCallback vol %d vn %d un %d",
145 fidp->Volume, fidp->Vnode, fidp->Unique);
147 /* do this first, so that if we're executing a callback granting call
148 * at this moment, we kill it before it can be merged in. Otherwise,
149 * it could complete while we're doing the scan below, and get missed
150 * by both the scan and by this code.
152 cm_RecordRacingRevoke(&tfid, 0);
154 lock_ObtainWrite(&cm_scacheLock);
155 /* do all in the hash bucket, since we don't know how many we'll find with
158 for(scp = cm_hashTablep[hash]; scp; scp=scp->nextp) {
159 if (scp->fid.volume == tfid.volume &&
160 scp->fid.vnode == tfid.vnode &&
161 scp->fid.unique == tfid.unique) {
163 lock_ReleaseWrite(&cm_scacheLock);
164 osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
165 lock_ObtainMutex(&scp->mx);
166 cm_DiscardSCache(scp);
167 lock_ReleaseMutex(&scp->mx);
168 cm_CallbackNotifyChange(scp);
169 lock_ObtainWrite(&cm_scacheLock);
173 lock_ReleaseWrite(&cm_scacheLock);
176 /* called to revoke a volume callback, which is typically issued when a volume
177 * is moved from one server to another.
179 * Called with no locks held.
181 void cm_RevokeVolumeCallback(struct rx_call *callp, AFSFid *fidp)
187 osi_Log1(afsd_logp, "RevokeVolumeCallback %d", fidp->Volume);
189 /* do this first, so that if we're executing a callback granting call
190 * at this moment, we kill it before it can be merged in. Otherwise,
191 * it could complete while we're doing the scan below, and get missed
192 * by both the scan and by this code.
194 tfid.cell = tfid.vnode = tfid.unique = 0;
195 tfid.volume = fidp->Volume;
196 cm_RecordRacingRevoke(&tfid, CM_RACINGFLAG_CANCELVOL);
199 lock_ObtainWrite(&cm_scacheLock);
200 for(hash = 0; hash < cm_hashTableSize; hash++) {
201 for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
202 if (scp->fid.volume == fidp->Volume) {
204 lock_ReleaseWrite(&cm_scacheLock);
205 lock_ObtainMutex(&scp->mx);
206 osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
207 cm_DiscardSCache(scp);
208 lock_ReleaseMutex(&scp->mx);
209 cm_CallbackNotifyChange(scp);
210 lock_ObtainWrite(&cm_scacheLock);
213 } /* search one hash bucket */
214 } /* search all hash buckets */
216 lock_ReleaseWrite(&cm_scacheLock);
219 /* handle incoming RPC callback breaking message.
220 * Called with no locks held.
222 SRXAFSCB_CallBack(struct rx_call *callp, AFSCBFids *fidsArrayp, AFSCBs *cbsArrayp)
227 osi_Log0(afsd_logp, "SRXAFSCB_CallBack");
229 for(i=0; i < (long) fidsArrayp->AFSCBFids_len; i++) {
230 tfidp = &fidsArrayp->AFSCBFids_val[i];
232 if (tfidp->Volume == 0)
233 continue; /* means don't do anything */
234 else if (tfidp->Vnode == 0)
235 cm_RevokeVolumeCallback(callp, tfidp);
237 cm_RevokeCallback(callp, tfidp);
243 /* called with no locks by RPC system when a server indicates that it has never
244 * heard from us, or for other reasons has had to discard callbacks from us
245 * without telling us, e.g. a network partition.
247 SRXAFSCB_InitCallBackState(struct rx_call *callp)
249 struct sockaddr_in taddr;
255 osi_Log0(afsd_logp, "SRXAFSCB_InitCallBackState");
257 if ((rx_ConnectionOf(callp)) && (rx_PeerOf(rx_ConnectionOf(callp)))) {
258 taddr.sin_family = AF_INET;
259 taddr.sin_addr.s_addr = rx_HostOf(rx_PeerOf(rx_ConnectionOf(callp)));
261 tsp = cm_FindServer(&taddr, CM_SERVER_FILE);
263 osi_Log1(afsd_logp, "Init Callback State server %x", tsp);
265 /* record the callback in the racing revokes structure. This
266 * shouldn't be necessary, since we shouldn't be making callback
267 * granting calls while we're going to get an initstate call,
268 * but there probably are some obscure races, so better safe
271 * We do this first since we don't hold the cm_scacheLock and vnode
272 * locks over the entire callback scan operation below. The
273 * big loop below is guaranteed to hit any callback already
274 * processed. The call to RecordRacingRevoke is guaranteed
275 * to kill any callback that is currently being returned.
276 * Anything that sneaks past both must start
277 * after the call to RecordRacingRevoke.
279 cm_RecordRacingRevoke(NULL, CM_RACINGFLAG_CANCELALL);
281 /* now search all vnodes looking for guys with this callback, if we
282 * found it, or guys with any callbacks, if we didn't find the server
283 * (that's how multihomed machines will appear and how we'll handle
284 * them, albeit a little inefficiently). That is, we're discarding all
285 * callbacks from all hosts if we get an initstate call from an unknown
286 * host. Since these calls are rare, and multihomed servers
287 * are "rare," hopefully this won't be a problem.
289 lock_ObtainWrite(&cm_scacheLock);
290 for(hash = 0; hash < cm_hashTableSize; hash++) {
291 for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
293 lock_ReleaseWrite(&cm_scacheLock);
294 lock_ObtainMutex(&scp->mx);
296 if (scp->cbServerp != NULL) {
297 /* we have a callback, now decide if we should clear it */
298 if (scp->cbServerp == tsp || tsp == NULL) {
299 osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
300 cm_DiscardSCache(scp);
304 lock_ReleaseMutex(&scp->mx);
306 cm_CallbackNotifyChange(scp);
307 lock_ObtainWrite(&cm_scacheLock);
309 } /* search one hash bucket */
310 } /* search all hash buckets */
312 lock_ReleaseWrite(&cm_scacheLock);
314 /* we're done with the server structure */
315 if (tsp) cm_PutServer(tsp);
321 /* just returns if we're up */
322 SRXAFSCB_Probe(struct rx_call *callp)
324 osi_Log0(afsd_logp, "SRXAFSCB_Probe - not implemented");
328 /* debug interface: not implemented */
329 SRXAFSCB_GetCE64(struct rx_call *callp, long index, AFSDBCacheEntry *cep)
332 osi_Log0(afsd_logp, "SRXAFSCB_GetCE64 - not implemented");
336 /* debug interface: not implemented */
337 SRXAFSCB_GetLock(struct rx_call *callp, long index, AFSDBLock *lockp)
340 osi_Log0(afsd_logp, "SRXAFSCB_GetLock - not implemented");
344 /* debug interface: not implemented */
345 SRXAFSCB_GetCE(struct rx_call *callp, long index, AFSDBCacheEntry *cep)
348 osi_Log0(afsd_logp, "SRXAFSCB_GetCE - not implemented");
352 /* debug interface: not implemented */
353 SRXAFSCB_XStatsVersion(struct rx_call *callp, long *vp)
356 osi_Log0(afsd_logp, "SRXAFSCB_XStatsVersion - not implemented");
361 /* debug interface: not implemented */
362 SRXAFSCB_GetXStats(struct rx_call *callp, long cvn, long coln, long *srvp, long *timep,
363 AFSCB_CollData *datap)
366 osi_Log0(afsd_logp, "SRXAFSCB_GetXStats - not implemented");
370 /* debug interface: not implemented */
371 SRXAFSCB_InitCallBackState2(struct rx_call *callp, struct interfaceAddr* addr)
374 osi_Log0(afsd_logp, "SRXAFSCB_InitCallBackState2 - not implemented");
378 /* debug interface: not implemented */
379 SRXAFSCB_WhoAreYou(struct rx_call *callp, struct interfaceAddr* addr)
382 osi_Log0(afsd_logp, "SRXAFSCB_WhoAreYou - not implemented");
386 /* debug interface: not implemented */
387 SRXAFSCB_InitCallBackState3(struct rx_call *callp, afsUUID* serverUuid)
390 osi_Log0(afsd_logp, "SRXAFSCB_InitCallBackState3 - not implemented");
394 /* debug interface: not implemented */
395 SRXAFSCB_ProbeUuid(struct rx_call *callp, afsUUID* clientUuid)
398 osi_Log0(afsd_logp, "SRXAFSCB_ProbeUuid - not implemented");
402 /*------------------------------------------------------------------------
403 * EXPORTED SRXAFSCB_GetServerPrefs
406 * Routine to list server preferences used by this client.
409 * a_call : Ptr to Rx call on which this request came in.
410 * a_index : Input server index
411 * a_srvr_addr : Output server address (0xffffffff on last server)
412 * a_srvr_rank : Output server rank
418 * Nothing interesting.
422 *------------------------------------------------------------------------*/
424 int SRXAFSCB_GetServerPrefs(
425 struct rx_call *a_call,
427 afs_int32 *a_srvr_addr,
428 afs_int32 *a_srvr_rank)
430 osi_Log0(afsd_logp, "SRXAFSCB_GetServerPrefs - not implemented");
432 *a_srvr_addr = 0xffffffff;
433 *a_srvr_rank = 0xffffffff;
437 /*------------------------------------------------------------------------
438 * EXPORTED SRXAFSCB_GetCellServDB
441 * Routine to list cells configured for this client
444 * a_call : Ptr to Rx call on which this request came in.
445 * a_index : Input cell index
446 * a_name : Output cell name ("" on last cell)
447 * a_hosts : Output cell database servers
453 * Nothing interesting.
457 *------------------------------------------------------------------------*/
459 int SRXAFSCB_GetCellServDB(
460 struct rx_call *a_call,
467 osi_Log0(afsd_logp, "SRXAFSCB_GetCellServDB - not implemented");
469 t_name = (char *)malloc(AFSNAMEMAX);
472 a_hosts->serverList_len = 0;
476 /*------------------------------------------------------------------------
477 * EXPORTED SRXAFSCB_GetLocalCell
480 * Routine to return name of client's local cell
483 * a_call : Ptr to Rx call on which this request came in.
484 * a_name : Output cell name
490 * Nothing interesting.
494 *------------------------------------------------------------------------*/
496 int SRXAFSCB_GetLocalCell(
497 struct rx_call *a_call,
502 osi_Log0(afsd_logp, "SRXAFSCB_GetLocalCell");
505 t_name = (char *)malloc(strlen(cm_rootCellp->namep)+1);
506 strcpy(t_name, cm_rootCellp->namep);
508 t_name = (char *)malloc(1);
517 * afs_MarshallCacheConfig - marshall client cache configuration
521 * IN callerVersion - the rpc stat version of the caller.
523 * IN config - client cache configuration.
525 * OUT ptr - buffer where configuration is marshalled.
531 static void afs_MarshallCacheConfig(
532 afs_uint32 callerVersion,
533 cm_initparams_v1 *config,
537 * We currently only support version 1.
539 *(ptr++) = config->nChunkFiles;
540 *(ptr++) = config->nStatCaches;
541 *(ptr++) = config->nDataCaches;
542 *(ptr++) = config->nVolumeCaches;
543 *(ptr++) = config->firstChunkSize;
544 *(ptr++) = config->otherChunkSize;
545 *(ptr++) = config->cacheSize;
546 *(ptr++) = config->setTime;
547 *(ptr++) = config->memCache;
552 /*------------------------------------------------------------------------
553 * EXPORTED SRXAFSCB_GetCacheConfig
556 * Routine to return parameters used to initialize client cache.
557 * Client may request any format version. Server may not return
558 * format version greater than version requested by client.
561 * a_call: Ptr to Rx call on which this request came in.
562 * callerVersion: Data format version desired by the client.
563 * serverVersion: Data format version of output data.
564 * configCount: Number bytes allocated for output data.
565 * config: Client cache configuration.
571 * Nothing interesting.
575 *------------------------------------------------------------------------*/
577 int SRXAFSCB_GetCacheConfig(a_call, callerVersion, serverVersion,
579 struct rx_call *a_call;
580 afs_uint32 callerVersion;
581 afs_uint32 *serverVersion;
582 afs_uint32 *configCount;
585 afs_uint32 *t_config;
587 extern cm_initparams_v1 cm_initParams;
589 osi_Log0(afsd_logp, "SRXAFSCB_GetCacheConfig - version 1 only");
592 * Currently only support version 1
594 allocsize = sizeof(cm_initparams_v1);
595 t_config = (afs_uint32 *)malloc(allocsize);
597 afs_MarshallCacheConfig(callerVersion, &cm_initParams, t_config);
599 *serverVersion = AFS_CLIENT_RETRIEVAL_FIRST_EDITION;
600 *configCount = allocsize;
601 config->cacheConfig_val = t_config;
602 config->cacheConfig_len = allocsize/sizeof(afs_uint32);
607 /* called by afsd without any locks to initialize this module */
608 void cm_InitCallback(void)
610 lock_InitializeRWLock(&cm_callbackLock, "cm_callbackLock");
611 cm_activeCallbackGrantingCalls = 0;
614 /* called with locked scp; tells us whether we've got a callback.
615 * Expirations are checked by a background daemon so as to make
616 * this function as inexpensive as possible
618 int cm_HaveCallback(cm_scache_t *scp)
620 #ifdef AFS_FREELANCE_CLIENT
621 // yj: we handle callbacks specially for callbacks on the root directory
622 // Since it's local, we almost always say that we have callback on it
623 // The only time we send back a 0 is if we're need to initialize or
624 // reinitialize the fake directory
626 // There are 2 state variables cm_fakeGettingCallback and cm_fakeDirCallback
627 // cm_fakeGettingCallback is 1 if we're in the process of initialization and
628 // hence should return false. it's 0 otherwise
629 // cm_fakeDirCallback is 0 if we haven't loaded the fake directory, it's 1
630 // if the fake directory is loaded and this is the first time cm_HaveCallback
631 // is called since then. We return false in this case to allow cm_GetCallback
632 // to be called because cm_GetCallback has some initialization work to do.
633 // If cm_fakeDirCallback is 2, then it means that the fake directory is in
634 // good shape and we simply return true, provided no change is detected.
637 if (cm_freelanceEnabled &&
638 scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
639 scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) { // if it's something on /afs
640 if (!(scp->fid.vnode==0x1 && scp->fid.unique==0x1)) // if it's not root.afs
643 lock_ObtainMutex(&cm_Freelance_Lock);
644 fdc = cm_fakeDirCallback;
645 fgc = cm_fakeGettingCallback;
646 lock_ReleaseMutex(&cm_Freelance_Lock);
648 if (fdc==1) { // first call since init
650 } else if (fdc==2 && !fgc) { // we're in good shape
651 if (cm_getLocalMountPointChange()) { // check for changes
652 cm_clearLocalMountPointChange(); // clear the changefile
653 lock_ReleaseMutex(scp->mx); // this is re-locked in reInitLocalMountPoints
654 cm_reInitLocalMountPoints(); // start reinit
655 lock_ObtainMutex(scp->mx); // now get the lock back
658 return 1; // no change
665 if (scp->cbServerp != NULL)
670 /* need to detect a broken callback that races with our obtaining a callback.
671 * Need to be able to do this even if we don't know the file ID of the file
672 * we're breaking the callback on at the time we start the acquisition of the
673 * callback (as in the case where we are creating a file).
675 * So, we start by writing down the count of the # of callbacks we've received
676 * so far, and bumping a global counter of the # of callback granting calls
677 * outstanding (all done under cm_callbackLock).
679 * When we're back from the call, we look at all of the callback revokes with
680 * counter numbers greater than the one we recorded in our caller's structure,
681 * and replay those that are higher than when we started the call.
683 * We free all the structures in the queue when the count of the # of outstanding
684 * callback-granting calls drops to zero.
686 * We call this function with the scp locked, too, but in its current implementation,
687 * this knowledge is not used.
689 void cm_StartCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp)
691 lock_ObtainWrite(&cm_callbackLock);
692 cbrp->callbackCount = cm_callbackCount;
693 cm_activeCallbackGrantingCalls++;
694 cbrp->startTime = osi_Time();
695 cbrp->serverp = NULL;
696 lock_ReleaseWrite(&cm_callbackLock);
699 /* Called at the end of a callback-granting call, to remove the callback
700 * info from the scache entry, if necessary.
702 * Called with scp locked, so we can discard the callbacks easily with
703 * this locking hierarchy.
705 void cm_EndCallbackGrantingCall(cm_scache_t *scp, cm_callbackRequest_t *cbrp,
706 AFSCallBack *cbp, long flags)
708 cm_racingRevokes_t *revp; /* where we are */
709 cm_racingRevokes_t *nrevp; /* where we'll be next */
712 lock_ObtainWrite(&cm_callbackLock);
713 if (flags & CM_CALLBACK_MAINTAINCOUNT) {
714 osi_assert(cm_activeCallbackGrantingCalls > 0);
717 osi_assert(cm_activeCallbackGrantingCalls-- > 0);
719 if (cm_activeCallbackGrantingCalls == 0) freeFlag = 1;
722 /* record the callback; we'll clear it below if we really lose it */
724 scp->cbServerp = cbrp->serverp;
725 scp->cbExpires = cbrp->startTime + cbp->ExpirationTime;
728 /* a callback was actually revoked during our granting call, so
729 * run down the list of revoked fids, looking for ours.
730 * If activeCallbackGrantingCalls is zero, free the elements, too.
732 * May need to go through entire list just to do the freeing.
734 for(revp = cm_racingRevokesp; revp; revp = nrevp) {
735 nrevp = (cm_racingRevokes_t *) osi_QNext(&revp->q);
736 /* if this callback came in later than when we started the
737 * callback-granting call, and if this fid is the right fid,
738 * then clear the callback.
740 if (scp && cbrp->callbackCount != cm_callbackCount
741 && revp->callbackCount > cbrp->callbackCount
742 && (( scp->fid.volume == revp->fid.volume &&
743 scp->fid.vnode == revp->fid.vnode &&
744 scp->fid.unique == revp->fid.unique)
746 ((revp->flags & CM_RACINGFLAG_CANCELVOL) &&
747 scp->fid.volume == revp->fid.volume)
749 (revp->flags & CM_RACINGFLAG_CANCELALL))) {
750 /* this one matches */
752 "Racing revoke scp %x old cbc %d rev cbc %d cur cbc %d",
754 cbrp->callbackCount, revp->callbackCount,
756 cm_DiscardSCache(scp);
758 * Since we don't have a callback to preserve, it's
759 * OK to drop the lock and re-obtain it.
761 lock_ReleaseMutex(&scp->mx);
762 cm_CallbackNotifyChange(scp);
763 lock_ObtainMutex(&scp->mx);
765 if (freeFlag) free(revp);
768 /* if we freed the list, zap the pointer to it */
769 if (freeFlag) cm_racingRevokesp = NULL;
771 lock_ReleaseWrite(&cm_callbackLock);
774 /* if flags is 1, we want to force the code to make one call, anyway.
775 * called with locked scp; returns with same.
777 long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
778 struct cm_req *reqp, long flags)
782 AFSFetchStatus afsStatus;
784 AFSCallBack callback;
786 cm_callbackRequest_t cbr;
791 osi_Log2(afsd_logp, "GetCallback scp %x flags %lX", scp, flags);
793 #ifdef AFS_FREELANCE_CLIENT
794 // The case where a callback is needed on /afs is handled
795 // specially. We need to fetch the status by calling
796 // cm_MergeStatus and mark that cm_fakeDirCallback is 2
797 if (cm_freelanceEnabled) {
798 if (scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
799 scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
800 scp->fid.unique==0x1 &&
801 scp->fid.vnode==0x1) {
802 // Start by indicating that we're in the process
803 // of fetching the callback
805 lock_ObtainMutex(&cm_Freelance_Lock);
806 cm_fakeGettingCallback = 1;
807 lock_ReleaseMutex(&cm_Freelance_Lock);
809 // Fetch the status info
810 cm_MergeStatus(scp, &afsStatus, &volSync, userp, 0);
812 // Indicate that the callback is not done
813 lock_ObtainMutex(&cm_Freelance_Lock);
814 cm_fakeDirCallback = 2;
815 // Indicate that we're no longer fetching the callback
816 cm_fakeGettingCallback = 0;
817 lock_ReleaseMutex(&cm_Freelance_Lock);
822 if (scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && scp->fid.volume==AFS_FAKE_ROOT_VOL_ID) {
823 osi_Log0(afsd_logp,"cm_getcallback should NEVER EVER get here... ");
826 #endif /* AFS_FREELANCE_CLIENT */
828 mustCall = (flags & 1);
829 cm_AFSFidFromFid(&tfid, &scp->fid);
831 if (!mustCall && cm_HaveCallback(scp)) return 0;
833 /* turn off mustCall, since it has now forced us past the check above */
836 /* otherwise, we have to make an RPC to get the status */
837 sflags = CM_SCACHESYNC_FETCHSTATUS | CM_SCACHESYNC_GETCALLBACK;
838 cm_SyncOp(scp, NULL, NULL, NULL, 0, sflags);
839 cm_StartCallbackGrantingCall(scp, &cbr);
841 lock_ReleaseMutex(&scp->mx);
843 /* now make the RPC */
844 osi_Log1(afsd_logp, "CALL FetchStatus vp %x", (long) scp);
846 code = cm_Conn(&sfid, userp, reqp, &connp);
849 code = RXAFS_FetchStatus(connp->callp, &tfid,
850 &afsStatus, &callback, &volSync);
852 } while (cm_Analyze(connp, userp, reqp, &sfid, &volSync, NULL,
854 code = cm_MapRPCError(code, reqp);
855 osi_Log0(afsd_logp, "CALL FetchStatus DONE");
857 lock_ObtainMutex(&scp->mx);
858 cm_SyncOpDone(scp, NULL, sflags);
860 cm_EndCallbackGrantingCall(scp, &cbr, &callback, 0);
861 cm_MergeStatus(scp, &afsStatus, &volSync, userp, 0);
864 cm_EndCallbackGrantingCall(NULL, NULL, NULL, 0);
866 /* now check to see if we got an error */
867 if (code) return code;
871 /* called periodically by cm_daemon to shut down use of expired callbacks */
872 void cm_CheckCBExpiration(void)
878 osi_Log0(afsd_logp, "CheckCBExpiration");
881 lock_ObtainWrite(&cm_scacheLock);
882 for(i=0; i<cm_hashTableSize; i++) {
883 for(scp = cm_hashTablep[i]; scp; scp=scp->nextp) {
885 lock_ReleaseWrite(&cm_scacheLock);
886 lock_ObtainMutex(&scp->mx);
887 if (scp->cbServerp && now > scp->cbExpires) {
888 osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
889 cm_DiscardSCache(scp);
891 lock_ReleaseMutex(&scp->mx);
892 lock_ObtainWrite(&cm_scacheLock);
893 osi_assert(scp->refCount-- > 0);
896 lock_ReleaseWrite(&cm_scacheLock);
899 /* debug interface: not implemented */
900 int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
901 char **a_name, serverList *a_hosts)
904 osi_Log0(afsd_logp, "SRXAFSCB_GetCellByNum - not implemented");
908 /* debug interface: not implemented */
909 int SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call, afs_int32 a_cellnum,
910 char **a_name, serverList *a_hosts)
913 osi_Log0(afsd_logp, "SRXAFSCB_TellMeAboutYourself - not implemented");