Solid-state drive data recovery method, device, medium, and computer program product
By transferring write cache data to the preset storage space and reconstructing metadata when the solid-state drive fails, the problem of solid-state drive data loss is solved and the full data is effectively recovered.
Patent Information
- Application Number
- CN202511100893.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-07
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-08-07
AI Technical Summary
When a solid-state drive fails, the data and metadata in the write cache cannot be written to the non-volatile memory, resulting in data loss and affecting the upper-layer system's ability to recover services.
When a fault is detected, the data in the write cache is transferred to the preset storage space, and the metadata is reconstructed through the data recovery tool firmware, rewritten to the write cache, and combined with the data in the non-volatile memory to generate the full amount of metadata.
It achieves full data recovery in the event of a solid-state drive failure, avoids data loss, and improves data security and recovery efficiency.
Smart Images

Figure CN120610853B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data recovery technology, and in particular to a solid-state hard drive data recovery method, device, medium, and computer program product. Background Art
[0002] Solid-state drives (SSDs) typically write data received from the host into a write cache. When the total amount of data in the write cache reaches a preset upper limit, the data in the write cache is written to non-volatile memory (NAND). In addition, SSDs also write metadata about the data in a memory space. Typically, when the SSD is powered off, data in the write cache that does not reach the preset upper limit, as well as metadata in the SSD's memory space, needs to be written to the NAND. When the SSD is powered on again, the metadata needs to be read from the NAND and restored.
[0003] However, when an SSD fails before powering off, it cannot write data in the write cache that has not reached the preset limit, nor the metadata in the SSD's memory space, to the NAND. This results in the loss of data and metadata not written to the NAND, which in turn affects the recovery of the SSD's upper-layer systems. Therefore, a reliable solid-state drive recovery method is urgently needed to restore all data and metadata in the event of an SSD failure, thus avoiding data loss. Summary of the Invention
[0004] The present application provides a solid-state drive data recovery method, device, medium, and computer program product to at least solve the problem of data loss when an SSD fails in the related art.
[0005] This application provides a solid-state drive data recovery method, including:
[0006] When a fault is detected in the solid-state hard disk, first data in the write cache of the solid-state hard disk is transferred to a preset storage space;
[0007] When performing data recovery on the solid state drive, determining initial reconstruction metadata based on the second data written into the non-volatile memory of the solid state drive;
[0008] Rewriting the first data in the preset storage space into the write cache;
[0009] Obtaining a first logical address and a first serial number of first data in the write cache;
[0010] Target reconstruction metadata is generated based on the first logical address, the first sequence number, and the initial reconstruction metadata.
[0011] The present application provides a solid-state hard drive data recovery device, comprising:
[0012] A transfer module, configured to transfer the first data in the write cache of the solid-state drive to a preset storage space when a fault is detected in the solid-state drive;
[0013] a determination module, configured to determine initial reconstruction metadata according to second data written into the non-volatile memory of the solid-state drive when recovering data from the solid-state drive;
[0014] a rewriting module, configured to rewrite the first data in the preset storage space into the write cache;
[0015] An acquisition module, configured to acquire a first logical address and a first serial number of the first data in the write cache;
[0016] A generating module is configured to generate target reconstruction metadata based on the first logical address, the first serial number, and the initial reconstruction metadata.
[0017] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned solid-state hard drive data recovery methods when executing the computer program.
[0018] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned solid-state hard drive data recovery methods are implemented.
[0019] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned solid-state hard drive data recovery methods when executed by a processor.
[0020] Through the present application, when a solid-state drive fails, the data in the write cache is first written to the preset storage space. When the solid-state drive is restored, in addition to reconstructing the metadata of the data in the non-volatile memory, the data in the preset storage space is also rewritten to the write cache, and then the logical address and serial number of the data rewritten by the write cache are read, and combined with the metadata reconstructed based on the data in the non-volatile memory, the full amount of metadata is constructed. Therefore, the technical problem of data loss can be solved, and the technical effect of effectively recovering the full amount of data of the failed solid-state drive can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0022] Figure 1 A flowchart of a solid-state drive data recovery method provided in an embodiment of the present application;
[0023] Figure 2 A simplified structural diagram of a solid-state hard disk provided in an embodiment of the present application;
[0024] Figure 3 A schematic diagram of the structure of a write cache provided in an embodiment of the present application;
[0025] Figure 4 A schematic structural diagram of a solid-state hard drive data recovery device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0027] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0028] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0029] Because SSDs offer faster read and write speeds than traditional hard disk drives (HDDs), they are widely used in various fields, such as industrial production and finance. In extreme cases, multiple SSDs in a storage environment can fail and lose disks within a short period of time, potentially paralyzing the entire system and halting operations. If the SSD's upper-layer system is unable to recover operations through its own data recovery mechanisms, the SSD must perform data recovery. The more complete the SSD's data recovery, the more likely it is to successfully restore the upper-layer system.
[0030] SSDs typically use a write cache (i.e., contiguous storage space within the SSD) to store data. Specifically, the SSD receives write requests from the host and, according to certain rules, sequentially stores the host's data in the write cache. It then responds to the host, confirming the write request has been completed. When the amount of data in the write cache reaches a preset upper limit, the data in the write cache is transferred to the NAND. In practical applications, the write cache is typically divided into contiguous storage units based on the size of a physical page. Each storage unit is called a write cache buffer. In addition to data, SSDs also write metadata, such as the page table (Logical to Physical Table, L2P), or FTL mapping table, to a section of the write cache memory. When the SSD is powered off, the data in the write cache buffer that is not full and the metadata in the write cache memory must be transferred to the NAND. When the SSD is powered on again, the metadata must be read from the NAND and restored, allowing users to query the corresponding data in the NAND based on the restored metadata.
[0031] However, when an SSD fails, it cannot respond to commands from high-speed storage access protocols (such as NVMe) in the upper-layer system. As a result, the commands are not processed promptly and time out. The NVMe kernel driver then removes the failed SSD from the system. At this point, the data in the write cache buffer and the metadata in the write cache memory cannot be transferred to the NAND, resulting in data loss.
[0032] In the prior art, when an SSD fails, self-maintenance is prioritized, for example, by hot-swapping the failed drive or restarting the server to attempt repairs. However, if the drive is removed or the system loses power, the data and metadata in the write cache are lost. However, data recovery methods in the prior art can only recover data and metadata from NAND flash drives, not from the write cache, and thus fail to resolve the data loss issue.
[0033] An embodiment of the present application provides a solid-state hard drive data recovery method. The method is described in detail in conjunction with the execution process of the solid-state hard drive data recovery method (the technical terms involved must be explained).
[0034] Figure 1 A flow chart of a solid state drive data recovery method provided in an embodiment of the present application, which is applied to a solid state drive, specifically includes the following steps: Figure 1 The following steps are shown:
[0035] S110 : When a fault in the solid state drive is detected, transfer the first data in the write cache of the solid state drive to a preset storage space.
[0036] To ensure data in the write cache can be restored in the event of an SSD failure, the SSD periodically checks for failures during system operation. If an SSD failure prevents the write cache from being transferred to NAND, the previously written data in the write cache is transferred to a pre-set storage space, preventing data and metadata loss due to the inability to write to NAND.
[0037] Specifically, the data in the write cache includes data received from the host and metadata corresponding to the data, and the data received from the host is used as the first data.
[0038] The first data is data received from the host during the operation of the business system. Optionally, the first data includes but is not limited to user data, business data, and other types of data.
[0039] The preset storage space refers to a temporary storage area for the first data. Optionally, the preset storage space includes but is not limited to Nand and a read-only memory (ROM).
[0040] In this way, when the solid-state drive fails, the SSD will prioritize transferring the data and metadata in the write cache to the preset storage space for storage, avoiding the loss of data and metadata in the write cache due to the inability to write to NAND.
[0041] S120 . When recovering data from the solid state drive, determine initial reconstruction metadata based on the second data written into the non-volatile memory of the solid state drive.
[0042] In this embodiment, the SSD updates the data recovery tool firmware to the SSD through the SSD customization tool, and powers on and runs the data recovery firmware to start data recovery, and reconstructs metadata based on the second data written to the NAND to generate initial reconstruction metadata.
[0043] In order to understand the specific process of writing the second data into NAND, Figure 2 The simplified structural diagram of a solid-state drive (SSD) is shown below to explain the SSD's firmware system. The device mapper (DM) and loadable kernel module (LKM) constitute the SSD's firmware system. The DM exchanges read and write commands with the host through a hardware interface (HI). During the write process, the DM splits the write command into several write requests at a 4KB granularity and sends them to the LKM. The LKM receives the write command and applies for a write cache buffer. Upon successful application, it returns the write cache buffer address to the DM. After receiving the write cache buffer address, the DM uses the direct memory access (DMA) hardware unit to transfer the second data from the host memory to the write cache buffer in the SSD memory. The LKM then notifies the LKM that the data transfer is complete. The LKM is the software layer in the SSD, responsible for managing the second data in the write cache buffer and generating metadata based on the second data in the write cache buffer and writing it to the write cache memory. When the second data and its corresponding metadata in the write cache reach a preset upper limit, the LKM transfers the second data and its corresponding metadata from the write cache to the NAND.
[0044] Among them, the specific implementation method of S120 includes but is not limited to the following method: using the data recovery tool firmware, generating an initial reconstructed page table according to the physical address of the second data written into the non-volatile memory; and using the initial reconstructed page table as the initial reconstruction metadata.
[0045] Specifically, the second data written into the NAND respectively correspond to physical addresses, and the SSD reconstructs the page table based on the physical addresses through the data recovery tool firmware to obtain the initial reconstructed page table, thereby obtaining the initial reconstructed metadata.
[0046] The initially reconstructed page table may be an L2P table, also called an FTL mapping table.
[0047] S130: Rewrite the first data in the preset storage space into the write cache.
[0048] In this embodiment, before S130, the method also includes: setting the status of the solid-state hard disk to a read-only state through the data recovery tool firmware; the specific implementation method of S130 includes but is not limited to the following method: when the status of the solid-state hard disk is a read-only state, rewriting the first data in the preset storage space to the write cache through the data recovery tool firmware.
[0049] Specifically, when recovering data from a solid-state drive, the SSD can be set to a read-only state through the data recovery tool firmware. Then, after clearing the write cache buffer in the write cache through the data recovery tool firmware, the first data in the preset storage space is rewritten to the write cache, so as to temporarily store data in the preset storage space before data recovery, and restore the data in the preset storage space to the write cache when data is recovered.
[0050] In this way, the loss of the first data is avoided. Since the data recovery process is performed in the read-only mode of the SSD, the cache mechanism can be used more efficiently, and data security is also improved.
[0051] S140: Obtain a first logical address and a first sequence number of first data in the write cache.
[0052] It is understandable that in addition to restoring the first data to the write cache, the SSD also needs to restore the metadata reconstructed based on the second data to the write cache. The SSD then continues to use the data recovery tool firmware to scan the write cache to determine the first logical address and first serial number of the first data, so as to restore the metadata reconstructed based on the first data in the write cache based on the first logical address and the first serial number.
[0053] Among them, the write cache is pre-divided into multiple physical pages, and the physical pages are divided into multiple data frames according to preset bytes; then, the specific implementation method of S140 includes but is not limited to the following method: for any current physical page among the multiple physical pages, scan the current data frame in the current physical page through the data recovery tool firmware; if the first data is not scanned from the current data frame of the current physical page, continue to scan the next data frame of the current physical page until all data frames of the current physical page are scanned; for the next physical page among the multiple physical pages, repeat the step of scanning multiple data frames of the next physical page until all data frames of all physical pages are scanned, and obtain the first logical address and first serial number of the first data in the write cache.
[0054] The preset bytes may be 4 KB. A data frame may be understood as a 4 KB write cache buffer called a data frame, abbreviated as df.
[0055] To understand how write cache data is stored, see Figure 3 As shown in the structural diagram of the write cache, LKM will divide the write cache into several groups according to a certain logic. Generally, the write cache is first divided according to the physical page (page). For example, the write cache contains 32 physical pages, including physical page 0, physical page 1-physical page 30, and physical page 31. Each physical page is divided into 4 write cache buffers. A 4k-byte write cache buffer is a data frame. Each write cache buffer contains 4k bytes of data and 16 bytes of metadata. In order to accommodate more data in the same space, the cache buffer can store data based on triple-level cells (TLC). A TLC is a 3-layer physical page. A single-layer physical page contains 4 data frames, so a TLC page buffer contains a total of 12 data frame-sized write buffers. In addition, in order to enhance the data error correction capability, according to the data storage virtualization technology (RAID5 mechanism), for example, the stripe size is configured (31 + 1), that is, a write cache can contain 31 TLC page buffers for data and 1 TLC page buffer for verification data. Such a combination is called a super page buffer, forming a super page buffer. Figure 3 Write cache shown.
[0056] When the DM notifies the LKM that the first data has been written from the host to the write cache buffer, the LKM records the logical block addressing (LBA) and sequence number as metadata of the first data. The write cache buffer contains 4k bytes of the first data, and the metadata of the first data in the write cache memory includes the logical address and sequence number, which are recorded before data recovery.
[0057] It can be understood that when data is recovered, after the data in the preset storage space is restored to the write cache, the write cache assigns a logical address to the re-written first data, and the logical address is recorded as the first logical address. At the same time, the serial number of the first data is also re-recorded as the first serial number to update the initial reconstructed metadata based on the first logical address and the first serial number.
[0058] In this way, when the SSD performs data recovery, in addition to recovering the first data in the write cache, it will also re-record the first logical address and first serial number of the first data to assist in fully recovering the metadata corresponding to the first data based on the first logical address and first serial number.
[0059] S150: Generate target reconstruction metadata based on the first logical address, the first sequence number, and the initial reconstruction metadata.
[0060] In this embodiment, the SSD performs a full metadata recovery process, i.e., reconstructs metadata, based on the first logical address, the first serial number, and the initial reconstruction metadata through the data recovery tool firmware to ensure full recovery of the data and metadata in the write cache.
[0061] Furthermore, after S150, the method further includes: using the data recovery tool firmware, writing the first data and the target reconstruction metadata into a solid-state hard disk that does not have any fault information.
[0062] Specifically, after the SSD recovers the data and metadata in the write cache, it only needs to insert another normal hard disk of the same model into the same server device, and use the DD command to read all the data in the read-only disk and restore it to the normal hard disk.
[0063] In this way, the entire data recovery process is completed, and the upper-level business system can be restored using the normal SSD that has backed up the data.
[0064] The solid-state drive data recovery method provided by the present application first writes the data in the write cache to the preset storage space when the solid-state drive fails. When recovering the data on the solid-state drive, in addition to reconstructing the metadata of the data in the non-volatile memory, the data in the preset storage space is also rewritten to the write cache, and then the logical address and serial number of the data rewritten by the write cache are read. The metadata reconstructed based on the data in the non-volatile memory are combined to construct the full amount of metadata. Therefore, the technical problem of data loss can be solved, and the technical effect of effectively recovering the full amount of data of the failed solid-state drive can be achieved.
[0065] In another embodiment of the present application, a specific implementation method of S110 is explained in detail.
[0066] In this embodiment, the solid-state drive includes multiple firmware cores, and the firmware cores are configured with a fault detection timer; then, before S110, the method also includes the following steps: S101, for any current firmware core among the multiple firmware cores of the solid-state drive, periodically sending a detection request to other firmware cores through the fault detection timer; S102, through the current firmware core, receiving the detection results fed back by other firmware cores based on the detection request; S103, through the current firmware core, determining whether the solid-state drive has a fault based on the number of detection requests sent and the number of detection results received.
[0067] Among them, the specific implementation method of S102 includes but is not limited to the following method: through the current firmware core, determine whether the number of detection requests sent and the number of detection results received are the same; if the number of detection requests sent and the number of detection results received are not the same, then through the current firmware core after a preset time, re-execute the steps of sending detection requests and receiving detection results; through the current firmware core, determine whether the number of resent detection requests is the same as the number of re-received detection results; if the number of resent detection requests is different from the number of re-received detection results, it is determined that there is a fault in the solid-state hard drive.
[0068] Specifically, in order to ensure that the write cache data can be transferred to the preset storage space of the SSD when a failure occurs in the SSD, each firmware core inside the SSD starts a fault detection timer and periodically (for example, every 2 minutes) sends a request to all other firmware cores to check normal operation. Under normal circumstances, when other firmware cores receive the request to check normal operation, they will reply to the requester that the operation is normal. When a firmware core fails (such as a core crash), it cannot respond normally to the request to check normal operation and cannot reply the inspection results to the requester. Then, the current firmware core can count whether the number of requests issued and the number of inspection results received are consistent. If they are consistent, it means that the SSD is operating normally as a whole and there is no need to transfer the write cache data. If they are inconsistent, wait for 10 seconds and then recheck. If they are still inconsistent, it is determined that the solid-state drive has a fault.
[0069] For the convenience of storage and recovery, before the first data stored in the write cache and its corresponding metadata are transferred to the preset storage space, the data in the preset storage space is erased in advance by using the data recovery tool firmware.
[0070] In this embodiment, after executing S103, the method also includes the following steps: when it is determined that there is a fault in the solid-state hard drive, the fault detection result is written into a preset result storage area of the solid-state hard drive through the current firmware core; through the current firmware core, whether the result storage areas of other firmware cores have written the fault detection result; then, the first data in the write cache of the solid-state hard drive is transferred to the preset storage space, including: if the fault detection result is written into the result storage areas of other firmware cores, the first data in the write cache is transferred to the preset storage space through the current firmware core.
[0071] Specifically, if there is a fault in the solid-state drive, the current firmware core of the SSD will update the inspection results to the preset result storage area of the SSD memory by locking it, and release the lock after the update is completed. Then, the current firmware core of the SSD reads the result storage areas of other firmware cores to see if the fault detection results are written; if so, the current firmware core is used as the last firmware core to update the inspection results, and checks whether all other faulty cores have updated the results. If the number of firmware cores with updated results and the firmware core number are consistent with the inspection results corresponding to the last firmware core to update the inspection results, then the last firmware core directly transfers the first data in the write cache to the preset storage space.
[0072] In this way, during business operation, SSD failures can be detected in a timely manner through multiple firmware cores of the SSD, and the failure detection results can be written into the preset result storage area of the solid-state drive. The firmware core that writes the first data in the preset storage space can be accurately determined to ensure that the write cache data can be transferred to the preset storage space of the SSD when the SSD fails, thereby avoiding the loss of write cache data.
[0073] In another embodiment of the present application, a specific implementation method of S150 is explained in detail.
[0074] In this embodiment, the initial reconstruction metadata is the initial reconstruction page table; therefore, the specific implementation method of S150 includes but is not limited to the following method:
[0075] S1501: Using the data recovery tool firmware, read the initially reconstructed page table according to the first logical address;
[0076] S1502: Determine whether the initially reconstructed page table has a page table entry corresponding to the first logical address, where the page table entry records a conversion relationship between a logical address of the write cache and a physical address of the non-volatile memory;
[0077] S1503: If a page table entry exists in the initially reconstructed page table, determine, by the data recovery tool firmware, whether a second logical address and a second serial number of the second data are read from the non-volatile memory;
[0078] S1504: If the second logical address and the second serial number are read, generate target reconstruction metadata according to the first serial number, the second serial number, the page table entry, and the initially reconstructed page table through the data recovery tool firmware.
[0079] After S1502 , the method further includes: if the initially reconstructed page table does not have a page table entry, updating the initially reconstructed page table according to the page table entry by using the data recovery tool firmware to obtain target reconstruction metadata.
[0080] After S1503 , the method further includes: if the second logical address and the second serial number are not read, updating the initially reconstructed page table according to the page table entry through the data recovery tool firmware to obtain target reconstruction metadata.
[0081] Among them, the specific implementation method of S1504 includes but is not limited to the following methods: judging whether the first serial number is greater than the second serial number; if the first serial number is greater than the second serial number, then through the data recovery tool firmware, updating the initial reconstructed page table according to the page table entry to obtain the target reconstruction metadata; if the first serial number is less than or equal to the second serial number, then through the data recovery tool firmware, using the initial reconstructed page table as the target reconstruction metadata.
[0082] In this embodiment, the first logical address is recorded as LBA1, the second logical address is recorded as LBA2, the first serial number is recorded as SeqNum_A, the second serial number is recorded as SeqNum_B, the initially reconstructed page table is recorded as the FTL mapping table, the FTLentry corresponding to LBA1 is recorded as the page table entry corresponding to the first logical address, and the target reconstruction metadata is recorded as cache index.
[0083] Specifically, the SSD reads the FTL mapping table according to LBA1 through the data recovery tool firmware. If the FTL entry is empty, the data recovery tool firmware updates the FTL mapping table according to the FTL entry corresponding to LBA1 to obtain the cache index, that is, updates the FTL entry corresponding to the LBA to the cache index.
[0084] In other cases, if the FTL mapping table contains an FTL entry corresponding to LBA1, that is, the FTL entry corresponding to LBA1 is a NAND address, the data recovery tool firmware determines whether LBA2 and SeqNum_B are read from the NAND; if LBA2 and SeqNum_B are not read from the NAND, the data recovery tool firmware updates the FTL mapping table according to the FTL entry corresponding to LBA1 to obtain the cache index, that is, updates the FTL entry corresponding to the LBA to the cache index; if LBA2 and SeqNum_B are read from the NAND, determines whether SeqNum_A is greater than SeqNum_B; if SeqNum_A is greater than SeqNum_B, the data recovery tool firmware updates the FTL mapping table according to the FTL entry corresponding to LBA1 to obtain the cache index, that is, updates the FTL entry corresponding to the LBA to the cache index; if SeqNum_A is less than or equal to SeqNum_B, the data recovery tool firmware uses the FTL mapping table as the cache index.
[0085] In this way, the data recovery tool firmware scans cache data and updates the FTL mapping table to ensure that not only the write cache data can be fully recovered, but also the metadata of the write cache data can be fully recovered. This truly achieves the effect of complete recovery without loss as long as the data is written to the disk, improving the overall system recovery capability.
[0086] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0087] An embodiment of the present application also provides a solid-state hard drive data recovery device, and the number of simple virtual device claims does not exceed one (except in special circumstances). The omitted virtual device claims should be described in detail in the specification and correspond one-to-one with the method claims.
[0088] Based on the above embodiments, Figure 4 This is a schematic diagram of the structure of a solid-state drive data recovery device provided in an embodiment of the present application. The solid-state drive data recovery device 400 includes a transfer module 401, a determination module 402, a rewrite module 403, an acquisition module 404, and a generation module 405, wherein:
[0089] The transfer module 401 is configured to transfer the first data in the write cache of the solid-state drive to a preset storage space when a fault is detected in the solid-state drive;
[0090] A determination module 402 is configured to determine initial reconstruction metadata based on second data written into the non-volatile memory of the solid-state drive when recovering data from the solid-state drive;
[0091] A rewriting module 403, configured to rewrite the first data in the preset storage space into the write cache;
[0092] An acquisition module 404 is configured to acquire a first logical address and a first sequence number of the first data in the write cache;
[0093] The generating module 405 is configured to generate target reconstruction metadata based on the first logical address, the first serial number, and the initial reconstruction metadata.
[0094] In some embodiments of the present disclosure, the solid-state drive includes a plurality of firmware cores, and the firmware cores are configured with a fault detection timer;
[0095] The device also includes:
[0096] a detection request sending module, configured to periodically send a detection request to any current firmware core among the multiple firmware cores of the solid-state drive through the fault detection timer to the other firmware cores;
[0097] A detection result receiving module, configured to receive, through the current firmware core, detection results fed back by other firmware cores based on the detection request;
[0098] A fault determination module is used to determine whether the solid-state drive has a fault based on the number of detection requests sent and the number of detection results received through the current firmware core.
[0099] In some embodiments of the present disclosure, the fault determination module is specifically configured to:
[0100] Determining, by the current firmware core, whether the number of sent detection requests and the number of received detection results are the same;
[0101] If the number of detection requests sent and the number of detection results received are different, re-execute the steps of sending detection requests and receiving detection results by the current firmware core after a preset time period;
[0102] Determining, by the current firmware core, whether the number of resent detection requests is the same as the number of re-received detection results;
[0103] If the number of the resent detection requests is different from the number of the re-received detection results, it is determined that the solid state drive has a fault.
[0104] In some embodiments of the present disclosure, the device further includes:
[0105] A first writing module is configured to write a fault detection result into a preset result storage area of the solid-state drive through the current firmware core when it is determined that the solid-state drive has a fault;
[0106] A reading module, configured to read, through the current firmware core, whether the result storage area of other firmware cores has been written with the fault detection result;
[0107] The transfer module 401 is specifically used for:
[0108] If the result storage areas of the other firmware cores are all written with the fault detection results, the first data in the write cache is transferred to the preset storage space through the current firmware core.
[0109] In some embodiments of the present disclosure, the determination module 402 is specifically configured to:
[0110] generating, by the data recovery tool firmware, an initial reconstructed page table according to the physical address of the second data written into the non-volatile memory;
[0111] The initially reconstructed page table is used as the initial reconstruction metadata.
[0112] In some embodiments of the present disclosure, the device further includes:
[0113] The state setting module is used to set the state of the solid-state drive to a read-only state through the data recovery tool firmware; the rewrite module 403 is specifically used to:
[0114] When the state of the solid state drive is in a read-only state, the first data in the preset storage space is rewritten into the write cache through the data recovery tool firmware.
[0115] In some embodiments of the present disclosure, the write buffer is pre-divided into multiple physical pages, and the physical pages are divided into multiple data frames according to preset bytes; the acquisition module 404 is specifically configured to:
[0116] For any current physical page among the multiple physical pages, scanning a current data frame in the current physical page by the data recovery tool firmware;
[0117] If the first data is not scanned from the current data frame of the current physical page, continue scanning the next data frame of the current physical page until all data frames of the current physical page are scanned;
[0118] For the next physical page among the multiple physical pages, the step of scanning multiple data frames of the next physical page is repeatedly performed until all data frames of all physical pages are scanned, and the first logical address and the first serial number of the first data in the write cache are obtained.
[0119] In some embodiments of the present disclosure, the initial reconstruction metadata is an initially reconstructed page table; the generation module 405 includes:
[0120] a reading unit, configured to read the initially reconstructed page table according to the first logical address through the data recovery tool firmware;
[0121] a first determining unit, configured to determine whether the initially reconstructed page table has a page table entry corresponding to a first logical address, wherein the page table entry records a conversion relationship between a logical address of the write cache and a physical address of the non-volatile memory;
[0122] a second determining unit, configured to determine, by the data recovery tool firmware, whether a second logical address and a second serial number of the second data are read from the non-volatile memory if the page table entry exists in the initially reconstructed page table;
[0123] The first generating unit is configured to generate the target reconstruction metadata according to the first serial number, the second serial number, the page table entry, and the initially reconstructed page table through the data recovery tool firmware if the second logical address and the second serial number are read.
[0124] In some embodiments of the present disclosure, the generating module 405 further includes:
[0125] The second generating unit is configured to update the initially reconstructed page table according to the page table entry by using the data recovery tool firmware to obtain the target reconstruction metadata if the initially reconstructed page table does not have the page table entry.
[0126] In some embodiments of the present disclosure, the generating module 405 further includes:
[0127] The third generating unit is configured to update the initially reconstructed page table according to the page table entry through the data recovery tool firmware to obtain the target reconstruction metadata if the second logical address and the second serial number are not read.
[0128] In some embodiments of the present disclosure, the first generating unit is specifically configured to:
[0129] Determining whether the first serial number is greater than the second serial number;
[0130] If the first sequence number is greater than the second sequence number, updating the initially reconstructed page table according to the page table entry by the data recovery tool firmware to obtain the target reconstruction metadata;
[0131] If the first serial number is less than or equal to the second serial number, the initially reconstructed page table is used as the target reconstruction metadata through the data recovery tool firmware.
[0132] In some embodiments of the present disclosure, the device further includes:
[0133] The second writing module is used to write the first data and the target reconstruction metadata into a solid-state hard disk without any fault information through the data recovery tool firmware.
[0134] For the description of the features in the embodiments corresponding to the solid state drive data recovery device, reference can be made to the relevant description of the embodiments corresponding to the solid state drive data recovery method, which will not be repeated here.
[0135] An embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps of any of the above-mentioned solid-state hard drive data recovery method embodiments.
[0136] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned solid-state hard drive data recovery method embodiments when run.
[0137] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0138] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned solid-state hard drive data recovery method embodiments are implemented.
[0139] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of any of the above-mentioned solid-state hard drive data recovery method embodiments.
[0140] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0141] The above is a detailed introduction to the solid-state hard drive data recovery method provided by this application. This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above examples is only intended to help understand the method and core concept of this application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
Claims
1. A method for recovering data from a solid-state drive, characterized in that: include: When a fault is detected in the solid-state hard disk, first data in the write cache of the solid-state hard disk is transferred to a preset storage space; When performing data recovery on the solid state drive, determining initial reconstruction metadata based on the second data written into the non-volatile memory of the solid state drive; Rewriting the first data in the preset storage space into the write cache; Obtaining a first logical address and a first serial number of first data in the write cache; generating target reconstruction metadata based on the first logical address, the first sequence number, and the initial reconstruction metadata; The determining of the initial reconstruction metadata according to the second data written into the non-volatile memory of the solid state drive includes: generating, by the data recovery tool firmware, an initial reconstructed page table according to the physical address of the second data written into the non-volatile memory; Using the initially reconstructed page table as the initial reconstruction metadata; The generating target reconstruction metadata based on the first logical address, the first sequence number, and the initial reconstruction metadata includes: Reading the initially reconstructed page table according to the first logical address using data recovery tool firmware; Determining whether the initially reconstructed page table has a page table entry corresponding to the first logical address, wherein the page table entry records a conversion relationship between the logical address of the write cache and the physical address of the non-volatile memory; If the page table entry exists in the initially reconstructed page table, determining, by the data recovery tool firmware, whether the second logical address and the second serial number of the second data are read from the non-volatile memory; If the second logical address and the second serial number are read, the target reconstruction metadata is generated by the data recovery tool firmware according to the first serial number, the second serial number, the page table entry and the initially reconstructed page table.
2. The solid state drive data recovery method according to claim 1, wherein: The solid-state drive includes a plurality of firmware cores, and each firmware core is configured with a fault detection timer; Before transferring the first data in the write cache of the solid state drive to a preset storage space, the method further includes: For any current firmware core among the multiple firmware cores of the solid-state drive, periodically sending a detection request to other firmware cores through the fault detection timer; receiving, through the current firmware core, detection results fed back by other firmware cores based on the detection request; Whether the solid-state drive is faulty is determined by the current firmware core according to the number of detection requests sent and the number of detection results received.
3. The solid state drive data recovery method according to claim 2, wherein: The determining, by the current firmware core, whether the solid-state drive has a fault according to the number of detection requests sent and the number of detection results received includes: Determining, by the current firmware core, whether the number of sent detection requests and the number of received detection results are the same; If the number of detection requests sent and the number of detection results received are different, re-execute the steps of sending detection requests and receiving detection results by the current firmware core after a preset time period; Determining, by the current firmware core, whether the number of resent detection requests is the same as the number of re-received detection results; If the number of the resent detection requests is different from the number of the re-received detection results, it is determined that the solid state drive has a fault.
4. The solid state drive data recovery method according to claim 2, wherein: Also includes: When it is determined that the solid state drive has a fault, the fault detection result is written into a preset result storage area of the solid state drive through the current firmware core; Reading, through the current firmware core, whether the result storage area of other firmware cores has been written with the fault detection result; The transferring the first data in the write cache of the solid state drive to a preset storage space includes: If the result storage areas of the other firmware cores are all written with the fault detection results, the first data in the write cache is transferred to the preset storage space through the current firmware core.
5. The solid state drive data recovery method according to claim 1, wherein: After determining the initial reconstruction metadata based on the second data written into the non-volatile memory of the solid state drive, the method further includes: Setting the state of the solid-state drive to a read-only state through a data recovery tool firmware; The step of rewriting the first data in the preset storage space to the write cache includes: When the state of the solid state drive is in a read-only state, the first data in the preset storage space is rewritten into the write cache through the data recovery tool firmware.
6. The solid state drive data recovery method according to claim 1, wherein: The write buffer is pre-divided into a plurality of physical pages, and the physical page is divided into a plurality of data frames according to preset bytes; The obtaining of the first logical address and the first serial number of the first data in the write cache includes: For any current physical page among the multiple physical pages, scanning a current data frame in the current physical page by using the data recovery tool firmware; If the first data is not scanned from the current data frame of the current physical page, continue scanning the next data frame of the current physical page until all data frames of the current physical page are scanned; For the next physical page among the multiple physical pages, the step of scanning multiple data frames of the next physical page is repeatedly performed until all data frames of all physical pages are scanned, and the first logical address and the first serial number of the first data in the write cache are obtained.
7. The solid state drive data recovery method according to claim 1, wherein: Also includes: If the page table entry does not exist in the initially reconstructed page table, the data recovery tool firmware updates the initially reconstructed page table according to the page table entry to obtain the target reconstruction metadata.
8. The solid state drive data recovery method according to claim 1, wherein: Also includes: If the second logical address and the second serial number are not read, the data recovery tool firmware updates the initially reconstructed page table according to the page table entry to obtain the target reconstruction metadata.
9. The solid state drive data recovery method according to claim 1, wherein: The step of generating the target reconstruction metadata by the data recovery tool firmware according to the first serial number, the second serial number, the page table entry, and the initially reconstructed page table includes: Determining whether the first serial number is greater than the second serial number; If the first sequence number is greater than the second sequence number, updating the initially reconstructed page table according to the page table entry by the data recovery tool firmware to obtain the target reconstruction metadata; If the first serial number is less than or equal to the second serial number, the initially reconstructed page table is used as the target reconstruction metadata through the data recovery tool firmware.
10. The solid state drive data recovery method according to claim 1, wherein: Also includes: The first data and the target reconstruction metadata are written into a solid-state hard disk without any fault information through data recovery tool firmware.
11. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the solid state drive data recovery method according to any one of claims 1 to 10 when executing the computer program.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the solid-state hard disk data recovery method according to any one of claims 1 to 10 are implemented.
13. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the solid state drive data recovery method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Data recovery method and system for fault storage device and related device
CN111813604A
Solid state disk data recovery method, terminal device, electronic device and storage medium
CN118152181A