A data recovery method, device, apparatus and medium
By scanning and restoring the mapping table of the solid-state drive, the problem of data loss caused by the inability to normally access the solid-state drive is solved, and data recovery and protection are achieved.
Patent Information
- Application Number
- CN202111612526.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2041-12-27
AI Technical Summary
Existing technologies cannot effectively recover data lost on solid-state drives due to inaccessibility, especially when the solid-state drive cannot be recognized, user data cannot be recovered.
By scanning all data blocks of the abnormal solid-state drive, the mapping table from the host logical address to the flash memory physical address is restored, and the mapping table is used to read data from the abnormal solid-state drive to achieve data recovery.
In the case of inability to access the solid-state drive normally, data recovery is achieved, avoiding complete loss of user data without damaging the source disk data.
Smart Images

Figure CN114281588B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data recovery technology, and in particular to a data recovery method, apparatus, device and medium. Background Art
[0002] Data recovery is the process of recovering lost data from all computer-related storage devices and restoring it to normal data. There are many reasons for data loss, including storage medium failure, software and hardware failure, abnormal power outage, crash, virus damage, hacker intrusion, human error, operating system failure, password loss, etc. Solid-state drive is an important storage device. If there is an abnormality in the solid-state drive, it will also lead to the loss of data stored in the solid-state drive. There are many existing solid-state drive data recovery methods, which are mainly aimed at two situations. One is to recover data lost due to virus infection, mistaken formatting, mistaken partition deletion, system reinstallation, abnormal power outage, logical error, sector damage, solid-state drive failure, etc. when the solid-state drive is intact; the other is to recover data when the solid-state drive is physically damaged, such as DRAM failure, DRAM welding failure, main control chip hardware failure, main control chip welding failure, NAND particle welding failure, etc.
[0003] Currently, existing data recovery tools are generally designed for situations where the SSD can be accessed normally. However, if the SSD encounters an abnormality during use that makes it inaccessible, such as a disk hang, some hangs can be recovered by powering on and off, but some hangs cannot be recovered even after powering on and off. This is also called "bricking," which means that the SSD cannot recognize the hard drive, resulting in user data loss. It can only be repaired by re-opening the card, but user data will also be completely lost. Although the SSD itself takes many reliability designs into consideration during the design process, most abnormal scenarios can be handled by firmware exception handling to ensure the normal use of the hard drive. However, when the SSD encounters an abnormality that makes it inaccessible, such as an unrecoverable hang, it means that the firmware in the disk can no longer be processed. How to recover data at this time is an urgent problem that needs to be solved. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a data recovery method, device, equipment and medium, which can realize data recovery of solid-state hard disk when the solid-state hard disk cannot be normally accessed. The specific scheme is as follows:
[0005] In a first aspect, the present application discloses a data recovery method, comprising:
[0006] Scan all data blocks of abnormal SSDs;
[0007] Recovering a first mapping table from host logical addresses to flash memory physical addresses corresponding to data in all the data blocks;
[0008] reading data from the abnormal solid state disk based on the first mapping table to obtain recovery data.
[0009] Optionally, the first mapping table of host logical addresses to flash memory physical addresses corresponding to data in all the data blocks comprises:
[0010] obtaining a second mapping table of flash memory physical addresses to host logical addresses corresponding to data in all the data blocks from a preset mapping table storage area of the abnormal solid state disk;
[0011] recovering the first mapping table of host logical addresses to flash memory physical addresses by using the second mapping table.
[0012] Optionally, if the preset mapping table storage area is damaged, the first mapping table of host logical addresses to flash memory physical addresses corresponding to data in all the data blocks comprises:
[0013] scanning each data page in all the data blocks to obtain metadata information stored in each data page;
[0014] recovering the first mapping table of host logical addresses to flash memory physical addresses corresponding to data in all the data blocks based on the metadata information.
[0015] Optionally, the second mapping table of flash memory physical addresses to host logical addresses corresponding to data in all the data blocks obtained from the preset mapping table storage area of the abnormal solid state disk comprises:
[0016] sorting sequence numbers of all the data blocks to obtain a sorting result; wherein the sequence number is a sequence number determined based on a data writing sequence;
[0017] obtaining the second mapping table of flash memory physical addresses to host logical addresses corresponding to data in all the data blocks from the preset mapping table storage area of the abnormal solid state disk based on the sorting result.
[0018] Optionally, before scanning all the data blocks of the abnormal solid state disk, the method further comprises:
[0019] setting the abnormal solid state disk to a read-only state.
[0020] Optionally, after setting the abnormal solid state disk to the read-only state, the method further comprises:
[0021] querying an encryption state of the abnormal solid state disk;
[0022] if the encryption state is encryption, decrypting the abnormal solid state disk.
[0023] Optionally, after reading data from the abnormal solid-state drive based on the first mapping table to obtain restored data, the method further includes:
[0024] The recovery data is copied to a new solid-state drive.
[0025] In a second aspect, the present application discloses a data recovery device, comprising:
[0026] Data block scanning module, used to scan all data blocks of abnormal solid-state drives;
[0027] A first mapping table recovery module, configured to recover a first mapping table from a host logical address to a flash memory physical address corresponding to all data in the data blocks;
[0028] A data recovery module is configured to read data from the abnormal solid-state drive based on the first mapping table to obtain recovered data.
[0029] In a third aspect, the present application discloses an electronic device, comprising:
[0030] Memory, used to store computer programs;
[0031] The processor is used to execute the computer program to implement the aforementioned data recovery method.
[0032] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program, which implements the aforementioned data recovery method when executed by a processor.
[0033] It can be seen that the present application first scans all data blocks of the abnormal solid-state drive, then recovers the first mapping table from the host logical address to the flash memory physical address corresponding to the data in all the data blocks, and finally reads the data from the abnormal solid-state drive based on the first mapping table to obtain the recovered data. In this way, when the abnormal solid-state drive cannot be accessed normally, the mapping table from the host logical address to the flash memory physical address is recovered, and the data is recovered using the mapping table, which can realize the data recovery of the solid-state drive when the solid-state drive cannot be accessed normally. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0035] Figure 1 A flow chart of a data recovery method disclosed in this application;
[0036] Figure 2 A flow chart of a specific data recovery method disclosed in this application;
[0037] Figure 3 This is a specific device connection diagram disclosed in this application;
[0038] Figure 4 This is a specific device connection diagram disclosed in this application;
[0039] Figure 5 This is a structural diagram of a data recovery device disclosed in this application;
[0040] Figure 6 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0041] The following will be combined with the 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 the embodiments. 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.
[0042] Currently, existing data recovery tools are generally designed for situations where the SSD can be accessed normally. However, if the SSD becomes inaccessible during use, such as a disk hang, some hangs can be recovered by powering on and off, while some hangs cannot be recovered even after powering on and off. This is also called bricking, which means that the SSD cannot recognize the hard drive, resulting in user data loss. It can only be repaired by re-opening the card, but in this case, the user data will also be completely lost. To this end, the present application provides a data recovery solution that can achieve data recovery of the SSD when the SSD cannot be accessed normally.
[0043] See also Figure 1 As shown, the embodiment of the present application discloses a data recovery method, including:
[0044] Step S11: Scan all data blocks of the abnormal solid state drive.
[0045] It should be noted that the SSD (i.e. Solid State Drive) is an important storage device, usually using semiconductor flash memory (NAND Flash) as the medium, and the main hardware components are master control, storage chip, interface (including SATA, PCIe, etc.), PCB (including power chip, resistor, capacitor, etc.), cache chip DRAM (optional). The solid state disk runs firmware (Firmware) internally, which is responsible for scheduling data read and write from the interface end to the medium end, as well as flash memory resource management, host address to flash memory physical location mapping and management, garbage collection, power failure recovery and other core internal algorithms. If the solid state disk is abnormal, the data stored in the solid state disk will also be lost.
[0046] In addition, the embodiment of the present application further comprises: setting the abnormal solid state disk to a read-only state before scanning all data blocks of the abnormal solid state disk.
[0047] Further, the encryption state of the abnormal solid state disk can be queried; if the encryption state is encrypted, the abnormal solid state disk is decrypted.
[0048] Step S12 recovers a first mapping table of host logical addresses to flash memory physical addresses corresponding to data in all the data blocks.
[0049] In a specific embodiment, the embodiment of the present application obtains a second mapping table of flash memory physical addresses to host logical addresses corresponding to data in all the data blocks from a preset mapping table storage area of the abnormal solid state disk; and recovers the first mapping table of host logical addresses to flash memory physical addresses by using the second mapping table. If the preset mapping table storage area is damaged, each data page in all the data blocks is scanned to obtain metadata information stored in each data page; and the first mapping table of host logical addresses to flash memory physical addresses corresponding to data in all the data blocks is recovered based on the metadata information.
[0050] In addition, in a specific embodiment, the embodiment of the present application can sort the serial numbers of all the data blocks to obtain a sorting result; wherein the serial number is a serial number determined based on data write order; and a second mapping table of flash memory physical addresses to host logical addresses corresponding to data in all the data blocks is obtained from a preset mapping table storage area of the abnormal solid state disk based on the sorting result.
[0051] It should be noted that in addition to storing user data, SSDs also contain a variety of metadata, primarily internal SSD management data. For example, the GHP (Global Host Page) manages reverse mapping entries, i.e., the mapping relationship between flash memory physical addresses and host logical addresses. The host logical address space is divided into 4k granularity units, and the 4k / 8 value recorded in the meta data of each page in the flash memory corresponds to the host logical address space location. For example, the mapping relationship between the host logical address and the flash memory physical address.
[0052] The internal storage media of a solid-state drive typically consists of multiple NAND Flash arrays. Each NAND Flash contains multiple blocks, and each block contains multiple pages. NAND Flash pages are divided into a data area and a spare area, storing user data and metadata, respectively. The metadata contains information such as the block's serial number (SN) and GHP. To improve concurrency, SSDs employ a multi-channel design, with each channel connected to multiple NAND Flash dies, each containing multiple blocks. Blocks with the same block number but belonging to different channels and dies are abstracted into a single large block, called a Super Block. The Super Block, which stores user data, is divided into two parts: a data area and an EOB area (which stores the preset mapping table). The data area is used to store user data, while the EOB area stores the initial mapping table from flash physical addresses to host logical addresses. The presence of the EOB area accelerates data recovery.
[0053] The data recovery solution provided by this application is based on the design of the EOB area and META data structure in the data block. By scanning the user data block, obtaining the SN of the data block, and sorting the SN from small to large, the newness and oldness of the data can be determined. The block with a larger SN indicates the newer data. Then, according to the newness and oldness of the data, the F2H (FlashTo Host, the mapping of the flash physical address to the host logical address, which is the reverse mapping of H2F) table in the EOB area is obtained in sequence, and the H2F (Host To Flash, the mapping table of the host logical address to the flash physical address) is quickly established through the F2H table. If the data in the EOB area is damaged, the META data is read from the Spare area of the Page by scanning each Page in the Block, and the H2F mapping table is constructed through the GHP in the META.
[0054] In the step of constructing the H2F mapping table through the GHP in the META, it is also necessary to sort the sequence numbers of all the data blocks according to the sorting result.
[0055] Step S13: Reading data from the abnormal solid-state drive based on the first mapping table to obtain restored data.
[0056] Furthermore, the recovery data is copied to a new solid-state hard drive.
[0057] In this way, data can be restored using a dual-disk method without damaging the source disk data.
[0058] For example, see Figure 2 As shown, an embodiment of the present application provides a specific data recovery method flow chart. The data recovery tool is deployed through the host, and the data recovery firmware is imported into the abnormal solid-state hard disk to be recovered through the data recovery tool. After the recovery is completed, the recovered data is copied to the new disk through the data migration copy tool. First, the solid-state hard disk enters the ROM (i.e., Read-Only Memory, read-only register) disk state. The ROM disk state refers to the disk entering the read-only state; then the data recovery firmware is loaded into the solid-state hard disk through the data recovery tool, and the firmware is started; then the data recovery process is entered, the disk system block data is scanned, the disk basic information (LLRM) used for data recovery is obtained, and the data recovery library (DRL) is initialized with LLRM. The DRL returns the table entry space size to the data recovery tool, which then requests memory from the host and provides it to the DRL for table entry recovery. The tool scans the user data blocks, obtains the SNs of the data blocks, sorts them, loads the F2H table based on the SN sorting, and recovers the H2F table. If the F2H table cannot be obtained, the tool scans each page in the user data block, obtains the GHP of the META Data in the page, and then rebuilds the H2F table. The tool reads the user data through the H2F table and copies the data to the new disk.
[0059] LLRM: Basic disk information for data recovery. DRL: Data Recovery Library. Different products organize metadata differently. This library hides the internal implementation of the disk from data recovery tools, achieving unified data recovery behavior. Both the data recovery tool and the data copy tool are deployed on the host's data recovery tool. In actual implementation, the two tools can be integrated into the same tool.
[0060] In addition, the data recovery firmware is loaded into the master controller of the disk to be recovered through the data recovery tool, and the data recovery firmware is not written to the disk flash. In the specific implementation process, data recovery needs to make the disk enter the ROM disk state. If the disk is in a state where the disk cannot be recognized, such as a hung disk, the disk to be recovered needs to short-circuit the FORCEROM PIN from the hung disk state to the ROM disk state. If the disk state can be scanned, the data recovery client tool can send the SOFTFORCEROM command to make the disk enter the ROM disk state. The device connection method is as follows Figure 3 If the host does not have two available USB ports, select Figure 4 The connection method is to use a hub cable to transfer.
[0061] That is, this application is based on the various user data blocks and metadata information in the solid-state hard drive. The data recovery tool is used on the host side to load the data recovery firmware into the abnormal solid-state hard drive for operation. Through the joint cooperation of the data recovery tool and the data recovery firmware, the disk is deeply rebuilt with the help of metadata information, and the mapping table entries from the host logical address to the flash memory physical address are restored, and the user data is found according to the mapping table entries. In order to prevent the data on the disk from being damaged again due to erroneous operations, the data on the disk is not destroyed during data recovery, and no erase operation is performed. The data recovery firmware is not written to the disk flash. After the data recovery is completed, the data needs to be copied to other disks, and the original abnormal disk needs to be re-activated before it can be used.
[0062] It can be seen that when the abnormal solid-state hard drive cannot be accessed normally, the present application restores the mapping table from the host logical address to the flash memory physical address, and uses the mapping table to perform data recovery, which can realize data recovery of the solid-state hard drive when the solid-state hard drive cannot be accessed normally.
[0063] See also Figure 5 As shown, the embodiment of the present application discloses a data recovery device, comprising:
[0064] A data block scanning module 11 is used to scan all data blocks of the abnormal solid state drive;
[0065] A first mapping table recovery module 12 is used to recover a first mapping table from a host logical address to a flash memory physical address corresponding to the data in all the data blocks;
[0066] The data recovery module 13 is configured to read data from the abnormal solid-state drive based on the first mapping table to obtain recovered data.
[0067] It can be seen that when the abnormal solid-state hard drive cannot be accessed normally, the present application restores the mapping table from the host logical address to the flash memory physical address, and uses the mapping table to perform data recovery, which can realize data recovery of the solid-state hard drive when the solid-state hard drive cannot be accessed normally.
[0068] The first mapping table recovery module 12 specifically includes:
[0069] A second mapping table acquisition submodule is configured to acquire, from a preset mapping table storage area of the abnormal solid state drive, a second mapping table from the flash memory physical address to the host logical address corresponding to the data in all the data blocks;
[0070] The first mapping table recovery submodule is used to recover the first mapping table from the host logical address to the flash memory physical address by using the second mapping table.
[0071] Furthermore, if the preset mapping table storage area is damaged, the first mapping table recovery module 12 is specifically used to scan each data page in all the data blocks to obtain the metadata information stored in each data page; and based on the metadata information, restore the first mapping table from the host logical address to the flash memory physical address corresponding to the data in all the data blocks.
[0072] The second mapping table acquisition submodule is specifically used to: sort the serial numbers of all the data blocks to obtain a sorting result; wherein the serial number is a serial number determined based on the data writing order; based on the sorting result, obtain a second mapping table from the flash memory physical address corresponding to the data in all the data blocks to the host logical address from the preset mapping table storage area of the abnormal solid-state hard drive.
[0073] Furthermore, the device further includes a read-only state setting module, which is used to set the abnormal solid-state hard disk to a read-only state before scanning all data blocks of the abnormal solid-state hard disk.
[0074] Furthermore, the device also includes a decryption module for querying the encryption status of the abnormal solid-state hard disk after setting the abnormal solid-state hard disk to a read-only state; if the encryption status is encrypted, decrypting the abnormal solid-state hard disk.
[0075] Furthermore, the device further comprises a data copy module, which is used to copy the restored data to a new solid-state hard disk.
[0076] See also Figure 6 As shown, an embodiment of the present application discloses an electronic device 20, including a processor 21 and a memory 22; wherein the memory 22 is used to store a computer program; the processor 21 is used to execute the computer program, and the data recovery method disclosed in the above embodiment.
[0077] For the specific process of the above data recovery method, please refer to the corresponding content disclosed in the above embodiments, which will not be repeated here.
[0078] Furthermore, the memory 22 as a carrier for resource storage may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the storage method may be temporary storage or permanent storage.
[0079] In addition, the electronic device 20 also includes a power supply 23, a communication interface 24, an input / output interface 25 and a communication bus 26; wherein the power supply 23 is used to provide an operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input / output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0080] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the data recovery method disclosed in the aforementioned embodiment.
[0081] For the specific process of the above data recovery method, please refer to the corresponding content disclosed in the above embodiments, which will not be repeated here.
[0082] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.
[0083] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0084] The above is a detailed introduction to a data recovery method, device, equipment and medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present application.
Claims
1. A data recovery method, characterized in that: include: Scan all data blocks of abnormal SSDs; Recovering a first mapping table from host logical addresses to flash memory physical addresses corresponding to data in all the data blocks; Reading data from the abnormal solid-state drive based on the first mapping table to obtain recovery data; The step of restoring the first mapping table from the host logical address to the flash memory physical address corresponding to the data in all the data blocks includes: Obtaining a second mapping table from a preset mapping table storage area of the abnormal solid state drive to a flash memory physical address corresponding to the data in all the data blocks to a host logical address; The first mapping table from host logical addresses to flash memory physical addresses is restored using the second mapping table.
2. The data recovery method according to claim 1, wherein: If the preset mapping table storage area is damaged, the first mapping table from the host logical address to the flash memory physical address corresponding to all the data in the data blocks is restored, including: Scan each data page in all the data blocks to obtain metadata information stored in each data page; A first mapping table from host logical addresses to flash memory physical addresses corresponding to data in all the data blocks is restored based on the metadata information.
3. The data recovery method according to claim 1, wherein: The step of obtaining a second mapping table from a preset mapping table storage area of the abnormal solid state drive to a host logical address corresponding to all the data blocks includes: Sorting the sequence numbers of all the data blocks to obtain a sorting result; wherein the sequence numbers are sequence numbers determined based on the order in which the data are written; Based on the sorting result, a second mapping table from the flash memory physical address to the host logical address corresponding to the data in all the data blocks is obtained from the preset mapping table storage area of the abnormal solid state drive.
4. The data recovery method according to claim 1, wherein: Before scanning all data blocks of the abnormal solid state drive, the method further includes: The abnormal solid-state hard disk is set to read-only state.
5. The data recovery method according to claim 4, characterized in that: After setting the abnormal solid-state hard disk to a read-only state, the method further includes: Querying the encryption status of the abnormal solid-state drive; If the encryption state is encrypted, the abnormal solid state hard disk is decrypted.
6. The data recovery method according to claim 1, wherein: After reading data from the abnormal solid-state drive based on the first mapping table to obtain restored data, the method further includes: The recovery data is copied to a new solid-state drive.
7. A data recovery device, characterized in that: include: Data block scanning module, used to scan all data blocks of abnormal solid-state drives; A first mapping table recovery module, configured to recover a first mapping table from a host logical address to a flash memory physical address corresponding to all data in the data blocks; a data recovery module, configured to read data from the abnormal solid-state drive based on the first mapping table to obtain recovered data; The first mapping table recovery module includes: A second mapping table acquisition submodule is configured to acquire, from a preset mapping table storage area of the abnormal solid state drive, a second mapping table from the flash memory physical address to the host logical address corresponding to the data in all the data blocks; The first mapping table recovery submodule is used to recover the first mapping table from the host logical address to the flash memory physical address by using the second mapping table.
8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the data recovery method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that Used to store a computer program, which, when executed by a processor, implements the data recovery method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Solid state disk, data recovery method thereof and terminal equipment
CN112988467A