CN117891657A - Data recovery method and device, electronic equipment and storage medium - Google Patents

Data recovery method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117891657A
CN117891657A CN202410064987.7A CN202410064987A CN117891657A CN 117891657 A CN117891657 A CN 117891657A CN 202410064987 A CN202410064987 A CN 202410064987A CN 117891657 A CN117891657 A CN 117891657A
Authority
CN
China
Prior art keywords
data
hard disk
stored
target
mechanical hard
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410064987.7A
Other languages
Chinese (zh)
Inventor
滕杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Yaxin Software Co ltd
Original Assignee
Nanjing Yaxin Software Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Yaxin Software Co ltd filed Critical Nanjing Yaxin Software Co ltd
Priority to CN202410064987.7A priority Critical patent/CN117891657A/en
Publication of CN117891657A publication Critical patent/CN117891657A/en
Pending legal-status Critical Current

Links

Abstract

The embodiment of the application provides a data recovery method, a data recovery device, electronic equipment and a storage medium, and relates to the technical field of computers. The data recovery method comprises the following steps: responding to a data recovery request for a mechanical hard disk, and determining data to be recovered in a target cache region based on data difference between the mechanical hard disk and the correspondingly configured target cache region; the target cache area is configured by utilizing a solid state disk and is used for caching data to be stored in the mechanical hard disk; writing the data to be recovered into the mechanical hard disk so as to recover the data to be recovered in the mechanical hard disk. According to the scheme, when temporary faults such as power failure and the like occur in the mechanical hard disk, the occurrence of data loss can be avoided, and therefore the integrity of data written into the mechanical hard disk can be ensured.

Description

