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>
25 /*extern void afsi_log(char *pattern, ...);*/
27 extern osi_hyper_t hzero;
30 osi_queue_t *cm_allFileLocks;
32 /* lock for globals */
33 osi_rwlock_t cm_scacheLock;
35 /* Dummy scache entry for use with pioctl fids */
36 cm_scache_t cm_fakeSCache;
38 #ifdef AFS_FREELANCE_CLIENT
39 extern osi_mutex_t cm_Freelance_Lock;
42 /* must be called with cm_scacheLock write-locked! */
43 void cm_AdjustLRU(cm_scache_t *scp)
45 if (scp == cm_data.scacheLRULastp)
46 cm_data.scacheLRULastp = (cm_scache_t *) osi_QPrev(&scp->q);
47 osi_QRemove((osi_queue_t **) &cm_data.scacheLRUFirstp, &scp->q);
48 osi_QAdd((osi_queue_t **) &cm_data.scacheLRUFirstp, &scp->q);
49 if (!cm_data.scacheLRULastp)
50 cm_data.scacheLRULastp = scp;
53 /* called with cm_scacheLock write-locked; find a vnode to recycle.
54 * Can allocate a new one if desperate, or if below quota (cm_data.maxSCaches).
56 cm_scache_t *cm_GetNewSCache(void)
63 if (cm_data.currentSCaches >= cm_data.maxSCaches) {
64 for (scp = cm_data.scacheLRULastp;
66 scp = (cm_scache_t *) osi_QPrev(&scp->q)) {
67 if (scp->refCount == 0)
72 osi_assert(scp >= cm_data.scacheBaseAddress && scp < (cm_scache_t *)cm_data.hashTablep);
73 /* we found an entry, so return it */
74 if (scp->flags & CM_SCACHEFLAG_INHASH) {
75 /* hash it out first */
76 i = CM_SCACHE_HASH(&scp->fid);
77 for (lscpp = &cm_data.hashTablep[i], tscp = cm_data.hashTablep[i];
79 lscpp = &tscp->nextp, tscp = tscp->nextp) {
82 scp->flags &= ~CM_SCACHEFLAG_INHASH;
86 osi_assertx(tscp, "afsd: scache hash screwup");
89 /* look for things that shouldn't still be set */
90 osi_assert(scp->bufWritesp == NULL);
91 osi_assert(scp->bufReadsp == NULL);
93 /* invalidate so next merge works fine;
94 * also initialize some flags */
95 scp->flags &= ~(CM_SCACHEFLAG_STATD
97 | CM_SCACHEFLAG_PURERO
98 | CM_SCACHEFLAG_OVERQUOTA
99 | CM_SCACHEFLAG_OUTOFSPACE);
100 scp->serverModTime = 0;
101 scp->dataVersion = 0;
102 scp->bulkStatProgress = hzero;
110 /* discard callback */
111 if (scp->cbServerp) {
112 cm_PutServer(scp->cbServerp);
113 scp->cbServerp = NULL;
117 /* remove from dnlc */
121 /* discard cached status; if non-zero, Close
122 * tried to store this to server but failed */
125 /* drop held volume ref */
127 cm_PutVolume(scp->volp);
131 /* discard symlink info */
132 scp->mountPointStringp[0] = 0;
133 memset(&scp->mountRootFid, 0, sizeof(cm_fid_t));
134 memset(&scp->dotdotFid, 0, sizeof(cm_fid_t));
136 /* not locked, but there can be no references to this guy
137 * while we hold the global refcount lock.
139 cm_FreeAllACLEnts(scp);
141 /* now remove from the LRU queue and put it back at the
142 * head of the LRU queue.
151 /* if we get here, we should allocate a new scache entry. We either are below
152 * quota or we have a leak and need to allocate a new one to avoid panicing.
154 scp = cm_data.scacheBaseAddress + cm_data.currentSCaches;
155 osi_assert(scp >= cm_data.scacheBaseAddress && scp < (cm_scache_t *)cm_data.hashTablep);
156 memset(scp, 0, sizeof(cm_scache_t));
157 scp->magic = CM_SCACHE_MAGIC;
158 lock_InitializeMutex(&scp->mx, "cm_scache_t mutex");
159 lock_InitializeRWLock(&scp->bufCreateLock, "cm_scache_t bufCreateLock");
161 /* and put it in the LRU queue */
162 osi_QAdd((osi_queue_t **) &cm_data.scacheLRUFirstp, &scp->q);
163 if (!cm_data.scacheLRULastp)
164 cm_data.scacheLRULastp = scp;
165 cm_data.currentSCaches++;
166 cm_dnlcPurgedp(scp); /* make doubly sure that this is not in dnlc */
171 /* like strcmp, only for fids */
172 int cm_FidCmp(cm_fid_t *ap, cm_fid_t *bp)
174 if (ap->vnode != bp->vnode)
176 if (ap->volume != bp->volume)
178 if (ap->unique != bp->unique)
180 if (ap->cell != bp->cell)
185 void cm_fakeSCacheInit(int newFile)
188 memset(&cm_data.fakeSCache, 0, sizeof(cm_scache_t));
189 cm_data.fakeSCache.cbServerp = (struct cm_server *)(-1);
190 /* can leave clientModTime at 0 */
191 cm_data.fakeSCache.fileType = CM_SCACHETYPE_FILE;
192 cm_data.fakeSCache.unixModeBits = 0777;
193 cm_data.fakeSCache.length.LowPart = 1000;
194 cm_data.fakeSCache.linkCount = 1;
195 cm_data.fakeSCache.refCount = 1;
197 lock_InitializeMutex(&cm_data.fakeSCache.mx, "cm_scache_t mutex");
201 cm_ValidateSCache(void)
203 cm_scache_t * scp, *lscp;
206 for ( scp = cm_data.scacheLRUFirstp, lscp = NULL, i = 0;
208 lscp = scp, scp = (cm_scache_t *) osi_QNext(&scp->q), i++ ) {
209 if (scp->magic != CM_SCACHE_MAGIC) {
210 afsi_log("cm_ValidateSCache failure: scp->magic != CM_SCACHE_MAGIC");
211 fprintf(stderr, "cm_ValidateSCache failure: scp->magic != CM_SCACHE_MAGIC\n");
214 if (scp->nextp && scp->nextp->magic != CM_SCACHE_MAGIC) {
215 afsi_log("cm_ValidateSCache failure: scp->nextp->magic != CM_SCACHE_MAGIC");
216 fprintf(stderr, "cm_ValidateSCache failure: scp->nextp->magic != CM_SCACHE_MAGIC\n");
219 if (scp->randomACLp && scp->randomACLp->magic != CM_ACLENT_MAGIC) {
220 afsi_log("cm_ValidateSCache failure: scp->randomACLp->magic != CM_ACLENT_MAGIC");
221 fprintf(stderr, "cm_ValidateSCache failure: scp->randomACLp->magic != CM_ACLENT_MAGIC\n");
224 if (scp->volp && scp->volp->magic != CM_VOLUME_MAGIC) {
225 afsi_log("cm_ValidateSCache failure: scp->volp->magic != CM_VOLUME_MAGIC");
226 fprintf(stderr, "cm_ValidateSCache failure: scp->volp->magic != CM_VOLUME_MAGIC\n");
229 if (i > cm_data.currentSCaches ) {
230 afsi_log("cm_ValidateSCache failure: LRU First queue loops");
231 fprintf(stderr, "cm_ValidateSCache failure: LUR First queue loops\n");
234 if (lscp != (cm_scache_t *) osi_QPrev(&scp->q)) {
235 afsi_log("cm_ValidateSCache failure: QPrev(scp) != previous");
236 fprintf(stderr, "cm_ValidateSCache failure: QPrev(scp) != previous\n");
241 for ( scp = cm_data.scacheLRULastp, lscp = NULL, i = 0; scp;
242 lscp = scp, scp = (cm_scache_t *) osi_QPrev(&scp->q), i++ ) {
243 if (scp->magic != CM_SCACHE_MAGIC) {
244 afsi_log("cm_ValidateSCache failure: scp->magic != CM_SCACHE_MAGIC");
245 fprintf(stderr, "cm_ValidateSCache failure: scp->magic != CM_SCACHE_MAGIC\n");
248 if (scp->nextp && scp->nextp->magic != CM_SCACHE_MAGIC) {
249 afsi_log("cm_ValidateSCache failure: scp->nextp->magic != CM_SCACHE_MAGIC");
250 fprintf(stderr, "cm_ValidateSCache failure: scp->nextp->magic != CM_SCACHE_MAGIC\n");
253 if (scp->randomACLp && scp->randomACLp->magic != CM_ACLENT_MAGIC) {
254 afsi_log("cm_ValidateSCache failure: scp->randomACLp->magic != CM_ACLENT_MAGIC");
255 fprintf(stderr, "cm_ValidateSCache failure: scp->randomACLp->magic != CM_ACLENT_MAGIC\n");
258 if (scp->volp && scp->volp->magic != CM_VOLUME_MAGIC) {
259 afsi_log("cm_ValidateSCache failure: scp->volp->magic != CM_VOLUME_MAGIC");
260 fprintf(stderr, "cm_ValidateSCache failure: scp->volp->magic != CM_VOLUME_MAGIC\n");
263 if (i > cm_data.currentSCaches ) {
264 afsi_log("cm_ValidateSCache failure: LRU Last queue loops");
265 fprintf(stderr, "cm_ValidateSCache failure: LUR Last queue loops\n");
268 if (lscp != (cm_scache_t *) osi_QNext(&scp->q)) {
269 afsi_log("cm_ValidateSCache failure: QNext(scp) != next");
270 fprintf(stderr, "cm_ValidateSCache failure: QNext(scp) != next\n");
275 for ( i=0; i < cm_data.hashTableSize; i++ ) {
276 for ( scp = cm_data.hashTablep[i]; scp; scp = scp->nextp ) {
277 if (scp->magic != CM_SCACHE_MAGIC) {
278 afsi_log("cm_ValidateSCache failure: scp->magic != CM_SCACHE_MAGIC");
279 fprintf(stderr, "cm_ValidateSCache failure: scp->magic != CM_SCACHE_MAGIC\n");
282 if (scp->nextp && scp->nextp->magic != CM_SCACHE_MAGIC) {
283 afsi_log("cm_ValidateSCache failure: scp->nextp->magic != CM_SCACHE_MAGIC");
284 fprintf(stderr, "cm_ValidateSCache failure: scp->nextp->magic != CM_SCACHE_MAGIC\n");
287 if (scp->randomACLp && scp->randomACLp->magic != CM_ACLENT_MAGIC) {
288 afsi_log("cm_ValidateSCache failure: scp->randomACLp->magic != CM_ACLENT_MAGIC");
289 fprintf(stderr, "cm_ValidateSCache failure: scp->randomACLp->magic != CM_ACLENT_MAGIC\n");
292 if (scp->volp && scp->volp->magic != CM_VOLUME_MAGIC) {
293 afsi_log("cm_ValidateSCache failure: scp->volp->magic != CM_VOLUME_MAGIC");
294 fprintf(stderr, "cm_ValidateSCache failure: scp->volp->magic != CM_VOLUME_MAGIC\n");
300 return cm_dnlcValidate();
304 cm_ShutdownSCache(void)
308 for ( scp = cm_data.scacheLRULastp; scp;
309 scp = (cm_scache_t *) osi_QPrev(&scp->q) ) {
310 if (scp->randomACLp) {
311 lock_ObtainMutex(&scp->mx);
312 cm_FreeAllACLEnts(scp);
313 lock_ReleaseMutex(&scp->mx);
315 lock_FinalizeMutex(&scp->mx);
316 lock_FinalizeRWLock(&scp->bufCreateLock);
319 return cm_dnlcShutdown();
322 void cm_InitSCache(int newFile, long maxSCaches)
324 static osi_once_t once;
326 if (osi_Once(&once)) {
327 lock_InitializeRWLock(&cm_scacheLock, "cm_scacheLock");
329 memset(cm_data.hashTablep, 0, sizeof(cm_scache_t *) * cm_data.hashTableSize);
330 cm_data.currentSCaches = 0;
331 cm_data.maxSCaches = maxSCaches;
332 cm_data.scacheLRUFirstp = cm_data.scacheLRULastp = NULL;
336 for ( scp = cm_data.scacheLRULastp; scp;
337 scp = (cm_scache_t *) osi_QPrev(&scp->q) ) {
338 lock_InitializeMutex(&scp->mx, "cm_scache_t mutex");
339 lock_InitializeRWLock(&scp->bufCreateLock, "cm_scache_t bufCreateLock");
341 scp->cbServerp = NULL;
343 scp->fileLocks = NULL;
349 scp->flags &= ~CM_SCACHEFLAG_WAITING;
352 cm_allFileLocks = NULL;
353 cm_fakeSCacheInit(newFile);
354 cm_dnlcInit(newFile);
359 /* version that doesn't bother creating the entry if we don't find it */
360 cm_scache_t *cm_FindSCache(cm_fid_t *fidp)
365 hash = CM_SCACHE_HASH(fidp);
367 osi_assert(fidp->cell != 0);
369 lock_ObtainWrite(&cm_scacheLock);
370 for (scp=cm_data.hashTablep[hash]; scp; scp=scp->nextp) {
371 if (cm_FidCmp(fidp, &scp->fid) == 0) {
372 cm_HoldSCacheNoLock(scp);
374 lock_ReleaseWrite(&cm_scacheLock);
378 lock_ReleaseWrite(&cm_scacheLock);
382 long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
388 cm_volume_t *volp = 0;
391 int special; // yj: boolean variable to test if file is on root.afs
393 extern cm_fid_t cm_rootFid;
395 hash = CM_SCACHE_HASH(fidp);
397 osi_assert(fidp->cell != 0);
399 if (fidp->cell== cm_data.rootFid.cell &&
400 fidp->volume==cm_data.rootFid.volume &&
401 fidp->vnode==0x0 && fidp->unique==0x0)
403 osi_Log0(afsd_logp,"cm_getSCache called with root cell/volume and vnode=0 and unique=0");
406 // yj: check if we have the scp, if so, we don't need
407 // to do anything else
408 lock_ObtainWrite(&cm_scacheLock);
409 for (scp=cm_data.hashTablep[hash]; scp; scp=scp->nextp) {
410 if (cm_FidCmp(fidp, &scp->fid) == 0) {
411 cm_HoldSCacheNoLock(scp);
414 lock_ReleaseWrite(&cm_scacheLock);
419 // yj: when we get here, it means we don't have an scp
420 // so we need to either load it or fake it, depending
421 // on whether the file is "special", see below.
423 // yj: if we're trying to get an scp for a file that's
424 // on root.afs of homecell, we want to handle it specially
425 // because we have to fill in the status stuff 'coz we
426 // don't want trybulkstat to fill it in for us
427 #ifdef AFS_FREELANCE_CLIENT
428 special = (fidp->cell==AFS_FAKE_ROOT_CELL_ID &&
429 fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
430 !(fidp->vnode==0x1 && fidp->unique==0x1));
431 isRoot = (fidp->cell==AFS_FAKE_ROOT_CELL_ID &&
432 fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
433 fidp->vnode==0x1 && fidp->unique==0x1);
434 if (cm_freelanceEnabled && isRoot) {
435 osi_Log0(afsd_logp,"cm_getSCache Freelance and isRoot");
436 /* freelance: if we are trying to get the root scp for the first
437 * time, we will just put in a place holder entry.
442 if (cm_freelanceEnabled && special) {
443 osi_Log0(afsd_logp,"cm_getSCache Freelance and special");
444 if (fidp->vnode > 1 && fidp->vnode <= cm_noLocalMountPoints + 2) {
445 lock_ObtainMutex(&cm_Freelance_Lock);
446 mp =(cm_localMountPoints+fidp->vnode-2)->mountPointStringp;
447 lock_ReleaseMutex(&cm_Freelance_Lock);
451 scp = cm_GetNewSCache();
454 scp->volp = cm_data.rootSCachep->volp;
455 scp->dotdotFid.cell=AFS_FAKE_ROOT_CELL_ID;
456 scp->dotdotFid.volume=AFS_FAKE_ROOT_VOL_ID;
457 scp->dotdotFid.unique=1;
458 scp->dotdotFid.vnode=1;
459 scp->flags |= (CM_SCACHEFLAG_PURERO | CM_SCACHEFLAG_RO);
460 scp->nextp=cm_data.hashTablep[hash];
461 cm_data.hashTablep[hash]=scp;
462 scp->flags |= CM_SCACHEFLAG_INHASH;
464 if (fidp->vnode > 1 && fidp->vnode <= cm_noLocalMountPoints + 2)
465 scp->fileType = (cm_localMountPoints+fidp->vnode-2)->fileType;
467 scp->fileType = CM_SCACHETYPE_INVALID;
469 lock_ObtainMutex(&cm_Freelance_Lock);
470 scp->length.LowPart = strlen(mp)+4;
471 strncpy(scp->mountPointStringp,mp,MOUNTPOINTLEN);
472 scp->mountPointStringp[MOUNTPOINTLEN-1] = '\0';
473 lock_ReleaseMutex(&cm_Freelance_Lock);
476 scp->unixModeBits=0x1ff;
477 scp->clientModTime=FakeFreelanceModTime;
478 scp->serverModTime=FakeFreelanceModTime;
479 scp->parentUnique = 0x1;
480 scp->parentVnode=0x1;
482 scp->dataVersion=cm_data.fakeDirVersion;
484 lock_ReleaseWrite(&cm_scacheLock);
485 /*afsi_log(" getscache done");*/
489 #endif /* AFS_FREELANCE_CLIENT */
491 /* otherwise, we need to find the volume */
492 if (!cm_freelanceEnabled || !isRoot) {
493 lock_ReleaseWrite(&cm_scacheLock); /* for perf. reasons */
494 cellp = cm_FindCellByID(fidp->cell);
496 return CM_ERROR_NOSUCHCELL;
498 code = cm_GetVolumeByID(cellp, fidp->volume, userp, reqp, &volp);
501 lock_ObtainWrite(&cm_scacheLock);
504 /* otherwise, we have the volume, now reverify that the scp doesn't
505 * exist, and proceed.
507 for (scp=cm_data.hashTablep[hash]; scp; scp=scp->nextp) {
508 if (cm_FidCmp(fidp, &scp->fid) == 0) {
509 cm_HoldSCacheNoLock(scp);
510 osi_assert(scp->volp == volp);
512 lock_ReleaseWrite(&cm_scacheLock);
520 /* now, if we don't have the fid, recycle something */
521 scp = cm_GetNewSCache();
522 osi_assert(!(scp->flags & CM_SCACHEFLAG_INHASH));
524 scp->volp = volp; /* a held reference */
526 if (!cm_freelanceEnabled || !isRoot) {
527 /* if this scache entry represents a volume root then we need
528 * to copy the dotdotFipd from the volume structure where the
529 * "master" copy is stored (defect 11489)
531 if (scp->fid.vnode == 1 && scp->fid.unique == 1) {
532 scp->dotdotFid = volp->dotdotFid;
535 if (volp->roID == fidp->volume)
536 scp->flags |= (CM_SCACHEFLAG_PURERO | CM_SCACHEFLAG_RO);
537 else if (volp->bkID == fidp->volume)
538 scp->flags |= CM_SCACHEFLAG_RO;
540 scp->nextp = cm_data.hashTablep[hash];
541 cm_data.hashTablep[hash] = scp;
542 scp->flags |= CM_SCACHEFLAG_INHASH;
545 /* XXX - The following fields in the cm_scache are
551 lock_ReleaseWrite(&cm_scacheLock);
553 /* now we have a held scache entry; just return it */
558 /* synchronize a fetch, store, read, write, fetch status or store status.
559 * Called with scache mutex held, and returns with it held, but temporarily
560 * drops it during the fetch.
562 * At most one flag can be on in flags, if this is an RPC request.
564 * Also, if we're fetching or storing data, we must ensure that we have a buffer.
566 * There are a lot of weird restrictions here; here's an attempt to explain the
567 * rationale for the concurrency restrictions implemented in this function.
569 * First, although the file server will break callbacks when *another* machine
570 * modifies a file or status block, the client itself is responsible for
571 * concurrency control on its own requests. Callback breaking events are rare,
572 * and simply invalidate any concurrent new status info.
574 * In the absence of callback breaking messages, we need to know how to
575 * synchronize incoming responses describing updates to files. We synchronize
576 * operations that update the data version by comparing the data versions.
577 * However, updates that do not update the data, but only the status, can't be
578 * synchronized with fetches or stores, since there's nothing to compare
579 * to tell which operation executed first at the server.
581 * Thus, we can allow multiple ops that change file data, or dir data, and
582 * fetches. However, status storing ops have to be done serially.
584 * Furthermore, certain data-changing ops are incompatible: we can't read or
585 * write a buffer while doing a truncate. We can't read and write the same
586 * buffer at the same time, or write while fetching or storing, or read while
587 * fetching a buffer (this may change). We can't fetch and store at the same
590 * With respect to status, we can't read and write at the same time, read while
591 * fetching, write while fetching or storing, or fetch and store at the same time.
593 * We can't allow a get callback RPC to run in concurrently with something that
594 * will return updated status, since we could start a call, have the server
595 * return status, have another machine make an update to the status (which
596 * doesn't change serverModTime), have the original machine get a new callback,
597 * and then have the original machine merge in the early, old info from the
598 * first call. At this point, the easiest way to avoid this problem is to have
599 * getcallback calls conflict with all others for the same vnode. Other calls
600 * to cm_MergeStatus that aren't associated with calls to cm_SyncOp on the same
601 * vnode must be careful not to merge in their status unless they have obtained
602 * a callback from the start of their call.
605 * Concurrent StoreData RPC's can cause trouble if the file is being extended.
606 * Each such RPC passes a FileLength parameter, which the server uses to do
607 * pre-truncation if necessary. So if two RPC's are processed out of order at
608 * the server, the one with the smaller FileLength will be processed last,
609 * possibly resulting in a bogus truncation. The simplest way to avoid this
610 * is to serialize all StoreData RPC's. This is the reason we defined
611 * CM_SCACHESYNC_STOREDATA_EXCL and CM_SCACHEFLAG_DATASTORING.
613 long cm_SyncOp(cm_scache_t *scp, cm_buf_t *bufp, cm_user_t *up, cm_req_t *reqp,
614 long rights, long flags)
616 osi_queueData_t *qdp;
622 /* lookup this first */
623 bufLocked = flags & CM_SCACHESYNC_BUFLOCKED;
625 /* some minor assertions */
626 if (flags & (CM_SCACHESYNC_STOREDATA | CM_SCACHESYNC_FETCHDATA
627 | CM_SCACHESYNC_READ | CM_SCACHESYNC_WRITE
628 | CM_SCACHESYNC_SETSIZE)) {
630 osi_assert(bufp->refCount > 0);
632 osi_assert(cm_FidCmp(&bufp->fid, &scp->fid) == 0);
636 else osi_assert(bufp == NULL);
638 /* Do the access check. Now we don't really do the access check
639 * atomically, since the caller doesn't expect the parent dir to be
640 * returned locked, and that is what we'd have to do to prevent a
641 * callback breaking message on the parent due to a setacl call from
642 * being processed while we're running. So, instead, we check things
643 * here, and if things look fine with the access, we proceed to finish
644 * the rest of this check. Sort of a hack, but probably good enough.
648 if (flags & CM_SCACHESYNC_FETCHSTATUS) {
649 /* if we're bringing in a new status block, ensure that
650 * we aren't already doing so, and that no one is
651 * changing the status concurrently, either. We need
652 * to do this, even if the status is of a different
653 * type, since we don't have the ability to figure out,
654 * in the AFS 3 protocols, which status-changing
655 * operation ran first, or even which order a read and
656 * a write occurred in.
658 if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
659 | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK)) {
660 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is FETCHING|STORING|SIZESTORING|GETCALLBACK want FETCHSTATUS", scp);
664 if (flags & (CM_SCACHESYNC_STORESIZE | CM_SCACHESYNC_STORESTATUS
665 | CM_SCACHESYNC_SETSIZE | CM_SCACHESYNC_GETCALLBACK)) {
666 /* if we're going to make an RPC to change the status, make sure
667 * that no one is bringing in or sending out the status.
669 if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING |
670 CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK)) {
671 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is FETCHING|STORING|SIZESTORING|GETCALLBACK want STORESIZE|STORESTATUS|SETSIZE|GETCALLBACK", scp);
674 if (scp->bufReadsp || scp->bufWritesp) {
675 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is bufRead|bufWrite want STORESIZE|STORESTATUS|SETSIZE|GETCALLBACK", scp);
679 if (flags & CM_SCACHESYNC_FETCHDATA) {
680 /* if we're bringing in a new chunk of data, make sure that
681 * nothing is happening to that chunk, and that we aren't
682 * changing the basic file status info, either.
684 if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
685 | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK)) {
686 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is FETCHING|STORING|SIZESTORING|GETCALLBACK want FETCHDATA", scp);
689 if (bufp && (bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING))) {
690 osi_Log2(afsd_logp, "CM SyncOp scp 0x%x bufp 0x%x is BUF_CMFETCHING|BUF_CMSTORING want FETCHDATA", scp, bufp);
694 if (flags & CM_SCACHESYNC_STOREDATA) {
695 /* same as fetch data */
696 if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
697 | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK)) {
698 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is FETCHING|STORING|SIZESTORING|GETCALLBACK want STOREDATA", scp);
701 if (bufp && (bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING))) {
702 osi_Log2(afsd_logp, "CM SyncOp scp 0x%x bufp 0x%x is BUF_CMFETCHING|BUF_CMSTORING want STOREDATA", scp, bufp);
707 if (flags & CM_SCACHESYNC_STOREDATA_EXCL) {
708 /* Don't allow concurrent StoreData RPC's */
709 if (scp->flags & CM_SCACHEFLAG_DATASTORING) {
710 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is DATASTORING want STOREDATA_EXCL", scp);
715 if (flags & CM_SCACHESYNC_ASYNCSTORE) {
716 /* Don't allow more than one BKG store request */
717 if (scp->flags & CM_SCACHEFLAG_ASYNCSTORING) {
718 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is ASYNCSTORING want ASYNCSTORE", scp);
723 if (flags & CM_SCACHESYNC_LOCK) {
724 /* Don't allow concurrent fiddling with lock lists */
725 if (scp->flags & CM_SCACHEFLAG_LOCKING) {
726 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is LOCKING want LOCK", scp);
731 /* now the operations that don't correspond to making RPCs */
732 if (flags & CM_SCACHESYNC_GETSTATUS) {
733 /* we can use the status that's here, if we're not
734 * bringing in new status.
736 if (scp->flags & (CM_SCACHEFLAG_FETCHING)) {
737 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is FETCHING want GETSTATUS", scp);
741 if (flags & CM_SCACHESYNC_SETSTATUS) {
742 /* we can make a change to the local status, as long as
743 * the status isn't changing now.
745 * If we're fetching or storing a chunk of data, we can
746 * change the status locally, since the fetch/store
747 * operations don't change any of the data that we're
750 if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING | CM_SCACHEFLAG_SIZESTORING)) {
751 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is FETCHING|STORING|SIZESTORING want SETSTATUS", scp);
755 if (flags & CM_SCACHESYNC_READ) {
756 /* we're going to read the data, make sure that the
757 * status is available, and that the data is here. It
758 * is OK to read while storing the data back.
760 if (scp->flags & CM_SCACHEFLAG_FETCHING) {
761 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is FETCHING want READ", scp);
764 if (bufp && ((bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMFULLYFETCHED)) == CM_BUF_CMFETCHING)) {
765 osi_Log2(afsd_logp, "CM SyncOp scp 0x%x bufp 0x%x is BUF_CMFETCHING want READ", scp, bufp);
769 if (flags & CM_SCACHESYNC_WRITE) {
770 /* don't write unless the status is stable and the chunk
773 if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
774 | CM_SCACHEFLAG_SIZESTORING)) {
775 osi_Log1(afsd_logp, "CM SyncOp scp 0x%x is FETCHING|STORING|SIZESTORING want WRITE", scp);
778 if (bufp && (bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING))) {
779 osi_Log2(afsd_logp, "CM SyncOp scp 0x%x bufp 0x%x is BUF_CMFETCHING|BUF_CMSTORING want WRITE", scp, bufp);
784 // yj: modified this so that callback only checked if we're
785 // not checking something on /afs
786 /* fix the conditional to match the one in cm_HaveCallback */
787 if ( (flags & CM_SCACHESYNC_NEEDCALLBACK)
788 #ifdef AFS_FREELANCE_CLIENT
789 && (!cm_freelanceEnabled ||
790 !(scp->fid.vnode==0x1 && scp->fid.unique==0x1) ||
791 scp->fid.cell!=AFS_FAKE_ROOT_CELL_ID ||
792 scp->fid.volume!=AFS_FAKE_ROOT_VOL_ID ||
793 cm_fakeDirCallback < 2)
794 #endif /* AFS_FREELANCE_CLIENT */
796 if (!cm_HaveCallback(scp)) {
797 osi_Log1(afsd_logp, "CM SyncOp getting callback on scp %x",
799 if (bufLocked) lock_ReleaseMutex(&bufp->mx);
800 code = cm_GetCallback(scp, up, reqp, 0);
802 lock_ReleaseMutex(&scp->mx);
803 lock_ObtainMutex(&bufp->mx);
804 lock_ObtainMutex(&scp->mx);
813 /* can't check access rights without a callback */
814 osi_assert(flags & CM_SCACHESYNC_NEEDCALLBACK);
816 if ((rights & PRSFS_WRITE) && (scp->flags & CM_SCACHEFLAG_RO))
817 return CM_ERROR_READONLY;
819 if (cm_HaveAccessRights(scp, up, rights, &outRights)) {
820 if (~outRights & rights) return CM_ERROR_NOACCESS;
823 /* we don't know the required access rights */
824 if (bufLocked) lock_ReleaseMutex(&bufp->mx);
825 code = cm_GetAccessRights(scp, up, reqp);
829 lock_ReleaseMutex(&scp->mx);
830 lock_ObtainMutex(&bufp->mx);
831 lock_ObtainMutex(&scp->mx);
837 /* if we get here, we're happy */
841 /* first check if we're not supposed to wait: fail
842 * in this case, returning with everything still locked.
844 if (flags & CM_SCACHESYNC_NOWAIT)
845 return CM_ERROR_WOULDBLOCK;
847 /* wait here, then try again */
848 osi_Log1(afsd_logp, "CM SyncOp sleeping scp 0x%x", scp);
849 if ( scp->flags & CM_SCACHEFLAG_WAITING ) {
852 osi_Log3(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING already set for 0x%x; %d threads; %d requests",
853 scp, scp->waitCount, scp->waitRequests);
855 osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING set for 0x%x", scp);
856 scp->flags |= CM_SCACHEFLAG_WAITING;
857 scp->waitCount = scp->waitRequests = 1;
860 lock_ReleaseMutex(&bufp->mx);
861 osi_SleepM((long) &scp->flags, &scp->mx);
863 lock_ObtainMutex(&bufp->mx);
864 lock_ObtainMutex(&scp->mx);
866 osi_Log3(afsd_logp, "CM SyncOp woke! scp 0x%x; still waiting %d threads of %d requests",
867 scp, scp->waitCount, scp->waitRequests);
868 if (scp->waitCount == 0) {
869 osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING reset for 0x%x", scp);
870 scp->flags &= ~CM_SCACHEFLAG_WAITING;
871 scp->waitRequests = 0;
873 } /* big while loop */
875 /* now, update the recorded state for RPC-type calls */
876 if (flags & CM_SCACHESYNC_FETCHSTATUS)
877 scp->flags |= CM_SCACHEFLAG_FETCHING;
878 if (flags & CM_SCACHESYNC_STORESTATUS)
879 scp->flags |= CM_SCACHEFLAG_STORING;
880 if (flags & CM_SCACHESYNC_STORESIZE)
881 scp->flags |= CM_SCACHEFLAG_SIZESTORING;
882 if (flags & CM_SCACHESYNC_GETCALLBACK)
883 scp->flags |= CM_SCACHEFLAG_GETCALLBACK;
884 if (flags & CM_SCACHESYNC_STOREDATA_EXCL)
885 scp->flags |= CM_SCACHEFLAG_DATASTORING;
886 if (flags & CM_SCACHESYNC_ASYNCSTORE)
887 scp->flags |= CM_SCACHEFLAG_ASYNCSTORING;
888 if (flags & CM_SCACHESYNC_LOCK)
889 scp->flags |= CM_SCACHEFLAG_LOCKING;
891 /* now update the buffer pointer */
892 if (flags & CM_SCACHESYNC_FETCHDATA) {
893 /* ensure that the buffer isn't already in the I/O list */
895 for(qdp = scp->bufReadsp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
896 tbufp = osi_GetQData(qdp);
897 osi_assert(tbufp != bufp);
901 /* queue a held reference to the buffer in the "reading" I/O list */
903 osi_SetQData(qdp, bufp);
906 bufp->cmFlags |= CM_BUF_CMFETCHING;
908 osi_QAdd((osi_queue_t **) &scp->bufReadsp, &qdp->q);
911 if (flags & CM_SCACHESYNC_STOREDATA) {
912 /* ensure that the buffer isn't already in the I/O list */
914 for(qdp = scp->bufWritesp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
915 tbufp = osi_GetQData(qdp);
916 osi_assert(tbufp != bufp);
920 /* queue a held reference to the buffer in the "writing" I/O list */
922 osi_SetQData(qdp, bufp);
925 bufp->cmFlags |= CM_BUF_CMSTORING;
927 osi_QAdd((osi_queue_t **) &scp->bufWritesp, &qdp->q);
933 /* for those syncops that setup for RPCs.
934 * Called with scache locked.
936 void cm_SyncOpDone(cm_scache_t *scp, cm_buf_t *bufp, long flags)
938 osi_queueData_t *qdp;
941 /* now, update the recorded state for RPC-type calls */
942 if (flags & CM_SCACHESYNC_FETCHSTATUS)
943 scp->flags &= ~CM_SCACHEFLAG_FETCHING;
944 if (flags & CM_SCACHESYNC_STORESTATUS)
945 scp->flags &= ~CM_SCACHEFLAG_STORING;
946 if (flags & CM_SCACHESYNC_STORESIZE)
947 scp->flags &= ~CM_SCACHEFLAG_SIZESTORING;
948 if (flags & CM_SCACHESYNC_GETCALLBACK)
949 scp->flags &= ~CM_SCACHEFLAG_GETCALLBACK;
950 if (flags & CM_SCACHESYNC_STOREDATA_EXCL)
951 scp->flags &= ~CM_SCACHEFLAG_DATASTORING;
952 if (flags & CM_SCACHESYNC_ASYNCSTORE)
953 scp->flags &= ~CM_SCACHEFLAG_ASYNCSTORING;
954 if (flags & CM_SCACHESYNC_LOCK)
955 scp->flags &= ~CM_SCACHEFLAG_LOCKING;
957 /* now update the buffer pointer */
958 if (flags & CM_SCACHESYNC_FETCHDATA) {
959 /* ensure that the buffer isn't already in the I/O list */
960 for(qdp = scp->bufReadsp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
961 tbufp = osi_GetQData(qdp);
962 if (tbufp == bufp) break;
964 osi_assert(qdp != NULL);
965 osi_assert(osi_GetQData(qdp) == bufp);
966 osi_QRemove((osi_queue_t **) &scp->bufReadsp, &qdp->q);
969 bufp->cmFlags &= ~(CM_BUF_CMFETCHING | CM_BUF_CMFULLYFETCHED);
970 if (bufp->flags & CM_BUF_WAITING) {
971 osi_Log2(afsd_logp, "CM SyncOpDone Waking [scp 0x%x] bufp 0x%x", scp, bufp);
972 osi_Wakeup((long) &bufp);
978 /* now update the buffer pointer */
979 if (flags & CM_SCACHESYNC_STOREDATA) {
980 /* ensure that the buffer isn't already in the I/O list */
981 for(qdp = scp->bufWritesp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
982 tbufp = osi_GetQData(qdp);
983 if (tbufp == bufp) break;
985 osi_assert(qdp != NULL);
986 osi_assert(osi_GetQData(qdp) == bufp);
987 osi_QRemove((osi_queue_t **) &scp->bufWritesp, &qdp->q);
990 bufp->cmFlags &= ~CM_BUF_CMSTORING;
991 if (bufp->flags & CM_BUF_WAITING) {
992 osi_Log2(afsd_logp, "CM SyncOpDone Waking [scp 0x%x] bufp 0x%x", scp, bufp);
993 osi_Wakeup((long) &bufp);
999 /* and wakeup anyone who is waiting */
1000 if (scp->flags & CM_SCACHEFLAG_WAITING) {
1001 osi_Log1(afsd_logp, "CM SyncOpDone Waking scp 0x%x", scp);
1002 osi_Wakeup((long) &scp->flags);
1006 /* merge in a response from an RPC. The scp must be locked, and the callback
1009 * Don't overwrite any status info that is dirty, since we could have a store
1010 * operation (such as store data) that merges some info in, and we don't want
1011 * to lose the local updates. Typically, there aren't many updates we do
1012 * locally, anyway, probably only mtime.
1014 * There is probably a bug in here where a chmod (which doesn't change
1015 * serverModTime) that occurs between two fetches, both of whose responses are
1016 * handled after the callback breaking is done, but only one of whose calls
1017 * started before that, can cause old info to be merged from the first call.
1019 void cm_MergeStatus(cm_scache_t *scp, AFSFetchStatus *statusp, AFSVolSync *volp,
1020 cm_user_t *userp, int flags)
1022 // yj: i want to create some fake status for the /afs directory and the
1023 // entries under that directory
1024 #ifdef AFS_FREELANCE_CLIENT
1025 if (cm_freelanceEnabled && scp == cm_data.rootSCachep) {
1026 osi_Log0(afsd_logp,"cm_MergeStatus Freelance cm_data.rootSCachep");
1027 statusp->InterfaceVersion = 0x1;
1028 statusp->FileType = CM_SCACHETYPE_DIRECTORY;
1029 statusp->LinkCount = scp->linkCount;
1030 statusp->Length = cm_fakeDirSize;
1031 statusp->DataVersion = cm_data.fakeDirVersion;
1032 statusp->Author = 0x1;
1033 statusp->Owner = 0x0;
1034 statusp->CallerAccess = 0x9;
1035 statusp->AnonymousAccess = 0x9;
1036 statusp->UnixModeBits = 0x1ff;
1037 statusp->ParentVnode = 0x1;
1038 statusp->ParentUnique = 0x1;
1039 statusp->ResidencyMask = 0;
1040 statusp->ClientModTime = FakeFreelanceModTime;
1041 statusp->ServerModTime = FakeFreelanceModTime;
1043 statusp->SyncCounter = 0;
1044 statusp->dataVersionHigh = 0;
1046 #endif /* AFS_FREELANCE_CLIENT */
1048 if (!(flags & CM_MERGEFLAG_FORCE)
1049 && statusp->DataVersion < (unsigned long) scp->dataVersion) {
1050 struct cm_cell *cellp;
1052 cellp = cm_FindCellByID(scp->fid.cell);
1053 if (scp->cbServerp) {
1054 struct cm_volume *volp = NULL;
1056 cm_GetVolumeByID(cellp, scp->fid.volume, userp,
1057 (cm_req_t *) NULL, &volp);
1058 osi_Log2(afsd_logp, "old data from server %x volume %s",
1059 scp->cbServerp->addr.sin_addr.s_addr,
1060 volp ? volp->namep : "(unknown)");
1064 osi_Log3(afsd_logp, "Bad merge, scp %x, scp dv %d, RPC dv %d",
1065 scp, scp->dataVersion, statusp->DataVersion);
1066 /* we have a number of data fetch/store operations running
1067 * concurrently, and we can tell which one executed last at the
1068 * server by its mtime.
1069 * Choose the one with the largest mtime, and ignore the rest.
1071 * These concurrent calls are incompatible with setting the
1072 * mtime, so we won't have a locally changed mtime here.
1074 * We could also have ACL info for a different user than usual,
1075 * in which case we have to do that part of the merge, anyway.
1076 * We won't have to worry about the info being old, since we
1077 * won't have concurrent calls
1078 * that change file status running from this machine.
1080 * Added 3/17/98: if we see data version regression on an RO
1081 * file, it's probably due to a server holding an out-of-date
1082 * replica, rather than to concurrent RPC's. Failures to
1083 * release replicas are now flagged by the volserver, but only
1084 * since AFS 3.4 5.22, so there are plenty of clients getting
1085 * out-of-date replicas out there.
1087 * If we discover an out-of-date replica, by this time it's too
1088 * late to go to another server and retry. Also, we can't
1089 * reject the merge, because then there is no way for
1090 * GetAccess to do its work, and the caller gets into an
1091 * infinite loop. So we just grin and bear it.
1093 if (!(scp->flags & CM_SCACHEFLAG_RO))
1096 scp->serverModTime = statusp->ServerModTime;
1098 if (!(scp->mask & CM_SCACHEMASK_CLIENTMODTIME)) {
1099 scp->clientModTime = statusp->ClientModTime;
1101 if (!(scp->mask & CM_SCACHEMASK_LENGTH)) {
1102 scp->length.LowPart = statusp->Length;
1103 scp->length.HighPart = 0;
1106 scp->serverLength.LowPart = statusp->Length;
1107 scp->serverLength.HighPart = 0;
1109 scp->linkCount = statusp->LinkCount;
1110 scp->dataVersion = statusp->DataVersion;
1111 scp->owner = statusp->Owner;
1112 scp->group = statusp->Group;
1113 scp->unixModeBits = statusp->UnixModeBits & 07777;
1115 if (statusp->FileType == File)
1116 scp->fileType = CM_SCACHETYPE_FILE;
1117 else if (statusp->FileType == Directory)
1118 scp->fileType = CM_SCACHETYPE_DIRECTORY;
1119 else if (statusp->FileType == SymbolicLink) {
1120 if ((scp->unixModeBits & 0111) == 0)
1121 scp->fileType = CM_SCACHETYPE_MOUNTPOINT;
1123 scp->fileType = CM_SCACHETYPE_SYMLINK;
1126 osi_Log1(afsd_logp, "Merge, Invalid File Type, scp %x", scp);
1127 scp->fileType = 0; /* invalid */
1129 /* and other stuff */
1130 scp->parentVnode = statusp->ParentVnode;
1131 scp->parentUnique = statusp->ParentUnique;
1133 /* and merge in the private acl cache info, if this is more than the public
1134 * info; merge in the public stuff in any case.
1136 scp->anyAccess = statusp->AnonymousAccess;
1138 if (userp != NULL) {
1139 cm_AddACLCache(scp, userp, statusp->CallerAccess);
1143 /* note that our stat cache info is incorrect, so force us eventually
1144 * to stat the file again. There may be dirty data associated with
1145 * this vnode, and we want to preserve that information.
1147 * This function works by simply simulating a loss of the callback.
1149 * This function must be called with the scache locked.
1151 void cm_DiscardSCache(cm_scache_t *scp)
1153 lock_AssertMutex(&scp->mx);
1154 if (scp->cbServerp) {
1155 cm_PutServer(scp->cbServerp);
1156 scp->cbServerp = NULL;
1159 cm_dnlcPurgedp(scp);
1160 cm_dnlcPurgevp(scp);
1161 cm_FreeAllACLEnts(scp);
1164 void cm_AFSFidFromFid(AFSFid *afsFidp, cm_fid_t *fidp)
1166 afsFidp->Volume = fidp->volume;
1167 afsFidp->Vnode = fidp->vnode;
1168 afsFidp->Unique = fidp->unique;
1171 void cm_HoldSCacheNoLock(cm_scache_t *scp)
1173 osi_assert(scp != 0);
1174 osi_assert(scp->refCount >= 0);
1178 void cm_HoldSCache(cm_scache_t *scp)
1180 osi_assert(scp != 0);
1181 lock_ObtainWrite(&cm_scacheLock);
1182 osi_assert(scp->refCount >= 0);
1184 lock_ReleaseWrite(&cm_scacheLock);
1187 void cm_ReleaseSCacheNoLock(cm_scache_t *scp)
1189 osi_assert(scp != 0);
1190 osi_assert(scp->refCount-- >= 0);
1193 void cm_ReleaseSCache(cm_scache_t *scp)
1195 osi_assert(scp != 0);
1196 lock_ObtainWrite(&cm_scacheLock);
1197 osi_assert(scp->refCount != 0);
1199 lock_ReleaseWrite(&cm_scacheLock);
1202 /* just look for the scp entry to get filetype */
1203 /* doesn't need to be perfectly accurate, so locking doesn't matter too much */
1204 int cm_FindFileType(cm_fid_t *fidp)
1209 hash = CM_SCACHE_HASH(fidp);
1211 osi_assert(fidp->cell != 0);
1213 lock_ObtainWrite(&cm_scacheLock);
1214 for (scp=cm_data.hashTablep[hash]; scp; scp=scp->nextp) {
1215 if (cm_FidCmp(fidp, &scp->fid) == 0) {
1216 lock_ReleaseWrite(&cm_scacheLock);
1217 return scp->fileType;
1220 lock_ReleaseWrite(&cm_scacheLock);
1224 /* dump all scp's that have reference count > 0 to a file.
1225 * cookie is used to identify this batch for easy parsing,
1226 * and it a string provided by a caller
1228 int cm_DumpSCache(FILE *outputFile, char *cookie, int lock)
1236 lock_ObtainRead(&cm_scacheLock);
1238 sprintf(output, "%s - dumping scache - cm_data.currentSCaches=%d, cm_data.maxSCaches=%d\n", cookie, cm_data.currentSCaches, cm_data.maxSCaches);
1239 WriteFile(outputFile, output, strlen(output), &zilch, NULL);
1241 for (scp = cm_data.scacheLRULastp; scp; scp = (cm_scache_t *) osi_QPrev(&scp->q))
1243 if (scp->refCount != 0)
1245 sprintf(output, "%s fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%u\n",
1246 cookie, scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique,
1248 WriteFile(outputFile, output, strlen(output), &zilch, NULL);
1252 sprintf(output, "%s - dumping cm_data.hashTable - cm_data.hashTableSize=%d\n", cookie, cm_data.hashTableSize);
1253 WriteFile(outputFile, output, strlen(output), &zilch, NULL);
1255 for (i = 0; i < cm_data.hashTableSize; i++)
1257 for(scp = cm_data.hashTablep[i]; scp; scp=scp->nextp)
1259 if (scp->refCount != 0)
1261 sprintf(output, "%s scp=0x%08X, hash=%d, fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%u\n",
1262 cookie, (void *)scp, i, scp->fid.cell, scp->fid.volume, scp->fid.vnode,
1263 scp->fid.unique, scp->refCount);
1264 WriteFile(outputFile, output, strlen(output), &zilch, NULL);
1269 sprintf(output, "%s - Done dumping scache.\n", cookie);
1270 WriteFile(outputFile, output, strlen(output), &zilch, NULL);
1273 lock_ReleaseRead(&cm_scacheLock);