Windows: Invalidate all volumes at library init
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 24 Jan 2012 22:09:01 +0000 (17:09 -0500)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 27 Jan 2012 00:11:18 +0000 (16:11 -0800)
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 <jaltman@secure-endpoints.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp
src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h

index 3869d29..93a37fa 100644 (file)
@@ -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)
@@ -7442,6 +7503,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
         //
 
index dca9a63..ad4759c 100644 (file)
@@ -1154,6 +1154,9 @@ NTSTATUS
 AFSInvalidateVolume( IN AFSVolumeCB *VolumeCB,
                      IN ULONG Reason);
 
+VOID
+AFSInvalidateAllVolumes( VOID);
+
 NTSTATUS
 AFSVerifyEntry( IN GUID *AuthGroup,
                 IN AFSDirectoryCB *DirectoryCB);