Data recovery method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data recovery method, a data recovery device, an electronic device, and a storage medium.
Background
As a conventional common hard disk, a mechanical hard disk (HARD DISK DRIVE, HDD) is widely used because of its advantages such as low price and large storage capacity. When the HDD is used for storing data, the data to be stored is written into a buffer area of the HDD, and then the data to be stored is transferred from the buffer area of the HDD to the HDD. In the data storage process, if the HDD has temporary faults such as power failure, the data to be stored written into the buffer area of the HDD is lost, so that at least part of the data in the data to be stored cannot be stored into the HDD, and the data loss condition is caused.
Therefore, how to avoid the occurrence of data loss when using the HDD to store data is a technical problem to be solved by related technicians.
Disclosure of Invention
The embodiment of the application provides a data recovery method, a data recovery device, electronic equipment and a storage medium, which are used for solving one or more of the technical problems.
In a first aspect, an embodiment of the present application provides a data recovery method, including:
Responding to a data recovery request aiming at the mechanical hard disk, and determining data to be recovered in a target cache region based on the data difference between the mechanical hard disk and the correspondingly configured target cache region; the target cache region is configured by utilizing a solid state disk and is used for caching data to be stored in the mechanical hard disk.
In a second aspect, an embodiment of the present application provides a data recovery apparatus, including:
The to-be-recovered data determining module is used for responding to a data recovery request aiming at the mechanical hard disk, and determining to-be-recovered data in the target cache area based on the data difference between the mechanical hard disk and the correspondingly configured target cache area; the target cache area is configured by utilizing a solid state disk and is used for caching data to be stored in the mechanical hard disk;
And the data recovery module is used for writing the data to be recovered into the mechanical hard disk so as to recover the data to be recovered in the mechanical hard disk.
In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory, where the processor implements the method provided by any embodiment of the present application when the computer program is executed.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having a computer program stored therein, the computer program when executed by a processor implementing a method provided by any of the embodiments of the present application.
Compared with the prior art, the application has the following advantages:
according to the technical scheme, the data to be stored in the mechanical hard disk are cached in the target cache area, and the target cache area is configured for the mechanical hard disk by utilizing the solid state hard disk, so that even if temporary faults such as power failure occur in the mechanical hard disk in the process of storing the data to be stored in the mechanical hard disk, at least part of the data in the data to be stored cannot be successfully stored in the mechanical hard disk, and corresponding data to be stored still can be cached in the target cache area. In this case, after the temporary faults such as power failure are solved and the mechanical hard disk is restarted and operated, at least part of the data to be stored which is not successfully stored in the mechanical hard disk will become difference data between the mechanical hard disk and the corresponding configured target buffer zone. At this time, by aiming at the data recovery request, based on the data difference between the mechanical hard disk and the corresponding configured target cache region, determining the data to be recovered in the target cache region, and writing the data to be recovered into the mechanical hard disk, so as to recover the data to be recovered in the mechanical hard disk, that is, at least part of the data which is not successfully stored in the mechanical hard disk in the data to be stored can be restored in the mechanical hard disk. Therefore, the technical scheme of the application can avoid the occurrence of the data loss condition when the mechanical hard disk has temporary faults such as power failure and the like, thereby ensuring the integrity of the data written into the mechanical hard disk.
The foregoing summary is for the purpose of the specification only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features of the present application will become apparent by reference to the drawings and the following detailed description.
Drawings
In the drawings, the same reference numerals refer to the same or similar parts or elements throughout the several views unless otherwise specified. The figures are not necessarily drawn to scale. It is appreciated that these drawings depict only some embodiments according to the disclosure and are not therefore to be considered limiting of its scope.
Fig. 1 is a schematic diagram illustrating an application process of a data recovery method according to an embodiment of the present application;
FIG. 2 is a flow chart of a method for recovering data provided in an embodiment of the present application;
FIG. 3 is a schematic diagram of a data recovery device according to an embodiment of the present application; and
Fig. 4 shows a block diagram of an electronic device for implementing an embodiment of the application.
Detailed Description
Hereinafter, only certain exemplary embodiments are briefly described. As will be recognized by those skilled in the pertinent art, the described embodiments may be modified in numerous different ways without departing from the spirit or scope of the present application. Accordingly, the drawings and description are to be regarded as illustrative in nature, and not as restrictive.
In order to facilitate understanding of the technical solutions of the embodiments of the present application, the following describes related technologies of the embodiments of the present application. The following related technologies may be optionally combined with the technical solutions of the embodiments of the present application, which all belong to the protection scope of the embodiments of the present application.
The embodiment of the application relates to a data recovery scheme, which is used for responding to a data recovery request aiming at a mechanical hard disk, determining data to be recovered in a target cache area based on the data difference between the mechanical hard disk and the correspondingly configured target cache area, and writing the data to be recovered into the mechanical hard disk so as to recover the data to be recovered in the mechanical hard disk. The target cache region is configured by using a Solid state disk (Solid-STATE DRIVE, SSD) and is used for caching data to be stored in the mechanical hard disk.
Specifically, in the case of configuring the HDD with the SSD for caching data to be stored, the process of storing the data to be stored to the HDD is: firstly caching data to be stored in an SSD, then writing the data to be stored into a cache area of the HDD from the SSD, and finally transferring the data to be stored into the HDD from the cache area of the HDD.
If temporary faults such as power failure occur in the HDD (or the HDD and the SSD) during the process of storing the data to be stored in the HDD, the data to be stored written in the buffer area of the HDD is lost, so that at least part of the data to be stored cannot be stored in the HDD temporarily, and at this time, the at least part of the data cannot be stored in the HDD. However, since the target buffer is configured for the HDD by using the SSD, the data stored in the SSD is not lost due to the occurrence of a temporary failure such as a power failure, and therefore, even if the temporary failure such as a power failure occurs, the data to be stored is still stored in the SSD. In this way, after the temporary faults such as power failure are solved and the HDD (or the HDD and the SSD) is restarted and operated, at least part of the data to be stored which is not successfully stored in the HDD becomes difference data between the HDD and the target buffer area correspondingly configured.
After the temporary faults such as power failure are solved, and the HDD (or the HDD and the SSD) is restarted and operated, if the data recovery request can be aimed, determining data to be recovered in the target cache area based on the data difference between the HDD and the corresponding configured target cache area, and writing the data to be recovered into the HDD so as to recover the data to be recovered in the HDD, namely, at least part of the data which is not successfully stored in the HDD in the data to be stored can be restored to the HDD. Therefore, when the HDD has temporary faults such as power failure, the occurrence of data loss can be avoided, and the integrity of data written into the HDD can be ensured.
In the embodiment of the present application, the execution body related to the data recovery scheme may be a hardware device (such as a server and a terminal device) with a data recovery function, and in particular, in the embodiment of the present application, the execution body of the data recovery scheme is not limited in particular.
In the embodiment of the application, the data recovery request for the mechanical hard disk can be a data recovery request issued by an execution body (such as a server and terminal equipment) for the HDD by oneself after the temporary faults of the HDD such as power failure and the like are solved, and the HDD is restarted and operated. The data recovery request for the mechanical hard disk may be a data recovery request sent to the execution body (such as a server and a terminal device) by a related person through an electronic device after the HDD is restarted and operated after a temporary failure such as a power failure of the HDD is solved.
The buffer configured for the HDD by the SSD is referred to as a target buffer for convenience of distinction from the buffer of the HDD itself.
In the embodiment of the application, the target cache area can be divided into a metadata area and a data cache area. The metadata area is used for storing metadata corresponding to the data to be stored, and the data cache area is used for caching the data to be stored. Specifically, metadata is used at least to describe: the data storage device comprises a total storage space corresponding to a data cache region, an used storage space corresponding to the data cache region, an available storage space corresponding to the data cache region, storage addresses respectively corresponding to a plurality of data in the data to be stored in the data cache region, storage addresses respectively allocated to a plurality of data in the data to be stored in an HDD (hard disk drive), data states respectively corresponding to the plurality of data and the like.
And the data states corresponding to the data are used for representing the data synchronization condition corresponding to each data in the data. In an example, the data states are identified based on a data state flag, where the data state flag includes three states, synchronized, unsynchronized, and invalid. The synchronized is used for identifying that the data is synchronized to the HDD, the unsynchronized is used for identifying that the data is not synchronized to the HDD, and the invalid identifying data is temporarily unable to perform data synchronization.
In an example, the data to be stored is stored in the target buffer in the form of a log, and at this time, the existence form of each data in the data to be stored in the target buffer is a log buffer record, that is, each log buffer record corresponds to one data in the data to be stored. In this case, the metadata is also used to describe the maximum number of log cache records that the data cache area can store, the number of log cache records that have been used, the number of cache records that have been allocated, the number of cache records that have not been used, and the number of cache records to be released. Specifically, the maximum log buffer record number is used to represent the maximum number of log buffer records that can be buffered in the data buffer area, and one log buffer record generally corresponds to one data. The number of log cache records that have been used is used to represent the number of log cache records that have been stored in the data cache region (i.e., the number of data that have been stored). The cache record number refers to a pre-configured ID (Identity Document, dedicated number) for the maximum number of log cache records, for example, the maximum number of log cache records is 100, and then the cache record number may be 0-99. In the process of storing the data to be stored in the target cache region in the log format, corresponding cache record numbers are sequentially allocated to each data (log cache record corresponding to each data) in the data to be stored in the cache according to the sequence of the cache time from front to back.
In the embodiment of the application, the process of writing the data to be stored into the target cache area is as follows: after receiving a data writing request for specified data in data to be stored, judging whether available storage space exists in a target cache area, if so, calculating the storage space required by storing the specified data according to the data offset corresponding to the data to be stored, and distributing corresponding storage addresses for the specified data in the available storage space of the target cache area so as to write the specified data into the corresponding storage addresses.
In the process of storing the data to be stored in the target cache area in a log format, a cache record number is allocated to the specified data, a storage address where metadata corresponding to the specified data is located is found according to the allocated cache record number, and after the storage address where the metadata corresponding to the specified data is located is found, the metadata corresponding to the specified data can be updated. Specifically, the cache record number corresponding to the specified data, the storage address corresponding to the specified data in the data cache area, and the like may be updated into the corresponding metadata, and the data state of the specified data may be configured as invalid in the corresponding metadata. In addition, after the specified data is written into the data buffer, the data state of the specified data needs to be further configured to be unsynchronized, and at this time, the specified data is converted into unsynchronized data.
In the embodiment of the application, the process of executing the cache release operation is as follows: firstly, searching synchronized data in a target cache region, and sequentially executing a cache release operation for a plurality of data in the synchronized data. After the data is synchronized from the target cache to the HDD, the corresponding data state is marked as synchronized, at which point the data is converted to synchronized data. In the case of data conversion into synchronized data, the data is the object for which the cache release operation is directed.
In the case of storing data to be stored in the target buffer in the log format, after synchronizing the data from the target buffer to the HDD, since the data is converted into synchronized data, that is, an object for which the cache release operation is directed, the cache record number corresponding to the data can be regarded as the cache record number to be released.
Under the condition that data to be stored are stored in a target cache area in a log format, in the process of executing the cache release operation, the cache record number to be released is searched first. Since the data to be stored is sequentially allocated with corresponding buffer record numbers for each data in the data buffer to be stored in the order from front to back according to the buffer time in the process of storing the data in the target buffer in the log format, and after the data is synchronized from the target buffer to the HDD, the data is converted into synchronized data, and the buffer record number corresponding to the data is used as the buffer record number to be released, each buffer record number to be released corresponds to one log buffer record (i.e. corresponds to one synchronized data) to be subjected to the buffer release operation. Thus, in the event that the cache record number to be released is found, the log cache record of the cache release operation to be performed (i.e., the synchronized data is determined) can be determined.
In order to more clearly show the data recovery method provided in the embodiment of the present application, first, an application example of the data recovery method provided in the embodiment of the present application is described, where the data recovery method is applied to data recovery of application data, and in this case, the data to be stored and the data to be recovered are both application data. The specific implementation process of this application example can refer to fig. 1, and the illustrated data recovery process is as follows:
In order to store the application data to the HDD, it is necessary to buffer the application data to the SSD, then write the application data from the SSD to the HDD-owned buffer, and finally transfer the application data from the HDD-owned buffer to the HDD. In the process of transferring application data from a cache area of the HDD to the HDD, if the HDD (or the HDD and the SSD) has a power failure, at least part of the application data cannot be stored to the HDD temporarily. In this case, after the HDD (or HDD and SSD) is powered on again, the server side may issue a data recovery request for the HDD, determine data to be recovered in the target buffer based on a data difference between the mechanical hard disk and the correspondingly configured target buffer in response to the data recovery request, and further write the data to be recovered to the mechanical hard disk, so as to recover the data to be recovered in the mechanical hard disk.
Because the target cache area is configured for the HDD by using the SSD, the data stored in the SSD cannot be lost due to temporary faults such as power failure, namely, the target cache area stores application data. Therefore, when the HDD (or the HDD and the SSD) is powered on again, at least part of the application data that is temporarily not successfully stored in the HDD becomes difference data between the HDD and the target buffer area correspondingly configured. In this way, by determining the data to be recovered in the target buffer area and further writing the data to be recovered into the mechanical hard disk, at least part of data which is temporarily unsuccessfully stored in the HDD in the application data can be restored to the HDD, so that when temporary faults such as power failure and the like occur in the HDD, the occurrence of data loss can be avoided, and the integrity of the data written into the HDD can be further ensured.
It should be noted that, the above application examples of the data recovery method provided in the embodiments of the present application are for ease of understanding and are not intended to limit the data recovery method provided in the embodiments of the present application. Specifically, an application scenario of the data recovery method provided in the embodiment of the present application is not specifically limited.
The following describes the technical scheme of the present application and how the technical scheme of the present application solves the above technical problems in detail with specific embodiments. The following related technologies may be optionally combined with the technical solutions of the embodiments of the present application, which all belong to the protection scope of the embodiments of the present application, and the same or similar concepts or processes may not be described in some embodiments.
Fig. 2 shows a flow chart of a data recovery method 200 provided in an embodiment of the application, which may include steps S201-S202.
In step S201, in response to a data recovery request for the mechanical hard disk, determining data to be recovered in the target cache region based on a data difference between the mechanical hard disk and the correspondingly configured target cache region; the target cache region is configured by utilizing a solid state disk and is used for caching data to be stored in the mechanical hard disk.
In the embodiment of the application, the data recovery request for the mechanical hard disk can be a data recovery request issued by an execution body (such as a server and terminal equipment) for the HDD by oneself after the temporary faults of the HDD such as power failure and the like are solved, and the HDD is restarted and operated. The data recovery request for the mechanical hard disk may be a data recovery request sent to the execution body (such as a server and a terminal device) by a related person through an electronic device after the HDD is restarted and operated after a temporary failure such as a power failure of the HDD is solved.
If temporary faults such as power failure occur in the HDD (or the HDD and the SSD) during the process of storing the data to be stored in the HDD, the data to be stored written in the buffer area of the HDD is lost, so that at least part of the data to be stored cannot be stored in the HDD temporarily, and at this time, the at least part of the data cannot be stored in the HDD. However, the target buffer area is configured for the HDD by using the SSD, and the data stored in the SSD is not lost due to the occurrence of temporary faults such as power failure, so that the temporary faults such as power failure of the HDD are solved, and at least part of the data to be stored which is not successfully stored in the HDD after the HDD is restarted and operated, namely, the difference data between the HDD and the correspondingly configured target buffer area.
In one possible implementation manner, in order to determine the data to be recovered in the target cache area more accurately and efficiently, when determining the data to be recovered in the target cache area based on the data difference between the mechanical hard disk and the corresponding configured target cache area, the synchronized data in the target cache area and the stored data in the mechanical hard disk may be compared first to determine the target difference data, and then the target difference data is determined to be the data to be recovered. Wherein the synchronized data comprises data whose data state is marked as synchronized to the mechanical hard disk.
Specifically, for the data (i.e., unsynchronized data) marked as being not synchronized to the HDD in the data to be stored, after the temporary faults such as power failure of the HDD are solved, the HDD is restarted and operated, and then the data synchronization operation is continued. For the data (i.e., synchronized data) with the data state marked as synchronized to the HDD in the data to be stored, after temporary faults such as power failure of the HDD are solved, the HDD is restarted and operated, and if a data recovery request for the mechanical hard disk is not received, the data synchronization operation is not continued again. It follows that for data whose data state is marked as not synchronized to the HDD (i.e., unsynchronized data) in the data to be stored, it is not necessary to be the object of data recovery. In addition, since the HDD has a temporary failure such as power failure, the data lost by the HDD (i.e., the data to be restored in the HDD) is generally data that has been transferred to the HDD-owned cache area among the data to be stored, but the HDD-owned cache area is not written to the HDD when the HDD has a temporary failure such as power failure. That is, the data lost by the HDD (i.e., the data that needs to be recovered in the HDD) is typically at least part of the synchronized data.
Based on the above analysis, the target difference data is determined by comparing the synchronized data in the target buffer area with the stored data in the mechanical hard disk, and then the target difference data is determined as the data to be recovered, so that the data to be recovered can be accurately determined generally, and the efficiency of determining the data to be recovered is higher because only the synchronized data in the target buffer area and the stored data in the mechanical hard disk need to be compared.
In one possible implementation manner, when comparing the synchronized data in the target buffer area with the stored data in the mechanical hard disk, and determining the target difference data, the multiple data may be compared with the stored data sequentially from back to front according to the data storage time sequence corresponding to the multiple data in the synchronized data, so as to determine the target difference data.
The data storage time sequence corresponding to the plurality of data in the synchronized data refers to the time sequence of caching the plurality of data in the synchronized data into the target cache region. The step of comparing the plurality of data with the stored data sequentially from back to front means that the data which is cached in the target cache area in the plurality of data is compared with the stored data.
Because the later the data buffered in the target buffer is, the later the time of being transferred to the buffer of the HDD, the less likely the corresponding data is stored in the HDD from the buffer of the HDD when temporary faults such as power failure occur in the HDD. That is, the more likely that data that is later buffered in the target buffer among the synchronized data will become data lost by the HDD (i.e., data that needs to be restored in the HDD) when a temporary failure such as a power failure occurs in the HDD. Therefore, according to the data storage time sequence corresponding to the plurality of data in the synchronized data, the plurality of data are sequentially compared with the stored data from back to front, the target difference data are determined, and the determination efficiency and accuracy of the target difference data can be improved.
In an example, data to be stored is stored in the target buffer area in a log form, and in the process of storing the data to be stored in the target buffer area in a log form, corresponding buffer record numbers are sequentially allocated to each data (log buffer record corresponding to each data) in the data buffer to be stored according to the sequence of the buffer time from front to back. In this case, according to the buffer record numbers corresponding to the respective data in the data buffer to be stored, the data storage time sequence corresponding to the plurality of data in the data buffer to be stored can be determined, and correspondingly, when the plurality of data are sequentially compared with the stored data from back to front according to the data storage time sequence corresponding to the plurality of data in the synchronized data, the data storage time sequence corresponding to the plurality of data in the synchronized data can be determined according to the buffer record numbers corresponding to the plurality of data in the synchronized data when the target difference data is determined.
Specifically, since in the case of storing data to be stored in the target cache area in the log format, when the cache record number to be released is found, the log cache record of the cache release operation to be performed (i.e., the synchronized data is determined) can be determined. Therefore, after the cache record number to be released is found, the plurality of data can be sequentially compared with the stored data from back to front according to the current cache record number to be released so as to determine the target difference data.
In addition, before the data comparison, the data state of the data needs to be read, if the data state of the data is synchronized, the data is proved to be synchronized to the log cache record (i.e. the synchronized data) in the HDD self-contained cache region, and at this time, the data needs to be compared with the stored data. If the data state of the data is invalid, the buffer record number corresponding to the data is not the buffer record number to be released, and meanwhile, the buffer record number before the buffer record number corresponding to the data is not the buffer record number to be released, in this case, the log buffer record corresponding to the corresponding buffer record number is not synchronized to the log buffer record (i.e. synchronized data) in the HDD self-contained buffer zone, and at this time, the data comparison needs to be stopped and the confirmation of the data to be recovered is completed.
In an example, to save resources required for data recovery and improve the confirmation efficiency of the data to be recovered, in the process of comparing the synchronized data in the target cache area with the stored data in the mechanical hard disk, determining the target difference data, continuously determining whether the data storage space required by the current difference data reaches the available storage space of the HDD, and stopping comparing the synchronized data in the target cache area with the stored data in the mechanical hard disk when the data storage space required by the different data reaches the available storage space of the HDD, and taking the current difference data as the target difference data.
In one possible implementation manner, when comparing the plurality of data with the stored data sequentially from back to front to determine the target difference data, the corresponding metadata can be read in the target cache area for the target data in the plurality of data first so as to determine the storage address allocated to the target data in the mechanical hard disk. Then, whether the storage address stores data or not is determined, when the storage address does not store data, the stored data can be directly determined that the stored data does not contain target data, the target data is added to target difference data, when the storage address stores data, the data stored by the storage address can be further read, the target data is compared with the data stored by the storage address, and when data difference exists between the target data and the data stored by the storage address, the corresponding difference data is added to the target difference data.
When the storage address does not store data, the target data in the synchronized data can be proved to be not successfully stored in the HDD, and in this case, the target data is directly added to the target difference data, so that the target difference data can be accurately and efficiently confirmed, and the data to be recovered can be accurately and efficiently confirmed. When the data is stored in the storage address, in order to accurately determine the target difference data, the target data and the data stored in the storage address need to be compared first, and the corresponding difference data is added to the target difference data only when the data difference exists between the target data and the data stored in the storage address.
In an example, before comparing the target data with the data stored in the storage addresses, it may be determined whether the storage addresses include the storage addresses corresponding to the compared data, and if so, when comparing the target data with the data stored in the storage addresses, only the data comparison needs to be performed with respect to other storage addresses in the storage addresses.
In one example, MD5 verification (Checksum) may be employed to achieve data alignment. However, in the embodiment of the present application, the comparison method adopted in the data comparison is not particularly limited.
After determining the data to be recovered, the data recovery method provided in the embodiment of the present application further executes step S202, where in step S202, the data to be recovered is written into the mechanical hard disk, so as to recover the data to be recovered in the mechanical hard disk.
The process of writing data to be restored to the HDD is as follows: writing the data to be recovered into the buffer memory of the HDD from the target buffer memory, and then transferring the data to be recovered from the buffer memory of the HDD to the HDD. In one example, the data to be stored is stored in the target cache in log form. In this case, when the data to be recovered is written to the mechanical hard disk, the data to be recovered may be written to the mechanical hard disk by means of log replay.
In addition, in order to make the target buffer area continuously available, after writing the data to be restored to the mechanical hard disk, a cache release operation needs to be performed in the target buffer area with respect to the data to be restored.
According to the data recovery method provided by the embodiment of the application, the data to be stored in the mechanical hard disk is cached in the target cache area, and the target cache area is configured for the mechanical hard disk by utilizing the solid state disk, so that even if temporary faults such as power failure occur in the mechanical hard disk in the process of storing the data to be stored in the mechanical hard disk, at least part of the data in the data to be stored cannot be successfully stored in the mechanical hard disk, and corresponding data to be stored still can be cached in the target cache area. In this case, at least part of the data to be stored, which is not successfully stored in the mechanical hard disk, is the difference data between the mechanical hard disk and the corresponding configured target cache region, and at this time, if the data recovery request is aimed at, the data to be recovered is determined in the target cache region based on the data difference between the mechanical hard disk and the corresponding configured target cache region, and the data to be recovered is written into the mechanical hard disk, so that the data to be recovered is recovered in the mechanical hard disk, and at least part of the data, which is not successfully stored in the mechanical hard disk, in the data to be stored is restored in the mechanical hard disk. Therefore, the data recovery method provided by the embodiment of the application can avoid the occurrence of the data loss condition when the mechanical hard disk has temporary faults such as power failure and the like, thereby ensuring the integrity of the data written into the mechanical hard disk.
Corresponding to the application example of the method and the data recovery method provided by the embodiment of the application, the embodiment of the application also provides a data recovery device. Referring to fig. 3, which is a block diagram illustrating a data recovery apparatus 300 according to an embodiment of the present application, the apparatus 300 may include:
The to-be-restored data determining module 301 is configured to determine to-be-restored data in a target cache region based on a data difference between the mechanical hard disk and the correspondingly configured target cache region in response to a data restoration request for the mechanical hard disk; the target cache area is configured by utilizing a solid state disk and is used for caching data to be stored in the mechanical hard disk;
the data recovery module 302 is configured to write the data to be recovered to the mechanical hard disk, so as to recover the data to be recovered in the mechanical hard disk.
In one possible implementation, the data to be restored determination module 301 includes:
The first data comparison sub-module is used for comparing the synchronized data in the target cache area with the stored data in the mechanical hard disk and determining target difference data; the synchronized data includes data whose data state is marked as synchronized to the mechanical hard disk;
and the data to be recovered determining submodule is used for determining the target difference data as the data to be recovered.
In one possible implementation, the first data alignment sub-module includes:
And the second data comparison sub-module is used for comparing the plurality of data with the stored data in sequence from back to front according to the data storage time sequence corresponding to the plurality of data in the synchronized data, and determining target difference data.
In one possible implementation, the second data comparison submodule includes:
The storage address determining submodule is used for reading corresponding metadata in a target cache area aiming at target data in a plurality of data and determining a storage address allocated to the target data in the mechanical hard disk;
The first difference data determining sub-module is used for determining that the stored data does not contain target data when the storage address does not store the data, and adding the target data to the target difference data.
In one possible implementation, the second data comparison sub-module further includes:
The data reading sub-module is used for reading the data stored in the storage address when the data is stored in the storage address;
The third data comparison sub-module is used for comparing the target data with the data stored by the storage address;
and the second difference data determining sub-module is used for adding corresponding difference data to the target difference data when the data difference exists between the target data and the data stored in the storage address.
In one possible implementation, the data to be stored is stored in the target buffer area in the form of a log; the data recovery module 302 includes:
And the data writing sub-module is used for writing the data to be recovered into the mechanical hard disk in a log replay mode.
In one possible implementation, the apparatus further includes:
And the cache release module is used for executing cache release operation on the data to be restored in the target cache area after the data to be restored is written into the mechanical hard disk.
The functions of each module in each device of the embodiment of the present application may be referred to the corresponding descriptions in the above methods, and have corresponding beneficial effects, which are not described herein.
Fig. 4 is a block diagram of an electronic device for implementing an embodiment of the application. As shown in fig. 4, the electronic device includes: a memory 401 and a processor 402, the memory 401 stores a computer program executable on the processor 402. The processor 402, when executing the computer program, implements the methods of the above-described embodiments. The number of memories 401 and processors 402 may be one or more.
The electronic device further includes:
And the communication interface 403 is used for communicating with external equipment and carrying out data interaction transmission.
If the memory 401, the processor 402, and the communication interface 403 are implemented independently, the memory 401, the processor 402, and the communication interface 403 may be connected to each other by a bus and perform communication with each other. The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (PERIPHERAL COMPONENT INTERCONNECT, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The bus may be classified as an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in fig. 4, but not only one bus or one type of bus.
Alternatively, in a specific implementation, if the memory 401, the processor 402, and the communication interface 403 are integrated on a chip, the memory 401, the processor 402, and the communication interface 403 may complete communication with each other through internal interfaces.
The embodiment of the application provides a computer readable storage medium storing a computer program which, when executed by a processor, implements the method provided in the embodiment of the application.
The embodiment of the application also provides a chip, which comprises a processor and is used for calling the instructions stored in the memory from the memory and running the instructions stored in the memory, so that the communication equipment provided with the chip executes the method provided by the embodiment of the application.
The embodiment of the application also provides a chip, which comprises: the input interface, the output interface, the processor and the memory are connected through an internal connection path, the processor is used for executing codes in the memory, and when the codes are executed, the processor is used for executing the method provided by the application embodiment.
It should be appreciated that the processor may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), field programmable gate array (Field Programmable GATE ARRAY, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. A general purpose processor may be a microprocessor or any conventional processor or the like. It is noted that the processor may be a processor supporting an advanced reduced instruction set machine (ADVANCED RISC MACHINES, ARM) architecture.
Further, optionally, the memory may include a read-only memory and a random access memory, and may further include a nonvolatile random access memory. The memory may be volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), programmable ROM (PROM), erasable Programmable ROM (EPROM), electrically Erasable EPROM (EEPROM), or flash Memory, among others. Volatile memory can include random access memory (Random Access Memory, RAM), which acts as external cache memory. By way of example, and not limitation, many forms of RAM are available. For example, static random access memory (STATIC RAM, SRAM), dynamic random access memory (Dynamic Random Access Memory, DRAM), synchronous Dynamic Random Access Memory (SDRAM), double data rate synchronous dynamic random access memory (double DATA RATE SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (ENHANCED SDRAM, ESDRAM), synchronous link dynamic random access memory (SYNCHLINK DRAM, SLDRAM), and direct memory bus RAM (DR RAM).
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions in accordance with the present application are fully or partially produced. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. Computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present application. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present application, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
Any process or method description in a flowchart or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process. And the scope of the preferred embodiments of the present application includes additional implementations in which functions may be performed in a substantially simultaneous manner or in an opposite order from that shown or discussed, including in accordance with the functions that are involved.
Logic and/or steps represented in the flowcharts or otherwise described herein, e.g., a ordered listing of executable instructions for implementing logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions.
It is to be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, the various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the methods of the embodiments described above may be performed by a program that, when executed, comprises one or a combination of the steps of the method embodiments, instructs the associated hardware to perform the method.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing module, or each unit may exist alone physically, or two or more units may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules described above, if implemented in the form of software functional modules and sold or used as a stand-alone product, may also be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a magnetic or optical disk, or the like.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that various modifications and substitutions are possible within the scope of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (10)

1. A data recovery method, comprising:
Responding to a data recovery request for a mechanical hard disk, and determining data to be recovered in a target cache region based on data difference between the mechanical hard disk and the correspondingly configured target cache region; the target cache area is configured by utilizing a solid state disk and is used for caching data to be stored in the mechanical hard disk;
writing the data to be recovered into the mechanical hard disk so as to recover the data to be recovered in the mechanical hard disk.
2. The method of claim 1, wherein the determining data to be restored in the target cache based on a data difference between the mechanical hard disk and a correspondingly configured target cache comprises:
Comparing the synchronized data in the target cache area with the stored data in the mechanical hard disk to determine target difference data; the synchronized data comprises data with a data state marked as synchronized to the mechanical hard disk;
and determining the target difference data as the data to be recovered.
3. The method of claim 2, wherein the comparing the synchronized data in the target cache region with the stored data in the mechanical hard disk, determining target difference data comprises:
And sequentially comparing the plurality of data with the stored data from back to front according to the data storage time sequence corresponding to the plurality of data in the synchronized data, and determining the target difference data.
4. The method of claim 3, wherein the sequentially comparing the plurality of data with the stored data from back to front, determining the target variance data comprises:
For target data in the plurality of data, corresponding metadata is read in the target cache area, and a storage address allocated to the target data in the mechanical hard disk is determined;
when the storage address does not store data, determining that the stored data does not contain the target data, and adding the target data to the target difference data.
5. The method of claim 4, wherein the method further comprises:
When the storage address stores data, reading the data stored by the storage address;
comparing the target data with the data stored in the storage address;
when there is a data difference between the target data and the data stored at the storage address, corresponding difference data is added to the target difference data.
6. The method of claim 1, wherein the data to be stored is stored in the target cache area in a log form; the writing the data to be recovered to the mechanical hard disk comprises the following steps:
And writing the data to be recovered into the mechanical hard disk in a log replay mode.
7. The method of claim 1, wherein after the writing of the data to be restored to the mechanical hard disk, the method further comprises:
and executing a cache release operation for the data to be restored in the target cache region.
8. A data recovery apparatus comprising:
The system comprises a to-be-restored data determining module, a to-be-restored data restoring module and a restoring module, wherein the to-be-restored data determining module is used for responding to a data restoring request aiming at a mechanical hard disk, and determining to-be-restored data in a target cache area based on data difference between the mechanical hard disk and the correspondingly configured target cache area; the target cache area is configured by utilizing a solid state disk and is used for caching data to be stored in the mechanical hard disk;
and the data recovery module is used for writing the data to be recovered into the mechanical hard disk so as to recover the data to be recovered in the mechanical hard disk.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory, the processor implementing the method of any one of claims 1-7 when the computer program is executed.
10. A computer readable storage medium having stored therein a computer program which, when executed by a processor, implements the method of any of claims 1-7.
CN202410064987.7A 2024-01-16 2024-01-16 Data recovery method and device, electronic equipment and storage medium Pending CN117891657A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410064987.7A CN117891657A (en) 2024-01-16 2024-01-16 Data recovery method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410064987.7A CN117891657A (en) 2024-01-16 2024-01-16 Data recovery method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117891657A true CN117891657A (en) 2024-04-16

Family

ID=90639205

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410064987.7A Pending CN117891657A (en) 2024-01-16 2024-01-16 Data recovery method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117891657A (en)

Similar Documents

Publication Publication Date Title
US9778998B2 (en) Data restoration method and system
CN109614276B (en) Fault processing method and device, distributed storage system and storage medium
CN109542682B (en) Data backup method, device, equipment and storage medium
CN111383031B (en) Intelligent contract execution method and system in block chain and electronic equipment
US20060200500A1 (en) Method of efficiently recovering database
CN110753084B (en) Uplink data reading method, cache server and computer readable storage medium
CN110019063B (en) Method for computing node data disaster recovery playback, terminal device and storage medium
CN111125040A (en) Method, apparatus and storage medium for managing redo log
WO2014088655A1 (en) Consistency of data in persistent memory
CN111666046B (en) Data storage method, device and equipment
US20150067442A1 (en) Information processing apparatus and data repairing method
CN114385418A (en) Protection method, device, equipment and storage medium for communication equipment
CN110737716A (en) data writing method and device
CN117891657A (en) Data recovery method and device, electronic equipment and storage medium
CN113535095B (en) Data storage method, device and equipment for double storage pools and storage medium
US9235349B2 (en) Data duplication system, data duplication method, and program thereof
CN112346913A (en) Data recovery method, device, equipment and storage medium
CN111625199A (en) Method and device for improving reliability of data path of solid state disk, computer equipment and storage medium
CN112988469B (en) State backup method and device in alliance chain and electronic equipment
CN111984460B (en) Metadata recovery method and device
US20230045119A1 (en) Data access method and apparatus
CN117112311B (en) I/O driven data recovery method, system and device
US20230385148A1 (en) Proactive loss notification and handling in data storage devices
US20220083533A1 (en) Performing Operations based on Distributedly Stored Data
CN116248693A (en) Light-weight operation method and device for Raft consensus algorithm of block chain

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination