https://git.reactos.org/?p=reactos.git;a=commitdiff;h=216a2cae733be32a80c1c…
commit 216a2cae733be32a80c1ce8281fc08c9bbea27b9
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Dec 31 14:14:24 2017 +0100
[NTFS] Use LookasideList allocations for FILE_RECORD_HEADER.
TODO: use a specific tag
This, and previous commit, should speed up a bit the driver until caching gets
implemented
---
drivers/filesystems/ntfs/attrib.c | 14 ++---
drivers/filesystems/ntfs/create.c | 38 +++++--------
drivers/filesystems/ntfs/dirctl.c | 4 +-
drivers/filesystems/ntfs/fcb.c | 27 ++++-----
drivers/filesystems/ntfs/finfo.c | 22 ++++----
drivers/filesystems/ntfs/fsctl.c | 55 +++++++++++--------
drivers/filesystems/ntfs/mft.c | 110 ++++++++++++++++++-------------------
drivers/filesystems/ntfs/ntfs.h | 2 +
drivers/filesystems/ntfs/rw.c | 28 +++++-----
drivers/filesystems/ntfs/volinfo.c | 26 ++++-----
10 files changed, 156 insertions(+), 170 deletions(-)
diff --git a/drivers/filesystems/ntfs/attrib.c b/drivers/filesystems/ntfs/attrib.c
index 846c16da80..1a04b763a2 100644
--- a/drivers/filesystems/ntfs/attrib.c
+++ b/drivers/filesystems/ntfs/attrib.c
@@ -1083,9 +1083,7 @@ FreeClusters(PNTFS_VCB Vcb,
}
// Read the $Bitmap file
- BitmapRecord = ExAllocatePoolWithTag(NonPagedPool,
- Vcb->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ BitmapRecord = ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
if (BitmapRecord == NULL)
{
DPRINT1("Error: Unable to allocate memory for bitmap file record!\n");
@@ -1096,7 +1094,7 @@ FreeClusters(PNTFS_VCB Vcb,
if (!NT_SUCCESS(Status))
{
DPRINT1("Error: Unable to read file record for bitmap!\n");
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BitmapRecord);
return 0;
}
@@ -1104,7 +1102,7 @@ FreeClusters(PNTFS_VCB Vcb,
if (!NT_SUCCESS(Status))
{
DPRINT1("Error: Unable to find data attribute for bitmap file!\n");
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BitmapRecord);
return 0;
}
@@ -1116,7 +1114,7 @@ FreeClusters(PNTFS_VCB Vcb,
{
DPRINT1("Error: Unable to allocate memory for bitmap file data!\n");
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BitmapRecord);
return 0;
}
@@ -1156,13 +1154,13 @@ FreeClusters(PNTFS_VCB Vcb,
{
ReleaseAttributeContext(DataContext);
ExFreePoolWithTag(BitmapData, TAG_NTFS);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BitmapRecord);
return Status;
}
ReleaseAttributeContext(DataContext);
ExFreePoolWithTag(BitmapData, TAG_NTFS);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BitmapRecord);
// Save updated data runs to file record
diff --git a/drivers/filesystems/ntfs/create.c b/drivers/filesystems/ntfs/create.c
index f37a9518cd..0ce5771ae3 100644
--- a/drivers/filesystems/ntfs/create.c
+++ b/drivers/filesystems/ntfs/create.c
@@ -114,9 +114,7 @@ NtfsMoonWalkID(PDEVICE_EXTENSION DeviceExt,
DPRINT1("NtfsMoonWalkID(%p, %I64x, %p)\n", DeviceExt, Id, OutPath);
RtlZeroMemory(FullPath, sizeof(FullPath));
- MftRecord = ExAllocatePoolWithTag(NonPagedPool,
- DeviceExt->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ MftRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (MftRecord == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -155,7 +153,7 @@ NtfsMoonWalkID(PDEVICE_EXTENSION DeviceExt,
break;
}
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, MftRecord);
if (!NT_SUCCESS(Status))
return Status;
@@ -191,9 +189,7 @@ NtfsOpenFileById(PDEVICE_EXTENSION DeviceExt,
return STATUS_OBJECT_NAME_NOT_FOUND;
}
- MftRecord = ExAllocatePoolWithTag(NonPagedPool,
- DeviceExt->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ MftRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (MftRecord == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -202,13 +198,13 @@ NtfsOpenFileById(PDEVICE_EXTENSION DeviceExt,
Status = ReadFileRecord(DeviceExt, MftId, MftRecord);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, MftRecord);
return Status;
}
if (!(MftRecord->Flags & FRH_IN_USE))
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, MftRecord);
return STATUS_OBJECT_PATH_NOT_FOUND;
}
@@ -221,14 +217,14 @@ NtfsOpenFileById(PDEVICE_EXTENSION DeviceExt,
Status = NtfsMakeFCBFromDirEntry(DeviceExt, NULL, &Name, NULL, MftRecord,
MftId, &FCB);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
MftRecord);
return Status;
}
}
ASSERT(FCB != NULL);
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, MftRecord);
Status = NtfsAttachFCBToFileObject(DeviceExt,
FCB,
@@ -506,9 +502,7 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
ExAcquireResourceExclusiveLite(&(Fcb->MainResource), TRUE);
- fileRecord = ExAllocatePoolWithTag(NonPagedPool,
-
Fcb->Vcb->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ fileRecord =
ExAllocateFromNPagedLookasideList(&Fcb->Vcb->FileRecLookasideList);
if (fileRecord)
{
@@ -532,7 +526,7 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
DoneOverwriting:
if (fileRecord)
- ExFreePoolWithTag(fileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Fcb->Vcb->FileRecLookasideList,
fileRecord);
if (dataContext)
ReleaseAttributeContext(dataContext);
@@ -741,7 +735,7 @@ NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt,
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Failed to create empty B-Tree!\n");
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -760,7 +754,7 @@ NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt,
{
DPRINT1("ERROR: Unable to create empty index root!\n");
DestroyBTree(Tree);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -773,7 +767,7 @@ NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt,
{
DPRINT1("ERROR: Failed to add index root to new file record!\n");
ExFreePoolWithTag(NewIndexRoot, TAG_NTFS);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -803,7 +797,7 @@ NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt,
}
ExFreePoolWithTag(NewIndexRoot, TAG_NTFS);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
return Status;
}
@@ -829,9 +823,7 @@ NtfsCreateEmptyFileRecord(PDEVICE_EXTENSION DeviceExt)
DPRINT1("NtfsCreateEmptyFileRecord(%p)\n", DeviceExt);
// allocate memory for file record
- FileRecord = ExAllocatePoolWithTag(NonPagedPool,
- DeviceExt->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ FileRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (!FileRecord)
{
DPRINT1("ERROR: Unable to allocate memory for file record!\n");
@@ -963,7 +955,7 @@ NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt,
CaseSensitive);
}
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
return Status;
}
diff --git a/drivers/filesystems/ntfs/dirctl.c b/drivers/filesystems/ntfs/dirctl.c
index ab784fce3d..3c8d3cdb9a 100644
--- a/drivers/filesystems/ntfs/dirctl.c
+++ b/drivers/filesystems/ntfs/dirctl.c
@@ -388,7 +388,7 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
{
DPRINT1("Ignoring duplicate MFT entry 0x%x\n", MFTRecord);
Ccb->Entry++;
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+
ExFreeToNPagedLookasideList(&DeviceExtension->FileRecLookasideList, FileRecord);
continue;
}
OldMFTRecord = MFTRecord;
@@ -468,7 +468,7 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
}
BufferLength -= Buffer0->NextEntryOffset;
Buffer += Buffer0->NextEntryOffset;
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExtension->FileRecLookasideList,
FileRecord);
}
if (Buffer0)
diff --git a/drivers/filesystems/ntfs/fcb.c b/drivers/filesystems/ntfs/fcb.c
index f8057ee2ff..8a4f460546 100644
--- a/drivers/filesystems/ntfs/fcb.c
+++ b/drivers/filesystems/ntfs/fcb.c
@@ -311,9 +311,7 @@ NtfsMakeRootFCB(PNTFS_VCB Vcb)
PFILE_RECORD_HEADER MftRecord;
PFILENAME_ATTRIBUTE FileName;
- MftRecord = ExAllocatePoolWithTag(NonPagedPool,
- Vcb->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ MftRecord = ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
if (MftRecord == NULL)
{
return NULL;
@@ -321,21 +319,21 @@ NtfsMakeRootFCB(PNTFS_VCB Vcb)
if (!NT_SUCCESS(ReadFileRecord(Vcb, NTFS_FILE_ROOT, MftRecord)))
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return NULL;
}
FileName = GetFileNameFromRecord(Vcb, MftRecord, NTFS_FILE_NAME_WIN32);
if (!FileName)
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return NULL;
}
Fcb = NtfsCreateFCB(L"\\", NULL, Vcb);
if (!Fcb)
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return NULL;
}
@@ -355,7 +353,7 @@ NtfsMakeRootFCB(PNTFS_VCB Vcb)
NtfsAddFCBToTable(Vcb, Fcb);
NtfsGrabFCB(Vcb, Fcb);
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return Fcb;
}
@@ -570,6 +568,7 @@ NtfsDirFindFile(PNTFS_VCB Vcb,
if ((FileRecord->Flags & FRH_DIRECTORY) && Colon != 0)
{
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
return STATUS_INVALID_PARAMETER;
}
else if (Colon != 0)
@@ -583,7 +582,7 @@ NtfsDirFindFile(PNTFS_VCB Vcb,
}
Status = NtfsMakeFCBFromDirEntry(Vcb, DirectoryFcb, &File, Colon, FileRecord,
MFTIndex, FoundFCB);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
return Status;
}
@@ -734,9 +733,7 @@ NtfsReadFCBAttribute(PNTFS_VCB Vcb,
PNTFS_ATTR_CONTEXT AttrCtxt;
ULONGLONG AttrLength;
- FileRecord = ExAllocatePoolWithTag(NonPagedPool,
- Vcb->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ FileRecord = ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
if (FileRecord == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -745,14 +742,14 @@ NtfsReadFCBAttribute(PNTFS_VCB Vcb,
Status = ReadFileRecord(Vcb, pFCB->MFTIndex, FileRecord);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
return Status;
}
Status = FindAttribute(Vcb, FileRecord, Type, Name, NameLength, &AttrCtxt,
NULL);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
return Status;
}
@@ -761,14 +758,14 @@ NtfsReadFCBAttribute(PNTFS_VCB Vcb,
if (*Data == NULL)
{
ReleaseAttributeContext(AttrCtxt);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
return STATUS_INSUFFICIENT_RESOURCES;
}
ReadAttribute(Vcb, AttrCtxt, 0, *Data, AttrLength);
ReleaseAttributeContext(AttrCtxt);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
return STATUS_SUCCESS;
}
diff --git a/drivers/filesystems/ntfs/finfo.c b/drivers/filesystems/ntfs/finfo.c
index fb7df5f4d4..9a1b44b388 100644
--- a/drivers/filesystems/ntfs/finfo.c
+++ b/drivers/filesystems/ntfs/finfo.c
@@ -236,7 +236,7 @@ NtfsGetSteamInformation(PNTFS_FCB Fcb,
if (*BufferLength < sizeof(FILE_STREAM_INFORMATION))
return STATUS_BUFFER_TOO_SMALL;
- FileRecord = ExAllocatePoolWithTag(NonPagedPool,
DeviceExt->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ FileRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (FileRecord == NULL)
{
DPRINT1("Not enough memory!\n");
@@ -247,7 +247,7 @@ NtfsGetSteamInformation(PNTFS_FCB Fcb,
if (!NT_SUCCESS(Status))
{
DPRINT1("Can't find record!\n");
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -285,7 +285,7 @@ NtfsGetSteamInformation(PNTFS_FCB Fcb,
}
FindCloseAttribute(&Context);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
return Status;
}
@@ -577,7 +577,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
// Allocate non-paged memory for the file record
- FileRecord = ExAllocatePoolWithTag(NonPagedPool,
DeviceExt->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ FileRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (FileRecord == NULL)
{
DPRINT1("Couldn't allocate memory for file record!");
@@ -591,7 +591,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
{
// We couldn't get the file's record. Free the memory and return the
error
DPRINT1("Can't find record for %wS!\n", Fcb->ObjectName);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -607,7 +607,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
NewFileSize))
{
DPRINT1("Couldn't decrease file size!\n");
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return STATUS_USER_MAPPED_FILE;
}
}
@@ -626,7 +626,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
if (!NT_SUCCESS(Status))
{
DPRINT1("No '%S' data stream associated with file!\n",
Fcb->Stream);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -642,7 +642,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
{
// TODO - just fail for now
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return STATUS_ACCESS_DENIED;
}
}
@@ -652,7 +652,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
if (!NT_SUCCESS(Status))
{
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -663,7 +663,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
{
DPRINT1("Unable to find FileName attribute associated with file!\n");
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return STATUS_INVALID_PARAMETER;
}
@@ -684,7 +684,7 @@ NtfsSetEndOfFile(PNTFS_FCB Fcb,
CaseSensitive);
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
return Status;
}
diff --git a/drivers/filesystems/ntfs/fsctl.c b/drivers/filesystems/ntfs/fsctl.c
index 76337ec448..87858e07c0 100644
--- a/drivers/filesystems/ntfs/fsctl.c
+++ b/drivers/filesystems/ntfs/fsctl.c
@@ -274,11 +274,13 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
ExFreePool(BootSector);
- DeviceExt->MasterFileTable = ExAllocatePoolWithTag(NonPagedPool,
- NtfsInfo->BytesPerFileRecord,
- TAG_NTFS);
+ ExInitializeNPagedLookasideList(&DeviceExt->FileRecLookasideList,
+ NULL, NULL, 0, NtfsInfo->BytesPerFileRecord,
TAG_NTFS, 0);
+
+ DeviceExt->MasterFileTable =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (DeviceExt->MasterFileTable == NULL)
{
+ ExDeleteNPagedLookasideList(&DeviceExt->FileRecLookasideList);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -291,7 +293,8 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed reading MFT.\n");
- ExFreePool(DeviceExt->MasterFileTable);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
DeviceExt->MasterFileTable);
+ ExDeleteNPagedLookasideList(&DeviceExt->FileRecLookasideList);
return Status;
}
@@ -305,17 +308,17 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
if (!NT_SUCCESS(Status))
{
DPRINT1("Can't find data attribute for Master File Table.\n");
- ExFreePool(DeviceExt->MasterFileTable);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
DeviceExt->MasterFileTable);
+ ExDeleteNPagedLookasideList(&DeviceExt->FileRecLookasideList);
return Status;
}
- VolumeRecord = ExAllocatePoolWithTag(NonPagedPool,
- NtfsInfo->BytesPerFileRecord,
- TAG_NTFS);
+ VolumeRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (VolumeRecord == NULL)
{
DPRINT1("Allocation failed for volume record\n");
- ExFreePool(DeviceExt->MasterFileTable);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
DeviceExt->MasterFileTable);
+ ExDeleteNPagedLookasideList(&DeviceExt->FileRecLookasideList);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -327,8 +330,9 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed reading volume file\n");
- ExFreePool(VolumeRecord);
- ExFreePool(DeviceExt->MasterFileTable);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
VolumeRecord);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
DeviceExt->MasterFileTable);
+ ExDeleteNPagedLookasideList(&DeviceExt->FileRecLookasideList);
return Status;
}
@@ -367,8 +371,9 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
if (VolumeFcb == NULL)
{
DPRINT1("Failed allocating volume FCB\n");
- ExFreePool(VolumeRecord);
- ExFreePool(DeviceExt->MasterFileTable);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
VolumeRecord);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
DeviceExt->MasterFileTable);
+ ExDeleteNPagedLookasideList(&DeviceExt->FileRecLookasideList);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -398,7 +403,7 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
ReleaseAttributeContext(AttrCtxt);
}
- ExFreePool(VolumeRecord);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, VolumeRecord);
NtfsInfo->MftZoneReservation = NtfsQueryMftZoneReservation();
@@ -418,6 +423,7 @@ NtfsMountVolume(PDEVICE_OBJECT DeviceObject,
PNTFS_CCB Ccb = NULL;
PNTFS_VCB Vcb = NULL;
NTSTATUS Status;
+ BOOLEAN Lookaside = FALSE;
DPRINT1("NtfsMountVolume() called\n");
@@ -446,6 +452,8 @@ NtfsMountVolume(PDEVICE_OBJECT DeviceObject,
if (!NT_SUCCESS(Status))
goto ByeBye;
+ Lookaside = TRUE;
+
NewDeviceObject->Flags |= DO_DIRECT_IO;
Vcb = (PVOID)NewDeviceObject->DeviceExtension;
RtlZeroMemory(Vcb, sizeof(NTFS_VCB));
@@ -558,6 +566,9 @@ ByeBye:
if (NewDeviceObject)
IoDeleteDevice(NewDeviceObject);
+
+ if (Lookaside)
+ ExDeleteNPagedLookasideList(&Vcb->FileRecLookasideList);
}
DPRINT("NtfsMountVolume() done (Status: %lx)\n", Status);
@@ -672,9 +683,7 @@ GetNtfsFileRecord(PDEVICE_EXTENSION DeviceExt,
return STATUS_BUFFER_TOO_SMALL;
}
- FileRecord = ExAllocatePoolWithTag(NonPagedPool,
- DeviceExt->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ FileRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (FileRecord == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -705,7 +714,7 @@ GetNtfsFileRecord(PDEVICE_EXTENSION DeviceExt,
OutputBuffer->FileRecordLength = DeviceExt->NtfsInfo.BytesPerFileRecord;
RtlCopyMemory(OutputBuffer->FileRecordBuffer, FileRecord,
DeviceExt->NtfsInfo.BytesPerFileRecord);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
Irp->IoStatus.Information = FIELD_OFFSET(NTFS_FILE_RECORD_OUTPUT_BUFFER,
FileRecordBuffer) + DeviceExt->NtfsInfo.BytesPerFileRecord;
@@ -794,9 +803,7 @@ GetVolumeBitmap(PDEVICE_EXTENSION DeviceExt,
ToCopy = Stack->Parameters.FileSystemControl.OutputBufferLength -
FIELD_OFFSET(VOLUME_BITMAP_BUFFER, Buffer);
}
- BitmapRecord = ExAllocatePoolWithTag(NonPagedPool,
- DeviceExt->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ BitmapRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (BitmapRecord == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -806,7 +813,7 @@ GetVolumeBitmap(PDEVICE_EXTENSION DeviceExt,
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed reading volume bitmap: %lx\n", Status);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
BitmapRecord);
return Status;
}
@@ -814,7 +821,7 @@ GetVolumeBitmap(PDEVICE_EXTENSION DeviceExt,
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed find $DATA for bitmap: %lx\n", Status);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
BitmapRecord);
return Status;
}
@@ -833,7 +840,7 @@ GetVolumeBitmap(PDEVICE_EXTENSION DeviceExt,
}
_SEH2_END;
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, BitmapRecord);
return Status;
}
diff --git a/drivers/filesystems/ntfs/mft.c b/drivers/filesystems/ntfs/mft.c
index 8594f79e56..4724e8d899 100644
--- a/drivers/filesystems/ntfs/mft.c
+++ b/drivers/filesystems/ntfs/mft.c
@@ -277,7 +277,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Couldn't find $BITMAP attribute of Mft!\n");
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
return Status;
}
@@ -308,7 +308,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
if (!BitmapBuffer)
{
DPRINT1("ERROR: Unable to allocate memory for bitmap attribute!\n");
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
ReleaseAttributeContext(BitmapContext);
return STATUS_INSUFFICIENT_RESOURCES;
@@ -326,7 +326,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
if (BytesRead != BitmapSize.LowPart)
{
DPRINT1("ERROR: Bytes read != Bitmap size!\n");
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
ExFreePoolWithTag(BitmapBuffer, TAG_NTFS);
ReleaseAttributeContext(BitmapContext);
@@ -338,7 +338,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Failed to set size of $MFT data attribute!\n");
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
ExFreePoolWithTag(BitmapBuffer, TAG_NTFS);
ReleaseAttributeContext(BitmapContext);
@@ -351,7 +351,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Couldn't find $BITMAP attribute of Mft!\n");
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
return Status;
}
@@ -369,7 +369,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Failed to set size of bitmap attribute!\n");
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList,
BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
ExFreePoolWithTag(BitmapBuffer, TAG_NTFS);
ReleaseAttributeContext(BitmapContext);
@@ -384,7 +384,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Failed to update $MFT file record!\n");
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
ExFreePoolWithTag(BitmapBuffer, TAG_NTFS);
ReleaseAttributeContext(BitmapContext);
@@ -395,7 +395,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
Status = WriteAttribute(Vcb, BitmapContext, 0, BitmapBuffer, NewBitmapSize,
&LengthWritten, Vcb->MasterFileTable);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
ExFreePoolWithTag(BitmapBuffer, TAG_NTFS);
ReleaseAttributeContext(BitmapContext);
@@ -410,7 +410,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Failed to write blank file record!\n");
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList,
BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
ExFreePoolWithTag(BitmapBuffer, TAG_NTFS);
ReleaseAttributeContext(BitmapContext);
@@ -422,7 +422,7 @@ IncreaseMftSize(PDEVICE_EXTENSION Vcb, BOOLEAN CanWait)
Status = UpdateMftMirror(Vcb);
// Cleanup
- ExFreePoolWithTag(BlankFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, BlankFileRecord);
ExReleaseResourceLite(&(Vcb->DirResource));
ExFreePoolWithTag(BitmapBuffer, TAG_NTFS);
ReleaseAttributeContext(BitmapContext);
@@ -1301,7 +1301,7 @@ WriteAttribute(PDEVICE_EXTENSION Vcb,
// Do we need to read the file record?
if (FileRecord == NULL)
{
- FileRecord = ExAllocatePoolWithTag(NonPagedPool,
Vcb->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ FileRecord =
ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
if (!FileRecord)
{
DPRINT1("Error: Couldn't allocate file record!\n");
@@ -1326,7 +1326,7 @@ WriteAttribute(PDEVICE_EXTENSION Vcb,
{
DPRINT1("ERROR: Couldn't find matching attribute!\n");
if(FileRecordAllocated)
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -1340,7 +1340,7 @@ WriteAttribute(PDEVICE_EXTENSION Vcb,
DPRINT1("DRIVER ERROR: Data being written extends past end of file
record!\n");
ReleaseAttributeContext(FoundContext);
if (FileRecordAllocated)
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList,
FileRecord);
return STATUS_INVALID_PARAMETER;
}
@@ -1355,7 +1355,7 @@ WriteAttribute(PDEVICE_EXTENSION Vcb,
ReleaseAttributeContext(FoundContext);
if (FileRecordAllocated)
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
if (NT_SUCCESS(Status))
*RealLengthWritten = Length;
@@ -1624,9 +1624,7 @@ UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
NewAllocationSize,
CaseSensitive ? "TRUE" : "FALSE");
- MftRecord = ExAllocatePoolWithTag(NonPagedPool,
- Vcb->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ MftRecord = ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
if (MftRecord == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -1635,7 +1633,7 @@ UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
Status = ReadFileRecord(Vcb, ParentMFTIndex, MftRecord);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return Status;
}
@@ -1643,7 +1641,7 @@ UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
Status = FindAttribute(Vcb, MftRecord, AttributeIndexRoot, L"$I30", 4,
&IndexRootCtx, NULL);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return Status;
}
@@ -1651,7 +1649,7 @@ UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
if (IndexRecord == NULL)
{
ReleaseAttributeContext(IndexRootCtx);
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -1661,7 +1659,7 @@ UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
DPRINT1("ERROR: Failed to read Index Root!\n");
ExFreePoolWithTag(IndexRecord, TAG_NTFS);
ReleaseAttributeContext(IndexRootCtx);
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
}
IndexRoot = (PINDEX_ROOT_ATTRIBUTE)IndexRecord;
@@ -1699,7 +1697,7 @@ UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
ReleaseAttributeContext(IndexRootCtx);
ExFreePoolWithTag(IndexRecord, TAG_NTFS);
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return Status;
}
@@ -2158,9 +2156,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
ULONG NodeSize;
// Allocate memory for the parent directory
- ParentFileRecord = ExAllocatePoolWithTag(NonPagedPool,
- DeviceExt->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ ParentFileRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (!ParentFileRecord)
{
DPRINT1("ERROR: Couldn't allocate memory for file record!\n");
@@ -2171,7 +2167,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
Status = ReadFileRecord(DeviceExt, DirectoryMftIndex, ParentFileRecord);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
DPRINT1("ERROR: Couldn't read parent directory with index
%I64u\n",
DirectoryMftIndex);
return Status;
@@ -2194,7 +2190,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
{
DPRINT1("ERROR: Couldn't find $I30 $INDEX_ROOT attribute for parent
directory with MFT #: %I64u!\n",
DirectoryMftIndex);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2230,7 +2226,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
{
DPRINT1("ERROR: Couldn't allocate memory for index root
attribute!\n");
ReleaseAttributeContext(IndexRootContext);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -2241,7 +2237,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
DPRINT1("ERROR: Couln't read index root attribute for Mft index
#%I64u\n", DirectoryMftIndex);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2256,7 +2252,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
DPRINT1("ERROR: Failed to create B-Tree from Index!\n");
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2280,7 +2276,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
DestroyBTree(NewTree);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2329,7 +2325,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
DestroyBTree(NewTree);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2341,7 +2337,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
DestroyBTree(NewTree);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2390,7 +2386,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
DestroyBTree(NewTree);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2402,7 +2398,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
DestroyBTree(NewTree);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2444,7 +2440,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
DestroyBTree(NewTree);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2471,7 +2467,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
ExFreePoolWithTag(NewIndexRoot, TAG_NTFS);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
DPRINT1("ERROR: Unable to set resident attribute length!\n");
return Status;
}
@@ -2484,7 +2480,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Failed to update file record of directory with index:
%llx\n", DirectoryMftIndex);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
ExFreePoolWithTag(NewIndexRoot, TAG_NTFS);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
@@ -2505,7 +2501,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
ExFreePoolWithTag(NewIndexRoot, TAG_NTFS);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2539,7 +2535,7 @@ NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
ExFreePoolWithTag(NewIndexRoot, TAG_NTFS);
ReleaseAttributeContext(IndexRootContext);
ExFreePoolWithTag(I30IndexRoot, TAG_NTFS);
- ExFreePoolWithTag(ParentFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
ParentFileRecord);
return Status;
}
@@ -2668,7 +2664,7 @@ UpdateMftMirror(PNTFS_VCB Vcb)
ULONG LengthWritten;
// Allocate memory for the Mft mirror file record
- MirrorFileRecord = ExAllocatePoolWithTag(NonPagedPool,
Vcb->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ MirrorFileRecord =
ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
if (!MirrorFileRecord)
{
DPRINT1("Error: Failed to allocate memory for $MFTMirr!\n");
@@ -2680,7 +2676,7 @@ UpdateMftMirror(PNTFS_VCB Vcb)
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Failed to read $MFTMirr!\n");
- ExFreePoolWithTag(MirrorFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList,
MirrorFileRecord);
return Status;
}
@@ -2689,7 +2685,7 @@ UpdateMftMirror(PNTFS_VCB Vcb)
if (!NT_SUCCESS(Status))
{
DPRINT1("ERROR: Couldn't find $DATA attribute!\n");
- ExFreePoolWithTag(MirrorFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList,
MirrorFileRecord);
return Status;
}
@@ -2699,7 +2695,7 @@ UpdateMftMirror(PNTFS_VCB Vcb)
{
DPRINT1("ERROR: Couldn't find $DATA attribute!\n");
ReleaseAttributeContext(MirrDataContext);
- ExFreePoolWithTag(MirrorFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList,
MirrorFileRecord);
return Status;
}
@@ -2715,7 +2711,7 @@ UpdateMftMirror(PNTFS_VCB Vcb)
DPRINT1("Error: Couldn't allocate memory for $DATA buffer!\n");
ReleaseAttributeContext(MftDataContext);
ReleaseAttributeContext(MirrDataContext);
- ExFreePoolWithTag(MirrorFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList,
MirrorFileRecord);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -2729,7 +2725,7 @@ UpdateMftMirror(PNTFS_VCB Vcb)
ReleaseAttributeContext(MftDataContext);
ReleaseAttributeContext(MirrDataContext);
ExFreePoolWithTag(DataBuffer, TAG_NTFS);
- ExFreePoolWithTag(MirrorFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList,
MirrorFileRecord);
return STATUS_UNSUCCESSFUL;
}
@@ -2750,7 +2746,7 @@ UpdateMftMirror(PNTFS_VCB Vcb)
ReleaseAttributeContext(MftDataContext);
ReleaseAttributeContext(MirrDataContext);
ExFreePoolWithTag(DataBuffer, TAG_NTFS);
- ExFreePoolWithTag(MirrorFileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MirrorFileRecord);
return Status;
}
@@ -3116,9 +3112,7 @@ NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
CaseSensitive ? "TRUE" : "FALSE",
OutMFTIndex);
- MftRecord = ExAllocatePoolWithTag(NonPagedPool,
- Vcb->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ MftRecord = ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
if (MftRecord == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -3127,7 +3121,7 @@ NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
Status = ReadFileRecord(Vcb, MFTIndex, MftRecord);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return Status;
}
@@ -3135,7 +3129,7 @@ NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
Status = FindAttribute(Vcb, MftRecord, AttributeIndexRoot, L"$I30", 4,
&IndexRootCtx, NULL);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return Status;
}
@@ -3143,7 +3137,7 @@ NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
if (IndexRecord == NULL)
{
ReleaseAttributeContext(IndexRootCtx);
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -3170,7 +3164,7 @@ NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
OutMFTIndex);
ExFreePoolWithTag(IndexRecord, TAG_NTFS);
- ExFreePoolWithTag(MftRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
return Status;
}
@@ -3213,7 +3207,7 @@ NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
FsRtlDissectName(Current, &Current, &Remaining);
}
- *FileRecord = ExAllocatePoolWithTag(NonPagedPool,
Vcb->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ *FileRecord = ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
if (*FileRecord == NULL)
{
DPRINT("NtfsLookupFileAt: Can't allocate MFT record\n");
@@ -3224,7 +3218,7 @@ NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
if (!NT_SUCCESS(Status))
{
DPRINT("NtfsLookupFileAt: Can't read MFT record\n");
- ExFreePoolWithTag(*FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, *FileRecord);
return Status;
}
@@ -3328,7 +3322,7 @@ NtfsFindFileAt(PDEVICE_EXTENSION Vcb,
return Status;
}
- *FileRecord = ExAllocatePoolWithTag(NonPagedPool,
Vcb->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ *FileRecord = ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
if (*FileRecord == NULL)
{
DPRINT("NtfsFindFileAt: Can't allocate MFT record\n");
@@ -3339,7 +3333,7 @@ NtfsFindFileAt(PDEVICE_EXTENSION Vcb,
if (!NT_SUCCESS(Status))
{
DPRINT("NtfsFindFileAt: Can't read MFT record\n");
- ExFreePoolWithTag(*FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, *FileRecord);
return Status;
}
diff --git a/drivers/filesystems/ntfs/ntfs.h b/drivers/filesystems/ntfs/ntfs.h
index 0b64b7247e..7b88f7b7c4 100644
--- a/drivers/filesystems/ntfs/ntfs.h
+++ b/drivers/filesystems/ntfs/ntfs.h
@@ -116,6 +116,8 @@ typedef struct
NTFS_INFO NtfsInfo;
+ NPAGED_LOOKASIDE_LIST FileRecLookasideList;
+
ULONG MftDataOffset;
ULONG Flags;
ULONG OpenHandleCount;
diff --git a/drivers/filesystems/ntfs/rw.c b/drivers/filesystems/ntfs/rw.c
index 038caa4516..fc3a62c7cc 100644
--- a/drivers/filesystems/ntfs/rw.c
+++ b/drivers/filesystems/ntfs/rw.c
@@ -79,7 +79,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
return STATUS_NOT_IMPLEMENTED;
}
- FileRecord = ExAllocatePoolWithTag(NonPagedPool,
DeviceExt->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ FileRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (FileRecord == NULL)
{
DPRINT1("Not enough memory!\n");
@@ -90,7 +90,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
if (!NT_SUCCESS(Status))
{
DPRINT1("Can't find record!\n");
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -122,7 +122,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
FindCloseAttribute(&Context);
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -131,7 +131,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
{
DPRINT1("Reading beyond stream end!\n");
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return STATUS_END_OF_FILE;
}
@@ -159,7 +159,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
{
DPRINT1("Not enough memory!\n");
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return STATUS_INSUFFICIENT_RESOURCES;
}
AllocatedBuffer = TRUE;
@@ -171,7 +171,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
{
DPRINT1("Read failure!\n");
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
if (AllocatedBuffer)
{
ExFreePoolWithTag(ReadBuffer, TAG_NTFS);
@@ -180,7 +180,7 @@ NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
}
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
*LengthRead = ToRead;
@@ -355,7 +355,7 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
}
// allocate non-paged memory for the FILE_RECORD_HEADER
- FileRecord = ExAllocatePoolWithTag(NonPagedPool,
DeviceExt->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
+ FileRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (FileRecord == NULL)
{
DPRINT1("Not enough memory! Can't write %wS!\n",
Fcb->PathName);
@@ -369,7 +369,7 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
{
// We couldn't get the file's record. Free the memory and return the
error
DPRINT1("Can't find record for %wS!\n", Fcb->ObjectName);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -408,7 +408,7 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
FindCloseAttribute(&Context);
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -437,7 +437,7 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
if (!NT_SUCCESS(Status))
{
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
*LengthWritten = 0;
return Status;
}
@@ -469,7 +469,7 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
{
// TODO - just fail for now
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
*LengthWritten = 0;
return STATUS_ACCESS_DENIED;
}
@@ -485,7 +485,7 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
{
DPRINT1("Write failure!\n");
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
FileRecord);
return Status;
}
@@ -499,7 +499,7 @@ NTSTATUS NtfsWriteFile(PDEVICE_EXTENSION DeviceExt,
}
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(FileRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
return Status;
}
diff --git a/drivers/filesystems/ntfs/volinfo.c b/drivers/filesystems/ntfs/volinfo.c
index 6b7e598819..565a6012bc 100644
--- a/drivers/filesystems/ntfs/volinfo.c
+++ b/drivers/filesystems/ntfs/volinfo.c
@@ -47,9 +47,7 @@ NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt)
DPRINT1("NtfsGetFreeClusters(%p)\n", DeviceExt);
- BitmapRecord = ExAllocatePoolWithTag(NonPagedPool,
- DeviceExt->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ BitmapRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (BitmapRecord == NULL)
{
return 0;
@@ -58,14 +56,14 @@ NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt)
Status = ReadFileRecord(DeviceExt, NTFS_FILE_BITMAP, BitmapRecord);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
BitmapRecord);
return 0;
}
Status = FindAttribute(DeviceExt, BitmapRecord, AttributeData, L"", 0,
&DataContext, NULL);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
BitmapRecord);
return 0;
}
@@ -75,7 +73,7 @@ NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt)
if (BitmapData == NULL)
{
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
BitmapRecord);
return 0;
}
@@ -94,7 +92,7 @@ NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt)
FreeClusters = RtlNumberOfClearBits(&Bitmap);
ExFreePoolWithTag(BitmapData, TAG_NTFS);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, BitmapRecord);
return FreeClusters;
}
@@ -122,9 +120,7 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
DPRINT1("NtfsAllocateClusters(%p, %lu, %lu, %p, %p)\n", DeviceExt,
FirstDesiredCluster, DesiredClusters, FirstAssignedCluster, AssignedClusters);
- BitmapRecord = ExAllocatePoolWithTag(NonPagedPool,
- DeviceExt->NtfsInfo.BytesPerFileRecord,
- TAG_NTFS);
+ BitmapRecord =
ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
if (BitmapRecord == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -133,14 +129,14 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
Status = ReadFileRecord(DeviceExt, NTFS_FILE_BITMAP, BitmapRecord);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
BitmapRecord);
return Status;
}
Status = FindAttribute(DeviceExt, BitmapRecord, AttributeData, L"", 0,
&DataContext, NULL);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
BitmapRecord);
return Status;
}
@@ -151,7 +147,7 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
if (BitmapData == NULL)
{
ReleaseAttributeContext(DataContext);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
BitmapRecord);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -169,7 +165,7 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
ReleaseAttributeContext(DataContext);
ExFreePoolWithTag(BitmapData, TAG_NTFS);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList,
BitmapRecord);
return STATUS_DISK_FULL;
}
@@ -201,7 +197,7 @@ NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
ReleaseAttributeContext(DataContext);
ExFreePoolWithTag(BitmapData, TAG_NTFS);
- ExFreePoolWithTag(BitmapRecord, TAG_NTFS);
+ ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, BitmapRecord);
return Status;
}