mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
- Route the stream file objects also through the close path.
- Calculate the size of the fcb hash table depend on the file system type. svn path=/trunk/; revision=14422
This commit is contained in:
parent
7bf6af0dce
commit
e31b75dfe5
5 changed files with 46 additions and 36 deletions
|
@ -49,6 +49,19 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
|
||||||
if (pFcb->Flags & FCB_DELETE_PENDING &&
|
if (pFcb->Flags & FCB_DELETE_PENDING &&
|
||||||
pFcb->OpenHandleCount == 1)
|
pFcb->OpenHandleCount == 1)
|
||||||
{
|
{
|
||||||
|
PFILE_OBJECT tmpFileObject;
|
||||||
|
tmpFileObject = pFcb->FileObject;
|
||||||
|
if (tmpFileObject != NULL)
|
||||||
|
{
|
||||||
|
pFcb->FileObject = NULL;
|
||||||
|
#ifdef USE_ROS_CC_AND_FS
|
||||||
|
CcRosReleaseFileCache(tmpFileObject);
|
||||||
|
#else
|
||||||
|
CcUninitializeCacheMap(tmpFileObject, NULL, NULL);
|
||||||
|
#endif
|
||||||
|
ObDereferenceObject(tmpFileObject);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* FIXME:
|
/* FIXME:
|
||||||
* CcPurgeCacheSection is unimplemented.
|
* CcPurgeCacheSection is unimplemented.
|
||||||
|
|
|
@ -43,11 +43,8 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
|
||||||
pFcb->RefCount--;
|
pFcb->RefCount--;
|
||||||
FileObject->FsContext2 = NULL;
|
FileObject->FsContext2 = NULL;
|
||||||
}
|
}
|
||||||
else if (FileObject->FileName.Buffer)
|
else
|
||||||
{
|
{
|
||||||
// This a FO, that was created outside from FSD.
|
|
||||||
// Some FO's are created with IoCreateStreamFileObject() insid from FSD.
|
|
||||||
// This FO's haven't a FileName.
|
|
||||||
if (FileObject->DeletePending)
|
if (FileObject->DeletePending)
|
||||||
{
|
{
|
||||||
if (pFcb->Flags & FCB_DELETE_PENDING)
|
if (pFcb->Flags & FCB_DELETE_PENDING)
|
||||||
|
|
|
@ -191,10 +191,10 @@ vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
|
||||||
|
|
||||||
while (pFCB)
|
while (pFCB)
|
||||||
{
|
{
|
||||||
Index = pFCB->Hash.Hash % FCB_HASH_TABLE_SIZE;
|
Index = pFCB->Hash.Hash % pVCB->HashTableSize;
|
||||||
ShortIndex = pFCB->ShortHash.Hash % FCB_HASH_TABLE_SIZE;
|
ShortIndex = pFCB->ShortHash.Hash % pVCB->HashTableSize;
|
||||||
pFCB->RefCount--;
|
pFCB->RefCount--;
|
||||||
if (pFCB->RefCount <= 0 && (!vfatFCBIsDirectory (pFCB) || pFCB->Flags & FCB_DELETE_PENDING))
|
if (pFCB->RefCount == 0)
|
||||||
{
|
{
|
||||||
tmpFcb = pFCB->parentFcb;
|
tmpFcb = pFCB->parentFcb;
|
||||||
RemoveEntryList (&pFCB->FcbListEntry);
|
RemoveEntryList (&pFCB->FcbListEntry);
|
||||||
|
@ -227,22 +227,6 @@ vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
|
||||||
}
|
}
|
||||||
entry->next = pFCB->Hash.next;
|
entry->next = pFCB->Hash.next;
|
||||||
}
|
}
|
||||||
if (vfatFCBIsDirectory(pFCB))
|
|
||||||
{
|
|
||||||
/* Uninitialize file cache if initialized for this file object. */
|
|
||||||
if (pFCB->FileObject->SectionObjectPointer->SharedCacheMap)
|
|
||||||
{
|
|
||||||
#ifdef USE_ROS_CC_AND_FS
|
|
||||||
CcRosReleaseFileCache(pFCB->FileObject);
|
|
||||||
#else
|
|
||||||
CcUninitializeCacheMap(pFCB->FileObject, NULL, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
vfatDestroyCCB(pFCB->FileObject->FsContext2);
|
|
||||||
pFCB->FileObject->FsContext2 = NULL;
|
|
||||||
pFCB->FileObject->FsContext = NULL;
|
|
||||||
ObDereferenceObject(pFCB->FileObject);
|
|
||||||
}
|
|
||||||
vfatDestroyFCB (pFCB);
|
vfatDestroyFCB (pFCB);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -259,8 +243,8 @@ vfatAddFCBToTable(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
|
||||||
ULONG Index;
|
ULONG Index;
|
||||||
ULONG ShortIndex;
|
ULONG ShortIndex;
|
||||||
|
|
||||||
Index = pFCB->Hash.Hash % FCB_HASH_TABLE_SIZE;
|
Index = pFCB->Hash.Hash % pVCB->HashTableSize;
|
||||||
ShortIndex = pFCB->ShortHash.Hash % FCB_HASH_TABLE_SIZE;
|
ShortIndex = pFCB->ShortHash.Hash % pVCB->HashTableSize;
|
||||||
|
|
||||||
InsertTailList (&pVCB->FcbListHead, &pFCB->FcbListEntry);
|
InsertTailList (&pVCB->FcbListHead, &pFCB->FcbListEntry);
|
||||||
|
|
||||||
|
@ -292,7 +276,7 @@ vfatGrabFCBFromTable(PDEVICE_EXTENSION pVCB, PUNICODE_STRING PathNameU)
|
||||||
|
|
||||||
Hash = vfatNameHash(0, PathNameU);
|
Hash = vfatNameHash(0, PathNameU);
|
||||||
|
|
||||||
entry = pVCB->FcbHashTable[Hash % FCB_HASH_TABLE_SIZE];
|
entry = pVCB->FcbHashTable[Hash % pVCB->HashTableSize];
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
vfatSplitPathName(PathNameU, &DirNameU, &FileNameU);
|
vfatSplitPathName(PathNameU, &DirNameU, &FileNameU);
|
||||||
|
@ -353,6 +337,7 @@ vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
|
||||||
fileObject->FsContext = fcb;
|
fileObject->FsContext = fcb;
|
||||||
fileObject->FsContext2 = newCCB;
|
fileObject->FsContext2 = newCCB;
|
||||||
fcb->FileObject = fileObject;
|
fcb->FileObject = fileObject;
|
||||||
|
fcb->RefCount++;
|
||||||
|
|
||||||
#ifdef USE_ROS_CC_AND_FS
|
#ifdef USE_ROS_CC_AND_FS
|
||||||
fileCacheQuantum = (vcb->FatInfo.BytesPerCluster >= PAGE_SIZE) ?
|
fileCacheQuantum = (vcb->FatInfo.BytesPerCluster >= PAGE_SIZE) ?
|
||||||
|
@ -375,12 +360,7 @@ vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fcb->Flags |= FCB_CACHE_INITIALIZED;
|
fcb->Flags |= FCB_CACHE_INITIALIZED;
|
||||||
|
|
||||||
#ifdef USE_ROS_CC_AND_FS
|
|
||||||
return status;
|
|
||||||
#else
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PVFATFCB
|
PVFATFCB
|
||||||
|
|
|
@ -372,6 +372,8 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
|
||||||
PDEVICE_OBJECT DeviceToMount;
|
PDEVICE_OBJECT DeviceToMount;
|
||||||
UNICODE_STRING NameU = RTL_CONSTANT_STRING(L"\\$$Fat$$");
|
UNICODE_STRING NameU = RTL_CONSTANT_STRING(L"\\$$Fat$$");
|
||||||
UNICODE_STRING VolumeNameU = RTL_CONSTANT_STRING(L"\\$$Volume$$");
|
UNICODE_STRING VolumeNameU = RTL_CONSTANT_STRING(L"\\$$Volume$$");
|
||||||
|
ULONG HashTableSize;
|
||||||
|
FATINFO FatInfo;
|
||||||
|
|
||||||
DPRINT("VfatMount(IrpContext %x)\n", IrpContext);
|
DPRINT("VfatMount(IrpContext %x)\n", IrpContext);
|
||||||
|
|
||||||
|
@ -385,7 +387,7 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
|
||||||
|
|
||||||
DeviceToMount = IrpContext->Stack->Parameters.MountVolume.DeviceObject;
|
DeviceToMount = IrpContext->Stack->Parameters.MountVolume.DeviceObject;
|
||||||
|
|
||||||
Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS, NULL);
|
Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS, &FatInfo);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
goto ByeBye;
|
goto ByeBye;
|
||||||
|
@ -398,9 +400,24 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
|
||||||
goto ByeBye;
|
goto ByeBye;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Use prime numbers for the table size */
|
||||||
|
if (FatInfo.FatType == FAT12)
|
||||||
|
{
|
||||||
|
HashTableSize = 4099; // 4096 = 4 * 1024
|
||||||
|
}
|
||||||
|
else if (FatInfo.FatType == FAT16 ||
|
||||||
|
FatInfo.FatType == FATX16)
|
||||||
|
{
|
||||||
|
HashTableSize = 16411; // 16384 = 16 * 1024
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HashTableSize = 65537; // 65536 = 64 * 1024;
|
||||||
|
}
|
||||||
|
HashTableSize = FCB_HASH_TABLE_SIZE;
|
||||||
DPRINT("VFAT: Recognized volume\n");
|
DPRINT("VFAT: Recognized volume\n");
|
||||||
Status = IoCreateDevice(VfatGlobalData->DriverObject,
|
Status = IoCreateDevice(VfatGlobalData->DriverObject,
|
||||||
sizeof (DEVICE_EXTENSION),
|
ROUND_UP(sizeof (DEVICE_EXTENSION), sizeof(DWORD)) + sizeof(HASHENTRY*) * HashTableSize,
|
||||||
NULL,
|
NULL,
|
||||||
FILE_DEVICE_FILE_SYSTEM,
|
FILE_DEVICE_FILE_SYSTEM,
|
||||||
0,
|
0,
|
||||||
|
@ -413,7 +430,9 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
|
||||||
|
|
||||||
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
|
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
|
||||||
DeviceExt = (PVOID) DeviceObject->DeviceExtension;
|
DeviceExt = (PVOID) DeviceObject->DeviceExtension;
|
||||||
RtlZeroMemory(DeviceExt, sizeof(DEVICE_EXTENSION));
|
RtlZeroMemory(DeviceExt, ROUND_UP(sizeof(DEVICE_EXTENSION), sizeof(DWORD)) + sizeof(HASHENTRY*) * HashTableSize);
|
||||||
|
DeviceExt->FcbHashTable = (HASHENTRY**)((ULONG_PTR)DeviceExt + ROUND_UP(sizeof(DEVICE_EXTENSION), sizeof(DWORD)));
|
||||||
|
DeviceExt->HashTableSize = HashTableSize;
|
||||||
|
|
||||||
/* use same vpb as device disk */
|
/* use same vpb as device disk */
|
||||||
DeviceObject->Vpb = DeviceToMount->Vpb;
|
DeviceObject->Vpb = DeviceToMount->Vpb;
|
||||||
|
@ -557,7 +576,7 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
|
||||||
|
|
||||||
/* read volume label */
|
/* read volume label */
|
||||||
ReadVolumeLabel(DeviceExt, DeviceObject->Vpb);
|
ReadVolumeLabel(DeviceExt, DeviceObject->Vpb);
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
ByeBye:
|
ByeBye:
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,8 @@ typedef struct DEVICE_EXTENSION
|
||||||
|
|
||||||
KSPIN_LOCK FcbListLock;
|
KSPIN_LOCK FcbListLock;
|
||||||
LIST_ENTRY FcbListHead;
|
LIST_ENTRY FcbListHead;
|
||||||
struct _HASHENTRY* FcbHashTable[FCB_HASH_TABLE_SIZE];
|
ULONG HashTableSize;
|
||||||
|
struct _HASHENTRY** FcbHashTable;
|
||||||
|
|
||||||
PDEVICE_OBJECT StorageDevice;
|
PDEVICE_OBJECT StorageDevice;
|
||||||
PFILE_OBJECT FATFileObject;
|
PFILE_OBJECT FATFileObject;
|
||||||
|
|
Loading…
Reference in a new issue