- 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:
Hartmut Birr 2005-04-01 18:35:34 +00:00
parent 7bf6af0dce
commit e31b75dfe5
5 changed files with 46 additions and 36 deletions

View file

@ -49,6 +49,19 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
if (pFcb->Flags & FCB_DELETE_PENDING &&
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
/* FIXME:
* CcPurgeCacheSection is unimplemented.

View file

@ -43,11 +43,8 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
pFcb->RefCount--;
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 (pFcb->Flags & FCB_DELETE_PENDING)

View file

@ -191,10 +191,10 @@ vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
while (pFCB)
{
Index = pFCB->Hash.Hash % FCB_HASH_TABLE_SIZE;
ShortIndex = pFCB->ShortHash.Hash % FCB_HASH_TABLE_SIZE;
Index = pFCB->Hash.Hash % pVCB->HashTableSize;
ShortIndex = pFCB->ShortHash.Hash % pVCB->HashTableSize;
pFCB->RefCount--;
if (pFCB->RefCount <= 0 && (!vfatFCBIsDirectory (pFCB) || pFCB->Flags & FCB_DELETE_PENDING))
if (pFCB->RefCount == 0)
{
tmpFcb = pFCB->parentFcb;
RemoveEntryList (&pFCB->FcbListEntry);
@ -227,22 +227,6 @@ vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
}
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);
}
else
@ -259,8 +243,8 @@ vfatAddFCBToTable(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
ULONG Index;
ULONG ShortIndex;
Index = pFCB->Hash.Hash % FCB_HASH_TABLE_SIZE;
ShortIndex = pFCB->ShortHash.Hash % FCB_HASH_TABLE_SIZE;
Index = pFCB->Hash.Hash % pVCB->HashTableSize;
ShortIndex = pFCB->ShortHash.Hash % pVCB->HashTableSize;
InsertTailList (&pVCB->FcbListHead, &pFCB->FcbListEntry);
@ -292,7 +276,7 @@ vfatGrabFCBFromTable(PDEVICE_EXTENSION pVCB, PUNICODE_STRING PathNameU)
Hash = vfatNameHash(0, PathNameU);
entry = pVCB->FcbHashTable[Hash % FCB_HASH_TABLE_SIZE];
entry = pVCB->FcbHashTable[Hash % pVCB->HashTableSize];
if (entry)
{
vfatSplitPathName(PathNameU, &DirNameU, &FileNameU);
@ -353,6 +337,7 @@ vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
fileObject->FsContext = fcb;
fileObject->FsContext2 = newCCB;
fcb->FileObject = fileObject;
fcb->RefCount++;
#ifdef USE_ROS_CC_AND_FS
fileCacheQuantum = (vcb->FatInfo.BytesPerCluster >= PAGE_SIZE) ?
@ -375,12 +360,7 @@ vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
#endif
fcb->Flags |= FCB_CACHE_INITIALIZED;
#ifdef USE_ROS_CC_AND_FS
return status;
#else
return STATUS_SUCCESS;
#endif
}
PVFATFCB

View file

@ -372,6 +372,8 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
PDEVICE_OBJECT DeviceToMount;
UNICODE_STRING NameU = RTL_CONSTANT_STRING(L"\\$$Fat$$");
UNICODE_STRING VolumeNameU = RTL_CONSTANT_STRING(L"\\$$Volume$$");
ULONG HashTableSize;
FATINFO FatInfo;
DPRINT("VfatMount(IrpContext %x)\n", IrpContext);
@ -385,7 +387,7 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
DeviceToMount = IrpContext->Stack->Parameters.MountVolume.DeviceObject;
Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS, NULL);
Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS, &FatInfo);
if (!NT_SUCCESS(Status))
{
goto ByeBye;
@ -398,9 +400,24 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
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");
Status = IoCreateDevice(VfatGlobalData->DriverObject,
sizeof (DEVICE_EXTENSION),
ROUND_UP(sizeof (DEVICE_EXTENSION), sizeof(DWORD)) + sizeof(HASHENTRY*) * HashTableSize,
NULL,
FILE_DEVICE_FILE_SYSTEM,
0,
@ -413,7 +430,9 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
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 */
DeviceObject->Vpb = DeviceToMount->Vpb;
@ -557,7 +576,7 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext)
/* read volume label */
ReadVolumeLabel(DeviceExt, DeviceObject->Vpb);
Status = STATUS_SUCCESS;
ByeBye:

View file

@ -241,7 +241,8 @@ typedef struct DEVICE_EXTENSION
KSPIN_LOCK FcbListLock;
LIST_ENTRY FcbListHead;
struct _HASHENTRY* FcbHashTable[FCB_HASH_TABLE_SIZE];
ULONG HashTableSize;
struct _HASHENTRY** FcbHashTable;
PDEVICE_OBJECT StorageDevice;
PFILE_OBJECT FATFileObject;