From 87f6d5a8f003f71724c7a49c6ab178a3f1efd2f9 Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Sat, 8 May 2004 05:33:07 +0000 Subject: [PATCH] writethru-dslots-allocate-once-20040507 FIXES 4071 only allocate once for WriteThroughDSlots --- src/afs/afs.h | 1 + src/afs/afs_dcache.c | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/afs/afs.h b/src/afs/afs.h index c3464ef69..355a29345 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -932,6 +932,7 @@ struct fcache { /* 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 */ diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 0fe30cdae..4b5c69fdd 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -2582,8 +2582,8 @@ afs_WriteThroughDSlots(void) { 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); @@ -2593,9 +2593,7 @@ afs_WriteThroughDSlots(void) * 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]; @@ -2605,7 +2603,7 @@ afs_WriteThroughDSlots(void) tdc->refCount++; ReleaseWriteLock(&tdc->tlock); - ents[entcount++] = tdc; + QAdd(&DirtyQ, &tdc->dirty); } } MReleaseWriteLock(&afs_xdcache); @@ -2616,9 +2614,11 @@ afs_WriteThroughDSlots(void) * 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; @@ -2638,7 +2638,6 @@ afs_WriteThroughDSlots(void) afs_PutDCache(tdc); } - afs_osi_Free(ents, entmax * sizeof(struct dcache *)); MObtainWriteLock(&afs_xdcache, 617); if (!touchedit && (cacheDiskType != AFS_FCACHE_TYPE_MEM)) { -- 2.39.5