Windows: AFSPerformObjectInvalidate hold ExtentsResource shared
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 21 Feb 2012 01:50:53 +0000 (20:50 -0500)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 22 Feb 2012 07:53:50 +0000 (23:53 -0800)
The AFSPerformObjectInvalidate() was obtaining exclusive
access to the Fcb ExtentsResource even though it was not
tearing down the extents list.  The ExtentsResource could
be held shared instead.  Doing so will avoid the following
deadlock:

Thread 1:
 nt!MmPurgeSection+0x403
 nt!CcPurgeCacheSection+0x100
 AFSRedirLib!AFSPerformObjectInvalidate+0xd4
 AFSRedirLib!AFSWorkerThread+0xa4
 nt!PspSystemThreadStartup+0x2e

Thread 2:
 AFSRedirLib!AFSAcquireShared+0x18
 AFSRedirLib!AFSMarkDirty+0x68
 AFSRedirLib!AFSNonCachedWrite+0x603
 AFSRedirLib!AFSCommonWrite+0x5fa
 AFSRedirLib!AFSWrite+0x20
 nt!IofCallDriver+0x45
 AFSRedir!AFSWrite+0x57
 nt!IofCallDriver+0x45
 fltMgr!FltpDispatch+0x6f
 nt!IofCallDriver+0x45
 AMFilter+0x2c6e
 nt!IofCallDriver+0x45
 PMDriver+0x112a
 nt!IofCallDriver+0x45
 OpLoader+0x1cd2
 nt!IofCallDriver+0x45
 savonaccesscontrol+0x6f15
 savonaccessfilter+0x2fa0
 nt!IofCallDriver+0x45
 nt!IoAsynchronousPageWrite+0xd0
 nt!MiMappedPageWriter+0x127
 nt!PspSystemThreadStartup+0x2e

Thread 1 is attempting to perform a cache purge which cannot complete
until Thread 2 is finished but Thread 2 requires the ExtentsResource
which is held by Thread 1.

Change-Id: I4582093cf973f61cf6aff0df5e23b6711ec708b3
Reviewed-on: http://gerrit.openafs.org/6744
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSExtentsSupport.cpp
src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp

index 2882409..f2b41c5 100644 (file)
@@ -61,7 +61,7 @@ AFSLockForExtentsTrim( IN AFSFcb *Fcb)
 
     AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
                   AFS_TRACE_LEVEL_VERBOSE,
-                  "AFSLockForExtentsTrim Acuiring Fcb extents lock %08lX EXCL %08lX\n",
+                  "AFSLockForExtentsTrim Acquiring Fcb extents lock %08lX EXCL %08lX\n",
                   &pNPFcb->Specific.File.ExtentsResource,
                   PsGetCurrentThread());
 
@@ -80,7 +80,7 @@ AFSLockForExtentsTrimNoWait( IN AFSFcb *Fcb)
 
     AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
                   AFS_TRACE_LEVEL_VERBOSE,
-                  "AFSLockForExtentsTrimNoWait Attempting to acquiring Fcb extent lock %08lX EXCL %08lX\n",
+                  "AFSLockForExtentsTrimNoWait Attempting to acquire Fcb extent lock %08lX EXCL %08lX\n",
                   &pNPFcb->Specific.File.ExtentsResource,
                   PsGetCurrentThread());
 
index dfd8968..c7c90d7 100644 (file)
@@ -8579,7 +8579,14 @@ AFSPerformObjectInvalidate( IN AFSObjectInfoCB *ObjectInfo,
                     AFSAcquireExcl( &ObjectInfo->Fcb->NPFcb->Resource,
                                     TRUE);
 
-                    AFSLockForExtentsTrim( ObjectInfo->Fcb);
+                    AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+                                  AFS_TRACE_LEVEL_VERBOSE,
+                                  "AFSPerformObjectInvalidate Acquiring Fcb extents lock %08lX EXCL %08lX\n",
+                                  &ObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource,
+                                  PsGetCurrentThread());
+
+                    AFSAcquireShared( &ObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource,
+                                      TRUE);
 
                     __try
                     {