mirror of
https://github.com/reactos/reactos.git
synced 2025-07-08 17:27:55 +00:00
[NTOS:CC] Protect CcFlushCache call with a mutex
Fix crash when the function was called concurrently for the same file by BTRFS driver. CORE-19664
This commit is contained in:
parent
0899f4b2b1
commit
cf4138fa24
2 changed files with 8 additions and 2 deletions
|
@ -1142,6 +1142,8 @@ CcFlushCache (
|
||||||
IoStatus->Information = 0;
|
IoStatus->Information = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeAcquireGuardedMutex(&SharedCacheMap->FlushCacheLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We flush the VACBs that we find here.
|
* We flush the VACBs that we find here.
|
||||||
* If there is no (dirty) VACB, it doesn't mean that there is no data to flush, so we call Mm to be sure.
|
* If there is no (dirty) VACB, it doesn't mean that there is no data to flush, so we call Mm to be sure.
|
||||||
|
@ -1161,7 +1163,7 @@ CcFlushCache (
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
CcRosReleaseVacb(SharedCacheMap, vacb, FALSE, FALSE);
|
CcRosReleaseVacb(SharedCacheMap, vacb, FALSE, FALSE);
|
||||||
goto quit;
|
break;
|
||||||
}
|
}
|
||||||
DirtyVacb = TRUE;
|
DirtyVacb = TRUE;
|
||||||
|
|
||||||
|
@ -1191,7 +1193,7 @@ CcFlushCache (
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
goto quit;
|
break;
|
||||||
|
|
||||||
if (IoStatus)
|
if (IoStatus)
|
||||||
IoStatus->Information += MmIosb.Information;
|
IoStatus->Information += MmIosb.Information;
|
||||||
|
@ -1211,6 +1213,8 @@ CcFlushCache (
|
||||||
FlushStart -= FlushStart % VACB_MAPPING_GRANULARITY;
|
FlushStart -= FlushStart % VACB_MAPPING_GRANULARITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeReleaseGuardedMutex(&SharedCacheMap->FlushCacheLock);
|
||||||
|
|
||||||
quit:
|
quit:
|
||||||
if (IoStatus)
|
if (IoStatus)
|
||||||
{
|
{
|
||||||
|
@ -1319,6 +1323,7 @@ CcRosInitializeFileCache (
|
||||||
KeInitializeSpinLock(&SharedCacheMap->CacheMapLock);
|
KeInitializeSpinLock(&SharedCacheMap->CacheMapLock);
|
||||||
InitializeListHead(&SharedCacheMap->CacheMapVacbListHead);
|
InitializeListHead(&SharedCacheMap->CacheMapVacbListHead);
|
||||||
InitializeListHead(&SharedCacheMap->BcbList);
|
InitializeListHead(&SharedCacheMap->BcbList);
|
||||||
|
KeInitializeGuardedMutex(&SharedCacheMap->FlushCacheLock);
|
||||||
|
|
||||||
SharedCacheMap->Flags = SHARED_CACHE_MAP_IN_CREATION;
|
SharedCacheMap->Flags = SHARED_CACHE_MAP_IN_CREATION;
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,7 @@ typedef struct _ROS_SHARED_CACHE_MAP
|
||||||
LIST_ENTRY CacheMapVacbListHead;
|
LIST_ENTRY CacheMapVacbListHead;
|
||||||
BOOLEAN PinAccess;
|
BOOLEAN PinAccess;
|
||||||
KSPIN_LOCK CacheMapLock;
|
KSPIN_LOCK CacheMapLock;
|
||||||
|
KGUARDED_MUTEX FlushCacheLock;
|
||||||
#if DBG
|
#if DBG
|
||||||
BOOLEAN Trace; /* enable extra trace output for this cache map and it's VACBs */
|
BOOLEAN Trace; /* enable extra trace output for this cache map and it's VACBs */
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue