3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * PROJECT: ReactOS kernel
21 * FILE: ntoskrnl/mm/pagefile.c
22 * PURPOSE: Paging file functions
23 * PROGRAMMER: David Welch (welch@mcmail.com)
28 /* INCLUDES *****************************************************************/
34 #if defined (ALLOC_PRAGMA)
35 #pragma alloc_text(INIT, MmInitPagingFile)
40 MiFindExportedRoutineByName(IN PVOID DllBase
,
41 IN PANSI_STRING ExportName
);
43 /* TYPES *********************************************************************/
45 typedef struct _PAGINGFILE
47 LIST_ENTRY PagingFileListEntry
;
48 PFILE_OBJECT FileObject
;
49 LARGE_INTEGER MaximumSize
;
50 LARGE_INTEGER CurrentSize
;
54 KSPIN_LOCK AllocMapLock
;
56 PRETRIEVAL_POINTERS_BUFFER RetrievalPointers
;
58 PAGINGFILE
, *PPAGINGFILE
;
60 typedef struct _RETRIEVEL_DESCRIPTOR_LIST
62 struct _RETRIEVEL_DESCRIPTOR_LIST
* Next
;
63 RETRIEVAL_POINTERS_BUFFER RetrievalPointers
;
65 RETRIEVEL_DESCRIPTOR_LIST
, *PRETRIEVEL_DESCRIPTOR_LIST
;
67 /* GLOBALS *******************************************************************/
69 #define PAIRS_PER_RUN (1024)
71 #define MAX_PAGING_FILES (32)
73 /* List of paging files, both used and free */
74 static PPAGINGFILE PagingFileList
[MAX_PAGING_FILES
];
76 /* Lock for examining the list of paging files */
77 static KSPIN_LOCK PagingFileListLock
;
79 /* Number of paging files */
80 static ULONG MiPagingFileCount
;
81 ULONG MmNumberOfPagingFiles
;
83 /* Number of pages that are available for swapping */
84 PFN_COUNT MiFreeSwapPages
;
86 /* Number of pages that have been allocated for swapping */
87 PFN_COUNT MiUsedSwapPages
;
89 BOOLEAN MmZeroPageFile
;
92 * Number of pages that have been reserved for swapping but not yet allocated
94 static PFN_COUNT MiReservedSwapPages
;
97 * Ratio between reserved and available swap pages, e.g. setting this to five
98 * forces one swap page to be available for every five swap pages that are
99 * reserved. Setting this to zero turns off commit checking altogether.
101 #define MM_PAGEFILE_COMMIT_RATIO (1)
104 * Number of pages that can be used for potentially swapable memory without
105 * pagefile space being reserved. The intention is that this allows smss
106 * to start up and create page files while ordinarily having a commit
109 #define MM_PAGEFILE_COMMIT_GRACE (256)
112 * Translate between a swap entry and a file and offset pair.
114 #define FILE_FROM_ENTRY(i) ((i) & 0x0f)
115 #define OFFSET_FROM_ENTRY(i) ((i) >> 11)
116 #define ENTRY_FROM_FILE_OFFSET(i, j) ((i) | ((j) << 11) | 0x400)
118 /* Make sure there can be only 16 paging files */
119 C_ASSERT(FILE_FROM_ENTRY(0xffffffff) < MAX_PAGING_FILES
);
121 static BOOLEAN MmSwapSpaceMessage
= FALSE
;
123 /* FUNCTIONS *****************************************************************/
127 MmBuildMdlFromPages(PMDL Mdl
, PPFN_NUMBER Pages
)
129 memcpy(Mdl
+ 1, Pages
, sizeof(PFN_NUMBER
) * (PAGE_ROUND_UP(Mdl
->ByteOffset
+Mdl
->ByteCount
)/PAGE_SIZE
));
131 /* FIXME: this flag should be set by the caller perhaps? */
132 Mdl
->MdlFlags
|= MDL_IO_PAGE_READ
;
138 MmIsFileObjectAPagingFile(PFILE_OBJECT FileObject
)
142 /* Loop through all the paging files */
143 for (i
= 0; i
< MiPagingFileCount
; i
++)
145 /* Check if this is one of them */
146 if (PagingFileList
[i
]->FileObject
== FileObject
) return TRUE
;
155 MmShowOutOfSpaceMessagePagingFile(VOID
)
157 if (!MmSwapSpaceMessage
)
159 DPRINT1("MM: Out of swap space.\n");
160 MmSwapSpaceMessage
= TRUE
;
165 MmGetOffsetPageFile(PRETRIEVAL_POINTERS_BUFFER RetrievalPointers
, LARGE_INTEGER Offset
)
167 /* Simple binary search */
168 ULONG first
, last
, mid
;
170 last
= RetrievalPointers
->ExtentCount
- 1;
171 while (first
<= last
)
173 mid
= (last
- first
) / 2 + first
;
174 if (Offset
.QuadPart
< RetrievalPointers
->Extents
[mid
].NextVcn
.QuadPart
)
178 Offset
.QuadPart
+= RetrievalPointers
->Extents
[0].Lcn
.QuadPart
- RetrievalPointers
->StartingVcn
.QuadPart
;
183 if (Offset
.QuadPart
>= RetrievalPointers
->Extents
[mid
-1].NextVcn
.QuadPart
)
185 Offset
.QuadPart
+= RetrievalPointers
->Extents
[mid
].Lcn
.QuadPart
- RetrievalPointers
->Extents
[mid
-1].NextVcn
.QuadPart
;
193 if (mid
== RetrievalPointers
->ExtentCount
- 1)
197 if (Offset
.QuadPart
< RetrievalPointers
->Extents
[mid
+1].NextVcn
.QuadPart
)
199 Offset
.QuadPart
+= RetrievalPointers
->Extents
[mid
+1].Lcn
.QuadPart
- RetrievalPointers
->Extents
[mid
].NextVcn
.QuadPart
;
205 KeBugCheck(MEMORY_MANAGEMENT
);
206 #if defined(__GNUC__)
208 return (LARGE_INTEGER
)0LL;
212 const LARGE_INTEGER dummy
=
223 MmWriteToSwapPage(SWAPENTRY SwapEntry
, PFN_NUMBER Page
)
227 LARGE_INTEGER file_offset
;
228 IO_STATUS_BLOCK Iosb
;
231 UCHAR MdlBase
[sizeof(MDL
) + sizeof(ULONG
)];
232 PMDL Mdl
= (PMDL
)MdlBase
;
234 DPRINT("MmWriteToSwapPage\n");
238 KeBugCheck(MEMORY_MANAGEMENT
);
239 return(STATUS_UNSUCCESSFUL
);
242 i
= FILE_FROM_ENTRY(SwapEntry
);
243 offset
= OFFSET_FROM_ENTRY(SwapEntry
);
245 if (PagingFileList
[i
]->FileObject
== NULL
||
246 PagingFileList
[i
]->FileObject
->DeviceObject
== NULL
)
248 DPRINT1("Bad paging file 0x%.8X\n", SwapEntry
);
249 KeBugCheck(MEMORY_MANAGEMENT
);
252 MmInitializeMdl(Mdl
, NULL
, PAGE_SIZE
);
253 MmBuildMdlFromPages(Mdl
, &Page
);
254 Mdl
->MdlFlags
|= MDL_PAGES_LOCKED
;
256 file_offset
.QuadPart
= offset
* PAGE_SIZE
;
257 file_offset
= MmGetOffsetPageFile(PagingFileList
[i
]->RetrievalPointers
, file_offset
);
259 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
260 Status
= IoSynchronousPageWrite(PagingFileList
[i
]->FileObject
,
265 if (Status
== STATUS_PENDING
)
267 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
268 Status
= Iosb
.Status
;
271 if (Mdl
->MdlFlags
& MDL_MAPPED_TO_SYSTEM_VA
)
273 MmUnmapLockedPages (Mdl
->MappedSystemVa
, Mdl
);
280 MmReadFromSwapPage(SWAPENTRY SwapEntry
, PFN_NUMBER Page
)
284 LARGE_INTEGER file_offset
;
285 IO_STATUS_BLOCK Iosb
;
288 UCHAR MdlBase
[sizeof(MDL
) + sizeof(ULONG
)];
289 PMDL Mdl
= (PMDL
)MdlBase
;
291 DPRINT("MmReadFromSwapPage\n");
295 KeBugCheck(MEMORY_MANAGEMENT
);
296 return(STATUS_UNSUCCESSFUL
);
299 i
= FILE_FROM_ENTRY(SwapEntry
);
300 offset
= OFFSET_FROM_ENTRY(SwapEntry
);
302 if (PagingFileList
[i
]->FileObject
== NULL
||
303 PagingFileList
[i
]->FileObject
->DeviceObject
== NULL
)
305 DPRINT1("Bad paging file 0x%.8X\n", SwapEntry
);
306 KeBugCheck(MEMORY_MANAGEMENT
);
309 MmInitializeMdl(Mdl
, NULL
, PAGE_SIZE
);
310 MmBuildMdlFromPages(Mdl
, &Page
);
311 Mdl
->MdlFlags
|= MDL_PAGES_LOCKED
;
313 file_offset
.QuadPart
= offset
* PAGE_SIZE
;
314 file_offset
= MmGetOffsetPageFile(PagingFileList
[i
]->RetrievalPointers
, file_offset
);
316 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
317 Status
= IoPageRead(PagingFileList
[i
]->FileObject
,
322 if (Status
== STATUS_PENDING
)
324 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
325 Status
= Iosb
.Status
;
327 if (Mdl
->MdlFlags
& MDL_MAPPED_TO_SYSTEM_VA
)
329 MmUnmapLockedPages (Mdl
->MappedSystemVa
, Mdl
);
337 MmInitPagingFile(VOID
)
341 KeInitializeSpinLock(&PagingFileListLock
);
345 MiReservedSwapPages
= 0;
347 for (i
= 0; i
< MAX_PAGING_FILES
; i
++)
349 PagingFileList
[i
] = NULL
;
351 MiPagingFileCount
= 0;
355 MiAllocPageFromPagingFile(PPAGINGFILE PagingFile
)
360 KeAcquireSpinLock(&PagingFile
->AllocMapLock
, &oldIrql
);
362 for (i
= 0; i
< PagingFile
->AllocMapSize
; i
++)
364 for (j
= 0; j
< 32; j
++)
366 if (!(PagingFile
->AllocMap
[i
] & (1 << j
)))
368 PagingFile
->AllocMap
[i
] |= (1 << j
);
369 PagingFile
->UsedPages
++;
370 PagingFile
->FreePages
--;
371 KeReleaseSpinLock(&PagingFile
->AllocMapLock
, oldIrql
);
372 return((i
* 32) + j
);
377 KeReleaseSpinLock(&PagingFile
->AllocMapLock
, oldIrql
);
383 MmFreeSwapPage(SWAPENTRY Entry
)
389 i
= FILE_FROM_ENTRY(Entry
);
390 off
= OFFSET_FROM_ENTRY(Entry
);
392 KeAcquireSpinLock(&PagingFileListLock
, &oldIrql
);
393 if (PagingFileList
[i
] == NULL
)
395 KeBugCheck(MEMORY_MANAGEMENT
);
397 KeAcquireSpinLockAtDpcLevel(&PagingFileList
[i
]->AllocMapLock
);
399 PagingFileList
[i
]->AllocMap
[off
>> 5] &= (~(1 << (off
% 32)));
401 PagingFileList
[i
]->FreePages
++;
402 PagingFileList
[i
]->UsedPages
--;
407 KeReleaseSpinLockFromDpcLevel(&PagingFileList
[i
]->AllocMapLock
);
408 KeReleaseSpinLock(&PagingFileListLock
, oldIrql
);
413 MmAllocSwapPage(VOID
)
420 KeAcquireSpinLock(&PagingFileListLock
, &oldIrql
);
422 if (MiFreeSwapPages
== 0)
424 KeReleaseSpinLock(&PagingFileListLock
, oldIrql
);
428 for (i
= 0; i
< MAX_PAGING_FILES
; i
++)
430 if (PagingFileList
[i
] != NULL
&&
431 PagingFileList
[i
]->FreePages
>= 1)
433 off
= MiAllocPageFromPagingFile(PagingFileList
[i
]);
434 if (off
== 0xFFFFFFFF)
436 KeBugCheck(MEMORY_MANAGEMENT
);
437 KeReleaseSpinLock(&PagingFileListLock
, oldIrql
);
438 return(STATUS_UNSUCCESSFUL
);
442 KeReleaseSpinLock(&PagingFileListLock
, oldIrql
);
444 entry
= ENTRY_FROM_FILE_OFFSET(i
, off
);
449 KeReleaseSpinLock(&PagingFileListLock
, oldIrql
);
450 KeBugCheck(MEMORY_MANAGEMENT
);
454 static PRETRIEVEL_DESCRIPTOR_LIST FASTCALL
455 MmAllocRetrievelDescriptorList(ULONG Pairs
)
458 PRETRIEVEL_DESCRIPTOR_LIST RetDescList
;
460 Size
= sizeof(RETRIEVEL_DESCRIPTOR_LIST
) + Pairs
* 2 * sizeof(LARGE_INTEGER
);
461 RetDescList
= ExAllocatePool(NonPagedPool
, Size
);
464 RtlZeroMemory(RetDescList
, Size
);
471 NtCreatePagingFile(IN PUNICODE_STRING FileName
,
472 IN PLARGE_INTEGER InitialSize
,
473 IN PLARGE_INTEGER MaximumSize
,
477 OBJECT_ATTRIBUTES ObjectAttributes
;
479 IO_STATUS_BLOCK IoStatus
;
480 PFILE_OBJECT FileObject
;
481 PPAGINGFILE PagingFile
;
484 FILE_FS_SIZE_INFORMATION FsSizeInformation
;
485 PRETRIEVEL_DESCRIPTOR_LIST RetDescList
;
486 PRETRIEVEL_DESCRIPTOR_LIST CurrentRetDescList
;
488 ULONG BytesPerAllocationUnit
;
491 LARGE_INTEGER MaxVcn
;
494 KPROCESSOR_MODE PreviousMode
;
495 UNICODE_STRING CapturedFileName
;
496 LARGE_INTEGER SafeInitialSize
, SafeMaximumSize
;
498 DPRINT("NtCreatePagingFile(FileName %wZ, InitialSize %I64d)\n",
499 FileName
, InitialSize
->QuadPart
);
501 if (MiPagingFileCount
>= MAX_PAGING_FILES
)
503 return(STATUS_TOO_MANY_PAGING_FILES
);
506 PreviousMode
= ExGetPreviousMode();
508 if (PreviousMode
!= KernelMode
)
512 SafeInitialSize
= ProbeForReadLargeInteger(InitialSize
);
513 SafeMaximumSize
= ProbeForReadLargeInteger(MaximumSize
);
515 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
517 /* Return the exception code */
518 _SEH2_YIELD(return _SEH2_GetExceptionCode());
524 SafeInitialSize
= *InitialSize
;
525 SafeMaximumSize
= *MaximumSize
;
528 /* Pagefiles can't be larger than 4GB and ofcourse the minimum should be
529 smaller than the maximum */
530 if (0 != SafeInitialSize
.u
.HighPart
)
532 return STATUS_INVALID_PARAMETER_2
;
534 if (0 != SafeMaximumSize
.u
.HighPart
)
536 return STATUS_INVALID_PARAMETER_3
;
538 if (SafeMaximumSize
.u
.LowPart
< SafeInitialSize
.u
.LowPart
)
540 return STATUS_INVALID_PARAMETER_MIX
;
543 Status
= ProbeAndCaptureUnicodeString(&CapturedFileName
,
546 if (!NT_SUCCESS(Status
))
551 InitializeObjectAttributes(&ObjectAttributes
,
557 Status
= IoCreateFile(&FileHandle
,
565 FILE_SYNCHRONOUS_IO_NONALERT
,
570 SL_OPEN_PAGING_FILE
| IO_NO_PARAMETER_CHECKING
);
572 ReleaseCapturedUnicodeString(&CapturedFileName
,
574 if (!NT_SUCCESS(Status
))
579 Status
= ZwQueryVolumeInformationFile(FileHandle
,
582 sizeof(FILE_FS_SIZE_INFORMATION
),
583 FileFsSizeInformation
);
584 if (!NT_SUCCESS(Status
))
590 BytesPerAllocationUnit
= FsSizeInformation
.SectorsPerAllocationUnit
*
591 FsSizeInformation
.BytesPerSector
;
592 /* FIXME: If we have 2048 BytesPerAllocationUnit (FAT16 < 128MB) there is
593 * a problem if the paging file is fragmented. Suppose the first cluster
594 * of the paging file is cluster 3042 but cluster 3043 is NOT part of the
595 * paging file but of another file. We can't write a complete page (4096
596 * bytes) to the physical location of cluster 3042 then. */
597 if (BytesPerAllocationUnit
% PAGE_SIZE
)
599 DPRINT1("BytesPerAllocationUnit %lu is not a multiple of PAGE_SIZE %d\n",
600 BytesPerAllocationUnit
, PAGE_SIZE
);
602 return STATUS_UNSUCCESSFUL
;
605 Status
= ZwSetInformationFile(FileHandle
,
608 sizeof(LARGE_INTEGER
),
609 FileAllocationInformation
);
610 if (!NT_SUCCESS(Status
))
616 Status
= ObReferenceObjectByHandle(FileHandle
,
622 if (!NT_SUCCESS(Status
))
628 CurrentRetDescList
= RetDescList
= MmAllocRetrievelDescriptorList(PAIRS_PER_RUN
);
630 if (CurrentRetDescList
== NULL
)
632 ObDereferenceObject(FileObject
);
634 return(STATUS_NO_MEMORY
);
637 #if defined(__GNUC__)
645 MaxVcn
.QuadPart
= (SafeInitialSize
.QuadPart
+ BytesPerAllocationUnit
- 1) / BytesPerAllocationUnit
;
648 Status
= ZwFsControlFile(FileHandle
,
653 FSCTL_GET_RETRIEVAL_POINTERS
,
655 sizeof(LARGE_INTEGER
),
656 &CurrentRetDescList
->RetrievalPointers
,
657 sizeof(RETRIEVAL_POINTERS_BUFFER
) + PAIRS_PER_RUN
* 2 * sizeof(LARGE_INTEGER
));
658 if (!NT_SUCCESS(Status
))
662 CurrentRetDescList
= RetDescList
;
663 RetDescList
= RetDescList
->Next
;
664 ExFreePool(CurrentRetDescList
);
666 ObDereferenceObject(FileObject
);
670 ExtentCount
+= CurrentRetDescList
->RetrievalPointers
.ExtentCount
;
671 if (CurrentRetDescList
->RetrievalPointers
.Extents
[CurrentRetDescList
->RetrievalPointers
.ExtentCount
-1].NextVcn
.QuadPart
< MaxVcn
.QuadPart
)
673 CurrentRetDescList
->Next
= MmAllocRetrievelDescriptorList(PAIRS_PER_RUN
);
674 if (CurrentRetDescList
->Next
== NULL
)
678 CurrentRetDescList
= RetDescList
;
679 RetDescList
= RetDescList
->Next
;
680 ExFreePool(CurrentRetDescList
);
682 ObDereferenceObject(FileObject
);
684 return(STATUS_NO_MEMORY
);
686 Vcn
= CurrentRetDescList
->RetrievalPointers
.Extents
[CurrentRetDescList
->RetrievalPointers
.ExtentCount
-1].NextVcn
;
687 CurrentRetDescList
= CurrentRetDescList
->Next
;
695 PagingFile
= ExAllocatePool(NonPagedPool
, sizeof(*PagingFile
));
696 if (PagingFile
== NULL
)
700 CurrentRetDescList
= RetDescList
;
701 RetDescList
= RetDescList
->Next
;
702 ExFreePool(CurrentRetDescList
);
704 ObDereferenceObject(FileObject
);
706 return(STATUS_NO_MEMORY
);
709 RtlZeroMemory(PagingFile
, sizeof(*PagingFile
));
711 PagingFile
->FileObject
= FileObject
;
712 PagingFile
->MaximumSize
.QuadPart
= SafeMaximumSize
.QuadPart
;
713 PagingFile
->CurrentSize
.QuadPart
= SafeInitialSize
.QuadPart
;
714 PagingFile
->FreePages
= (ULONG
)(SafeInitialSize
.QuadPart
/ PAGE_SIZE
);
715 PagingFile
->UsedPages
= 0;
716 KeInitializeSpinLock(&PagingFile
->AllocMapLock
);
718 AllocMapSize
= (PagingFile
->FreePages
/ 32) + 1;
719 PagingFile
->AllocMap
= ExAllocatePool(NonPagedPool
,
720 AllocMapSize
* sizeof(ULONG
));
721 PagingFile
->AllocMapSize
= AllocMapSize
;
723 if (PagingFile
->AllocMap
== NULL
)
727 CurrentRetDescList
= RetDescList
;
728 RetDescList
= RetDescList
->Next
;
729 ExFreePool(CurrentRetDescList
);
731 ExFreePool(PagingFile
);
732 ObDereferenceObject(FileObject
);
734 return(STATUS_NO_MEMORY
);
736 DPRINT("ExtentCount: %lu\n", ExtentCount
);
737 Size
= sizeof(RETRIEVAL_POINTERS_BUFFER
) + ExtentCount
* 2 * sizeof(LARGE_INTEGER
);
738 PagingFile
->RetrievalPointers
= ExAllocatePool(NonPagedPool
, Size
);
739 if (PagingFile
->RetrievalPointers
== NULL
)
743 CurrentRetDescList
= RetDescList
;
744 RetDescList
= RetDescList
->Next
;
745 ExFreePool(CurrentRetDescList
);
747 ExFreePool(PagingFile
->AllocMap
);
748 ExFreePool(PagingFile
);
749 ObDereferenceObject(FileObject
);
751 return(STATUS_NO_MEMORY
);
754 RtlZeroMemory(PagingFile
->AllocMap
, AllocMapSize
* sizeof(ULONG
));
755 RtlZeroMemory(PagingFile
->RetrievalPointers
, Size
);
758 PagingFile
->RetrievalPointers
->ExtentCount
= ExtentCount
;
759 PagingFile
->RetrievalPointers
->StartingVcn
= RetDescList
->RetrievalPointers
.StartingVcn
;
760 CurrentRetDescList
= RetDescList
;
761 while (CurrentRetDescList
)
763 memcpy(&PagingFile
->RetrievalPointers
->Extents
[Count
],
764 CurrentRetDescList
->RetrievalPointers
.Extents
,
765 CurrentRetDescList
->RetrievalPointers
.ExtentCount
* 2 * sizeof(LARGE_INTEGER
));
766 Count
+= CurrentRetDescList
->RetrievalPointers
.ExtentCount
;
767 RetDescList
= CurrentRetDescList
;
768 CurrentRetDescList
= CurrentRetDescList
->Next
;
769 ExFreePool(RetDescList
);
772 if (PagingFile
->RetrievalPointers
->ExtentCount
!= ExtentCount
||
773 PagingFile
->RetrievalPointers
->Extents
[ExtentCount
- 1].NextVcn
.QuadPart
!= MaxVcn
.QuadPart
)
775 ExFreePool(PagingFile
->RetrievalPointers
);
776 ExFreePool(PagingFile
->AllocMap
);
777 ExFreePool(PagingFile
);
778 ObDereferenceObject(FileObject
);
780 return(STATUS_UNSUCCESSFUL
);
784 * Change the entries from lcn's to volume offset's.
786 PagingFile
->RetrievalPointers
->StartingVcn
.QuadPart
*= BytesPerAllocationUnit
;
787 for (i
= 0; i
< ExtentCount
; i
++)
789 PagingFile
->RetrievalPointers
->Extents
[i
].Lcn
.QuadPart
*= BytesPerAllocationUnit
;
790 PagingFile
->RetrievalPointers
->Extents
[i
].NextVcn
.QuadPart
*= BytesPerAllocationUnit
;
793 KeAcquireSpinLock(&PagingFileListLock
, &oldIrql
);
794 for (i
= 0; i
< MAX_PAGING_FILES
; i
++)
796 if (PagingFileList
[i
] == NULL
)
798 PagingFileList
[i
] = PagingFile
;
802 MiFreeSwapPages
= MiFreeSwapPages
+ PagingFile
->FreePages
;
804 KeReleaseSpinLock(&PagingFileListLock
, oldIrql
);
808 MmSwapSpaceMessage
= FALSE
;
810 return(STATUS_SUCCESS
);