/* kept in memory */
struct dcache {
struct afs_q lruq; /* Free queue for in-memory images */
+ struct afs_q dirty; /* Queue of dirty entries that need written */
afs_rwlock_t lock; /* Protects validPos, some f */
afs_rwlock_t tlock; /* Atomizes updates to refCount */
afs_rwlock_t mflock; /* Atomizes accesses/updates to mflags */
{
register struct dcache *tdc;
register afs_int32 i, touchedit = 0;
- struct dcache **ents;
- int entmax, entcount;
+
+ struct afs_q DirtyQ, *tq;
AFS_STATCNT(afs_WriteThroughDSlots);
* for every dcache entry, and exit xdcache.
*/
MObtainWriteLock(&afs_xdcache, 283);
- entmax = afs_cacheFiles;
- ents = afs_osi_Alloc(entmax * sizeof(struct dcache *));
- entcount = 0;
+ QInit(&DirtyQ);
for (i = 0; i < afs_cacheFiles; i++) {
tdc = afs_indexTable[i];
tdc->refCount++;
ReleaseWriteLock(&tdc->tlock);
- ents[entcount++] = tdc;
+ QAdd(&DirtyQ, &tdc->dirty);
}
}
MReleaseWriteLock(&afs_xdcache);
* afs_cacheInodep, and flush it. Don't forget to put back
* the refcounts.
*/
- for (i = 0; i < entcount; i++) {
- tdc = ents[i];
+#define DQTODC(q) ((struct dcache *)(((char *) (q)) - sizeof(struct afs_q)))
+
+ for (tq = DirtyQ.prev; tq != &DirtyQ; tq = QPrev(tq)) {
+ tdc = DQTODC(tq);
if (tdc->dflags & DFEntryMod) {
int wrLock;
afs_PutDCache(tdc);
}
- afs_osi_Free(ents, entmax * sizeof(struct dcache *));
MObtainWriteLock(&afs_xdcache, 617);
if (!touchedit && (cacheDiskType != AFS_FCACHE_TYPE_MEM)) {