Windows: AFSPerformObjectInvalidate hold ExtentsResource shared

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>
This commit is contained in:
Jeffrey Altman 2012-02-20 20:50:53 -05:00 committed by Jeffrey Altman
parent 08d800b896
commit 5965c5390b
2 changed files with 10 additions and 3 deletions

View 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());

View 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
{