From: Pierre Schweitzer Date: Sat, 6 Aug 2016 08:30:30 +0000 (+0000) Subject: [FASTFAT] X-Git-Tag: backups/sndblst@72664~484 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=ccacd0b3f1d31c975a61a408f4a9b935c20a548f;hp=60c0a0a00d836c3189c99eed48b6daeff4a99960 [FASTFAT] Track child FCB in parent FCB to allow browsing them in case it's needed. This allows fixing a FIXME and offering better performances when renaming a directory. CORE-11377 CORE-11426 svn path=/trunk/; revision=72124 --- diff --git a/reactos/drivers/filesystems/fastfat/fcb.c b/reactos/drivers/filesystems/fastfat/fcb.c index ad17fa6aac2..f8b0a48409e 100644 --- a/reactos/drivers/filesystems/fastfat/fcb.c +++ b/reactos/drivers/filesystems/fastfat/fcb.c @@ -153,6 +153,7 @@ vfatNewFCB( rcFCB->RFCB.PagingIoResource = &rcFCB->PagingIoResource; rcFCB->RFCB.Resource = &rcFCB->MainResource; rcFCB->RFCB.IsFastIoPossible = FastIoIsNotPossible; + InitializeListHead(&rcFCB->ParentListHead); return rcFCB; } @@ -271,6 +272,8 @@ vfatDestroyFCB( ExDeleteResourceLite(&pFCB->PagingIoResource); ExDeleteResourceLite(&pFCB->MainResource); ExFreeToNPagedLookasideList(&VfatGlobalData->FcbLookasideList, pFCB); + RemoveEntryList(&pFCB->ParentListEntry); + ASSERT(IsListEmpty(&pFCB->ParentListHead)); } BOOLEAN @@ -455,6 +458,7 @@ vfatUpdateFCB( /* Save old parent */ OldParent = Fcb->parentFcb; + RemoveEntryList(&Fcb->ParentListEntry); /* Reinit FCB */ vfatInitFCBFromDirEntry(pVCB, Fcb, DirContext); @@ -464,6 +468,7 @@ vfatUpdateFCB( CcFlushCache(&Fcb->SectionObjectPointers, NULL, 0, NULL); } Fcb->parentFcb = ParentFcb; + InsertTailList(&ParentFcb->ParentListHead, &Fcb->ParentListEntry); vfatAddFCBToTable(pVCB, Fcb); /* If we moved across directories, dereference our old parent @@ -673,6 +678,7 @@ vfatMakeFCBFromDirEntry( vfatFCBInitializeCacheFromVolume(vcb, rcFCB); } rcFCB->parentFcb = directoryFCB; + InsertTailList(&directoryFCB->ParentListHead, &rcFCB->ParentListEntry); vfatAddFCBToTable(vcb, rcFCB); *fileFCB = rcFCB; diff --git a/reactos/drivers/filesystems/fastfat/finfo.c b/reactos/drivers/filesystems/fastfat/finfo.c index 7ce51eeefb2..3f18eaee00b 100644 --- a/reactos/drivers/filesystems/fastfat/finfo.c +++ b/reactos/drivers/filesystems/fastfat/finfo.c @@ -704,19 +704,17 @@ VfatSetRenameInformation( vfatSplitPathName(&NewName, &NewPath, &NewFile); DPRINT("New dir: %wZ, New file: %wZ\n", &NewPath, &NewFile); - /* FIXME: Do it in a more efficient way, like linking FCBs to their parent FCB so that we browse less FCBs - * Note: The FIXME is the way MS FastFAT seems to do it - */ - if (vfatFCBIsDirectory(FCB)) + if (vfatFCBIsDirectory(FCB) && !IsListEmpty(&FCB->ParentListHead)) { PLIST_ENTRY Entry; PVFATFCB VolFCB; - for (Entry = DeviceExt->FcbListHead.Flink; Entry != &DeviceExt->FcbListHead; Entry = Entry->Flink) + for (Entry = FCB->ParentListHead.Flink; Entry != &FCB->ParentListHead; Entry = Entry->Flink) { - VolFCB = CONTAINING_RECORD(Entry, VFATFCB, FcbListEntry); - if (VolFCB->parentFcb == FCB && VolFCB->OpenHandleCount != 0) + VolFCB = CONTAINING_RECORD(Entry, VFATFCB, ParentListEntry); + if (VolFCB->OpenHandleCount != 0) { + ASSERT(VolFCB->parentFCB == FCB); DPRINT1("At least one children file opened! %wZ (%u, %u)\n", &VolFCB->PathNameU, VolFCB->RefCount, VolFCB->OpenHandleCount); Status = STATUS_ACCESS_DENIED; ASSERT(OldReferences == FCB->parentFcb->RefCount);