Data recovery method, data recovery device, and computer-readable storage medium
By using a data recovery method that reads and writes logical addresses into SSD engineering mode, the cumbersome data recovery process and sensitive data leakage issues when SSDs malfunction can be resolved, enabling autonomous and secure data recovery.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHONGSHAN JIANGBOLONG ELECTRONICS CO LTD
- Filing Date
- 2021-11-01
- Publication Date
- 2026-05-05
AI Technical Summary
In existing technologies, when an SSD fails to function properly, data recovery methods are cumbersome, time-consuming, and carry the risk of leaking critical and sensitive information.
By establishing a communication connection with the storage device, entering engineering mode, reading the stored data and obtaining the logical address, writing the stored data to the second storage device, and using data recovery firmware to overwrite the original firmware, the autonomy and security of data recovery are ensured.
It achieves autonomous, safe, and reliable data recovery, avoiding long and cumbersome return-to-factory recovery processes and sensitive data leaks, thus ensuring data integrity.
Smart Images

Figure CN116069552B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data recovery method, a data recovery device, and a computer-readable storage medium. Background Technology
[0002] Currently, due to the immaturity of firmware technology in storage devices, poor quality of NAND (NAND flash memory) chips, firmware boot failure, or abnormal operation of the main controller, it is inevitable that SSDs (Solid State Disks) will sometimes malfunction.
[0003] Manufacturers typically opt to return defective SSDs to customers within the limits allowed by the Return Material Authorization (RMA) process, but this often results in the loss of the customer's original data. Alternatively, they may send the defective SSD back to the manufacturer for data recovery, but this method is not only cumbersome and time-consuming but also raises data confidentiality concerns. Critical and sensitive data within the SSD may be leaked during the recovery process, posing a significant risk. Summary of the Invention
[0004] The main technical problem addressed by this application is to provide a data recovery method, a data recovery device, and a computer-readable storage medium, in order to solve the problems that existing data recovery methods are cumbersome, time-consuming, and pose a significant risk of leakage of critical and sensitive information.
[0005] To address the aforementioned issues, a first aspect of this application provides a data recovery and write method for a storage device, comprising: establishing a communication connection with a first storage device; reading stored data from the first storage device in response to the first storage device operating in engineering mode; obtaining the logical address of the stored data in response to the stored data being logical data; and writing the stored data to a second storage device based on the logical address.
[0006] The step of reading the stored data of the first storage device includes: sending data recovery firmware to the first storage device to enable the first storage device to run the data recovery firmware; and sending a data read command to the first storage device running the data recovery firmware to read the stored data.
[0007] The steps, after reading the stored data of the first storage device in response to the first storage device operating in engineering mode and before obtaining the logical address and write order of the stored data in response to the stored data being logical data, include: reading the metadata of the stored data; and determining whether the stored data is logical data based on the data attributes of the stored data corresponding to the record in the metadata.
[0008] The step of obtaining the logical address of the stored data includes: obtaining the logical address of the stored data of the corresponding record in the metadata.
[0009] The step of writing storage data to the second storage device based on the logical address includes: writing the storage data to the storage location in the second storage device corresponding to the logical address.
[0010] The step of writing storage data to the second storage device based on a logical address includes: obtaining the writing order of the storage data; and writing the last data written among the storage data with the same logical address that has been written multiple times to the first storage device to the storage location corresponding to the logical address in the second storage device according to the writing order.
[0011] The step of writing storage data to the second storage device based on a logical address includes: writing storage data to the corresponding offset position of the set image file according to the logical address; and storing the set image file to the second storage device.
[0012] The step of writing the stored data to the corresponding offset position of the set image file according to the logical address includes: obtaining the writing order of the stored data; and writing the last data written among the stored data with the same logical address that has been written multiple times to the first storage device to the offset position corresponding to the logical address in the set image file according to the writing order.
[0013] The step of establishing a communication connection with the first storage device and the step of reading the stored data of the first storage device in response to the first storage device running in engineering mode further includes: obtaining characteristic parameters of the first storage device; determining whether the first storage device is in a preset support list based on the characteristic parameters; and the step of reading the stored data of the first storage device in response to the first storage device running in engineering mode, which includes: reading the stored data in the first storage device in response to the first storage device being in the preset support list and the first storage device running in engineering mode.
[0014] The process includes, after writing the stored data to the second storage device based on the logical address, the following steps: obtaining the model of the first storage device and the number of storage chips included in the first storage device; determining whether all storage spaces of the first storage device have been traversed based on the model and the number; and ending the current data recovery process in response to the conclusion that all storage spaces of the first storage device have been traversed.
[0015] To address the aforementioned problems, a second aspect of this application provides a data recovery apparatus, comprising a memory and a processor coupled to each other; the memory stores program data; and the processor executes the program data to implement the data recovery method as described in any of the preceding claims.
[0016] To address the aforementioned problems, a third aspect of this application provides a computer-readable storage medium having program instructions stored thereon, wherein the program instructions, when executed by a processor, implement the write recovery method described in any of the preceding claims.
[0017] The beneficial effects of this invention are as follows: Unlike the prior art, the data recovery method in this application, when connected to the first storage device and determined that the first storage device is running in engineering mode, can read the stored data of the first storage device. When the stored data is logical data, it can obtain the logical address of the stored data, and write the stored data to a designated second storage device based on the logical address. This enables autonomous, safe, and reliable data recovery from a first storage device that is not working properly, and effectively avoids the problems of sending the first storage device back to the manufacturer for data recovery, which leads to long recovery cycles, cumbersome steps, and leakage or loss of some key and sensitive data. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating the first embodiment of the data recovery method of this application;
[0019] Figure 2 yes Figure 1 A flowchart illustrating an embodiment of S12;
[0020] Figure 3 yes Figure 1 A flowchart illustrating an embodiment of S14;
[0021] Figure 4 yes Figure 1 A flowchart of another embodiment of S14;
[0022] Figure 5 yes Figure 4 A flowchart of another embodiment of S1411;
[0023] Figure 6This is a flowchart illustrating the second embodiment of the data recovery method of this application;
[0024] Figure 7 This is a flowchart illustrating the third embodiment of the data recovery method of this application;
[0025] Figure 8 This is a flowchart illustrating the fourth embodiment of the data recovery method of this application;
[0026] Figure 9 This is a flowchart illustrating a specific embodiment of the data recovery method of this application;
[0027] Figure 10 This is a schematic diagram of the structure of an embodiment of the storage device of this application;
[0028] Figure 11 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0029] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0030] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.
[0031] In this paper, the terms "system" and "network" are often used interchangeably. The term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this paper means two or more.
[0032] Please see Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the data recovery method of this application. It should be noted that the terms "comprising" and "having," and any variations thereof, in this application are intended to cover non-exclusive inclusion. Specifically, this embodiment includes the following steps:
[0033] S11: Establish a communication connection with the first storage device.
[0034] Specifically, the data recovery method provided in this application can be applied to a smart terminal. For example, a data recovery application running on the user terminal can be used to read data from a storage device that is no longer functioning properly, in order to recover the data written to the storage device before the malfunction. Of course, in other embodiments, the data recovery method can also be applied to a cloud server or the back-end computer of the storage device manufacturer, and this embodiment does not limit this application.
[0035] Specifically, a first storage device that is no longer functioning properly can establish a communication connection with a smart terminal intended for data recovery by plugging its interface into the corresponding interface of the smart terminal.
[0036] Understandably, the smart terminal can be a user terminal, and the communication connection between the first storage device and the user terminal via an interface plug-in is a local connection, without the need to connect to the network to request network services. Specifically, data recovery of the first storage device is achieved through a data recovery application running on the user terminal, without the need for professional personnel to operate, thereby effectively ensuring the safety and reliability of the corresponding data information during the data recovery process.
[0037] In another embodiment, the smart terminal may further include a cloud server and a user terminal that are interconnected. For example, the corresponding data recovery application runs on the official website of the manufacturer, enabling data recovery from the first storage device connected to the user terminal via network communication. Alternatively, the smart terminal may further include a backend computer of the manufacturer and a user terminal that are interconnected, with the corresponding recovery application running on the backend computer and the first storage device interface connected to the user terminal. The backend computer can send corresponding program control instructions to the first storage device through the user terminal to perform data recovery from the first storage device. This application does not limit this aspect.
[0038] It should be noted that the data interaction between the aforementioned cloud server or backend computer and the user terminal only involves the transmission of program control instructions, and cannot involve the exchange or acquisition of data information.
[0039] Optionally, the first storage device may be any reasonable storage device such as SSD (Solid State Disk), UFS (Universal Flash Storage), or eMMC (embedded Multi Media Card), and this application does not limit it in this regard.
[0040] Optionally, the smart terminal may be any reasonable smart terminal capable of running applications, such as a computer, tablet computer, smartphone, or server; this application does not limit this.
[0041] S12: In response to the first storage device operating in engineering mode, read the stored data of the first storage device.
[0042] Understandably, the first storage device is currently unable to function properly. In order to distinguish it from the normally functioning storage device and to ensure that data interaction can be performed on the first storage device that is not functioning properly, special processing is required for the first storage device. For example, the user needs to put the first storage device that is not functioning properly into engineering mode by following the operation instructions and using any reasonable method such as shorting the reserved pins.
[0043] Specifically, when a smart terminal detects that the first storage device with which it has a current communication connection is running in engineering mode, it can determine that the first storage device is no longer working properly and needs to start a data recovery program in order to read the stored data before the first storage device malfunctioned.
[0044] S13: In response to the stored data being logical data, obtain the logical address of the stored data.
[0045] Understandably, after obtaining the current stored data in the first storage device, the smart terminal also needs to identify and distinguish the stored data. For example, the program data in the stored data does not involve the user's private data and usually does not need to be restored.
[0046] Specifically, when the smart terminal detects that the currently acquired stored data is logical data, it can restore and save the logical data in sequence, and further obtain the logical address of the logical data. For example, it can obtain the logical address of the logical data by reading the mapping table stored in the first storage device; or it can obtain the logical address of the logical data recorded in the corresponding firmware by reading the metadata space of the first storage device.
[0047] It should be noted that this logical data is an operand type, used to represent the "yes" or "no," or "true" or "false" states in binary logic. A logical address, in computer architecture, refers to the address of a memory cell, storage element, or network host as seen from the application's perspective. Logical addresses often differ from physical addresses; they can be translated into physical addresses using an address translator or mapping functions.
[0048] Firmware is the program written into EPROM (Erasable Programmable Read-Only Memory) or EEPROM (Electrically Erasable Programmable Read-Only Memory). Firmware refers to the device "driver" stored inside a device. Through firmware, the operating system can implement specific machine operations according to standard device drivers; for example, optical drives and CD burners all have internal firmware. Firmware is the software that performs the most basic and lowest-level work of a system. In hardware devices, firmware is the soul of the hardware device, because some hardware devices have no other software components besides firmware. Therefore, firmware determines the functionality and performance of the hardware device.
[0049] S14: Write the stored data to the second storage device based on the logical address.
[0050] Specifically, after obtaining the logical address of the stored data to be recovered, the stored data can be written to the storage location corresponding to the logical address in the second storage device according to the logical address; or, when the purpose is to restore the stored data to a set image file, the corresponding offset position of the stored data to the set image file can be calculated according to the logical address, so that after the stored data is restored to the set image file, the set image file can be further stored in the second storage device.
[0051] It is understood that the second storage device is a storage device that is different from the first storage device and can work normally. Specifically, it can be the storage space in the smart terminal for data recovery, or any other reasonable storage device that is connected to the smart terminal for communication. This application does not limit it in this regard.
[0052] The above solution, upon establishing a communication connection with a malfunctioning first storage device and determining that the first storage device is operating in engineering mode, reads the stored data of the first storage device. If the stored data is logical data, it obtains the logical address of the stored data, enabling the storage data to be written to a designated second storage device based on the logical address. This allows for autonomous, secure, and reliable data recovery from the malfunctioning first storage device, effectively avoiding the problems of sending the first storage device back to the manufacturer for data recovery, which would result in a long recovery cycle, cumbersome procedures, and the leakage or loss of some critical and sensitive data.
[0053] Please refer to the following: Figure 2 , Figure 2 yes Figure 1 A flowchart illustrating an embodiment of S12 is shown. In one embodiment, the first embodiment of the data writing method for the storage device of this application, in addition to the above-described S11-S14, further includes some more specific steps. Specifically, S12 may further include the following steps:
[0054] S121: Send data recovery firmware to the first storage device so that the first storage device runs the data recovery firmware.
[0055] Understandably, since the first storage device is no longer able to function normally, in order to ensure that data can be effectively read or acquired from the first storage device, the smart terminal specifically sends data recovery firmware to the first storage device to overwrite the original firmware in the first storage device, so that the first storage device can run the data recovery firmware.
[0056] S122: Send a data read command to the first storage device running the data recovery firmware to read the stored data.
[0057] Furthermore, after the first storage device runs the data recovery firmware, the smart terminal can send a data read command that can be recognized and responded to by the first storage device, thereby reading the stored data in the first storage device.
[0058] In a specific application scenario, when the first storage device, which is adjusted to engineering mode, is plugged into the user terminal through an interface, the data recovery application running on the user terminal, after recognizing the first storage device in engineering mode, specifically downloads a firmware for data recovery to the main controller of the first storage device, so that it can send a dedicated data read command that can be recognized and responded to by the first storage device based on the data recovery firmware.
[0059] Furthermore, in one embodiment, the above-mentioned S13 may further include: obtaining the logical address of the storage data of the corresponding record in the metadata.
[0060] Understandably, in the metadata space of the first storage device, such as NAND, the response firmware records the write order, logical address, and data attributes of each 4K logical data sent by the host.
[0061] Specifically, the smart terminal can obtain the logical address of the stored data corresponding to the record in the metadata by reading the metadata space of the first storage device. In other embodiments, the smart terminal can also obtain the logical address of the logical data by reading the mapping table stored in the first storage device, which is not limited in this application.
[0062] Furthermore, in one embodiment, the above-mentioned S14 may further include: writing the stored data to the storage location in the second storage device corresponding to the logical address.
[0063] Understandably, after obtaining the logical address of the logical data, the storage data to be recovered can be written to the storage location corresponding to the logical address in the second storage device.
[0064] Please refer to the following: Figure 3 , Figure 3 yes Figure 1 A flowchart illustrating an embodiment of step S14. In one embodiment, step S14 may further include the following steps:
[0065] S1401: Obtain the write order of stored data.
[0066] It is understandable that in the data storage of storage devices, it is often unavoidable that the same stored data will exist. For example, stored data with the same logical address will be written to the first storage device multiple times. In order to ensure that invalid data occupies the storage space of the second storage device as much as possible, it is necessary to identify the writing order of the same stored data.
[0067] Specifically, the smart terminal can obtain the writing order of the stored data corresponding to the record in the metadata by reading the metadata space of the first storage device. In other embodiments, the smart terminal can also directly obtain the writing order of each piece of stored data written to the first storage device by reading any reasonable information such as the timestamp of the stored data, and this application does not limit this.
[0068] S1402: According to the writing order, the last data written among the storage data with the same logical address that has been written multiple times to the first storage device is written to the storage location corresponding to the logical address in the second storage device.
[0069] Understandably, the recovery of the corresponding stored data by the smart terminal is performed sequentially according to the reading order, writing the currently acquired stored data to the storage location corresponding to the logical address in the second storage device in turn. Furthermore, if the logical addresses corresponding to consecutive stored data are the same during the recovery process, the last stored data written to the first storage device can overwrite the previously written identical stored data, thus preserving the last written data among multiple writes to the first storage device that have the same logical address.
[0070] Specifically, the stored data can be restored sequentially according to the location order of the storage space in the first storage device. For example, restoration can begin from the stored data in the first storage page and continue until the last storage page. If the stored data to be restored in the third storage page has appeared in the first storage page (i.e., has the same logical address as a piece of stored data in the first storage page) and has already been restored to the second storage device, and if the stored data in the third storage page was written to the first storage device more recently, then when restoring the same stored data in the third storage page to the storage location corresponding to the logical address in the second storage device, the already restored stored data in the first storage page will be overwritten. If the stored data in the third storage page was written to the second storage device more recently, then the stored data in the first storage page that has already been restored to the second storage device will be retained, and the stored data in the third storage page will not be restored. This process continues until the stored data in each storage page of the first storage device is restored to the second storage device, and the last stored data written to the first storage device with the same logical address is retained.
[0071] Please refer to the following: Figure 4 , Figure 4 yes Figure 1 A flowchart illustrating another embodiment of S14. In one embodiment, S14 may further include the following steps:
[0072] S1411: Write the stored data to the corresponding offset position of the set image file according to the logical address.
[0073] Specifically, when the goal is to restore the stored data to the designated image file, the corresponding offset position of the stored data written to the designated image file needs to be calculated based on the logical address of the obtained stored data, so as to restore the stored data to the designated image file accordingly.
[0074] S1412: Store the configuration image file to the second storage device.
[0075] Furthermore, after restoring the stored data to the corresponding setting image file, the setting image file can be stored in the second storage device.
[0076] Please refer to the following: Figure 5 , Figure 5 yes Figure 4 A flowchart of another embodiment of S1411.
[0077] In one embodiment, S1411 may further include the following steps:
[0078] S14111: Get the write order of stored data.
[0079] It is understandable that in the data storage of storage devices, it is often unavoidable that the same stored data will exist. For example, stored data with the same logical address will be written to the first storage device multiple times. In order to ensure that invalid data occupies the storage space of the second storage device as much as possible, it is also necessary to identify the writing order of the same stored data.
[0080] Specifically, the smart terminal can obtain the writing order of the stored data corresponding to the record in the metadata by reading the metadata space of the first storage device. In other embodiments, the smart terminal can also directly obtain the writing order of each piece of stored data written to the first storage device by reading any reasonable information such as the timestamp of the stored data, and this application does not limit this.
[0081] S14112: According to the writing order, the last data written among the storage data with the same logical address that has been written multiple times to the first storage device is written to the offset position corresponding to the logical address in the set image file.
[0082] Specifically, when the goal is to restore the stored data to a designated image file, the corresponding offset position of the stored data written to the designated image file needs to be calculated based on the logical address of the obtained stored data, so as to restore the stored data to the designated image file accordingly. Based on the writing order of the obtained stored data, it is ensured that the last data written among the stored data with the same logical address that has been written to the first storage device multiple times is restored to the designated image file.
[0083] Please see Figure 6 , Figure 6 This is a flowchart illustrating the second embodiment of the data recovery method of this application. The data recovery method of this embodiment... Figure 1 A detailed embodiment of the data recovery method is illustrated in the flowchart, which includes the following steps:
[0084] S21: Establish a communication connection with the first storage device.
[0085] S22: In response to the first storage device operating in engineering mode, read the stored data of the first storage device.
[0086] Among them, S21 and S22 and Figure 1 S11 and S12 are the same. Please refer to the textual descriptions of S11 and S12 for details, which will not be repeated here.
[0087] S23: Read the metadata of the stored data.
[0088] Understandably, in the metadata space of the first storage device, such as NAND, the response firmware records the write order, logical address, and data attributes of each 4K logical data sent by the host.
[0089] This data attribute is used to distinguish whether the 4K data is firmware program data or logical data.
[0090] Specifically, when the smart terminal determines that the first storage device is running in engineering mode, it further reads the metadata space of the first storage device to read the metadata of the stored data, that is, the writing order, logical address and data attributes of each logical data.
[0091] S24: Determine whether the stored data is logical data based on the data attributes of the corresponding record in the metadata.
[0092] Therefore, by reading the metadata of the stored data, it is possible to determine whether the stored data is logical data based on the data attributes of the corresponding record in the metadata.
[0093] If it is determined that the stored data is logical data, then S25 is executed; if it is determined that the stored data is not logical data, then S22 is executed again, until all the storage space of the first storage device has been traversed.
[0094] S25: Obtain the logical address of the stored data.
[0095] S26: Write the stored data to the second storage device based on the logical address.
[0096] Among them, S25 and S26 and Figure 1 S13 and S14 are the same. Please refer to S13 and S14 and their related textual descriptions for details. They will not be repeated here.
[0097] Please see Figure 7 , Figure 7 This is a flowchart illustrating the third embodiment of the data recovery method of this application. The data recovery method of this embodiment... Figure 3 A detailed embodiment of the data recovery method is illustrated in the flowchart, which includes the following steps:
[0098] S31: Establish a communication connection with the first storage device.
[0099] Among them, S31 and Figure 1 The same applies to S11. Please refer to S11 and its related textual descriptions for details, which will not be repeated here.
[0100] S32: Obtain the characteristic parameters of the first storage device.
[0101] Understandably, in order to differentiate products from different companies and protect user data privacy, when recovering data from a first storage device that is no longer functioning properly, it is also necessary to determine whether the corresponding smart terminal has data recovery permissions for the current first storage device.
[0102] Specifically, the feature code or signal sent by the first storage device to the smart terminal is detected to obtain the feature parameters of the first storage device, such as the model or product serial number of the first storage device, or any reasonable feature parameter, so as to identify and distinguish the first storage device through the feature parameters.
[0103] S33: Determine whether the first storage device is in the preset support list based on the feature parameters.
[0104] Furthermore, the smart terminal has a pre-defined support list that establishes data recovery permissions for the first storage device based on its characteristic parameters. This allows the terminal to determine whether it has data recovery permissions for the first storage device currently connected to the smart terminal based on whether the characteristic parameters are present in the pre-defined support list when the characteristic parameters of the first storage device are obtained.
[0105] If the first storage device is in the preset support list of the smart terminal, then S34 is executed; if the first storage device is not in the preset support list of the smart terminal, then S37 is executed.
[0106] S34: In response to the first storage device operating in engineering mode, read the stored data of the first storage device.
[0107] S35: In response to the stored data being logical data, obtain the logical address of the stored data.
[0108] S36: Write the stored data to the second storage device based on the logical address.
[0109] Among them, S34, S35 and S36 and Figure 1 S12, S13 and S14 are the same. Please refer to the textual descriptions of S12, S13 and S14 and their related texts for details. They will not be repeated here.
[0110] S37: End the current recovery process.
[0111] Specifically, if it is determined that the first storage device does not exist in the preset support list of the smart terminal, it indicates that the smart terminal does not have data recovery permissions for the first storage device, and the current data recovery program needs to be terminated, and a corresponding prompt message will pop up to inform the user.
[0112] Please see Figure 8 , Figure 8 This is a flowchart illustrating the fourth embodiment of the data recovery method of this application. The data recovery method of this embodiment... Figure 1 A detailed embodiment of the data recovery method is illustrated in the flowchart, which includes the following steps:
[0113] S41: Establish a communication connection with the first storage device.
[0114] S42: In response to the first storage device operating in engineering mode, read the stored data of the first storage device.
[0115] S43: In response to the stored data being logical data, obtain the logical address of the stored data.
[0116] S44: Write the stored data to the second storage device based on the logical address.
[0117] Among them, S41, S42, S43 and S44 and Figure 1 S11, S12, S13 and S14 are the same. Please refer to the textual descriptions of S11, S12, S13 and S14 and their related texts for details. They will not be repeated here.
[0118] S45: Obtain the model number of the first storage device and the number of storage chips included in the first storage device.
[0119] Understandably, since the data recovery process for the data stored in the first storage device is performed sequentially, it is necessary to determine the specific storage space size of the first storage device in order to prevent premature termination of the data recovery process and to ensure that important data is not missed.
[0120] Since mass production is the mainstream production method in industry today, industrial products of the same model usually have the same functional parameters. For example, storage devices of the same model usually have the same storage space size.
[0121] Specifically, in order to obtain the specific storage space size of the first storage device, before or during data recovery of the first storage device, it is also necessary to obtain the model of the first storage device and the number of storage chips included in the first storage device, so as to determine the storage space size of the first storage device.
[0122] S46: Determine whether all storage spaces of the first storage device have been traversed based on the model and quantity.
[0123] Furthermore, by obtaining the model of the first storage device and the number of storage chips included in the first storage device, it is possible to determine the storage space size of the first storage device, so as to determine whether the current data recovery has traversed all the storage space of the first storage device.
[0124] If all the storage space of the first storage device has been traversed, then S47 is executed; if all the storage space of the first storage device has not been traversed, then S42 is executed again, until all the storage space of the first storage device has been traversed.
[0125] S47: In response to having traversed all the storage space of the first storage device, terminate the current data recovery process.
[0126] Specifically, once it is determined that all storage spaces of the first storage device have been traversed, it indicates that the data originally stored in the first storage device has been completely restored to the specified image file or the specified second storage device for recovery, and the current data recovery process can be terminated.
[0127] Please see Figure 9 , Figure 9 This is a flowchart illustrating a specific embodiment of the data recovery method of this application. This embodiment includes the following steps:
[0128] S51: Select storage device.
[0129] Specifically, select the storage device that is no longer functioning properly and connect it to a smart terminal loaded with the recovery application.
[0130] S52: Determine whether the storage device is in the default support list of the recovery application.
[0131] Obtain characteristic parameters of the storage device, such as the product model, to determine whether the product model exists in the preset support list of the recovery application pre-set in the smart terminal.
[0132] If the storage device is in the preset support list of the recovery application, then S53 is executed; if the storage device is not in the preset support list of the recovery application, then S54 is executed.
[0133] S53: Enter engineering mode?
[0134] Furthermore, it detects whether the storage device has entered engineering mode, for example, by detecting whether the preset pins of the storage device have been shorted.
[0135] If the storage device enters engineering mode, S55 is executed; if the storage device does not enter engineering mode, S54 is executed.
[0136] S54: Recovery failed.
[0137] Specifically, if the storage device is not in the preset support list of the recovery application or the storage device has not entered engineering mode, the recovery is deemed to have failed, and a corresponding prompt message will pop up to remind the user.
[0138] S55: Download dedicated data recovery firmware.
[0139] Specifically, since the storage device is no longer able to function normally, in order to ensure that data can be effectively read or acquired from the storage device, the smart terminal sends data recovery firmware to the storage device to overwrite the original firmware in the first storage device, so that the storage device runs the data recovery firmware.
[0140] S56: Obtain the characteristic parameters of the storage device.
[0141] Understandably, in order to differentiate between products from different companies and to protect user data privacy, when recovering data from a primary storage device that is no longer functioning properly, it is necessary to determine whether the user has the authority to recover the data.
[0142] Specifically, the feature code or signal sent by the first storage device to the smart terminal is detected to obtain the feature parameters of the first storage device, such as the model or product serial number of the first storage device, or any reasonable feature parameter, in order to identify and distinguish the first storage device.
[0143] S57: Traverse all storage spaces of the storage device.
[0144] Specifically, the storage space of the storage device is traversed to sequentially obtain the stored data in the storage device until all the storage space of the storage device has been traversed.
[0145] S58: Is the data type of the metadata record of the currently acquired stored data logical data?
[0146] Understandably, storage devices, such as SSDs, record the corresponding data attributes, logical address, and write order in the metadata of each 4K data when writing data to their NAND FLASH programming host.
[0147] When data recovery is required, the SSD can enter engineering mode using a preset method, then download and run dedicated data recovery firmware on the controller. This dedicated firmware responds to the manufacturer-provided dedicated data recovery application. The dedicated data recovery tool traverses all NAND flash space in the SSD via commands, starting from Page 0 of Block 0 (the smallest storage and processing unit in the database) and proceeding sequentially to the last page of the last block. Based on the metadata content of each 4KB segment, it determines whether to recover the data, the logical address to recover, and other relevant operations. After the traversal is complete, the original disk's contents are fully backed up to a specified image file or a new disk.
[0148] If the currently stored data is logical data, then execute S59; if the currently stored data is not logical data, then execute S57.
[0149] S59: Whether the data write order of the metadata record is the latest.
[0150] It is understandable that in the data storage of storage devices, it is often unavoidable that the same stored data will exist, for example, stored data with the same logical address will be written to the storage device multiple times.
[0151] Specifically, the smart terminal can read the metadata space of the storage device to obtain the writing order of the corresponding record of the storage data in the metadata, and determine whether the storage data being restored is the latest storage data written to the storage device based on the writing order, that is, the storage data written in the last storage device.
[0152] If the current write order is the latest, then execute S510; if the current write order is not the latest, then execute S57.
[0153] S510: Restore to an image file or restore to a specified hard drive.
[0154] Furthermore, the current recovery / storage method can be determined by the program, either by restoring the stored data to an image file or by restoring it to a specified hard drive. This can be set by the program or determined by receiving corresponding selection commands from the user.
[0155] If it is determined that the current stored data should be restored to an image file, then S511 is executed; if it is determined that the current stored data should be restored to a specified hard disk, then S512 is executed.
[0156] S511: Based on the logical address recorded in the metadata, write the data just read to the offset position of the specified image file to complete the recovery of a data entry.
[0157] Once it is determined that the current stored data will be restored to an image file, the data just read is written to the offset position of the specified image file according to the logical address of the metadata record, so as to complete the restoration of a piece of data.
[0158] S512: Based on the logical address recorded in the metadata, write the data just read to the same logical address on the specified hard drive to complete the recovery of a data entry.
[0159] When it is determined that the currently stored data will be restored to the specified hard drive, the data just read is written to the same logical address of the specified hard drive according to the logical address recorded in the metadata, thus completing the recovery of one piece of data.
[0160] S513: Check if all storage spaces have been traversed.
[0161] Specifically, it detects whether all storage spaces have been traversed, for example, by using a predetermined storage space size of the storage device to determine whether all storage spaces have been traversed.
[0162] If all storage spaces have been traversed, then S514 is executed; if not, then S57 is executed.
[0163] S514: Recovery complete.
[0164] Please see Figure 10 , Figure 10 This is a schematic diagram of the structure of a storage device according to an embodiment of the present application. The data recovery device 61 includes a memory 611 and a processor 612 coupled to each other; the memory 611 stores program data; the processor 612 is used to execute the program data to implement the data recovery method as described in any of the preceding claims.
[0165] In one embodiment, the data recovery device 61 specifically includes an interface (not shown), a first storage space (not shown), a second storage space (not shown), and a processor 612 that are coupled to each other; wherein, the interface is used to connect to the storage device whose data is to be recovered, the first storage space stores program data, and the processor 612 is used to execute the program data to implement the data recovery method as described above, so as to store the stored data in the storage device to the second storage space.
[0166] Optionally, the storage device may be any reasonable storage device such as SSD (Solid State Disk), UFS (Universal Flash Storage), or eMMC (embedded Multi Media Card), and this application does not limit it in this regard.
[0167] Optionally, the data recovery device 61 may be any reasonable smart terminal capable of running applications, such as a computer, tablet computer, smartphone, or server; this application does not limit this.
[0168] Specifically, processor 612 can also be referred to as a CPU (Central Processing Unit). Processor 612 may be an integrated circuit chip with signal processing capabilities. Processor 612 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 612 can be implemented using integrated circuit chips.
[0169] Please see Figure 11 , Figure 11 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer-readable storage medium 71 stores program instructions 711 that can be executed by a processor, the program instructions 711 being used to implement the data recovery method described in any of the above claims.
[0170] In the embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0171] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0172] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0173] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A data recovery method for a storage device, characterized in that, The data recovery method includes: Establish a communication connection with the first storage device; In response to the shorting of the reserved pin of the first storage device, it is determined that the first storage device is running in engineering mode, and program control instructions sent by the background computer are obtained; The program control command is sent to the first storage device to cause the first storage device to start the data recovery program; Read the stored data from before the first storage device malfunctioned; In response to the fact that the stored data is logical data, the logical address of the stored data is obtained; The stored data is written to the second storage device based on the logical address.
2. The data recovery method according to claim 1, characterized in that, The step of reading the stored data of the first storage device includes: Send data recovery firmware to the first storage device to enable the first storage device to run the data recovery firmware; A data read command is sent to the first storage device running the data recovery firmware to read the stored data.
3. The data recovery method according to claim 1, characterized in that, After the step of reading the stored data of the first storage device, and before the step of obtaining the logical address and write order of the stored data in response to the stored data being logical data, the following steps are included: Read the metadata of the stored data; Based on the data attributes of the stored data in the corresponding record in the metadata, it is determined whether the stored data is logical data.
4. The data recovery method according to claim 3, characterized in that, The step of obtaining the logical address of the stored data includes: Obtain the logical address of the stored data corresponding to the record in the metadata.
5. The data recovery method according to claim 1, characterized in that, The step of writing the stored data to the second storage device based on the logical address includes: The stored data is written to the storage location in the second storage device corresponding to the logical address.
6. The data recovery method according to claim 1, characterized in that, The step of writing the stored data to the second storage device based on the logical address includes: Obtain the write order of the stored data; According to the writing order, the last data written among the storage data with the same logical address that has been written multiple times to the first storage device is written to the storage location in the second storage device corresponding to the logical address.
7. The data recovery method according to claim 1, characterized in that, The step of writing the stored data to the second storage device based on the logical address includes: The stored data is written to the corresponding offset position of the set image file according to the logical address; The configuration image file is stored in the second storage device.
8. The data recovery method according to claim 7, characterized in that, The step of writing the stored data to the corresponding offset position of the set image file according to the logical address includes: Obtain the write order of the stored data; According to the writing order, the last data written among the storage data with the same logical address that has been written multiple times to the first storage device is written to the offset position corresponding to the logical address in the designated image file.
9. The data recovery method according to claim 1, characterized in that, After the step of establishing a communication connection with the first storage device and before the step of reading the stored data of the first storage device in response to the first storage device operating in engineering mode, the method further includes: Obtain the characteristic parameters of the first storage device; Based on the aforementioned feature parameters, determine whether the first storage device is in the preset support list; The step of reading the stored data of the first storage device in response to the first storage device operating in engineering mode includes: In response to the first storage device being in the preset support list and the first storage device being run in the engineering mode, the stored data in the first storage device is read.
10. The data recovery method according to claim 1, characterized in that, After the step of writing the stored data to the second storage device based on the logical address, the method further includes: Obtain the model number of the first storage device and the number of storage chips included in the first storage device; Based on the model and the quantity, determine whether all the storage space of the first storage device has been traversed; In response to having traversed all the storage space of the first storage device, the current data recovery process ends.
11. A data recovery device, characterized in that, The data recovery device includes a memory and a processor that are coupled to each other; The memory stores program data; The processor is used to execute the program data to implement the data recovery method as described in any one of claims 1-10.
12. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the data recovery method according to any one of claims 1-10.
Citation Information
Patent Citations
Data recovery method and device
CN103678039A