/*! * Called on shutdown, should deallocate memory, etc. */ void shutdown_cell(void) { struct afs_q *cq, *tq; struct cell *tc; #ifdef AFS_CACHE_VNODE_PATH if (cacheDiskType != AFS_FCACHE_TYPE_MEM) { afs_osi_FreeStr(afs_cellname_inode.ufs); } #endif AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell"); for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { tc = QTOC(cq); tq = QNext(cq); if (tc->cellName) afs_osi_FreeStr(tc->cellName); afs_osi_Free(tc, sizeof(struct cell)); } QInit(&CellLRU); { struct cell_name *cn = afs_cellname_head; while (cn) { struct cell_name *next = cn->next; afs_osi_FreeStr(cn->cellname); afs_osi_Free(cn, sizeof(struct cell_name)); cn = next; } } }
/* Does this dcache conflict with a multiPage request for this vcache? * * This function only exists for Solaris. This is used by afs_GetDownD to * calculate if trying to evict the given dcache may deadlock with an * in-progress afs_getpage call that is trying to get more than one page at * once. See afs_getpage for details. We return 0 if we do NOT conflict, * nonzero otherwise. If we return nonzero, we should NOT try to evict the * given dcache entry from the cache. * * Locking: tvc->vlock is write-locked on entry (and GLOCK is held) */ int osi_VM_MultiPageConflict(struct vcache *avc, struct dcache *adc) { struct multiPage_range *range; for (range = (struct multiPage_range *)avc->multiPage.next; range != &avc->multiPage; range = (struct multiPage_range *)QNext(&range->q)) { if (adc->f.chunk >= AFS_CHUNK(range->off) && adc->f.chunk <= AFS_CHUNK(range->off + range->len - 1)) { return 1; } } return 0; }
/*! * Execute a callback for each existing cell, without a lock on afs_xcell. * Iterate on CellLRU, and execute a callback for each cell until given arguments are met. * \see afs_TraverseCells * \param cb Traversal callback for each cell. * \param arg Callback arguments. * \return Found data or NULL. */ static void * afs_TraverseCells_nl(void *(*cb) (struct cell *, void *), void *arg) { struct afs_q *cq, *tq; struct cell *tc; void *ret = NULL; for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { tc = QTOC(cq); /* This is assuming that a NULL return is acceptable. */ if (cq) { tq = QNext(cq); } else { return NULL; } ret = cb(tc, arg); if (ret) break; } return ret; }