Author: fireball Date: Fri Nov 23 21:52:46 2007 New Revision: 30703
URL: http://svn.reactos.org/svn/reactos?rev=30703&view=rev Log: - Remove CmiInitHives. - Enable parallel hive loading, this speeds up boot by loading the registry in 6 threads instead of just one (once we start having large registries and MP support this will be more evident). - Added some little hacks to make this work for now. - Fix a memory leak in CmInit1. - Add hardware hive to machine hive list so it can be properly loaded after.
Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c trunk/reactos/ntoskrnl/cm/registry.c trunk/reactos/ntoskrnl/config/cmsysini.c
Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/ntfunc.c?rev=30... ============================================================================== --- trunk/reactos/ntoskrnl/cm/ntfunc.c (original) +++ trunk/reactos/ntoskrnl/cm/ntfunc.c Fri Nov 23 21:52:46 2007 @@ -582,8 +582,6 @@ NTAPI NtInitializeRegistry (IN USHORT Flag) { - NTSTATUS Status; - PAGED_CODE();
if (CmiRegistryInitialized == TRUE) @@ -591,13 +589,11 @@
/* Save boot log file */ IopSaveBootLogToFile(); - - Status = CmiInitHives (Flag); - + CmpCmdInit(Flag); CmiRegistryInitialized = TRUE;
- return Status; + return STATUS_SUCCESS; }
/* EOF */
Modified: trunk/reactos/ntoskrnl/cm/registry.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/registry.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/cm/registry.c (original) +++ trunk/reactos/ntoskrnl/cm/registry.c Fri Nov 23 21:52:46 2007 @@ -223,165 +223,6 @@ return STATUS_SUCCESS; }
-NTSTATUS -NTAPI -CmpGetRegistryPath(IN PWCHAR ConfigPath); - -NTSTATUS -CmiInitHives(BOOLEAN SetupBoot) -{ - NTSTATUS Status; - WCHAR ConfigPath[MAX_PATH]; - PWSTR EndPtr; - PCMHIVE CmHive; - BOOLEAN Allocate = TRUE; - UNICODE_STRING FileName, KeyName; - - DPRINT("CmiInitHives() called\n"); - - CmpGetRegistryPath(ConfigPath); - DPRINT("ConfigPath: %S\n", ConfigPath); - EndPtr = ConfigPath + wcslen(ConfigPath); - - /* Setup the file name for the SECURITY hive */ - wcscpy(EndPtr, REG_SEC_FILE_NAME); - RtlInitUnicodeString(&FileName, ConfigPath); - DPRINT ("ConfigPath: %S\n", ConfigPath); - - /* Load the hive */ - Status = CmpInitHiveFromFile(&FileName, - 0, - &CmHive, - &Allocate, - 0); - - /* Setup the key name for the SECURITY hive */ - RtlInitUnicodeString(&KeyName, REG_SEC_KEY_NAME); - - Status = CmpLinkHiveToMaster(&KeyName, - NULL, - CmHive, - FALSE, - NULL); - - /* Connect the SOFTWARE hive */ - wcscpy(EndPtr, REG_SOFTWARE_FILE_NAME); - RtlInitUnicodeString(&FileName, ConfigPath); - DPRINT ("ConfigPath: %S\n", ConfigPath); - - /* Load the hive */ - Status = CmpInitHiveFromFile(&FileName, - 0, - &CmHive, - &Allocate, - 0); - - /* Setup the key name for the SECURITY hive */ - RtlInitUnicodeString (&KeyName, REG_SOFTWARE_KEY_NAME); - - Status = CmpLinkHiveToMaster(&KeyName, - NULL, - CmHive, - FALSE, - NULL); - - /* Connect the SYSTEM hive only if it has been created */ - if (SetupBoot == TRUE) - { - HANDLE PrimaryHandle, LogHandle; - ULONG PrimaryDisposition, SecondaryDisposition; - ULONG ClusterSize, Length; - - /* Build the file name */ - wcscpy(EndPtr, REG_SYSTEM_FILE_NAME); - RtlInitUnicodeString(&FileName, ConfigPath); - DPRINT ("ConfigPath: %S\n", ConfigPath); - - /* Hive already exists */ - CmHive = CmpMachineHiveList[3].CmHive; - - /* Open the hive file and log */ - Status = CmpOpenHiveFiles(&FileName, - L".LOG", - &PrimaryHandle, - &LogHandle, - &PrimaryDisposition, - &SecondaryDisposition, - TRUE, - TRUE, - FALSE, - &ClusterSize); - if (!(NT_SUCCESS(Status)) || !(LogHandle)) - { - /* Bugcheck */ - KeBugCheck(BAD_SYSTEM_CONFIG_INFO); - } - - /* Save the file handles */ - CmHive->FileHandles[HFILE_TYPE_LOG] = LogHandle; - CmHive->FileHandles[HFILE_TYPE_PRIMARY] = PrimaryHandle; - - /* Allow lazy flushing since the handles are there */ - //ASSERT(CmHive->Hive.HiveFlags & HIVE_NOLAZYFLUSH); - CmHive->Hive.HiveFlags &= ~HIVE_NOLAZYFLUSH; - - /* Get the real size of the hive */ - Length = CmHive->Hive.Storage[Stable].Length + HBLOCK_SIZE; - - /* Check if the cluster size doesn't match */ - if (CmHive->Hive.Cluster != ClusterSize) ASSERT(FALSE); - - /* Set the file size */ - if (!CmpFileSetSize((PHHIVE)CmHive, HFILE_TYPE_PRIMARY, Length, Length)) - { - /* This shouldn't fail */ - ASSERT(FALSE); - } - } - - /* Connect the DEFAULT hive */ - wcscpy(EndPtr, REG_DEFAULT_USER_FILE_NAME); - RtlInitUnicodeString(&FileName, ConfigPath); - DPRINT ("ConfigPath: %S\n", ConfigPath); - - /* Load the hive */ - Status = CmpInitHiveFromFile(&FileName, - 0, - &CmHive, - &Allocate, - 0); - - /* Setup the key name for the SECURITY hive */ - RtlInitUnicodeString (&KeyName, REG_DEFAULT_USER_KEY_NAME); - - Status = CmpLinkHiveToMaster(&KeyName, - NULL, - CmHive, - FALSE, - NULL); - - /* Connect the SAM hive */ - wcscpy(EndPtr, REG_SAM_FILE_NAME); - RtlInitUnicodeString(&FileName, ConfigPath); - DPRINT ("ConfigPath: %S\n", ConfigPath); - - /* Load the hive */ - Status = CmpInitHiveFromFile(&FileName, - 0, - &CmHive, - &Allocate, - 0); - - /* Setup the key name for the SECURITY hive */ - RtlInitUnicodeString(&KeyName, REG_SAM_KEY_NAME); - Status = CmpLinkHiveToMaster(&KeyName, - NULL, - CmHive, - FALSE, - NULL); - return Status; -} - VOID NTAPI CmShutdownRegistry(VOID)
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c?... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmsysini.c (original) +++ trunk/reactos/ntoskrnl/config/cmsysini.c Fri Nov 23 21:52:46 2007 @@ -826,7 +826,7 @@ }
/* Add registry path */ - wcscat(ConfigPath, L"\System32\Config"); + wcscat(ConfigPath, L"\System32\Config\");
/* Done */ return STATUS_SUCCESS; @@ -888,13 +888,11 @@ RtlAppendStringToString((PSTRING)&FileName, (PSTRING)&TempName); if (!CmpMachineHiveList[i].CmHive) { - /* We need to allocate a ne whive structure */ + /* We need to allocate a new hive structure */ CmpMachineHiveList[i].Allocate = TRUE;
/* Load the hive file */ DPRINT1("[HiveLoad]: Load from file %wZ\n", &FileName); - CmpMachineHiveList[i].CmHive2 = (PVOID)0xBAADBEEF; - goto Later; Status = CmpInitHiveFromFile(&FileName, CmpMachineHiveList[i].HHiveFlags, &CmHive, @@ -918,13 +916,12 @@ } else { + if (ExpInTextModeSetup) { /* We already have a hive, is it volatile? */ CmHive = CmpMachineHiveList[i].CmHive; if (!(CmHive->Hive.HiveFlags & HIVE_VOLATILE)) { DPRINT1("[HiveLoad]: Open from file %wZ\n", &FileName); - CmpMachineHiveList[i].CmHive2 = CmHive; - goto Later;
/* It's now, open the hive file and log */ Status = CmpOpenHiveFiles(&FileName, @@ -957,7 +954,7 @@ CmHive->FileHandles[HFILE_TYPE_PRIMARY] = PrimaryHandle;
/* Allow lazy flushing since the handles are there -- remove sync hacks */ - ASSERT(CmHive->Hive.HiveFlags & HIVE_NOLAZYFLUSH); + //ASSERT(CmHive->Hive.HiveFlags & HIVE_NOLAZYFLUSH); CmHive->Hive.HiveFlags &= ~HIVE_NOLAZYFLUSH;
/* Get the real size of the hive */ @@ -979,17 +976,15 @@ /* Finally, set our allocated hive to the same hive we've had */ CmpMachineHiveList[i].CmHive2 = CmHive; ASSERT(CmpMachineHiveList[i].CmHive == CmpMachineHiveList[i].CmHive2); - } + }} }
/* We're done */ -Later: CmpMachineHiveList[i].ThreadFinished = TRUE;
/* Check if we're the last worker */ WorkerCount = InterlockedIncrement(&CmpLoadWorkerIncrement); if (WorkerCount == CM_NUMBER_OF_MACHINE_HIVES) - { /* Signal the event */ KeSetEvent(&CmpLoadWorkerEvent, 0, FALSE); @@ -1003,7 +998,7 @@ NTAPI CmpInitializeHiveList(IN USHORT Flag) { - WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH]; + WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH]; UNICODE_STRING TempName, FileName, RegName; HANDLE Thread; NTSTATUS Status; @@ -1019,7 +1014,8 @@ RtlInitEmptyUnicodeString(&RegName, RegBuffer, MAX_PATH);
/* Now build the system root path */ - RtlInitUnicodeString(&TempName, L"\SystemRoot\System32\Config\"); + CmpGetRegistryPath(ConfigPath); + RtlInitUnicodeString(&TempName, ConfigPath); RtlAppendStringToString((PSTRING)&FileName, (PSTRING)&TempName); FileStart = FileName.Length;
@@ -1105,11 +1101,10 @@
/* Now link the hive to its master */ DPRINT1("[HiveLoad]: Link %wZ\n", &RegName); -#if 0 Status = CmpLinkHiveToMaster(&RegName, NULL, CmpMachineHiveList[i].CmHive2, - CmpMachineHiveList[i].Allocate, + FALSE, //CmpMachineHiveList[i].Allocate, SecurityDescriptor); if (Status != STATUS_SUCCESS) { @@ -1121,9 +1116,8 @@ if (CmpMachineHiveList[i].Allocate) { /* Sync the new hive */ - HvSyncHive((PHHIVE)(CmpMachineHiveList[i].CmHive2)); - } -#endif + //HvSyncHive((PHHIVE)(CmpMachineHiveList[i].CmHive2)); + } }
/* Check if we created a new hive */ @@ -1310,19 +1304,27 @@ /* Bugcheck */ KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 11, Status, 0); } + + /* Add the hive to the hive list */ + CmpMachineHiveList[0].CmHive = (PCMHIVE)HardwareHive;
/* Attach it to the machine key */ RtlInitUnicodeString(&KeyName, REG_HARDWARE_KEY_NAME); Status = CmpLinkHiveToMaster(&KeyName, NULL, (PCMHIVE)HardwareHive, - FALSE, + FALSE, // TRUE SecurityDescriptor); if (!NT_SUCCESS(Status)) { /* Bugcheck */ KEBUGCHECKEX(CONFIG_INITIALIZATION_FAILED, 1, 12, Status, 0); } + + /* FIXME: Add to HiveList key */ + + /* Free the security descriptor */ + ExFreePool(SecurityDescriptor);
/* Fill out the Hardware key with the ARC Data from the Loader */ Status = CmpInitializeHardwareConfiguration(KeLoaderBlock);