Data recovery method and device, storage medium and electronic equipment
By saving the metadata snapshot of the SSD and the logical block address of the change amount when powered off, and marking the validity according to the number of saves, only the effective change amount is restored when powered on, the problem of too long powered on the SSD is solved, and faster data recovery and longer flash memory life are achieved.
Patent Information
- Application Number
- CN202510353026.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-07-04
AI Technical Summary
In the prior art, the change amount of solid-state drives are restored one by one during power-on, resulting in an increase in data recovery time, which in turn extends the power-on time of the solid-state drive.
When power is off, save the snapshot of the metadata and the logical block address of the change amount, and mark the target identifier of the change amount according to the number of times the logical block address is saved to identify whether the change amount is valid; when powering on, use the snapshot to restore the metadata and restore the effective change amount according to the target identifier.
Reduces the number of changes that need to be recovered, shortens data recovery time, reduces the power-on time of SSD, and extends the service life of flash memory.
Smart Images

Figure CN120256200A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a data recovery method, apparatus, storage medium, and electronic device. Background Art
[0002] When a solid state drive (SSD) powers off, it is necessary to completely save the metadata to the flash memory so as to perform data recovery when powering on and restore the SSD to the state before powering off.
[0003] Currently, in the related art, during the power-off process of an SSD, all changed amounts of the metadata are saved, and during the power-on process, the changed amounts are restored one by one.
[0004] However, in the related art, restoring the changed amounts one by one during the power-on process of the SSD increases the data recovery time, and further increases the power-on time of the SSD. Summary of the Invention
[0005] The present disclosure provides a data recovery method, apparatus, storage medium, and electronic device. Its main purpose is to solve the problem that in the related art, restoring the changed amounts one by one during the power-on process of the SSD increases the data recovery time, and further increases the power-on time of the SSD.
[0006] In a first aspect, the present application provides a data recovery method, including:
[0007] In response to receiving a power-off instruction, saving a snapshot corresponding to the metadata, and logical block addresses of changed amounts in the metadata;
[0008] According to the number of times of saving the logical block addresses, marking target identifiers of the changed amounts corresponding to the logical block addresses respectively, where the target identifier is used to identify whether the changed amount is valid;
[0009] In response to receiving a power-on instruction, restoring the metadata using the snapshot, and restoring valid changed amounts in the metadata according to the target identifier.
[0010] In a second aspect, the present application provides a data recovery apparatus, including:
[0011] A saving module, configured to save a snapshot corresponding to the metadata, and logical block addresses of changed amounts in the metadata in response to receiving a power-off instruction;
[0012] A marking module, configured to mark target identifiers of the changed amounts corresponding to the logical block addresses respectively according to the number of times of saving the logical block addresses, where the target identifier is used to identify whether the changed amount is valid;
[0013] A recovery module, configured to, in response to receiving a power-on instruction, recover metadata using a snapshot and recover valid changed amounts in the metadata according to a target identifier.
[0014] In a third aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method of the first aspect is implemented.
[0015] In a fourth aspect, the present application provides an electronic device, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, and when the processor executes the computer program, the method of the first aspect is implemented.
[0016] In a fifth aspect, the present application provides a computer program product, on which a computer program is stored, and when the computer program is executed by a processor, the method of the first aspect is implemented.
[0017] The data recovery method, apparatus, storage medium, and electronic device provided by the present disclosure, wherein the method includes: in response to receiving a power-off instruction, saving a snapshot corresponding to metadata and changed amounts in the metadata; marking target identifiers of the changed amounts respectively corresponding to logical block addresses according to the save times of the logical block addresses, where the target identifier is used to identify whether the changed amount is valid; in response to receiving a power-on instruction, recovering the metadata using the snapshot and recovering the valid changed amounts in the metadata according to the target identifier. Compared with the current prior art, the present application can, when receiving a power-off instruction, save the snapshot of the metadata and the logical block addresses of the changed amounts in the metadata, and according to the save times of the logical block addresses of the changed amounts, determine whether there is a situation where the same logical block address is rewritten repeatedly, and then determine the target identifier of the changed amount to identify the validity of the changed amount. When receiving a power-on instruction, first recover the metadata using the snapshot, then determine the valid changed amounts in the changed amounts according to the target identifier, and then recover the valid changed amounts in the metadata to complete the power-on process of the solid-state drive. In this way, during the power-on process of the solid-state drive, only the recovery operation of the valid changed amounts is performed, reducing the number of changed amounts to be recovered, reducing the recovery operation of the invalid changed amounts, thereby reducing the data recovery time and reducing the power-on time of the solid-state drive.
[0018] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become easily understood through the following description. Description of the Drawings
[0019] To more clearly illustrate the embodiments of the present application, the accompanying drawings required for the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0020] Figure 1 The flowchart of a data recovery method provided by an embodiment of the present application is shown;
[0021] Figure 2 The schematic diagram of an example provided by an embodiment of the present application is shown;
[0022] Figure 3 The schematic diagram of another example provided by an embodiment of the present application is shown;
[0023] Figure 4 The structural schematic diagram of a data recovery device provided by an embodiment of the present application is shown. Detailed implementation manners
[0024] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present application.
[0025] It should be noted that in the description of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, method, article or device including a series of elements includes not only those elements but also other elements not explicitly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present application are used to distinguish similar objects, rather than to describe a specific order or sequence.
[0026] In some examples, the power-on process of a solid-state drive is to restore the state of the solid-state drive to the state before power-off. The power-on time of the solid-state drive is an important performance indicator, which refers to the time required for the solid-state drive to go from a completely powered-off state to the completion of startup and be able to save and receive data transfer requests from the host. A short recovery time of the solid-state drive helps improve the startup efficiency of the host, enabling users to start working faster and helping to improve the business processing efficiency of enterprises. Specifically, for the power-on and power-off of the solid-state drive, it is necessary to save complete metadata when powering off, so that the solid-state drive can be completely restored to the state before power-on when powering on. Therefore, the way of saving metadata before power-off directly affects the power-on recovery process and the time required for power-on. The way of saving metadata when powering off needs to record all kinds of data required for power-on completely and ensure that these data can be saved quickly before power-off.
[0027] As a possible implementation, it is also possible to write a full snapshot of the metadata at regular intervals. However, this method takes a long time to write. In the face of abnormal power-off, the power-off time is only a few tens of milliseconds, and the entire metadata cannot be saved completely.
[0028] As another possible implementation, during the power-off process, only the changed amount of the metadata can be saved. In this way, the saving time is short, but data will be written to the flash memory frequently, resulting in frequent write and erase operations of the flash memory, and the flash memory will reach its upper limit of service life quickly. Correspondingly, during the power-on process, the changed amounts need to be restored one by one. However, the most time-consuming process of this method is to restore the metadata from the Not AND (NAND) flash memory to the Double Data Rate (DDR) memory. Limited by the random access speed of the Central Processing Unit (CPU) to the DDR memory, in the case of a large number of random write operations, it takes a long time to restore a large number of changed amounts, increasing the recovery time of the metadata, and thus extending the overall power-on time of the solid-state drive.
[0029] To improve the technical problem in the current related technology that when the solid-state drive restores the changed amounts one by one during the power-on process, it increases the data recovery time and thus increases the power-on time of the solid-state drive.
[0030] This embodiment provides a data recovery method, as Figure 1 shown, the method includes the following steps:
[0031] Step 101, in response to receiving a power-off instruction, save the snapshot corresponding to the metadata and the logical block addresses of the changed amounts in the metadata.
[0032] In some embodiments, when the solid-state drive receives a power-down instruction, it can save a metadata snapshot corresponding to the current time, as well as the logical block addresses (LBAs) of the changes generated before the power-down is completed. Here, the snapshot can be the content or status of the metadata corresponding to the current time node. The logical block address is a way to identify the location of data on a storage device. Especially in storage media such as hard disk drives and solid-state drives, the LBA provides a linear addressing scheme that allows the operating system to access any location on the storage media in a unified manner without caring about the underlying physical storage structure. Specifically, within a certain period of time, a certain amount of changes are recorded in the double data rate memory. When a certain amount is reached, such as when the capacity of the current buffer is reached, the changes, the logical addresses of the changes, and the snapshot can be written to the flash memory so as to be saved in the event of a power failure. In such a case, the latest state of the metadata can be saved in a relatively short time, and the write frequency to the flash memory can be reduced to a large extent, which helps to extend the service life of the flash memory.
[0033] In some embodiments, the execution subject of this embodiment can be a solid-state drive. After the solid-state drive receives the power-down instruction sent by the host, it can start storing metadata and feedback power-down completion information to the host after the power-down is completed. Correspondingly, after the solid-state drive receives the power-on instruction, it can restore the stored metadata and the changes in the metadata to reach the state before the solid-state drive was powered down.
[0034] Step 102: Mark the target identifiers of the changes corresponding to the logical block addresses according to the save times of the logical block addresses. The target identifier is used to identify whether the change is valid.
[0035] In some embodiments, there may be a situation where the same logical block address is written repeatedly. For such a situation, each written change is saved to the flash memory. During the data recovery process when powering on, if each written change is restored one by one, although this can ensure that the latest change written in the last recovery operation is written, the subsequently restored changes will overwrite the previously restored changes, that is, some invalid recovery operations are performed, increasing the power-on time. Therefore, it is possible to determine whether there is a repeated write situation according to the logical block addresses of each change. If there is a repeated write situation, only the last written change needs to be restored.
[0036] Specifically, by detecting the save times of the logical block addresses corresponding to the changes, it can be determined whether each change is the latest change written before the power-down, and the target identifier is used to mark each change to determine the validity of each change, so as to determine the valid changes that need to perform the recovery operation according to the target identifier during the power-on process, thereby reducing the power-on time of the solid-state drive.
[0037] Exemplarily, when saving the latest change amount, the logical block address of the latest change amount can be obtained and saved simultaneously, and the number of times the logical block address is saved is recorded. By comparing it with the logical block addresses of historical change amounts, if there is a matching logical block address, the number of times the logical block address is saved can be recorded as 2, indicating that the logical block address has been written repeatedly. The target identifier of the latest change amount corresponding to the last write of the repeatedly written logical block address can be marked as valid, and the target identifiers of historical change amounts that are not the last write can be marked as invalid, thereby further differentiating the change amounts and then improving the data recovery efficiency of the solid-state drive during power-on.
[0038] Step 103: In response to receiving a power-on instruction, use the snapshot to restore the metadata and restore the valid change amounts in the metadata according to the target identifiers.
[0039] Among them, the valid change amounts can include the change amounts with valid target identifiers and need to be restored during the power-on process; the invalid change amounts can include the change amounts with invalid target identifiers and do not need to be restored during the power-on process.
[0040] In some embodiments, during the power-off process, a snapshot of the metadata, the change amounts in the metadata, and the target identifiers corresponding to the change amounts are saved. For this data saving method, the power-on time of the solid-state drive mainly consists of two parts: the time required to restore the snapshot and the time required to restore the change amounts.
[0041] In some embodiments, after receiving a power-on instruction, the solid-state drive can first use the data stored in the snapshot to restore the metadata to the corresponding position in the memory, then read the target identifiers of each change amount, read the validity of each change amount according to the target identifiers, determine the valid change amounts and invalid change amounts in the change amounts, and perform the restoration operation of the valid change amounts in the metadata. For the invalid change amounts with invalid target identifiers, no specific restoration operation needs to be performed, reducing the data recovery time and the power-on recovery time of the solid-state drive, and thus improving the data recovery efficiency of the solid-state drive.
[0042] Compared with the current existing technologies, in this embodiment, when a power-off instruction is received, a snapshot of the metadata and the logical block addresses of the change amounts in the metadata can be saved, and whether there is a situation where the same logical block address is repeatedly written can be judged according to the save times of the logical block addresses of the change amounts, and then the target identifier of the change amount can be determined to identify the validity of the change amount. When a power-on instruction is received, first, the metadata is restored by using the snapshot, then the valid change amounts in the change amounts are determined according to the target identifier, and then the valid change amounts in the metadata are restored to complete the power-on process of the solid-state drive. In this way, during the power-on process of the solid-state drive, only the restoration operations of the valid change amounts are executed, the number of change amounts to be restored is reduced, the restoration operations of the invalid change amounts are reduced, and thus the data restoration time is reduced and the power-on time of the solid-state drive is reduced.
[0043] Further, as a refinement and extension of the above embodiment, in order to specifically illustrate the data restoration process of a specific solid-state drive, optionally, before step 101, the method of this embodiment may further include: creating a write buffer in the double data rate memory by using a log manager.
[0044] Optionally, saving the snapshot corresponding to the metadata and the change amounts in the metadata may specifically include: saving the snapshot to the basic data area of the write buffer; saving the change amounts to the variable area of the write buffer.
[0045] In a specific application scenario, when the solid-state drive is running and the metadata changes, the changed change amounts need to be saved, and a log manager (Journal Manager, JM) can be used for saving. Exemplarily, when the solid-state drive is running, when the log manager saves the logical block to physical block mapping table (Logical To Physical Table, L2P), a write buffer (Write Buffer) with a single-level cell (Single-Level Cell, SLC) SLC and a Page size (i.e., 16640 bytes) can be created in the DDR. The allocation of this buffer is as Figure 2 shown. This buffer may include but is not limited to a header area Header, a variable area Delta, a basic data area Base, an identification area Bitmap, etc. Among them, Header can be used to store header information, Delta can be used to store change amounts, Base can be used to store the snapshot of the metadata, and Bitmap can be used to store the target identifiers corresponding to the change amounts. Through this data storage method, the time for saving the metadata during the power-off process of the solid-state drive can be reduced, and it can be ensured that the complete metadata can be restored after power-on.
[0046] Optionally, step 102 may specifically include: determining whether the save count of the logical block address is greater than a preset count; if the save count of the logical block address is greater than the preset count, marking the target identifier of the latest change amount corresponding to the logical block address as valid, and marking the target identifier of the historical change amount corresponding to the logical block address as invalid; if the save count of the logical block address is less than or equal to the preset count, marking the target identifier of the latest change amount corresponding to the logical block address as valid.
[0047] In some embodiments, when filling the Delta of the write buffer with change amounts, the system will simultaneously record the logical block address corresponding to the current change amount. Exemplarily, each time the latest change amount is saved, the save count of the logical block address can be detected and compared with the preset count. To detect whether the logical block address is repeatedly written, the preset count can be set to 1. For example, if there are 2 logical block addresses in the buffer that are the same as the logical block address of the latest change amount, the save count of the logical block address can be recorded as 3, which is greater than the preset count, indicating that the logical block address is repeatedly written multiple times; if there is no logical block address in the buffer that is the same as the logical block address of the latest change amount, the save count of the logical block address can be recorded as 1, which is equal to the preset count, indicating that the logical block address is not repeatedly written.
[0048] Specifically, when the latest change amount needs to be saved to the buffer, it can be determined whether there is a historical change amount in the Delta of the write buffer that is the same as the LBA of the latest change amount. If there is a historical change amount with the same logical block address as the latest change amount, it means that the latest change amount is an update to the historical change amount, that is, the historical change amount will be overwritten by the latest change amount. Then, the target identifier of the historical change amount can be determined as invalid, and there is no need to perform data recovery when powering on. The target identifier of the latest change amount can be determined as valid for data recovery when powering on.
[0049] In this way, this embodiment can determine whether there are multiple change amounts with repeated writes in the write buffer according to the save count of the logical block address of each change amount, and distinguish between the latest change amount and the historical change amount corresponding to the repeatedly written logical address block based on the target identifier of each change amount, which is convenient for reducing the recovery operation of invalid change amounts when powering on, improving the data recovery efficiency, and thus effectively shortening the power-on time.
[0050] Further optionally, saving the snapshot to the basic data area of the write buffer may specifically include: saving the snapshot corresponding to the mapping table from logical blocks to physical blocks to the basic data areas corresponding to different write buffers according to the capacity of the basic data area.
[0051] Correspondingly, saving the logical block address of the change amount to the variable area of the write buffer may specifically include: saving the change amount and the logical block address of the change amount to the variable area according to the generation time of the change amount.
[0052] Exemplarily, when saving L2P, the part for saving the L2P change amount can be called L2P Delta, which together with the 64-byte Header occupies a total of 4KB; the part for saving the L2P table snapshot can be called L2P Base, which occupies 12KB. In the specific process of saving L2P, JM can divide the entire L2P into several parts according to the size of Base, and store the L2P snapshot into the corresponding Base of different write buffers.
[0053] Correspondingly, when the L2P change amount part fills the entire Delta part of the write buffer, the log manager can sequentially fetch it. At this time, 12KB of the L2P table needs to be saved as Base. The above content totals 16384 bytes (16K), and the last 256 bytes are unused. After the Header, Delta, and Base of this write buffer are all filled, JM can flush the entire buffer and save it to the flash memory. In this way, it can effectively reduce the flash write frequency, help extend the flash usage cycle, and ensure that the complete metadata can be restored after power-on.
[0054] Optionally, the method of this embodiment may further include: using the bitmap corresponding to the write buffer to store the target identifier corresponding to the change amount; when it is detected that the write buffer is full, flushing the data corresponding to the write buffer to the flash memory.
[0055] Among them, the bitmap can be used to accurately record the validity of each change amount in Delta. Its working principle is that each bit corresponds to a change amount and records the target identifier of this change amount.
[0056] Exemplarily, as Figure 3 shown, in the same write buffer, the target identifier stored in the bit of the bitmap can correspond to the change amount in the Delta area. When a new change amount is filled into the Delta area, the bitmap can be updated, and the target identifier of the historical change amount with the same address as the latest change amount is updated to invalid, and the bit value at the corresponding position in the Bitmap is modified to "0". If the LBA corresponding to the latest change amount is different from the previously stored change amount, then only the bit value corresponding to the latest change amount in the Bitmap is increased and can be recorded as "1", and the bit values corresponding to other change amounts in the Bitmap do not need to be modified. As the change amounts are continuously filled until the last change amount is successfully filled into the write Buffer, at this time the Bitmap will also complete all necessary modifications, accurately identifying which change amounts are valid and which are invalid. After the above operations are completed, the system will continue to fill the data into the basic data area and finally flush it into the NAND flash memory for persistent storage, realizing data storage in the solid-state drive during the power-off process.
[0057] In this embodiment, by adding a Bitmap for identifying whether the L2P change amount is valid, the valid Deltas are marked and saved at the end of the current Buffer. When powering on, it is possible to determine how many change amounts in the current Buffer are valid according to the bitmap, and only restore the valid change amounts, so as to reduce the number of change amounts for performing the restoration operation, reduce the time for restoring the metadata L2P, and thus further reduce the data restoration time and the overall time of the power-on process of the solid-state drive.
[0058] Optionally, using the snapshot to restore the metadata may specifically include: reading the snapshot from the flash memory and restoring the metadata to the corresponding position in the double data rate memory using the snapshot.
[0059] As a possible implementation manner, during power-on restoration, a page written down can be read up. After reading it up, the metadata corresponding to the snapshot in the Base is restored to the corresponding position in the DDR memory. Then, according to the target identifiers in the bitmap, the valid change amounts are restored by patching. Finally, the metadata after power-on is obtained, and the solid-state drive is restored to the state before power-off.
[0060] Optionally, restoring the valid change amounts in the metadata according to the target identifiers may specifically include: reading the bitmap corresponding to the write buffer from the flash memory; determining the change amounts with the target identifiers in the bitmap being valid as the valid change amounts; and performing patching processing on the metadata corresponding to the snapshot according to the positions of the valid change amounts in the double data rate memory to obtain the metadata after power-on.
[0061] In some embodiments, in response to receiving a power-on instruction, first, the information that has been stored can be read from the flash memory. Exemplarily, the data in the entire write buffer can be read. The system will determine the change amounts with the target identifiers being valid (such as "1") in the current Buffer according to the information recorded in the Bitmap as the valid change amounts, so as to implement the screening of the valid change amounts and reduce subsequent restoration operations.
[0062] Exemplarily, if data is repeatedly written to an LBA and each written data is saved, that is, all change amounts are saved, and Patch operations are performed one by one during power-on, only the variable after the latest Patch operation is the latest. Therefore, during power-on restoration, there are some invalid change amounts, resulting in some Patch operations being invalid, and only the Patch operation of the latest change amount is valid. Therefore, if only the latest change amount can be patched, the Patch operations can be reduced, thereby reducing the power-on time.
[0063] Specifically, the CPU can be used to patch the effective change amount of L2P to the corresponding position one by one. Compared with the method of restoring all change amounts, in this embodiment, without changing the hardware platform of the SSD, a bitmap is added to the write Buffer to record which of the change amounts stored in this Buffer are effective. During the power-on process, only the effective change amounts are restored, while the other ineffective change amounts are discarded. In this way, for the case of writing to the same LBA multiple times, only the last effective change amount needs to be patched, effectively reducing the amount of operations for patching the change amounts, thereby greatly reducing the patching time, further reducing the data recovery time, and reducing the power-on time of the hard disk.
[0064] Compared with the current existing technologies, in this embodiment, in response to receiving a power-off instruction, the snapshot corresponding to the metadata and the change amounts in the metadata can be saved first; then, according to the number of times the logical block address is saved, the target identifiers corresponding to the change amounts of the logical block addresses are marked, and the target identifier is used to identify whether the change amount is effective; in response to receiving a power-on instruction, the effective change amounts in the change amounts are determined based on the target identifier; finally, the metadata is restored using the snapshot and the effective change amounts. In this way, during the power-on process of the solid-state drive, only the recovery operations of the effective change amounts are performed, reducing the number of change amounts that need to be restored, reducing the recovery operations of the ineffective change amounts, further reducing the data recovery time, and reducing the power-on time of the solid-state drive. In addition, according to the capacity of the basic data area, the snapshot corresponding to the mapping table from the logical block to the physical block can be saved to the basic data area corresponding to different write buffers. After detecting that the data in the write buffer is full, the data is flushed to the flash memory, that is, when the cached metadata reaches a certain amount, the change amounts and snapshots corresponding to the metadata are flushed. In this way, the latest state of the metadata can be saved in a relatively short time, and the flash write frequency can be reduced to a great extent, which helps to extend the service life of the flash memory.
[0065] An embodiment of the present application also provides a data recovery device, as Figure 1 a specific implementation of the method shown, as Figure 4 shown, the device includes: a saving module 31, a marking module 32, and a restoring module 33.
[0066] The saving module 31 is configured to save the snapshot corresponding to the metadata and the logical block addresses of the change amounts in the metadata in response to receiving a power-off instruction;
[0067] The marking module 32 is configured to mark the target identifiers corresponding to the change amounts of the logical block addresses respectively according to the number of times the logical block address is saved, and the target identifier is used to identify whether the change amount is effective;
[0068] A recovery module 33, configured to, in response to receiving a power-on instruction, restore metadata using a snapshot and restore valid changed amounts in the metadata according to a target identifier.
[0069] In some examples of this embodiment, the marking module 32 is specifically configured to determine whether the save count of a logical block address is greater than a preset count; if the save count of the logical block address is greater than the preset count, mark the target identifier of the latest changed amount corresponding to the logical block address as valid and mark the target identifier of the historical changed amount corresponding to the logical block address as invalid; if the save count of the logical block address is less than or equal to the preset count, mark the target identifier of the latest changed amount corresponding to the logical block address as valid.
[0070] In some examples of this embodiment, the saving module 31 is further specifically configured to create a write buffer in a double data rate memory using a log manager; save a snapshot to a base data area of the write buffer; save the logical block address of the changed amount to a variable area of the write buffer.
[0071] In some examples of this embodiment, the saving module 31 is specifically configured to save the snapshot corresponding to the mapping table from logical blocks to physical blocks to the base data areas corresponding to different write buffers according to the capacity of the base data area; save the changed amount and the logical block address of the changed amount to the variable area according to the generation time of the changed amount.
[0072] In some examples of this embodiment, the saving module 31 is further specifically configured to store the target identifier corresponding to the changed amount using a bitmap corresponding to the write buffer; when it is detected that the write buffer is full, flush the data corresponding to the write buffer to the flash memory.
[0073] In some examples of this embodiment, the determination module 32 is specifically configured to read a snapshot from the flash memory and restore the metadata to a corresponding position in the double data rate memory using the snapshot.
[0074] In some examples of this embodiment, the recovery module 33 is specifically configured to read the bitmap corresponding to the write buffer from the flash memory; determine the changed amounts with the target identifier in the bitmap as valid changed amounts; perform patching processing on the metadata corresponding to the snapshot according to the positions of the valid changed amounts in the double data rate memory to obtain the metadata after power-on.
[0075] It should be noted that for other corresponding descriptions of each functional unit involved in a data recovery device provided in this embodiment, reference can be made to the corresponding description in Figure 1 and details are not described herein again.
[0076] Based on the above as Figure 1The method described above, correspondingly, this embodiment also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the method as described above Figure 1 shown.
[0077] Based on the method as described above Figure 1 shown, correspondingly, this embodiment also provides a computer program product, on which a computer program is stored, and when the computer program is executed by a processor, it implements the method as described above Figure 1 shown.
[0078] Based on such an understanding, the technical solution of this application can be embodied in the form of a software product, and this software product can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of various implementation scenarios of this application.
[0079] Based on the method as described above Figure 1 shown, and Figure 4 the virtual device embodiment shown, in order to achieve the above object, this embodiment of this application also provides an electronic device, such as a personal computer or a server, and this device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to implement the method as described above Figure 1 shown.
[0080] In some embodiments, the above-mentioned physical device may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, sensors, an audio circuit, a WI-FI module, and so on. The user interface may include a display screen (Display), an input unit such as a keyboard (Keyboard), etc., and optionally the user interface may further include a USB interface, a card reader interface, etc. The network interface may include a standard wired interface, a wireless interface (such as a WI-FI interface), etc. in some embodiments.
[0081] Those skilled in the art can understand that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and it may include more or fewer components, or combine certain components, or have different component arrangements.
[0082] The storage medium may further include an operating system and a network communication module. The operating system is a program for managing the hardware and software resources of the above-mentioned physical device, and supports the operation of an information processing program and other software and / or programs. The network communication module is used to implement communication between various components inside the storage medium, and communication with other hardware and software in the information processing physical device.
[0083] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or can also be implemented by hardware. By applying the solution of this embodiment, compared with the current existing technologies, in response to receiving a power-off instruction, this embodiment can first save the snapshot corresponding to the metadata and the change amount in the metadata; then, according to the save times of the logical block address, mark the target identifiers of the change amounts respectively corresponding to the logical block addresses, and the target identifiers are used to identify whether the change amounts are valid; in response to receiving a power-on instruction, then determine the valid change amounts in the change amounts according to the target identifiers; finally, use the snapshot and the valid change amounts to restore the metadata. In this way, during the power-on process of the solid-state drive, only the restoration operation of the valid change amounts is performed, reducing the number of change amounts that need to be restored, reducing the restoration operation of the invalid change amounts, thereby reducing the data restoration time and reducing the power-on time of the solid-state drive. In addition, according to the capacity of the basic data area, the snapshot corresponding to the mapping table from the logical block to the physical block can be saved to the basic data areas corresponding to different write buffers, and after detecting that the data in the write buffer is full, the data is flushed to the flash memory, that is, when the cached metadata reaches a certain amount, the change amounts and snapshots corresponding to the metadata are flushed, so that the latest state of the metadata can be saved in a relatively short time, and the flash write frequency can be reduced to a great extent, which helps to extend the service life of the flash memory.
[0084] It should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.
[0085] The above are only the specific embodiments of the present application, enabling those skilled in the art to understand or implement the present application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments herein, but will conform to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A data recovery method, characterized in that, including: responding to receiving a power-down instruction, saving a snapshot corresponding to metadata, and a logical block address of a change amount in the metadata; marking target identifiers corresponding to the change amounts respectively corresponding to the logical block addresses according to the save times of the logical block addresses, where the target identifiers are used to identify whether the change amounts are valid; responding to receiving a power-on instruction, restoring the metadata using the snapshot, and restoring valid change amounts in the metadata according to the target identifiers.
2. The method according to claim 1, characterized in that, The marking the target identifiers corresponding to the change amounts respectively corresponding to the logical block addresses according to the save times of the logical block addresses includes: judging whether the save times of the logical block addresses are greater than a preset number of times; if the save times of the logical block addresses are greater than the preset number of times, marking the target identifier of the latest change amount corresponding to the logical block address as valid, and marking the target identifier of the historical change amount corresponding to the logical block address as invalid; if the save times of the logical block addresses are less than or equal to the preset number of times, marking the target identifier of the latest change amount corresponding to the logical block address as valid.
3. The method according to claim 2, wherein Before the responding to receiving a power-down instruction, saving a snapshot corresponding to metadata, and a logical block address of a change amount in the metadata, the method further includes: creating a write buffer in a double data rate memory using a log manager; The saving a snapshot corresponding to metadata, and a logical block address of a change amount in the metadata includes: saving the snapshot to a basic data area of the write buffer; saving the logical block address of the change amount to a variable area of the write buffer.
4. The method according to claim 3, characterized in that The saving the snapshot to a basic data area of the write buffer includes: saving a snapshot corresponding to a mapping table from logical blocks to physical blocks to basic data areas corresponding to different write buffers according to the capacity of the basic data area; The saving the logical block address of the change amount to a variable area of the write buffer includes: saving the change amount and the logical block address of the change amount to the variable area according to the generation time of the change amount.
5. The method according to claim 3, wherein The method further includes: storing the target identifier corresponding to the change amount using a bitmap corresponding to the write buffer; when it is detected that the write buffer is full, flushing data corresponding to the write buffer to a flash memory.
6. The method according to claim 5, characterized in that, The restoring the metadata using the snapshot includes: reading the snapshot from the flash memory, and restoring the metadata to a corresponding position in the double data rate memory using the snapshot.
7. The method according to claim 5, characterized in that, The restoring valid change amounts in the metadata according to the target identifiers includes: reading the bitmap corresponding to the write buffer from the flash memory; determining change amounts with target identifiers being valid in the bitmap as the valid change amounts; performing patching processing on the metadata corresponding to the snapshot according to positions of the valid change amounts in the double data rate memory to obtain metadata after power-on.
8. A data recovery device, characterized in that, including: a saving module configured to respond to receiving a power-down instruction, save a snapshot corresponding to metadata, and a logical block address of a change amount in the metadata; A marking module, configured to mark a target identifier of a change amount corresponding to the logical block address respectively according to the number of times the logical block address is saved, where the target identifier is used to identify whether the change amount is valid; A recovery module, configured to, in response to receiving a power-on instruction, recover the metadata by using the snapshot, and recover valid change amounts in the metadata according to the target identifier.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.