Solid State Drive Failure Recovery Methods and Electronic Devices
By setting a read-only mode and rebuilding the L2P mapping table when a solid-state drive (SSD) fails, the problem of unreliable or lost data after an SSD failure is solved, achieving efficient and reliable data recovery.
Patent Information
- Application Number
- CN202511574252.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2045-10-30
AI Technical Summary
When a solid-state drive (SSD) fails, data cannot be recovered normally, resulting in unreliable or lost data, and the integrity and reliability of the data cannot be guaranteed during the recovery process.
When a solid-state drive (SSD) fails, it is set to read-only mode, the block units are traversed to obtain the type and write timestamp, the target block units are filtered, the metadata is restored to the first-level table based on the target block unit list, and the L2P mapping table is rebuilt.
It effectively solves the problems of data integrity and security when solid-state drives fail, significantly improves the efficiency and integrity of data recovery, and ensures the reliable operation of the system.
Smart Images

Figure CN121050935B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data recovery, and particularly relates to a fault recovery method of a solid state disk and an electronic device. BACKGROUND
[0002] For enterprise-level SSDs (Solid State Drives), the security and reliability of data are the core values, which are directly related to the stable operation of key businesses such as data centers, cloud computing platforms, financial systems, and communication networks. In these high-demand application scenarios, any data loss or service interruption may cause huge losses. Therefore, enterprise-level SSDs not only need to have high performance, but also need to protect data to the maximum extent in various abnormal or fault conditions and try to ensure that the data can be recovered.
[0003] In the related art, when the SSD enters a fault state, it cannot normally store data, and re-power-on operation is performed. If the SSD still recovers data in a normal manner, the recovered data is not reliable, and even errors occur in the recovery phase, resulting in failure to recover the data. SUMMARY
[0004] The present application provides a fault recovery method of a solid state disk and an electronic device to at least solve the problems that in the related art, after the SSD fails, the data cannot be effectively recovered, data is lost or errors occur in the recovery process, and the integrity and reliability of the recovered data cannot be guaranteed when the SSD is powered on again according to the normal recovery process.
[0005] The present application provides a fault recovery method of a solid state disk, comprising: in a case where it is determined that the solid state disk has a fault, setting the solid state disk to a read-only mode, and traversing a plurality of block units to obtain types and write time stamps of the block units; determining a plurality of target block units based on a target type and the types of the plurality of block units, and determining a target block unit list based on the write time stamps of the plurality of target block units; and based on logical addresses of metadata stored in the target block units in the target block unit list, recovering the metadata into a first-level table, the first-level table being used to represent a mapping relationship between the logical addresses and physical addresses.
[0006] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of the fault recovery method of the solid state disk.
[0007] The method for fault recovery of the solid state disk and the electronic device provided by the application can check the state flag bit to determine whether a fault occurs when the solid state disk is powered on. If it is determined that a fault occurs in the solid state disk, the solid state disk is set to a read-only mode to prevent further data damage. Subsequently, the system traverses the block units for storing metadata in the solid state disk, extracts the type and write time stamp of each block unit. By screening and sorting these block units, the system determines a target block unit list. Then, each page in the target block unit list is read, and according to the logical address of the metadata in the page, the corresponding physical address is recovered to a first-level table, and finally a complete L2P mapping table is reconstructed. In addition, if the solid state disk receives a formatting command, the read-only mode is exited, the fault recovery state flag bit is cleared, all user data and related metadata are cleared, and the formatting of the hard disk is completed. The present application effectively solves the problem that the data integrity and security cannot be guaranteed when the solid state disk fails, significantly improves the efficiency and integrity of data recovery, and ensures the reliable operation of the system. BRIEF DESCRIPTION OF DRAWINGS
[0008] In order to more clearly illustrate the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0009] Figure 1 The flow chart of the method for fault recovery of the solid state disk provided by the embodiments of the present application;
[0010] Figure 2 The flow chart of the method for fault recovery of the solid state disk provided by the embodiments of the present application;
[0011] Figure 3 The block diagram of the electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0012] The technical solutions in the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the present application.
[0013] It should be noted that in the description of the present application, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or further includes elements inherent to such a process, method, article or device. The terms "first", "second" and the like in the present application are used to distinguish similar objects, not to describe a specific order or sequence.
[0014] In order for those skilled in the art to better understand the present application, the present application will be further described in detail below in conjunction with the drawings and specific embodiments.
[0015] Metadata in the present application is the key information used to describe the attributes and characteristics of data, which does not contain the specific content of data, but provides contextual information about data, thereby helping us effectively manage and understand data. In SSD, metadata includes mapping type metadata such as logical address to physical address (L2P) metadata, which is used to quickly locate the data storage location; block management type metadata including block state information metadata, wear leveling record metadata, which is used to manage the use and recycling of blocks; performance optimization type metadata such as garbage collection priority information metadata, cache management metadata, which is used to improve SSD performance, etc.
[0016] Among them, L2P metadata is the key information used to record the mapping relationship between logical address and physical address in solid state disk, mainly composed of logical address, physical address and write time, etc. The main function of L2P metadata is to realize the fast conversion of logical address to physical address. In data read and write operation, the host initiates the request through logical address, while the SSD relies on L2P metadata to convert logical address to physical address, and quickly locates the actual storage location of data. Secondly, in the data recovery process, L2P metadata is the key basis for rebuilding data mapping relationship. When SSD fails and needs to be recovered, L2P metadata provides detailed information of data storage location and mapping relationship, ensuring the integrity and consistency of data. Finally, the write time stamp in L2P metadata helps the system to track the usage status and update order of data blocks, which is crucial for optimizing data storage, allocation and recovery process. Therefore, L2P metadata is not only the core component of the normal operation of SSD, but also the important basis for ensuring data security and system reliability.
[0017] In the process of saving metadata, each type of metadata is allocated an independent block unit dedicated to saving this metadata. Each time a page is saved, the metadata type, timestamp, and logical address information data are saved along with the metadata in the metadata of the page for subsequent quick access and recovery. This design ensures the integrity and reliability of the metadata, providing a solid foundation for the efficient operation and data security of solid-state drives. Metadata plays an important role in storage management, it is not only the core of data management, but also the key to data recovery, ensuring the efficient, reliable and stable operation of the storage system.
[0018] SSD is a high-speed storage device that uses flash technology for data storage. It uses NAND Flash, a non-volatile storage chip based on flash storage technology, to save data, abandoning the mechanical components in traditional mechanical hard drives. It has the advantages of fast read and write speed, strong shock resistance, low power consumption, light weight, small size and silent operation. In enterprise-level applications, the high performance and high reliability of SSD make it a core storage solution for key business scenarios such as data centers, cloud computing platforms, financial systems and communication networks.
[0019] Enterprise SSD not only can quickly handle large-scale data read and write operations, improve data processing efficiency and system response speed, but also can ensure data integrity and security through advanced storage management and error correction mechanisms. Its low latency and high throughput characteristics are crucial for supporting virtualization environments, database applications and real-time analysis in enterprise-level workloads, effectively improving business continuity and competitiveness. At the same time, enterprise SSD prolongs the service life and reduces the total cost of ownership through technologies such as wear leveling, power failure protection and data path protection, providing efficient, reliable and economical storage solutions for enterprises.
[0020] But in actual use environment, SSD may face a variety of risk factors, leading to its failure state, so as to be unable to read data normally, affecting the normal operation of business. Therefore, at the beginning of the design of storage firmware, a function needs to be included in the design scheme, that is, in the failure state, if the NAND Flash does not appear actual damage, the user data should be recovered as completely and accurately as possible. This ability not only improves the fault tolerance level of the storage device, but also provides a basis for the disaster recovery strategy of the upper system. For the production environment, it is crucial to quickly identify the failure and automatically enter the recoverable state, the earlier the recovery process is started, the earlier the business can be recovered, and the loss can be reduced. On this basis, combined with the host-side redundancy protection mechanism, such as RAID (Redundant Array of Independent Disks), data replication, snapshot backup, etc., the availability and recovery efficiency of the overall system can be further improved, and finally the rapid reconstruction and recovery of production business can be realized.
[0021] Among all the data structures that need to be recovered, the key content is the mapping relationship table of logical address to physical address, referred to as L2P mapping table in the following embodiments, which records the correspondence between the logical block address seen by the host and the actual physical location in the NAND Flash. Only by accurately reconstructing this mapping table can the SSD correctly parse the read request and locate the real data. Therefore, the core goal in the failure recovery process is to recover the L2P mapping table.
[0022] In order to achieve this goal, the SSD designs a multi-level mapping mechanism, including a primary table and a secondary table. Among them, the primary table is used to record the mapping relationship between the physical address and the logical address of the metadata, and each entry contains a logical address range and its corresponding physical address. The primary table is the core of data access, through which the system can quickly locate the physical location of data in the NAND Flash, and realize the fast read and write operation of data. The secondary table records the mapping relationship of the primary table, and the content mainly includes the physical address of the primary table, the logical range of the primary table, the timestamp and the check information of the metadata, and the index information for quickly finding a specific part of the primary table.
[0023] When the SSD does not fail, if the SSD receives a power-off instruction from the system, a series of operations will be triggered to prepare for safe power-off, and then the data in the cache that has not been written to the flash memory will be written to ensure that all user data is safely stored. At this time, the mapping management system of the SSD updates the L2P mapping table, and then records the latest mapping relationship, i.e., the primary table and the secondary table, and saves them to the designated flash memory block respectively. The secondary table is small in size and only needs one block to save, which enables the saving operation to be completed quickly during power-off, reducing the system waiting time. Finally, after all the mapping tables and key data are saved successfully, the system ends all the power-off procedures and completes the power-off.
[0024] The design of this mapping method ensures the integrity and accuracy of the primary table and the secondary table in the normal power-off storage processing flow of the SSD. It lays the foundation for the SSD to quickly recover the mapping relationship and correctly respond to the host request during the next power-on. Specifically, in the normal state, the secondary table saved during the last power-off can always be found in the power-on procedure, and the complete primary table is recovered according to the index entries of the secondary table, and finally the complete L2P mapping relationship from logical address to physical address is constructed in the memory according to the primary table and the sequence of logical addresses. At the same time, it also effectively reduces the wear and tear of the flash memory caused by unnecessary operations.
[0025] However, when the SSD fails, such as sudden power-off or system crash, the SSD may not be able to complete the power-off procedure, resulting in incomplete storage of the primary table or the secondary table. When the solid state disk is powered on again, it is difficult to recover a high-confidence L2P mapping relationship using the normal power-on procedure, and thus it is difficult to ensure the integrity and accuracy of the data stored in the SSD.
[0026] Therefore, a SSD failure storage recovery strategy is needed, which not only can rebuild the L2P mapping table, but also should be simple and easy to use, so as to quickly enter the recovery procedure and resume the normal operation of the business as soon as possible.
[0027] Embodiments of the present application provide a solid state disk failure recovery method, which is described in detail in combination with the execution flow of the solid state disk failure recovery method.
[0028] Figure 1 A flowchart of a solid state disk failure recovery method provided by embodiments of the present application.
[0029] With reference to the drawings, embodiments of the present application will be described in detail. Figure 1 The solid state disk failure recovery method of the present application comprises:
[0030] S1, obtaining the state flag bit of the solid state disk.
[0031] Specifically, when the solid state disk is powered on, the state flag bit of the solid state disk is first obtained.
[0032] S2, in the case of determining that the solid state disk is faulty according to the state flag, setting the solid state disk to read-only mode, and traversing a plurality of block units to obtain the type and write timestamp of the block unit.
[0033] Wherein, the read-only mode is a working mode of the solid state disk device, in this mode, the solid state disk device is limited to only allow reading data, and cannot perform write or modify data operation, so as to ensure that data is not further lost or damaged due to misoperation during data recovery. The write timestamp is a key information recorded in the metadata, which is used to identify the last time the corresponding block unit is written. Through the write timestamp, the system can effectively manage the version and order of the data, ensure that the latest data can be operated based on the latest data during fault recovery, and avoid errors caused by using outdated data.
[0034] Specifically, in the storage system of the solid state disk, all block units are divided into two parts, one part is used to save metadata, and the other part is used to save user data. The position of the block unit saving metadata is fixed. Exemplarily, the block units with setting numbers 0-99 can be used as the block units saving metadata. By fixing the block unit position storing metadata, the solid state disk only needs to traverse these specific block units when it fails, greatly reducing unnecessary workload and significantly improving scanning efficiency.
[0035] According to the obtained state flag of the solid state disk, it is further judged whether the solid state disk is faulty. After determining that the solid state disk is faulty, the solid state disk device is first set to read-only mode, and after completing the read-only mode setting, the system will traverse a plurality of block units stored in the solid state disk in turn. Exemplarily, the block units with numbers 0-99 for storing metadata are traversed, and the type information and corresponding write timestamp of each block unit are extracted.
[0036] S3, determining a plurality of target block units based on the target type and the type of the plurality of block units, and determining a target block unit list based on the write timestamp of the plurality of target block units.
[0037] Wherein, the target type refers to the type of block unit required in the solid state disk data recovery process, exemplarily, the target type is the type of block unit storing L2P metadata.
[0038] Specifically, a plurality of target block units meeting the target type (for example, the type of block unit storing L2P metadata) are selected from a plurality of block units stored in the solid state disk, and a target block unit list is formed based on the target block unit.
[0039] S4, based on the logical address of the metadata stored in the target block unit in the target block unit list, restoring the metadata into a first table, the first table being used to represent the mapping relationship between the logical address and the physical address.
[0040] The first table is a table recording the physical address and the logical address of the metadata, and is used to represent the mapping relationship between the logical address and the physical address. The logical address is a virtualized address space defined and used by the host operating system or the file system, and is expressed as a series of continuous and linear numbers. The physical address is a unique identifier of the actual storage location of the data on the NAND Flash, and accurately points to a certain block unit and a certain page.
[0041] Specifically, the target block unit list is traversed, and each page of each target block unit in the target block unit list is read, and the corresponding physical address is restored to the corresponding position in the first table according to the logical address of the metadata stored in the page. When all the pages of all the target block units are traversed, all the metadata can be restored to the first table.
[0042] When judging that the solid state disk is faulty, it is first set to a read-only mode to prevent further data damage. On this basis, the system traverses the block units in a pre-fixed position in the solid state disk for storing metadata, extracts the type and write time stamp of each block unit. Through accurate screening, the target block unit storing L2P metadata is obtained, and is sorted into a target block unit list. Finally, according to the logical address of the L2P metadata in the target block unit, the L2P metadata is restored to the corresponding position in the first table, so as to rebuild the mapping relationship between the logical address and the physical address, i.e. the L2P table.
[0043] Therefore, the use of the read-only mode effectively avoids data loss caused by misoperation, and ensures the integrity of the data; with the help of target block unit screening and list establishment, the system can quickly locate the key data and complete the recovery, significantly improving the accuracy of the recovery and the data security; the rebuilt mapping relationship lays a solid foundation for the subsequent data recovery process, and guarantees the reliability and efficiency of the entire data recovery process.
[0044] In some embodiments of the present application, the block unit includes at least one page, and the traversing of the plurality of block units to obtain the type and the write time stamp of the block unit includes: traversing the type and the metadata write time of the metadata stored in the first page of the block unit; determining the type of the block unit based on the type of the metadata, and determining the write time stamp based on the metadata write time.
[0045] Specifically, for each type of metadata, a separate block unit is allocated to specifically store this metadata, and the type of the block unit is one-to-one corresponding to the type of the metadata it stores, that is, the type of the block unit is determined by the type of the metadata it stores. For example, when the type of the metadata stored in the block unit is L2P metadata, the corresponding type of the block unit is L2P block unit. Among them, the write timestamp is an integer or a string used to mark the last write time of the data block, and its specific format depends on the design and needs of the storage system. The write timestamp is used to help the internal management system of the solid state disk track the usage status of the block unit to optimize data storage and allocation. The write time is recorded in the metadata, and the write time of the metadata in the first page of the block unit is taken as the write timestamp of the corresponding block unit.
[0046] Specifically, in the storage system of the solid state disk, each block unit includes one or more pages, and when traversing the block units stored in the solid state disk, the system reads the first page of each block unit in turn. By analyzing the metadata stored in the page, the metadata type and metadata write time are extracted, and according to the extracted metadata type, the type of the block unit is determined. For example, if the metadata type stored in the first page of the block unit is L2P metadata, it is determined that the type of the block unit is L2P metadata unit block. At the same time, the write time in the metadata is taken as the write timestamp of the block unit.
[0047] By efficiently analyzing the first page of each block unit, the system can complete the preliminary analysis of the entire solid state disk storage structure in a short time. This fast analysis capability enables the system to have a comprehensive understanding of the state of the storage device in the early stage of data recovery, including the distribution of key metadata and user data stored in the block unit. By analyzing the metadata type and write time of the first page of the block unit, the system can accurately identify the purpose of each block unit and the creation order of the data. This process not only provides key information for subsequent target block unit screening and data recovery, but also helps the system to plan the recovery process in advance, reasonably allocate resources, and reduce the recovery time as much as possible while ensuring the integrity and accuracy of data recovery, thereby improving the overall recovery efficiency. In addition, this mechanism also helps to optimize the daily management and maintenance of the solid state disk, such as garbage collection and wear leveling, further improving the performance and reliability of data storage of the system.
[0048] In some embodiments of the present application, determining the target block unit list based on the write timestamps of the plurality of target block units includes: sorting the write timestamps of the plurality of target block units in ascending order to obtain the target block unit list.
[0049] Specifically, in the use of the solid state disk, since each block unit is used sequentially, a new block unit is used only after the current block unit is full, therefore, when time sorting of the block units is needed, only the write time of the first page of each block unit needs to be referred to.
[0050] Specifically, first, the target block units are traversed one by one and put into the target block unit list one by one. At each time a new target block unit is added to the list, a sorting algorithm is used to sort the block units according to the write time stamp, to ensure that the block units in the list are arranged in ascending order of time stamp. The sorting algorithm can use bubble sort or other algorithms, and the specific implementation is not limited. This process continues until all target block units are scanned and added to the target block unit list, and finally a target block unit list in which all target block units are sorted in time stamp order is obtained.
[0051] By traversing the target block units one by one and using a sorting algorithm (such as bubble sort) to sort, the system can ensure that the block units in the list are arranged in time stamp order. This time stamp sorting mechanism not only improves the efficiency of data recovery, but also enhances the accuracy and reliability of the recovery process. The final target block unit list clearly reflects the write order of the data, providing strong support for subsequent data recovery operations, ensuring the integrity and consistency of data recovery.
[0052] In some embodiments of the present application, determining that the solid state disk has failed includes: in the case that the state flag bit of the solid state disk is a first flag bit, determining that the solid state disk has failed; in the case that the state flag bit of the solid state disk is a second flag bit, determining that the solid state disk has not failed.
[0053] The state flag bit of the solid state disk is a flag bit indicating whether the last power-off of the solid state disk was a normal power-off, and is used to indicate whether the state of the solid state disk is normal.
[0054] Specifically, when the solid state disk is powered on, the state flag bit is first checked. If the state flag bit is a first flag bit, exemplarily, the first flag bit can be set to 0, indicating that the solid state disk had some kind of failure before the last power-off, resulting in the power-off process not being completed, so that the state flag bit was not modified, and it is further determined that the solid state disk has failed.
[0055] If the state flag bit is a second flag bit, exemplarily, the second flag bit can be set to 1, it is determined that the solid state disk has not failed, indicating that the power-off process of the last power-off of the solid state disk was completed, and it is determined that the solid state disk has not failed.
[0056] In some embodiments, in the case where it is determined that the solid state disk has not failed, the state flag bit is changed to a second flag bit (e.g., 0), and the solid state disk continues to perform a normal mode power-on process. That is, in the power-on initialization process of the solid state disk, the main controller accesses the protected boot area in the NAND Flash, locates the secondary table according to the storage location of the valid metadata in the flash memory, loads the secondary table into the memory and verifies the integrity. Further, according to the physical storage location of each shard of the primary table recorded in the secondary table and the index of the secondary table, all shards of the primary table are loaded into the memory cache area in batches from the specified flash memory address. Finally, the shards of the primary table are reorganized according to the logical address sequence, and a complete logical-to-physical address mapping table, i.e., L2P table, is constructed in the memory. After the normal power-on process of the solid state disk is completed, the solid state disk enters a ready state, ready to respond to read / write requests from the host.
[0057] When the solid state disk is powered on, the state flag bit of the solid state disk is checked to identify whether the last power-off of the solid state disk was a normal power-off, and further to determine whether it has failed. Through this mechanism, it can quickly detect whether the solid state disk has failed, so that appropriate measures can be taken in a timely manner. This not only effectively protects the integrity of the data and avoids data loss or damage due to failure, but also significantly improves the reliability of the system and reduces business interruptions due to failure. In addition, through clear failure identification, the recovery process can be quickly started, the recovery efficiency is improved, the recovery time is shortened, and the stability and availability of the entire system are improved.
[0058] In some embodiments of the present application, the state flag bit of the solid state disk is pre-stored in one of the plurality of block units.
[0059] Specifically, the state flag bit of the solid state disk is pre-stored in a fixed block unit. For example, the state flag bit is fixedly stored in the first block unit, i.e., the block unit numbered 0.
[0060] When the solid state disk starts the power-on process, the state flag bit is first searched in the originally fixed block unit, and the last power-off process of the solid state disk is determined by checking the state flag bit, and further the failure of the solid state disk is determined. This provides a decision basis for the subsequent power-on process of the solid state disk, i.e., whether to enter the normal mode or the recovery mode.
[0061] The storage position of the fixed state flag bit first simplifies the search process of the system at power-on, can quickly locate the state flag bit, and thus quickly judges the last power-off state of the solid state disk to determine whether to enter the normal mode or the recovery mode subsequently. Secondly, the reliability and fault tolerance of the system are enhanced. Even if other block units are damaged, as long as the block unit where the state flag bit is located is intact, the system can accurately obtain the state information, avoiding misjudgment caused by the loss of the flag bit. Furthermore, this fixed storage position helps to improve the security and integrity protection of data. Since the state flag bit is crucial for fault recovery, the fixed position reduces the risk caused by position changes or storage errors. In addition, the fixed position setting facilitates hardware design and software management, reduces system complexity, improves overall performance and stability, and provides convenience for maintenance and fault diagnosis of the solid state disk.
[0062] In some embodiments of the present application, the fault recovery method of the solid state disk further comprises: marking the fault recovery state flag bit when the solid state disk is in the read-only mode.
[0063] The fault recovery state flag bit is used to control the solid state disk to execute the power-on process of the recovery mode.
[0064] Specifically, when the solid state disk is identified as having a fault, and its working mode is set to the read-only mode to prevent further data damage, the system marks the fault recovery state flag bit. Further, the solid state disk executes the power-on process of the recovery mode according to the fault recovery state flag bit.
[0065] Through this mechanism, the system can quickly respond when a fault occurs, and start the recovery process in time to minimize the risk of data loss. At the same time, this method also optimizes the switching between normal and recovery modes, improves the stability and availability of the system, and reduces the business interruption time caused by faults. In addition, it further enhances the flexibility of user data management, ensuring that the system can quickly recover to normal operation under the premise of data security. Not only solves the problems of low fault recovery efficiency and insufficient data security in the related art, but also provides a more stable and reliable storage solution for users.
[0066] In some embodiments of the present application, the fault recovery method of the solid state disk further comprises: in the case that the solid state disk receives a format command, exiting the read-only mode, clearing the mark of the fault recovery state flag bit, and setting the state flag bit of the solid state disk to a second flag bit.
[0067] The format instruction is an operation command initiated by a user, which is used to clear all user data and related metadata on the solid state disk.
[0068] Specifically, when the solid state disk executes the power-on process in the recovery mode, if the user wants to continue using the disk, a format command can be sent to the solid state disk. After receiving the format command, the solid state disk exits the read-only mode and thus restores the read-write authority of the solid state disk. Subsequently, the solid state disk clears the previously marked fault recovery state flag bit, and then performs a format operation, i.e., clears all user data and related metadata. After the format is completed, the solid state disk performs the normal power-off process, and after the normal power-off process is completed, the state flag bit is changed to the second flag bit (e.g., 1), i.e., the solid state disk enters the power-on process in the normal mode next time instead of entering the power-on process in the recovery mode.
[0069] When the solid state disk executes the power-on process in the recovery mode, the user-controllable format mechanism is introduced, which brings many significant advantages. This not only greatly enhances the user's control ability over the solid state disk, enabling the user to actively decide whether to clear the data and restore the normal operation mode according to the user's own needs, but also effectively avoids unnecessary repeated start of the recovery process by ensuring that the solid state disk after the format operation can smoothly switch to the normal state, thereby significantly improving the overall reliability and stability of the system and reducing the potential risks and performance loss caused by abnormal recovery process. At the same time, this mechanism completely eliminates the risk of data leakage in the process of clearing all user data and metadata, and provides a more secure and efficient storage device usage experience.
[0070] In some embodiments, when the solid state disk is in the power-on process in the recovery mode, if power-off occurs at this time, and the power-on process has not been completed, the state flag bit is still the first flag bit (e.g., 0), then the solid state disk will not restore any metadata, nor will it perform the power-off process in the normal mode, and the disk will still perform the power-on process in the recovery mode next time it is powered on.
[0071] In some embodiments of the present application, the fault recovery method of the solid state disk further comprises: in the case where the logical addresses of the metadata stored in the plurality of target block units are the same, taking the metadata corresponding to the maximum value in the write time stamp of the target block unit with the same logical address as the metadata of the corresponding target block unit.
[0072] Specifically, when the plurality of target block units are sorted and the target block unit list is constructed, if the metadata with the same logical address appears in the target block units, the write time stamps of these target block units are compared, and the metadata in the target block unit with the maximum write time stamp is selected as the final metadata of the corresponding target block unit.
[0073] Specifically, in the read-write process of the solid state disk, if the solid state disk fails, there may be cases such as incomplete write operation, mapping table update failure, error in data recovery process, and block damage. For example, sudden power failure may cause write interruption, new data cannot be completely written to the target location, and the block where the old data is located is not cleaned in time, resulting in multiple entries of the same logical address in the L2P mapping table. In addition, mapping table update failure may leave old entries, and if not handled correctly during data recovery, duplicate entries may be generated. These failures destroy the consistency of data and mapping relationship, causing logical address duplication. Therefore, in order to ensure the consistency and integrity of data, the latest metadata with the latest write timestamp needs to be selected during the recovery process. The latest metadata reflects the last valid write state of the data, which can ensure that the recovered data is consistent with the actual operation, avoiding errors or inconsistency problems caused by using outdated data.
[0074] In the data recovery process, if multiple metadata with the same logical address appear, the system selects the metadata with the latest timestamp by comparing the write timestamps of multiple target block units, thereby avoiding errors caused by recovering old data. Thus, it is ensured that the latest and most reliable mapping information is stored in the primary table, ensuring the consistency and correctness of the data, significantly improving the accuracy and reliability of data recovery. At the same time, the processing of redundant or outdated data is reduced, effectively improving the recovery efficiency and optimizing the system performance. In addition, by accurately recovering the latest mapping relationship, the stability of the system is enhanced, ensuring the correctness of data mapping, providing a solid guarantee for the normal operation and data management of the solid state disk.
[0075] In some embodiments of the present application, the fault recovery method of the solid state disk further comprises: in the case where the solid state disk does not fail, setting the state flag position of the solid state disk to the first flag bit; reading and recovering the secondary table and the primary table, and after the power-off of the solid state disk is completed, setting the state flag position of the solid state disk to the second flag bit.
[0076] Specifically, after the solid state disk is powered on, if it is checked that the state flag bit is the second flag bit (e.g. 1), it indicates that the power-off process was completed last time the disk was powered off, i.e. the solid state disk did not fail, at this time the state flag position of the solid state disk is set to the first flag bit (e.g. 0), and the power-on process of the normal mode is executed.
[0077] Further, the power-on process of the normal mode includes: obtaining the secondary table saved last time the power was turned off, sequentially recovering to the complete primary table according to the index entries of the secondary table, and finally reorganizing and splicing according to the logical address sequence according to the primary table, to construct a complete L2P mapping relationship of logical to physical address in the memory.
[0078] When the solid state disk receives the power-off instruction, it executes the power-off process. After all the power-off processes have been completed, the state flag bit is changed to the second flag bit (e.g., 1) in the last step of the power-off process.
[0079] In this way, the solid state disk ensures the accuracy of the state flag bit, protects the integrity of the data, and avoids unnecessary recovery operations triggered by flag bit errors. In addition, this method accurately determines the state of the solid state disk, reduces the execution of unnecessary recovery processes, optimizes system performance and improves startup efficiency, thereby significantly enhancing user experience. The solid state disk can quickly start in a normal state, reducing user waiting time and improving the overall reliability and usability of the system.
[0080] As a specific embodiment of the present application, with reference to Figure 2 The flow of the fault recovery method of the solid state disk of the present application can include:
[0081] S101, when the solid state disk is powered on, read the state flag bit;
[0082] S102, determine whether the SSD has failed according to the state flag bit, if yes, execute step S103; if no, execute step S107.
[0083] If the state flag bit is the second flag bit (e.g., 1), it indicates that the last power-off process has been completed, and the SSD is determined to be normal, and step S103 is executed. If the state flag bit is the first flag bit (e.g., 0), it indicates that the last power-off process has not been completed, and the SSD is determined to have failed, and step S107 is executed.
[0084] S103, read and restore the SSD secondary table.
[0085] S104, read and restore the SSD primary table according to the SSD secondary table.
[0086] S105, restore the L2P table according to the SSD primary table.
[0087] S106, set the state flag bit to the first flag bit (e.g., 0).
[0088] S107, set the working mode of the SSD to read-only mode and set the fault recovery state flag bit.
[0089] S108, traverse the SSD block unit to obtain the type and write timestamp of the block unit.
[0090] S109, create a list of block units of the target type (e.g., L2P metadata) and sort them by timestamp.
[0091] S110, traversing the metadata of all pages of the block unit list and establishing a first table.
[0092] S111, restoring the L2P table according to the first table.
[0093] S112, setting the state flag bit to a first flag bit (for example, 0).
[0094] Specifically, the state flag bit is read when the SSD is powered on, and whether the SSD is faulty is determined according to the value. If the state flag bit is 1, it indicates that the SSD is normal, and the secondary table, the first table, and finally the stored data are restored in sequence, and the state flag bit is set to 0. If the state flag bit is 0, it indicates that the SSD is faulty, and the recovery process is entered, the read-only mode is set, and the fault recovery state flag bit is marked, the block unit storing the metadata of the SSD is traversed to obtain the type and the timestamp, the block unit list of the L2P metadata is established and sorted according to the timestamp, the metadata of all pages of the list is traversed to establish the first table, the data is restored according to the mapping relationship between the logical address and the physical address in the first table, and the state flag bit is reset. When the power-on process in the recovery mode is executed, it is also necessary to determine whether a formatting instruction is received. If the formatting instruction sent by the user is received, the SSD exits the read-only mode, the fault recovery state flag bit is cleared, the SSD data is formatted, and the state flag bit is set to 1, so as to meet the use requirements of the user on the SSD.
[0095] The fault recovery method of the solid state disk provided in the application realizes fault detection and recovery through an automatic process, and ensures data safety and integrity. Specifically, when a fault occurs, the read-only mode is set and the state flag bit is marked, which effectively prevents further data damage and guarantees data consistency. At the same time, the formatting operation allows the user to actively clear the fault state, provides a flexible data management mode, and enhances user experience. In addition, through the management of the state flag bit and the fault recovery state flag bit, the system can smoothly switch between the normal and recovery modes, improve stability and reliability, reduce business interruption time, and improve system availability.
[0096] Through the description of the above implementation manner, those skilled in the art can clearly understand that the method according to the above embodiment can be realized by means of software and a necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better implementation manner.
[0097] Figure 3 The block schematic diagram of the electronic device provided in the embodiment of the application is shown.
[0098] The embodiment of the application also provides an electronic device, which specifically refers to Figure 3The electronic device 300 comprises a memory 310 for storing a computer program, and a processor 320 for executing the computer program to implement the steps of the aforementioned method for recovering from a failure of a solid state disk.
[0099] Those skilled in the art will further appreciate that the functions implemented by each of the examples described herein can be implemented in one or more electronic hardware and / or software modules. For example, the example steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware circuitry, in computer software stored on a computer readable medium, or in a combination of both. The term "software" should be given its broadest possible interpretation. The methods described herein can be implemented in software and / or hardware. The methods can be implemented using well-known computer processors and software implementation techniques. To clearly illustrate this interchangeability of hardware and software, various examples can be described generally in terms of their functionality without reference to the corresponding relationship between the hardware and software. Where specific hardware is described, it will be appreciated that software implementations are equivalent alternatives to, and can always be generated and used in place of, the described hardware. Similarly, generic references to software will be given in terms of their functionality without reference to specific software mechanisms unless otherwise specified. The particular software to be used is not limiting of the scope of the application. Rather, any suitable software that accomplishes the described functionality can be used. Those skilled in the art will recognize that the examples provided herein can be readily implemented in a computer system or other processing system using well-known computer processors and software implementation techniques.
[0100] The above provides a method for recovering from a failure of a solid state disk and an electronic device. The principles and implementation manners of the present application are described by applying specific examples. The above description of the examples is only used to help understand the method of the present application and its core idea. It should be noted that, for those skilled in the art, without departing from the principles of the present application, the present application can be improved and modified in several ways. These improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A method for failure recovery of a solid state drive, the method comprising: The method comprises: acquiring a state flag bit of the solid state disk; in a case where it is determined according to the state flag bit that the solid state disk has a fault, setting the solid state disk to a read-only mode, and traversing types of metadata and metadata writing times stored in a plurality of block unit front pages in a preset block unit number interval, wherein the block unit comprises at least one page; determining a type of the block unit based on the type of the metadata, and determining a writing time stamp based on the metadata writing time; determining a plurality of target block units based on a target type and the type of the plurality of block units, and sorting the writing time stamps of the plurality of target block units in ascending order to obtain a target block unit list, wherein in a case where the plurality of target block units store metadata of the same logical address, the metadata corresponding to the maximum value in the writing time stamps of the target block units of the same logical address are taken as the metadata of the corresponding target block units; based on the logical addresses of the metadata stored in the target block units in the target block unit list, restoring the metadata into a primary table, wherein the primary table is used to represent a mapping relationship between the logical address and the physical address.
2. The failure recovery method of a solid state drive according to claim 1, characterized by, determining that the solid state disk has a fault comprises: in a case where the state flag bit of the solid state disk is a first flag bit, determining that the solid state disk has a fault; in a case where the state flag bit of the solid state disk is a second flag bit, determining that the solid state disk does not have a fault.
3. The method of claim 2, wherein, The state flag bit of the solid state disk is pre-stored in one of the plurality of block units.
4. The method of claim 1, wherein, The method further comprises: in a case where the solid state disk is in the read-only mode, marking a fault recovery state flag bit.
5. The method of claim 4, wherein, The method further comprises: in a case where the solid state disk receives a formatting command, exiting the read-only mode, clearing the marking of the fault recovery state flag bit, and setting the state flag bit of the solid state disk to the second flag bit.
6. The method of claim 1, wherein, The method further comprises: in a case where the solid state disk does not have a fault, setting the state flag bit of the solid state disk to the first flag bit; reading and restoring a secondary table and a primary table, and after the solid state disk is powered off, setting the state flag bit of the solid state disk to the second flag bit.
7. An electronic device, comprising: comprise: a memory for storing a computer program; a processor for executing the computer program to implement the steps of the fault recovery method of the solid state disk according to any one of claims 1 to 6.
Citation Information
Patent Citations
Solid state disk (SSD) fault recovery method, SSD and system
CN116414616A
Data recovery method for encrypted ransomware
CN116501550A