diff --git a/src/afs/afs_buffer.c b/src/afs/afs_buffer.c index 4a9b58e2f5..9597cd52a7 100644 --- a/src/afs/afs_buffer.c +++ b/src/afs/afs_buffer.c @@ -515,6 +515,31 @@ DFlushBuffer(struct buffer *ab) afs_CFileClose(tfile); } +void +DFlushDCache(struct dcache *adc) +{ + int i; + struct buffer *tb; + + ObtainReadLock(&afs_bufferLock); + + for (i = 0; i <= PHPAGEMASK; i++) + for (tb = phTable[pHash(adc->index, i)]; tb != NULL; tb = tb->hashNext) + if (tb->fid == adc->index) { + ObtainWriteLock(&tb->lock, 701); + tb->lockers++; + ReleaseReadLock(&afs_bufferLock); + if (tb->dirty) { + DFlushBuffer(tb); + } + tb->lockers--; + ReleaseWriteLock(&tb->lock); + ObtainReadLock(&afs_bufferLock); + } + + ReleaseReadLock(&afs_bufferLock); +} + int DFlush(void) { diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 95855037b2..8a941d6af0 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -3879,6 +3879,9 @@ afs_MakeShadowDir(struct vcache *avc, struct dcache *adc) ReleaseWriteLock(&afs_xdcache); + /* Make sure and flush dir buffers back into the disk cache */ + DFlushDCache(adc); + /* Alloc a 4k block. */ data = afs_osi_Alloc(4096); if (!data) { diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 606a3cfc79..3657c669df 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -26,6 +26,7 @@ extern void afs_FreeAllAxs(struct axscache **headp); extern void shutdown_xscache(void); /* afs_buffer.c */ +extern void DFlushDCache(struct dcache *); extern void shutdown_bufferpackage(void); /* afs_call.c */