mirror of
https://github.com/reactos/reactos.git
synced 2025-04-28 01:11:35 +00:00
- Fixed some locking problems during different processes access the same sections (dlls).
- Reduced the overhead in MmCreateImageSection if for a file the caching is initialized already. - Moved some values from SECTION_OBJECT to MM_IMAGE_SECTION_OBJECT. - Removed the lock from SECTION_OBJECT. svn path=/trunk/; revision=4982
This commit is contained in:
parent
8abf146aac
commit
9195641c84
5 changed files with 675 additions and 587 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: view.c,v 1.63 2003/06/16 19:16:32 hbirr Exp $
|
/* $Id: view.c,v 1.64 2003/06/27 21:28:30 hbirr Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/cc/view.c
|
* FILE: ntoskrnl/cc/view.c
|
||||||
|
@ -1077,6 +1077,39 @@ CcRosReleaseFileCache(PFILE_OBJECT FileObject)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
CcTryToInitializeFileCache(PFILE_OBJECT FileObject)
|
||||||
|
{
|
||||||
|
PBCB Bcb;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
ExAcquireFastMutex(&ViewLock);
|
||||||
|
|
||||||
|
Bcb = FileObject->SectionObjectPointer->SharedCacheMap;
|
||||||
|
if (Bcb == NULL)
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (FileObject->PrivateCacheMap == NULL)
|
||||||
|
{
|
||||||
|
FileObject->PrivateCacheMap = Bcb;
|
||||||
|
Bcb->RefCount++;
|
||||||
|
}
|
||||||
|
if (Bcb->BcbRemoveListEntry.Flink != NULL)
|
||||||
|
{
|
||||||
|
RemoveEntryList(&Bcb->BcbRemoveListEntry);
|
||||||
|
Bcb->BcbRemoveListEntry.Flink = NULL;
|
||||||
|
}
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
ExReleaseFastMutex(&ViewLock);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
CcRosInitializeFileCache(PFILE_OBJECT FileObject,
|
CcRosInitializeFileCache(PFILE_OBJECT FileObject,
|
||||||
ULONG CacheSegmentSize)
|
ULONG CacheSegmentSize)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef __INCLUDE_INTERNAL_CC_H
|
#ifndef __INCLUDE_INTERNAL_CC_H
|
||||||
#define __INCLUDE_INTERNAL_CC_H
|
#define __INCLUDE_INTERNAL_CC_H
|
||||||
/* $Id: cc.h,v 1.17 2003/01/11 15:21:09 hbirr Exp $ */
|
/* $Id: cc.h,v 1.18 2003/06/27 21:28:30 hbirr Exp $ */
|
||||||
#include <ddk/ntifs.h>
|
#include <ddk/ntifs.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ VOID CcInit(VOID);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty);
|
CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty);
|
||||||
|
|
||||||
NTSTATUS
|
PCACHE_SEGMENT
|
||||||
CcRosSuggestFreeCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty);
|
CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
CcRosGetCacheSegmentChain(PBCB Bcb,
|
CcRosGetCacheSegmentChain(PBCB Bcb,
|
||||||
|
@ -127,5 +127,8 @@ CcRosRequestCacheSegment (BCB* Bcb,
|
||||||
PBOOLEAN UptoDate,
|
PBOOLEAN UptoDate,
|
||||||
CACHE_SEGMENT** CacheSeg);
|
CACHE_SEGMENT** CacheSeg);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
CcTryToInitializeFileCache(PFILE_OBJECT FileObject);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -79,7 +79,7 @@ typedef struct _MM_SECTION_SEGMENT
|
||||||
ULONG Attributes;
|
ULONG Attributes;
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
ULONG RawLength;
|
ULONG RawLength;
|
||||||
KMUTEX Lock;
|
FAST_MUTEX Lock;
|
||||||
ULONG ReferenceCount;
|
ULONG ReferenceCount;
|
||||||
SECTION_PAGE_DIRECTORY PageDirectory;
|
SECTION_PAGE_DIRECTORY PageDirectory;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
|
@ -88,6 +88,22 @@ typedef struct _MM_SECTION_SEGMENT
|
||||||
BOOLEAN WriteCopy;
|
BOOLEAN WriteCopy;
|
||||||
} MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
|
} MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
|
||||||
|
|
||||||
|
typedef struct _MM_IMAGE_SECTION_OBJECT
|
||||||
|
{
|
||||||
|
PVOID ImageBase;
|
||||||
|
PVOID EntryPoint;
|
||||||
|
ULONG StackReserve;
|
||||||
|
ULONG StackCommit;
|
||||||
|
ULONG Subsystem;
|
||||||
|
ULONG MinorSubsystemVersion;
|
||||||
|
ULONG MajorSubsystemVersion;
|
||||||
|
ULONG ImageCharacteristics;
|
||||||
|
USHORT Machine;
|
||||||
|
BOOLEAN Executable;
|
||||||
|
ULONG NrSegments;
|
||||||
|
MM_SECTION_SEGMENT Segments[0];
|
||||||
|
} MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT;
|
||||||
|
|
||||||
typedef struct _SECTION_OBJECT
|
typedef struct _SECTION_OBJECT
|
||||||
{
|
{
|
||||||
CSHORT Type;
|
CSHORT Type;
|
||||||
|
@ -98,19 +114,11 @@ typedef struct _SECTION_OBJECT
|
||||||
PFILE_OBJECT FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
LIST_ENTRY ViewListHead;
|
LIST_ENTRY ViewListHead;
|
||||||
KSPIN_LOCK ViewListLock;
|
KSPIN_LOCK ViewListLock;
|
||||||
KMUTEX Lock;
|
union
|
||||||
ULONG NrSegments;
|
{
|
||||||
PMM_SECTION_SEGMENT Segments;
|
PMM_IMAGE_SECTION_OBJECT ImageSection;
|
||||||
PVOID ImageBase;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
PVOID EntryPoint;
|
};
|
||||||
ULONG StackReserve;
|
|
||||||
ULONG StackCommit;
|
|
||||||
ULONG Subsystem;
|
|
||||||
ULONG MinorSubsystemVersion;
|
|
||||||
ULONG MajorSubsystemVersion;
|
|
||||||
ULONG ImageCharacteristics;
|
|
||||||
USHORT Machine;
|
|
||||||
BOOLEAN Executable;
|
|
||||||
} SECTION_OBJECT;
|
} SECTION_OBJECT;
|
||||||
|
|
||||||
#ifndef __USE_W32API
|
#ifndef __USE_W32API
|
||||||
|
@ -444,11 +452,7 @@ MmMarkPageUnmapped(PHYSICAL_ADDRESS PhysicalAddress);
|
||||||
VOID
|
VOID
|
||||||
MmFreeSectionSegments(PFILE_OBJECT FileObject);
|
MmFreeSectionSegments(PFILE_OBJECT FileObject);
|
||||||
|
|
||||||
typedef struct _MM_IMAGE_SECTION_OBJECT
|
|
||||||
{
|
|
||||||
ULONG NrSegments;
|
|
||||||
MM_SECTION_SEGMENT Segments[0];
|
|
||||||
} MM_IMAGE_SECTION_OBJECT, *PMM_IMAGE_SECTION_OBJECT;
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
MmFreeVirtualMemory(struct _EPROCESS* Process, PMEMORY_AREA MemoryArea);
|
MmFreeVirtualMemory(struct _EPROCESS* Process, PMEMORY_AREA MemoryArea);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: rmap.c,v 1.18 2003/06/06 21:01:36 hbirr Exp $
|
/* $Id: rmap.c,v 1.19 2003/06/27 21:28:30 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top directory
|
* COPYRIGHT: See COPYING in the top directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -150,8 +150,14 @@ MmWritePagePhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
||||||
|
|
||||||
if (PageOp->Thread != PsGetCurrentThread())
|
if (PageOp->Thread != PsGetCurrentThread())
|
||||||
{
|
{
|
||||||
MmReleasePageOp(PageOp);
|
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
|
Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
|
||||||
|
0,
|
||||||
|
KernelMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
|
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||||
|
MmReleasePageOp(PageOp);
|
||||||
if (Address < (PVOID)KERNEL_BASE)
|
if (Address < (PVOID)KERNEL_BASE)
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
@ -298,8 +304,14 @@ MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
||||||
Address, NULL, 0, MM_PAGEOP_PAGEOUT);
|
Address, NULL, 0, MM_PAGEOP_PAGEOUT);
|
||||||
if (PageOp->Thread != PsGetCurrentThread())
|
if (PageOp->Thread != PsGetCurrentThread())
|
||||||
{
|
{
|
||||||
MmReleasePageOp(PageOp);
|
|
||||||
MmUnlockAddressSpace(AddressSpace);
|
MmUnlockAddressSpace(AddressSpace);
|
||||||
|
Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
|
||||||
|
0,
|
||||||
|
KernelMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
|
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||||
|
MmReleasePageOp(PageOp);
|
||||||
if (Address < (PVOID)KERNEL_BASE)
|
if (Address < (PVOID)KERNEL_BASE)
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
@ -443,6 +455,7 @@ MmDeleteAllRmaps(PHYSICAL_ADDRESS PhysicalAddress, PVOID Context,
|
||||||
DPRINT1("MmDeleteAllRmaps: No rmaps.\n");
|
DPRINT1("MmDeleteAllRmaps: No rmaps.\n");
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
}
|
}
|
||||||
|
MmSetRmapListHeadPage(PhysicalAddress, NULL);
|
||||||
while (current_entry != NULL)
|
while (current_entry != NULL)
|
||||||
{
|
{
|
||||||
previous_entry = current_entry;
|
previous_entry = current_entry;
|
||||||
|
@ -454,7 +467,6 @@ MmDeleteAllRmaps(PHYSICAL_ADDRESS PhysicalAddress, PVOID Context,
|
||||||
}
|
}
|
||||||
ExFreeToNPagedLookasideList(&RmapLookasideList, previous_entry);
|
ExFreeToNPagedLookasideList(&RmapLookasideList, previous_entry);
|
||||||
}
|
}
|
||||||
MmSetRmapListHeadPage(PhysicalAddress, NULL);
|
|
||||||
ExReleaseFastMutex(&RmapListLock);
|
ExReleaseFastMutex(&RmapListLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue