[NTOSKRNL] Don't keep the spin lock hold too long when we lost the BCB race
authorPierre Schweitzer <pierre@reactos.org>
Fri, 12 Oct 2018 06:20:32 +0000 (08:20 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Fri, 12 Oct 2018 06:20:32 +0000 (08:20 +0200)
This will avoid a deadlock on unpin.

ntoskrnl/cc/pin.c

index bba8796..b3906a9 100644 (file)
@@ -385,6 +385,8 @@ CcPinRead (
         iBcb = CcpFindBcb(SharedCacheMap, FileOffset, Length, TRUE);
         if (iBcb != NULL)
         {
+            KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
+
             /* Free our now unused BCB */
             CcUnpinData(*Bcb);
 
@@ -414,8 +416,8 @@ CcPinRead (
 
             /* Insert ourselves in the linked list */
             InsertTailList(&SharedCacheMap->BcbList, &iBcb->BcbEntry);
+            KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
         }
-        KeReleaseSpinLock(&SharedCacheMap->BcbSpinLock, OldIrql);
     }
     /* We found a BCB, lock it and return it */
     else