From 3d10edc2d49e0e1c7a7a67c538a932347a91504c Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 24 Jan 2012 17:09:01 -0500 Subject: [PATCH] Windows: Invalidate all volumes at library init The afsredirlib.sys library driver is unloaded when the afsd_service stops and is reloaded when the afsd_service restarts. During the shutdown window any objects known to the kernel are preserved by afsredir.sys. When the afsd_service restarts, there are no valid callbacks on any objects so the afsredirlib.sys must invalidate all status info to permit the service to request a callback from the file server on next use. Change-Id: I3e8fa9513f435ff5cd1a8cfb8daa766aa30dd8c1 Reviewed-on: http://gerrit.openafs.org/6617 Tested-by: Jeffrey Altman Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp | 68 +++++++++++++++++++ .../afsrdr/kernel/lib/Include/AFSCommon.h | 3 + 2 files changed, 71 insertions(+) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp index 3869d29dba..93a37fa5af 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp @@ -2566,6 +2566,67 @@ AFSInvalidateVolume( IN AFSVolumeCB *VolumeCB, return ntStatus; } +VOID +AFSInvalidateAllVolumes( VOID) +{ + AFSVolumeCB *pVolumeCB = NULL; + AFSVolumeCB *pNextVolumeCB = NULL; + AFSDeviceExt *pRDRDeviceExt = NULL; + LONG lCount; + + pRDRDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension; + + AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSInvalidateAllVolumes Acquiring RDR VolumeListLock lock %08lX SHARED %08lX\n", + &pRDRDeviceExt->Specific.RDR.VolumeListLock, + PsGetCurrentThread()); + + AFSAcquireShared( &pRDRDeviceExt->Specific.RDR.VolumeListLock, + TRUE); + + pVolumeCB = pRDRDeviceExt->Specific.RDR.VolumeListHead; + + if ( pVolumeCB) + { + + AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING, + AFS_TRACE_LEVEL_VERBOSE, + "AFSInvalidateAllVolumes Acquiring VolumeRoot ObjectInfoTree lock %08lX SHARED %08lX\n", + pVolumeCB->ObjectInfoTree.TreeLock, + PsGetCurrentThread()); + + lCount = InterlockedIncrement( &pVolumeCB->VolumeReferenceCount); + } + + while( pVolumeCB != NULL) + { + + pNextVolumeCB = (AFSVolumeCB *)pVolumeCB->ListEntry.fLink; + + if ( pNextVolumeCB) + { + + lCount = InterlockedIncrement( &pNextVolumeCB->VolumeReferenceCount); + } + + AFSReleaseResource( &pRDRDeviceExt->Specific.RDR.VolumeListLock); + + // do I need to hold the volume lock here? + + AFSInvalidateVolume( pVolumeCB, AFS_INVALIDATE_EXPIRED); + + AFSAcquireShared( &pRDRDeviceExt->Specific.RDR.VolumeListLock, + TRUE); + + lCount = InterlockedDecrement( &pVolumeCB->VolumeReferenceCount); + + pVolumeCB = pNextVolumeCB; + } + + AFSReleaseResource( &pRDRDeviceExt->Specific.RDR.VolumeListLock); +} + NTSTATUS AFSVerifyEntry( IN GUID *AuthGroup, IN AFSDirectoryCB *DirEntry) @@ -7441,6 +7502,13 @@ AFSInitializeLibrary( IN AFSLibraryInitCB *LibraryInit) SetFlag( AFSGlobalRoot->Flags, AFS_VOLUME_ACTIVE_GLOBAL_ROOT); + // + // Invalidate all known volumes since contact with the service and therefore + // the file server was lost. + // + + AFSInvalidateAllVolumes(); + // // Drop the locks acquired above // diff --git a/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h b/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h index dca9a6333b..ad4759c046 100644 --- a/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h +++ b/src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h @@ -1154,6 +1154,9 @@ NTSTATUS AFSInvalidateVolume( IN AFSVolumeCB *VolumeCB, IN ULONG Reason); +VOID +AFSInvalidateAllVolumes( VOID); + NTSTATUS AFSVerifyEntry( IN GUID *AuthGroup, IN AFSDirectoryCB *DirectoryCB);