SSD power-on method and device, computer equipment and storage medium
By directly loading full metadata or performing incremental log playback during the SSD power-on phase, resource waste and recovery delay caused by relying on incremental log playback during the traditional SSD power-on phase is solved, and efficient metadata recovery and data consistency are achieved.
Patent Information
- Application Number
- CN202510327239.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-06-20
AI Technical Summary
Traditional SSDs rely on incremental log playback during the power-on phase to rebuild metadata consistency, resulting in waste of resources and delayed recovery, and may lead to data loss or metadata corruption in abnormal power failure.
During the normal power-down phase, the full metadata will be persisted and the incremental log will be cleared to generate a complete metadata storage identifier. During the power-on phase, based on the identification and residual log judgment mode, if it is normal power-off mode, the full amount of metadata is directly loaded, and if it is abnormal power-off mode, incremental log playback is performed.
It realizes efficient solidification of metadata state when powering down normally, accurately restores data consistency when powering down abnormally, shortens power-on time, improves abnormal recovery efficiency, and optimizes storage space utilization.
Smart Images

Figure CN120179447A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and more particularly to a power-on method, device, computer device, and storage medium for an SSD. Background Art
[0002] As a core component of modern storage systems, the metadata management mechanism of solid-state drives (SSDs) directly affects the power-on recovery efficiency and data reliability of devices. Traditional SSDs rely on incremental log replay to reconstruct metadata consistency during the power-on phase, but this solution has significant drawbacks: during normal power-off, the system usually retains both full metadata and incremental logs simultaneously, resulting in redundant occupation of storage space. At the same time, the continuous accumulation of incremental logs increases the log parsing overhead during subsequent power-on phases and prolongs the recovery time. If the system experiences an abnormal power-off, data loss or metadata corruption may occur due to the failure to persistently store metadata in a timely manner or incomplete logs. Existing technologies usually repair data by forcing full log replay or full disk scanning, but such operations are extremely time-consuming and seriously affect the SSD startup efficiency. Therefore, there is an urgent need for an SSD power-on method that can efficiently solidify the metadata state during normal power-off, accurately restore data consistency during abnormal power-off, and has a lightweight mode determination mechanism. Summary of the Invention
[0003] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a power-on method, device, computer device, and storage medium for an SSD, aiming to solve the problems of resource waste and recovery delay caused by traditional SSDs relying on incremental log replay to reconstruct metadata consistency during the power-on phase.
[0004] To achieve the above purpose, the present invention adopts the following technical solutions:
[0005] A power-on method for an SSD, comprising the following steps:
[0006] During the normal power-off phase, persistently store all metadata in memory in advance, clear all incremental logs, and generate a metadata complete storage identifier;
[0007] During the power-on phase, determine whether the system is in the normal power-off mode or the abnormal power-off mode based on the existence of the metadata complete storage identifier and residual incremental logs;
[0008] If it is in the normal power-off mode, directly load all metadata into memory;
[0009] If it is in the abnormal power-off mode, perform incremental log replay to restore metadata consistency.
[0010] In one embodiment, the specific conditions for determining whether the system is in the normal power-off mode or the abnormal power-off mode based on the existence of the metadata complete storage identifier and residual incremental logs are:
[0011] If the complete storage flag of the metadata is detected and no residual incremental log is detected, it is determined as the normal power-off mode;
[0012] If the complete storage flag of the metadata is not detected or there is a residual incremental log, it is determined as the abnormal power-off mode.
[0013] In one embodiment, the step of loading the full amount of metadata into the memory includes:
[0014] Start a background thread to load the full amount of metadata in a preset order, and synchronously open the host's access permission to the loaded metadata;
[0015] When the host requests to access the loaded metadata, record the address and frequency of the accessed loaded metadata page;
[0016] Mark the pages with access frequency exceeding the threshold within a unit time as hot metadata, and persistently store the address information of the hot metadata.
[0017] In one embodiment, during the power-on phase, preferentially load the hot metadata into the memory, and the loading order is in descending order of historical access frequency.
[0018] In one embodiment, when the host requests to access unloaded metadata, mark the requested unloaded metadata as target metadata;
[0019] Suspend the background thread and preferentially load the target metadata.
[0020] In one embodiment, the step of suspending the background thread and preferentially loading the target metadata includes:
[0021] Receive the host request, insert the target metadata page into the head of the background thread loading queue, and suspend the loading task of the current background thread;
[0022] Based on the inserted queue state and the metadata historical access frequency data, reorder the remaining unloaded metadata to generate an updated background thread loading order.
[0023] In one embodiment, the step of performing incremental log replay to restore metadata consistency includes:
[0024] Load the most recently persisted full amount of metadata into the memory as the baseline state for incremental log replay;
[0025] Parse the operation records in the incremental log to identify the transaction operations that were not completed before the abnormal power-off;
[0026] Roll back the unfinished transaction operations in reverse chronological order or replay them forward to restore the metadata to the consistent state of the last complete commit.
[0027] A power-on device for an SSD, comprising:
[0028] A metadata persistence module for persistently storing all metadata in memory to a non-volatile storage medium during normal power-off.
[0029] An incremental log clearing module for clearing all incremental logs and generating a metadata complete storage flag during normal power-off.
[0030] A mode determination module for determining whether the system is in normal power-off mode or abnormal power-off mode based on the presence of the metadata complete storage flag and residual incremental logs during power-on.
[0031] A full data loading module for directly loading all metadata into memory in normal power-off mode.
[0032] A log replay module for performing incremental log replay to restore metadata consistency in abnormal power-off mode.
[0033] A computer device, the computer device includes a memory and a processor, a computer program is stored on the memory, and when the processor executes the computer program, the above method is implemented.
[0034] A computer-readable storage medium, the storage medium stores a computer program, the computer program includes program instructions, and when the program instructions are executed by a processor, the above method can be implemented.
[0035] The beneficial effects of the present invention compared with the prior art are:
[0036] (1) In normal power-off mode, by clearing incremental logs and generating a metadata complete storage flag, all metadata can be directly loaded during power-on, completely skipping the log parsing and replay processes, greatly shortening the startup time. In abnormal power-off mode, only the residual incremental logs need to be replayed to restore consistency, avoiding time-consuming operations such as traditional full log replay or full disk scanning, and greatly improving the abnormal recovery efficiency.
[0037] (2) Clear incremental logs during normal power-off to eliminate the occupation of storage space by redundant data, and at the same time ensure data integrity through full metadata persistence; retain necessary logs during abnormal power-off to ensure the reparability of metadata, forming a balanced design of "lightweight in normal scenarios and guaranteed in abnormal scenarios".
[0038] The above description is only an overview of the technical solution of the present invention. In order to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the following preferred embodiments are specifically illustrated as follows. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a schematic flowchart of a power-on method for an SSD provided by an embodiment of the present invention;
[0040] Figure 2 It is a schematic block diagram of a power-on device for an SSD provided by an embodiment of the present invention;
[0041] Figure 3 It is a schematic block diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0042] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0043] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0044] It should be understood that when used in this specification and the appended claims, the terms "comprises" and "comprising" indicate the presence of the described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or their combinations.
[0045] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in this specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include the plural forms.
[0046] It should be further understood that the term " / and" used in this specification of the present invention and the appended claims refers to any combination and all possible combinations of one or more of the related listed items, and includes these combinations.
[0047] See Figure 1 As shown, an embodiment of the present invention discloses a power-on method for an SSD, including the following steps:
[0048] S100. During the normal power-off phase, persistently store all metadata in the memory in advance, clear all incremental logs, and generate a metadata complete storage identifier.
[0049] Specifically, during the normal power-off phase of the SSD when the system actively shuts down or enters the sleep mode according to the preset process, first write all metadata in the memory, including key information such as the file system structure and the address mapping table, completely into the non-volatile storage medium to ensure that the metadata can still be persistently stored after power-off, guaranteeing the integrity and recoverability of the metadata in the normal power-off scenario and avoiding the risk of data loss caused by direct power-off. Subsequently, clear all existing incremental logs (i.e., the temporary operation logs recording metadata changes), eliminate the occupation of storage space by redundant data, reduce the interference of invalid data on subsequent operations, and at the same time reduce the write wear of the flash medium. Finally, generate a unique metadata complete storage identifier, which is used to clearly indicate that this power-off is completed by the normal process and the metadata is in a complete and consistent state, providing a clear basis for the mode determination in the subsequent power-on phase, simplifying the logical complexity of state identification, and ensuring the reliability of the determination result.
[0050] S200. During the power-on phase, determine whether the system is in the normal power-off mode or the abnormal power-off mode according to the existence of the metadata complete storage identifier and the remaining incremental logs.
[0051] Specifically, during the power-on phase of the SSD, the system first checks whether there is a metadata complete storage identifier in the non-volatile storage medium and simultaneously checks whether there are any remaining incremental logs. If a complete storage identifier is detected and no incremental logs are found, it is determined to be in the normal power-off mode; if the storage identifier is not detected or there are remaining incremental logs, it is determined to be in the abnormal power-off mode. This dual verification mechanism combines the clarity of the identifier and the real-time nature of the logs, significantly improving the accuracy of mode determination.
[0052] S300. If it is in the normal power-off mode, directly load all metadata into the memory.
[0053] Specifically, when the system is determined to be in the normal power-off mode, directly read the persistently stored all metadata from the non-volatile storage medium and load it into the memory to complete the metadata recovery. Since the integrity and consistency of the metadata have been ensured during the normal power-off phase and the incremental logs have been completely cleared, there is no need to perform any log parsing or merging operations, skip the incremental log processing flow, and directly load all data to enable the system to enter the ready state, significantly shortening the power-on time.
[0054] S400. If it is in the abnormal power-off mode, perform incremental log replay to restore metadata consistency.
[0055] Specifically, when the system determines that it is in the abnormal power-off mode, it is necessary to perform an incremental log replay operation to restore metadata consistency. Through log replay, the system can reconstruct the unpersisted metadata changes lost due to abnormal power-off, ensuring data integrity and business continuity. At the same time, in this embodiment, in the case of abnormal power-off, only the remaining incremental logs need to be processed instead of full logs or the entire disk data, significantly reducing the recovery time required.
[0056] In one embodiment, the specific conditions for determining whether the system is in the normal power-off mode or the abnormal power-off mode based on the existence of the metadata complete storage identifier and the remaining incremental logs are as follows:
[0057] If the metadata complete storage identifier is detected and no remaining incremental logs are detected, it is determined to be in the normal power-off mode;
[0058] Specifically, during the power-on stage of the SSD, the system first scans the non-volatile storage medium to detect whether there is a pre-generated metadata complete storage identifier. If the identifier is detected, it further checks whether the incremental log storage area is empty, that is, there are no remaining incremental logs. If the identifier exists and there is no remaining log, it is determined that the system is in the normal power-off mode. That is to say, during the normal power-off stage, the full metadata persistent storage has been actively completed and all incremental logs have been cleared. Therefore, the existence of the identifier and the absence of logs together constitute sufficient evidence for the completion of the normal process. It can be understood that in this embodiment, the metadata complete storage identifier is obtained by reading the flag bits of a specific storage area or verifying the integrity of the preset fields. Through the dual verification mechanism of the existence of the identifier and the absence of logs, the misjudgment risk is significantly reduced, ensuring the high reliability of the determination of the normal power-off mode. At the same time, this determination process only requires simple identifier reading and log area status checking, without complex calculations or full disk scanning, and the determination time is extremely short, laying a foundation for the rapid selection of the power-on recovery path.
[0059] If the metadata complete storage identifier is not detected or there are remaining incremental logs, it is determined to be in the abnormal power-off mode.
[0060] Specifically, if during the detection process in the power-on stage, the metadata complete storage identifier is not found, that is, the identifier storage area is empty or the field verification fails, or remaining incremental logs are detected, that is, there are uncleared operation records in the log storage area, it is determined that the system is in the abnormal power-off mode. That is to say, during abnormal power-off, the system may leave evidence of missing identifiers or remaining logs due to sudden power failure, resulting in the failure to complete the identifier generation or log clearing operations in the normal power-off process. Through the dual verification mechanism of missing identifiers and remaining logs, it is ensured that any abnormal power-off scenario can be accurately identified, avoiding the risk of missed judgment. At the same time, the determination process only requires state detection of the preset areas of the storage medium, without causing additional resource consumption by verifying the entire disk metadata, maintaining the efficiency of the power-on stage while ensuring the accuracy of the determination.
[0061] In one embodiment, the step of loading all metadata into memory includes:
[0062] Start a background thread to load all metadata in a preset order and synchronously open the host's access permission to the loaded metadata;
[0063] Specifically, after it is determined as the normal power-off mode, the system starts a background thread to load all metadata from the non-volatile storage medium into memory in a preset order such as the physical block order or the logical address order. During the loading process, the system synchronously opens the host's access permission to the loaded metadata pages, allowing the host to preferentially access the loaded metadata pages when the background thread has not completed the full loading. This mechanism realizes the synchronous progress of metadata recovery and service response through parallel loading and access authorization, avoids the waiting time of the host before the full metadata is loaded, and significantly shortens the system ready time. Synchronously opening the access permission to the loaded data ensures that the host can immediately operate the available metadata and improves business continuity.
[0064] When the host requests to access the loaded metadata, record the address and frequency of the accessed loaded metadata page;
[0065] Specifically, when the host requests to access the loaded metadata page, the system records the logical or physical address of the accessed page in real time and counts the access frequency of each page within a unit time. It can be understood that in the specific implementation, the metadata address and the access count can be associated through a hash table or a counter matrix in the memory, and the heat value of each page can be dynamically updated to provide a data basis for hot data identification and ensure the objectivity and self-adaptability of subsequent optimization strategies.
[0066] Mark the pages whose access frequency exceeds the threshold within a unit time as hot metadata, and persistently store the address information of the hot metadata.
[0067] Specifically, the system filters out the hot metadata pages according to the preset threshold, marks them as high-priority data, and persistently stores the address information of these pages, such as the logical block address LBA or the physical page number, to a specific area of the non-volatile storage medium. The persistence operation is performed asynchronously during the idle period of the background thread or when the system is under low load to avoid affecting the real-time service performance.
[0068] It can be understood that in this embodiment, on the premise of ensuring the complete recovery of all metadata, the priority processing of high-frequency access data is realized. The parallel mechanism of background thread loading and access permission opening enables the system to respond to critical services at the initial stage of system startup; the dynamic identification and persistent storage of hot metadata provide data support for long-term performance optimization. Through the three-stage cooperation of asynchronous loading - access tracking - hot data solidification, the service response ability after the SSD is powered on is significantly enhanced.
[0069] In one embodiment, during the power-on stage, the hot metadata is preferentially loaded into the memory, and the loading order is arranged in descending order of historical access frequency.
[0070] Specifically, during the power-on stage, the system first reads the address information of the persisted hot metadata from a preset storage area of the non-volatile storage medium. These address information records the logical or physical locations of the hot metadata pages whose historical access frequency exceeds the threshold. The system accurately restores the address list of the hot metadata by parsing the structured data in the storage area, providing an input basis for subsequent priority loading, avoiding recalculating or dynamically analyzing hot data during the power-on stage, and significantly reducing the determination time.
[0071] Then, based on the historical access frequency data of the metadata persisted in the storage, the system sorts the address list of the hot metadata to generate a loading queue arranged from high to low in terms of access frequency, enabling the host to obtain the most frequently accessed metadata at the initial stage of loading, effectively reducing the queuing delay of service requests. For example, if the historical access frequency of a certain metadata page A is 500 times and that of page B is 300 times, the loading priority of A is higher than that of B. After the sorting is completed, the system sequentially reads the hot metadata pages from the non-volatile storage medium according to this order and writes them into the specified area of the memory.
[0072] Finally, the system loads the hot metadata from the storage medium to the memory item by item according to the sorted loading queue. For each completed loading of a hot metadata page, the access permission to this page is immediately opened to the host, rather than waiting for all hot data to be loaded, avoiding the host being blocked from services due to waiting for full loading, and greatly shortening the overall ready time of the system. For example, when page A is loaded, the host can immediately perform read and write operations on it, while the background thread continues to load subsequent data such as page B and page C.
[0073] In one embodiment, when the host requests to access unloaded metadata, the unloaded metadata requested to be accessed is marked as the target metadata;
[0074] Specifically, when the host initiates an access request for metadata, the system first detects whether the requested metadata page has been loaded into the memory. If there is no valid copy of this page in the memory, that is, it is not loaded, then this metadata page is marked as the target metadata. It can be understood that the marking operation is achieved by updating the metadata loading status table, marking the logical or physical address of the target metadata as the "to be preferentially loaded" status, and recording the request timestamp of the host to support subsequent priority calculation. By responding to the host request in real time and dynamically marking the unloaded data, the system can accurately identify the metadata pages urgently needed by the current service, avoiding request blocking caused by loading in a fixed order in the traditional scheme.
[0075] Suspend the background thread and preferentially load the target metadata.
[0076] Specifically, after completing the target metadata marking, the system immediately suspends the current loading task of the background thread and saves the loading progress such as the current reading address and buffer status in the background thread to a temporary storage area. Subsequently, the system reallocates the loading resources to the target metadata, reads the target metadata from the non-volatile storage medium and loads it into the memory. After the loading is completed, the access permission is immediately opened to the host, and finally the original loading task of the background thread is restored. This embodiment minimizes the recovery delay of the unloaded metadata requested by the host and greatly shortens the response time of the host request.
[0077] In one embodiment, the step of suspending the background thread and preferentially loading the target metadata includes:
[0078] Receive a host request, insert the target metadata page at the head of the background thread loading queue, and suspend the loading task of the current background thread;
[0079] Specifically, when the host requests access to unloaded metadata, the system immediately intercepts the request, extracts the address information of the target metadata page, and inserts it at the head of the background thread loading queue to ensure its highest loading priority, directly reducing the waiting time for the host to access the data. The insertion operation is implemented by modifying the queue pointer or dynamically adjusting the task linked list to ensure that the target metadata becomes the next loading task. At the same time, the system suspends the current loading task of the background thread and saves the progress status of the current task to a temporary register or memory area for subsequent recovery, thereby preserving the integrity of the loaded data and avoiding data rollback or repeated loading caused by task interruption.
[0080] Based on the queue status after insertion and the metadata historical access frequency data, reorder the remaining unloaded metadata to generate an updated background thread loading order.
[0081] Specifically, after the target metadata is inserted at the head of the queue, the system obtains a list of the remaining unloaded metadata in the current queue, combines the pre-stored metadata historical access frequency data, and reorders the remaining metadata to reduce the waiting time for subsequent host requests. It can be understood that the sorting rule in this embodiment is: the metadata page with a higher historical access frequency takes precedence over the page with a lower frequency. If the frequencies are the same, they are arranged in the original queue order, thus preventing the loading delay of high-value data caused by the insertion of the target metadata. For example, if the remaining metadata includes page A (frequency 200), page B (frequency 150), and page C (frequency 200), the sorting result is A→C→B. The updated loading order is written to the queue management module, and the background thread loads the data in the new order when it resumes execution.
[0082] In one embodiment, the step of performing incremental log replay to restore metadata consistency includes:
[0083] Loading the most recently persisted full - volume metadata into memory as the benchmark state for incremental log replay;
[0084] Specifically, after it is determined to be the abnormal power - off mode, the system first loads the most recently persisted full - volume metadata during the last normal power - off from the non - volatile storage medium into memory. This full - volume metadata represents the last known complete and consistent state before the abnormal power - off and serves as the benchmark starting point for incremental log replay, thus avoiding the overhead of reconstructing metadata from scratch or full - disk scanning and shortening the initial benchmark preparation time for the replay operation. For example, if the system has completed the Nth normal power - off before the abnormal power - off, the Nth stored full - volume metadata is loaded to ensure that subsequent log replay operations are executed based on the correct data snapshot.
[0085] Parsing the operation records in the incremental log to identify the transaction operations that were not completed before the abnormal power - off;
[0086] Specifically, the system reads the remaining incremental log and parses the operation records in the log one by one. It can be understood that the remaining incremental log is the log that was not cleared before the abnormal power - off. Each operation record contains operation types such as write or delete, target addresses, operation timestamps, and transaction commit status flags. By verifying the transaction commit flag, the uncompleted transaction operations are filtered out. By accurately identifying the uncompleted transactions, the system only needs to process the log records directly related to data consistency, avoiding redundant replay of the committed transactions.
[0087] Rolling back the uncompleted transaction operations in reverse chronological order or replaying them in forward chronological order to restore the metadata to the consistent state of the last complete commit.
[0088] Specifically, for the identified uncompleted transactions, the system selects reverse rollback or forward replay according to their operation types and logics to restore the metadata to the consistent state of the last complete commit. It can be understood that the specific rules for selection are:
[0089] If the uncompleted transaction contains partially executed but uncommitted operations, such as power - off during the transaction, these operations are revoked in reverse chronological order for reverse rollback to eliminate their impact on the metadata;
[0090] If the uncompleted transaction contains committed but unpersisted operations, such as the commit flag has been written but the data has not been flushed to disk, these operations are re - executed in forward chronological order for forward replay to complete the data change.
[0091] Through this selection mechanism, only the metadata inconsistency problems caused by abnormal power-off are repaired, rather than replaying all logs in full, greatly shortening the recovery time. At the same time, the logs are strictly processed according to the transaction boundary and operation order to ensure that the metadata is completely consistent with the state of the last successful submission after repair, greatly reducing the data error rate.
[0092] Please refer to Figure 2 , Figure 2 which is a schematic block diagram of a power-on device for an SSD provided by an embodiment of the present application. As Figure 2 shown, corresponding to the above power-on method for an SSD, the present application also provides a power-on device 500 for an SSD. The power-on device 500 for the SSD includes units for executing the above power-on method for an SSD, and the device can be configured in terminals such as desktop computers, tablet computers, laptops, etc.
[0093] A power-on device 500 for an SSD includes:
[0094] A metadata persistence module 510, configured to persistently store all metadata in the memory to a non-volatile storage medium during a normal power-off phase;
[0095] Specifically, during the normal power-off phase, the metadata persistence module 510 writes all metadata in the memory to a preset metadata storage area of the non-volatile storage medium through a NAND flash interface to ensure the integrity and persistence of the metadata. After the writing is completed, an interrupt signal is triggered to notify the next module to perform a log clearing operation.
[0096] An incremental log clearing module 520, configured to clear all incremental logs and generate a metadata complete storage identifier during a normal power-off phase;
[0097] Specifically, after receiving the interrupt signal from the metadata persistence module, the incremental log clearing module 520 traverses the incremental log storage area, deletes all remaining incremental logs such as uncommitted transaction operation records, and writes a metadata complete storage identifier at the head of the metadata storage area. After the identifier writing is completed, a power-off completion signal is triggered, and the SSD enters a power-off state.
[0098] A mode determination module 530, configured to determine whether the system is in a normal power-off mode or an abnormal power-off mode according to the existence of the metadata complete storage identifier and remaining incremental logs during a power-on phase;
[0099] Specifically, during the power-on stage, the mode determination module 530 first reads the header data of the metadata storage area through the NAND interface to detect whether there is a valid metadata integrity storage flag. At the same time, it scans the incremental log storage area to check whether there is a non-empty log block. If the flag exists and the log storage area is empty, it is determined as the normal power-off mode; if the flag is missing or there is a valid log in the log storage area, it is determined as the abnormal power-off mode, and a mode instruction is sent to the subsequent module.
[0100] The full data loading module 540 is used to directly load the full metadata into the memory in the normal power-off mode;
[0101] Specifically, when the mode determination module outputs a normal power-off mode instruction, the full data loading module 540 reads the full metadata from the metadata storage area, directly transmits it to the metadata mapping area in the memory through the DMA channel, and updates the address mapping table of the memory management unit so that the host can immediately access the loaded metadata. During the loading process, the module checks the metadata CRC in real time to ensure data integrity.
[0102] The log replay module 550 is used to perform incremental log replay in the abnormal power-off mode to restore metadata consistency.
[0103] Specifically, when the mode determination module outputs an abnormal power-off mode instruction, the log replay module 550 performs an incremental log replay operation. The specific process is as follows: Load the last persistently stored full metadata from the metadata storage area into the memory as a benchmark, parse the residual logs in the incremental log storage area, identify the uncommitted transactions, and roll back or replay the operations in the order of the transaction timestamps until the metadata is restored to the last complete commit state. After completion, update the memory metadata and notify the host that it can be accessed.
[0104] Please refer to Figure 3 , Figure 3 which is a schematic block diagram of a computer device provided by an embodiment of the present application. The computer device 600 can be a terminal or a server. Among them, the terminal can be an electronic device with communication functions such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device. The server can be an independent server or a server cluster composed of multiple servers.
[0105] See Figure 3 As shown, the computer device 600 includes a processor 620, a memory, and a network interface 650 connected through a system bus 610. Among them, the memory can include a non-volatile storage medium 630 and an internal memory 640.
[0106] The non-volatile storage medium 630 can store an operating system 631 and a computer program 632. The computer program 632 includes program instructions which, when executed, can cause the processor 320 to execute a power-on method for an SSD.
[0107] The processor 620 is used to provide computing and control capabilities to support the operation of the entire computer device 600.
[0108] The internal memory 640 provides an environment for the operation of the computer program 632 in the non-volatile storage medium 630. When the computer program 632 is executed by the processor 620, it can cause the processor 620 to execute a power-on method for an SSD.
[0109] The network interface 650 is used for network communication with other devices. Those skilled in the art can understand that Figure 3 the structure shown in [figures] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device 600 to which the solution of this application is applied. The specific computer device 600 may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0110] It should be understood that in the embodiments of this application, the processor 620 may be a central processing unit (CPU), and the processor 320 may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0111] Those of ordinary skill in the art can understand that all or part of the processes in the methods of implementing the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program includes program instructions. The computer program can be stored in a storage medium, and the storage medium is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0112] Therefore, the present application also provides a storage medium. The storage medium can be a computer-readable storage medium. The storage medium stores a computer program, where the computer program includes program instructions. When the program instructions are executed by a processor, the processor performs the following steps:
[0113] S100. In the normal power-down stage, persistently store all metadata in the memory in advance, clear all incremental logs, and generate a metadata complete storage identifier;
[0114] S200. In the power-on stage, determine whether the system is in the normal power-down mode or the abnormal power-off mode according to the existence of the metadata complete storage identifier and the residual incremental logs;
[0115] S300. If it is in the normal power-down mode, directly load all metadata into the memory;
[0116] S400. If it is in the abnormal power-off mode, perform incremental log replay to restore metadata consistency.
[0117] The storage medium can be a variety of computer-readable storage media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disc, etc., which can store program codes.
[0118] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0119] The non-company software tools or components that appear in the embodiments of the present application are only for illustrative introduction and do not represent actual use.
[0120] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of each unit is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0121] The steps in the method of the embodiments of the present application can be adjusted in sequence, combined, and deleted according to actual needs. The units in the device of the embodiments of the present application can be combined, divided, and deleted according to actual needs. In addition, in each embodiment of the present application, the functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit.
[0122] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods of the embodiments of the present application.
[0123] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A method for powering on an SSD, characterized in that: The following steps are involved: During the normal power-off phase, the full metadata in the memory is stored persistently in advance, all incremental logs are cleared, and a metadata complete storage identifier is generated; During the power-on phase, the system is judged to be in normal power-off mode or abnormal power-off mode based on whether there is a complete metadata storage identifier and residual incremental logs; If it is normal power-off mode, directly load all metadata into the memory; If it is abnormal power failure mode, perform incremental log playback to restore metadata consistency.
2. The method for powering on an SSD according to claim 1, characterized in that: The specific conditions for determining whether the system is in normal power-off mode or abnormal power-off mode based on whether there is a complete metadata storage identifier and a residual incremental log are: If the metadata complete storage indicator is detected and no residual incremental log is detected, it is determined to be in normal power-off mode; If the metadata complete storage mark is not detected or there are residual incremental logs, it is determined to be an abnormal power-off mode.
3. The method for powering on an SSD according to claim 1, characterized in that: The step of loading the full metadata into the memory includes: Start the background thread to load all metadata in the preset order, and simultaneously open the host's access rights to the loaded metadata; When the host requests to access the loaded metadata, the address and frequency of the loaded metadata page being accessed are recorded; The pages whose access frequency exceeds a threshold within a unit time are marked as hotspot metadata, and the address information of the hotspot metadata is persistently stored.
4. The method for powering on an SSD according to claim 3, characterized in that: During the power-on phase, the hotspot metadata is loaded into the memory first, and the loading order is arranged in descending order of historical access frequency.
5. The method for powering on an SSD according to claim 3, characterized in that: When the host requests to access unloaded metadata, the unloaded metadata requested to be accessed is marked as target metadata; Pause the background thread and prioritize loading the target metadata.
6. The method for powering on an SSD according to claim 5, characterized in that: The steps of pausing the background thread and preferentially loading the target metadata include: Receive host request, insert target metadata page to the first of background thread loading queue, and suspend current background thread loading task; Based on the queue status after insertion and the metadata historical access frequency data, the remaining unloaded metadata is reordered to generate an updated background thread loading order.
7. The method for powering on an SSD according to claim 1, characterized in that: The step of performing incremental log playback to restore metadata consistency includes: Load the most recently persisted full metadata into memory as the baseline state for incremental log playback; Parsing the operation records in the incremental log to identify the unfinished transaction operations before the abnormal power failure; The unfinished transaction operation is reversely rolled back or forwardly replayed in chronological order to restore the metadata to the last completely committed consistent state.
8. A power-on device for an SSD, characterized in that: include: The metadata persistence module is used to store the full metadata in the memory to a non-volatile storage medium during the normal power-off phase; The incremental log clearing module is used to clear all incremental logs and generate a complete metadata storage identifier during the normal power-off phase; A mode determination module, used to determine whether the system is in a normal power-off mode or an abnormal power-off mode according to whether the metadata complete storage identifier and the residual incremental log exist during the power-on phase; Full data loading module, used to directly load full metadata into memory in normal power-off mode; The log replay module is used to perform incremental log replay in abnormal power-off mode to restore metadata consistency.
9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the method according to any one of claims 1 to 7 can be implemented.
Citation Information
Cited By
Remote monitoring method and system for machine room power distribution equipment
CN121093240A