Data recovery method and device based on SMR disk, storage medium and electronic device
By restoring and replacing abnormal storage areas in SMR hard drives, the problem of unusable space after data deletion within a zone is solved, achieving more efficient storage space utilization and improving the space utilization rate and object storage recovery management efficiency of SMR hard drives.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2026-04-21
AI Technical Summary
When some data is deleted from an SMR hard drive's zone, the entire zone becomes unusable, resulting in wasted storage space. Existing file recovery methods are unable to effectively release invalid data blocks, leading to reduced space utilization.
When an abnormal data block occurs during the writing process, the abnormal storage area is identified, the abnormal data block is recovered and copied to the target storage area, and the abnormal storage area is replaced, thus enabling the simultaneous storage of multiple object files.
By restoring and replacing abnormal storage areas, hard disk space waste is reduced, the space utilization of SMR hard disks is improved, and the difficulty of object storage recovery management is reduced.
Smart Images

Figure CN115878381B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of file processing, and more specifically, to a data recovery method and apparatus, storage medium, and electronic device based on SMR disks. Background Technology
[0002] Shingled Magneting Recording (SMR) is a disk technology where adjacent tracks are partially overlapped sequentially, increasing storage density per unit of storage medium and reducing storage costs. SMR read behavior is the same as that of a regular disk, making it highly cost-effective for cloud storage applications primarily focused on video and image processing.
[0003] SMR hard drives only support sequential read / write operations within zones and can only delete entire zones. When partial data is deleted from a zone (i.e., it's actually marked as invalid), due to the SMR zone characteristics, the entire zone space cannot be reused. The space is categorized as used capacity, leading to reduced space utilization.
[0004] SMR hard drives write data sequentially using zones as the basic unit. If a zone is not filled with data blocks for a file object, it is reused to continue writing data blocks for the next file object, minimizing space waste. If an error occurs during the writing process, file recovery is required. Traditional file recovery methods use EC (Extended Recovery Capability) to calculate and recover corrupted data blocks from a zone and then restore them to a new zone. However, because the old zone still stores data blocks from the previous file object and cannot be released, invalid data exists in the old zone, resulting in wasted space. Summary of the Invention
[0005] This invention provides a data recovery method and apparatus, storage medium, and electronic device based on SMR disks, to at least solve the problem of wasted storage space in file storage in related technologies.
[0006] According to an embodiment of the present invention, a data recovery method based on an SMR disk is provided, comprising: when an abnormal data block occurs during the process of writing N+M data blocks of a target object file to N+M storage areas in a storage area set, the storage area to which the abnormal data block was written is determined as an abnormal storage area, wherein the target object file is any one of multiple object files that reuse the storage area set, the storage area set is set in an SMR disk, and M and N are both natural numbers greater than 1; recovering the data in the abnormal data block to obtain the target data block; copying the target data block and the normal data blocks already stored in the abnormal storage area to the target storage area, wherein the target storage area is a storage area other than the N+M storage areas; and replacing the abnormal storage area with the target storage area to simultaneously store multiple object files in the storage area set.
[0007] According to another embodiment of the present invention, a data recovery device based on an SMR disk is provided, comprising: a first writing module, configured to determine the storage area to which the abnormal data block was written as an abnormal storage area when an abnormal data block occurs during the process of writing N+M data blocks of a target object file to N+M storage areas in a storage area set, wherein the target object file is any one of multiple object files that reuse the storage area set, the storage area set is set in an SMR disk, and M and N are both natural numbers greater than 1; a first recovery module, configured to recover the data in the abnormal data block to obtain the target data block; a first copying module, configured to copy the target data block and the normal data blocks already stored in the abnormal storage area to the target storage area, wherein the target storage area is a storage area other than the N+M storage areas; and a first replacement module, configured to replace the abnormal storage area with the target storage area, so as to simultaneously store multiple object files in the storage area set.
[0008] In an exemplary embodiment, the apparatus further includes: a first establishment module, configured to establish a plurality of correspondences between the object files and the storage area set before determining the storage area to which the abnormal data block was written as an abnormal storage area when an abnormal data block occurs during the process of writing N+M data blocks of the target object file to N+M storage areas in the storage area set, wherein the correspondences include the storage relationship between each data block of each object file and each storage block in each of the storage areas.
[0009] In one exemplary embodiment, the apparatus further includes: a first determining module, configured to, when an abnormal data block occurs during the process of writing N+M data blocks of a target object file to N+M storage areas in a storage area set, determine the storage area to which the abnormal data block was written as an abnormal storage area, and then determine the length of each data block among the N+M data blocks of the target object file; and a second writing module, configured to write first preset data in the abnormal storage area using the length of each data block to complete the storage area set.
[0010] In an exemplary embodiment, the first recovery module includes a first recovery unit, configured to recover data in at least one of the abnormal data blocks, and obtain at least one of the target data blocks, when the number of abnormal data blocks is less than a preset number and the data in at least one of the abnormal data blocks is in a recoverable state.
[0011] In an exemplary embodiment, the first recovery unit includes: a first determining subunit, configured to determine data in other data blocks of the target object file, wherein the other data blocks are data blocks in the target object file other than the abnormal data blocks; and a first calculating subunit, configured to calculate at least one data in the abnormal data block based on the data in the other data blocks of the target object file, thereby obtaining at least one target data block.
[0012] In one exemplary embodiment, the first copying module includes: a first establishment unit for establishing the target storage region; a first copying unit for copying data from the target data block to a target storage block in the target storage region, wherein the position of the target storage block in the target storage region corresponds to the abnormal storage block of the abnormal data block in the abnormal storage region; and a second copying unit for copying normal data blocks already stored in the abnormal storage region to other storage blocks in the target storage region, wherein the position of the other storage blocks in the target storage region corresponds to the storage block of the normal data block in the abnormal storage region.
[0013] In one exemplary embodiment, the apparatus further includes: a first marking module, configured to mark a second preset data in a target storage block in the target storage area when the number of abnormal data blocks is greater than or equal to a preset number, or when the data in the abnormal data blocks is in an unrecoverable state, wherein the position of the target storage block in the target storage area corresponds to the abnormal storage block of the abnormal data blocks in the abnormal storage area.
[0014] According to yet another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.
[0015] According to yet another embodiment of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0016] This invention allows N+M object files to be simultaneously written into N+M corresponding storage areas in a storage area set. If an abnormal data block occurs during the writing process, the data in the abnormal data block is recovered to obtain the target data block. The target data block and all normal data blocks already stored in the abnormal storage area are copied to the target storage area. The abnormal storage area is then replaced with the target storage area, thus storing multiple object files simultaneously in the storage area set. This achieves the goal of simultaneously writing multiple object files into the storage area set and completely replacing any abnormal storage areas. Therefore, it solves the problem of wasted storage space in related technologies and reduces hard disk space waste. Attached Figure Description
[0017] Figure 1 This is a hardware structure block diagram of a mobile terminal for a data recovery method based on an SMR disk according to an embodiment of the present invention.
[0018] Figure 2 This is a flowchart of a data recovery method based on an SMR disk according to an embodiment of the present invention;
[0019] Figure 3 This is a schematic diagram illustrating the relationship between multiple object files and ZoneGroup according to an embodiment of the present invention;
[0020] Figure 4 This is a schematic diagram illustrating the file recovery process of multiple object files reusing the same ZoneGroup according to an embodiment of the present invention;
[0021] Figure 5 This is a flowchart illustrating the reuse of the same ZoneGroup by multiple object files according to an embodiment of the present invention;
[0022] Figure 6 This is a structural block diagram of a data recovery device based on an SMR disk according to an embodiment of the present invention. Detailed Implementation
[0023] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and examples.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0025] First, the relevant technologies involved in this invention will be explained:
[0026] EC, Erasure Code, is a technology that can take n original data sets, add m additional data sets (to store erasure codes), and then restore the original data from any n+m sets of data.
[0027] LBA, Logical Block Addressing, is a mode where parameters such as cylinder, head, and sector are not the actual physical parameters of the hard drive. When accessing the hard drive, the IDE controller translates the logical address determined by these parameters into the actual physical address of the hard drive.
[0028] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a data recovery method based on an SMR disk according to an embodiment of the present invention. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0029] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the SMR disk-based data recovery method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0030] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0031] This embodiment provides a data recovery method based on SMR disks. Figure 2 This is a flowchart of a data recovery method based on an SMR disk according to an embodiment of the present invention, as follows: Figure 2 As shown, the process includes the following steps:
[0032] In step S202, if an abnormal data block occurs during the process of writing N+M data blocks of the target object file to N+M storage areas in the storage area set, the storage area to which the abnormal data block was written is determined as an abnormal storage area. The target object file is any object file among multiple object files that reuse the storage area set. The storage area set is set in the SMR disk, and M and N are both natural numbers greater than 1.
[0033] Step S204: Recover the data in the abnormal data block to obtain the target data block;
[0034] Step S206: Copy the target data block and the normal data blocks already stored in the abnormal storage area to the target storage area, wherein the target storage area is the storage area other than N+M storage areas;
[0035] Step S208: Replace the abnormal storage area with the target storage area to store multiple object files simultaneously in the storage area set.
[0036] In this embodiment, the values of N and M can be flexibly set based on the actual reference scenario, where N can be a data block and M can be a check block. For example, an object file can be divided into 4+1 data blocks. The storage area set includes 4+1 storage areas.
[0037] In this embodiment, a file to be stored is divided into N object files. Each object file is further divided into 4+1 data blocks using a 4+1 redundancy pattern. Each data block is written to a Zone in an SMR disk data storage area. A set of N+M Zones is called a storage area set, ZoneGroup. The size of a data block can be 256MB, and one data block is written to a disk in one storage area.
[0038] In this embodiment, the storage areas in the storage area set can be obtained from different storage pools, racks, storage nodes, and SMR disks by the cloud storage metadata service. One ZoneGroup can correspond to multiple objects. During the recovery of abnormal data blocks, the data blocks of all objects in the abnormal storage zone can be fragmented for recovery. This involves copying the target data block and all normal data blocks already stored in the abnormal storage zone to the target storage zone, and then releasing the abnormal storage zone. This aims to reduce invalid data in the Zone, improve SMR disk space utilization, and reduce the difficulty of object storage recovery management.
[0039] In this embodiment, the reasons for data block writing failure include, but are not limited to, abnormal situations such as network jitter and program crashes.
[0040] The entity performing the above steps may be a terminal, a server, a specific processor set in the terminal or server, or a processor or processing device set up relatively independently of the terminal or server, but is not limited to these.
[0041] Through the above steps, N+M object files are simultaneously written to the corresponding N+M storage areas in the storage area set. If an abnormal data block occurs during the writing process, the data in the abnormal data block is recovered to obtain the target data block. The target data block and all normal data blocks already stored in the abnormal storage area are copied to the target storage area. The abnormal storage area is then replaced with the target storage area, thus storing multiple object files simultaneously in the storage area set. This achieves the goal of simultaneously writing multiple object files to the storage area set and completely replacing any abnormal storage areas. Therefore, it can solve the problem of wasted storage space in related technologies and reduce hard disk space waste.
[0042] In an exemplary embodiment, when an abnormal data block occurs during the process of writing N+M data blocks of a target object file to N+M storage areas in a storage area set, before determining the storage area to which the abnormal data block was written as an abnormal storage area, the method further includes: establishing a correspondence between multiple object files and the storage area set, wherein the correspondence includes the storage relationship between each data block of each object file and each storage block in each storage area. In this embodiment, the correspondence between multiple object files and the storage area set includes multiple object files simultaneously reusing the same storage area set. For example, as... Figure 3 As shown, a set of N+M Zones is called a ZoneGroup. The file to be stored is divided into multiple object files (Object1, Object2, ..., ObjectN). Each object file is further divided into 4+1 data blocks using a 4+1 redundancy pattern. Each data block corresponds to a storage block in a Zone of an SMR disk data storage area. Multiple data blocks from multiple object files can be written to storage blocks in multiple Zones simultaneously. This embodiment establishes a correspondence between multiple object files and a set of storage areas, allowing multiple object files to reuse the same set of storage areas simultaneously, significantly reducing disk space waste and improving disk space utilization.
[0043] In an exemplary embodiment, when an abnormal data block occurs during the process of writing N+M data blocks of a target object file to N+M storage areas in a storage area set, after determining the storage area where the abnormal data block was written as an abnormal storage area, the method further includes: determining the length of each data block among the N+M data blocks of the target object file; and writing first preset data into the abnormal storage area using the length of each data block to complete the storage area set. In this embodiment, the longest data block among the N+M data blocks can be written to fill in the storage areas in the ZoneGroup that contain shorter data blocks. This achieves the goal of maintaining the consistency of Zone lengths in the ZoneGroup. After completing the filling, the next data block of the object file can be written.
[0044] In one exemplary embodiment, recovering data from an abnormal data block to obtain a target data block includes: when the number of abnormal data blocks is less than a preset number, and the data in at least one abnormal data block is recoverable, recovering the data in at least one abnormal data block to obtain at least one target data block. In this embodiment, the preset number can be set based on the actual usage scenario, for example, setting the preset number to 1 or 2. Optionally, when the number of abnormal data blocks is less than the preset number, and the data in at least one abnormal data block is recoverable, recovering the data in at least one abnormal data block to obtain a target data block includes: determining the data in other data blocks in the target object file, wherein the other data blocks are data blocks in the target object file other than the abnormal data blocks; calculating the data in at least one abnormal data block based on the data in the other data blocks in the target object file to obtain at least one target data block. In this embodiment, the data of the abnormal data block can be calculated based on other normal data blocks in the target object file. This achieves the purpose of recovering the abnormal data block.
[0045] In one exemplary embodiment, copying both the target data block and the normal data blocks already stored in the abnormal storage region to the target storage region includes: establishing the target storage region; copying data from the target data block to a target storage block in the target storage region, wherein the position of the target storage block in the target storage region corresponds to the abnormal storage block of the abnormal data block in the abnormal storage region; and copying the normal data blocks already stored in the abnormal storage region to other storage blocks in the target storage region, wherein the positions of the other storage blocks in the target storage region correspond to the storage blocks of the normal data block in the abnormal storage region. In this embodiment, the target storage region can be pre-established or applied for from the SMR. For example, such as Figure 4As shown, multiple 4+1 written object files reuse the same ZoneGroup for file recovery. The third data block of object file Object2 encountered an error during the write process. After completion, it continued writing to the next object file, Object3. Since Object2 has been marked as an abnormal object file and meets the file recovery requirements (the number of corrupted data blocks does not exceed one), it needs to be recovered. The recovery method involves requesting the creation of a new target storage zone. Based on the position of the object file's data block in the abnormal storage zone, files are recovered sequentially according to LBA. Object1 and Object3 are normally written object files, and their block data is directly copied over. Object2 requires EC calculation, calculated based on the other four blocks of Object2. Finally, the recovered complete target storage zone replaces the abnormal storage zone, forming a new ZoneGroup with the other four zones. This achieves the goal of recovering the entire abnormal storage zone. By fragmenting all object blocks in a zone for recovery, invalid data in the zone is reduced, SMR disk space utilization is improved, and the difficulty of object storage recovery management is reduced. All object blocks on a Zone are migrated or restored to a new Zone, achieving overall data recovery of the entire Zone and releasing the entire Zone, thereby improving the space utilization of the SMR hard drive and enhancing the reliability of the entire distributed object storage data.
[0046] In one exemplary embodiment, the method further includes: marking a second preset data in a target storage block in the target storage area when the number of abnormal data blocks is greater than or equal to a preset number, or when the data in the abnormal data blocks is in an unrecoverable state, wherein the position of the target storage block in the target storage area corresponds to the abnormal storage block of the abnormal data blocks in the abnormal storage area. In this embodiment, unrecoverable object files can be filled with 0 by default in the target storage area Zone, meaning that the recovered invalid object files will still be invalid data, while satisfying the characteristic that SMR hard disk Zone space can only be written continuously.
[0047] The present invention will now be described in conjunction with specific embodiments:
[0048] This embodiment uses the scenario of reusing multiple object files and writing them into the same ZoneGroup as an example for illustration.
[0049] This embodiment is based on a distributed object system to globally manage the SMR hard disks on all storage nodes in the cloud storage cluster; it abstracts a storage area set ZoneGroup consisting of a group of N+M Zones based on SMR hard disks, where the storage areas Zone in ZoneGroup are obtained by the cloud storage metadata service from different storage pools, different racks, different storage nodes, and different SMR disks.
[0050] For example, such as Figure 3 As shown, the file to be stored is divided into multiple object files. Each object file is further divided into 4+1 data blocks using a 4+1 redundancy pattern. Each data block is written to a Zone in an SMR disk data storage area. A set of N+M Zones is called a ZoneGroup. Storing multiple object files on a ZoneGroup can greatly reduce disk space waste. When abnormal situations such as network jitter or program crashes occur, the writing of the object in progress may fail. When an object writing failure is detected, the object is marked as an abnormal object. The management node in the cloud storage cluster then writes the longest data block from the N+M data blocks of the abnormal object, padding the Zones in the ZoneGroup that contain shorter data blocks to maintain the consistency of Zone length within the ZoneGroup. After padding is completed, the writing of the next object file continues.
[0051] The file recovery process in scenarios where multiple objects reuse the same ZoneGroup is as follows: Figure 4 As shown, multiple objects written in 4+1 blocks reuse the same ZoneGroup for file recovery. The third data block of Object2 encountered an error during the write process. After being padded, the next object, Object3, was written. Since Object2 has been marked as an abnormal object and meets the file recovery requirements (the number of corrupted data blocks does not exceed M, M=1), recovery is necessary. The recovery method involves allocating a new Zone and recovering the file sequentially according to the position of the object block data within the Zone, following the LBA (Local Basic Architecture). Object1 and Object3 are objects that were written normally, so their block data is directly copied over. Object2 requires EC (Extended Calculation) calculation, based on the other four blocks of Object2. Finally, the recovered, complete Zone replaces the Zone containing the abnormal object, forming a new ZoneGroup with the other four Zones.
[0052] like Figure 5 As shown, this embodiment specifically includes the following steps:
[0053] S501, establish the correspondence between object files and ZoneGroups. Divide the file to be stored into multiple object files (Object1, Object2, ..., ObjectN), and divide each object file into N+M data blocks. Each block is stored on a Zone of an SMR disk. An object file has N+M blocks and needs to be written to N+M Zones of N+M disks simultaneously. This set of N+M Zones forms a ZoneGroup, thus establishing the correspondence between object files and ZoneGroups.
[0054] S502 writes multiple object files into the same ZoneGroup in N+M order, maximizing the use of disk space.
[0055] S503: Check if an exception occurred during the writing of the object file, causing the write to fail. If the write fails, execute S504; otherwise, write multiple object files to a ZoneGroup until the ZoneGroup is completely written.
[0056] S504 If an abnormal write failure occurs during the object writing process, the blocks of the failed object file on the ZoneGroup are padded with 0s according to the longest write length of the block, so that the write length of the object file on the ZoneGroup is consistent, and the object file is marked as an abnormal object file.
[0057] S505: Determine whether the padded ZoneGroup has been written. If not, proceed to step two to write the next object file to this ZoneGroup. Otherwise, proceed to S506.
[0058] S506: The completed ZoneGroup has been written, but an exception caused the write to fail, resulting in a recoverable file. The process then determines if the file meets the recoverability requirements: in N+M write mode, if the number of corrupted blocks in the object file does not exceed M, then the file recovery requirements are met; otherwise, the process terminates and object file recovery cannot be performed.
[0059] S507, for objects that meet the file recovery requirements, the entire Zone containing the corrupted block in the ZoneGroup storing the abnormal object file is restored to the newly allocated SMR Zone; the block data of normal objects only needs to be directly copied to the newly allocated Zone, and the data marked as abnormal is calculated by EC. The recovery order is based on the position of the object block data in the Zone, and the files are restored sequentially according to LBA.
[0060] S508: After the newly requested Zone has recovered all the data on the abnormal Zone, it replaces the abnormal Zone with the new Zone containing complete data and forms a new ZoneGroup with the other Zones.
[0061] S509: After an abnormal Zone is replaced, the Zone is released and placed into the entire cloud storage idle Zone management pool for the construction of new Zones and the writing of new object files.
[0062] In summary, this embodiment addresses the scenario of restoring multiple object files reusing the same ZoneGroup. It employs a unified recovery mechanism for the object file set, achieving full-block writing and deletion within the SMR Zone, reducing invalid Zone data, and improving the overall space utilization of the SMR hard drive. By dividing each object file into N+M blocks, a correspondence is established between the object file and the ZoneGroup based on the SMR hard drive. Individual object recovery is transformed into batch object data migration and recovery based on Zone as the recovery management unit, thereby reducing the difficulty of object storage recovery management.
[0063] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0064] This embodiment also provides a data recovery device based on an SMR disk, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0065] Figure 6 This is a structural block diagram of a data recovery device based on an SMR disk according to an embodiment of the present invention, as shown below. Figure 6 As shown, the device includes:
[0066] The first writing module 62 is used to determine the storage area to which the abnormal data block was written as an abnormal storage area when an abnormal data block occurs during the process of writing N+M data blocks of the target object file to N+M storage areas in the storage area set. The target object file is any one of multiple object files that reuse the storage area set. The storage area set is set in the SMR disk. M and N are both natural numbers greater than 1.
[0067] The first recovery module 64 is used to recover the data in the above-mentioned abnormal data block to obtain the target data block;
[0068] The first copying module 66 is used to copy the target data block and the normal data block already stored in the abnormal storage area to the target storage area, wherein the target storage area is a storage area other than the above N+M storage areas.
[0069] The first replacement module 68 is used to replace the abnormal storage area with the target storage area mentioned above, so as to store multiple object files mentioned above in the set of storage areas at the same time.
[0070] In one exemplary embodiment, the above-described apparatus further includes:
[0071] The first establishment module is used to establish multiple correspondences between the aforementioned object files and the aforementioned storage area set before determining the storage area to which the abnormal data block was written as an abnormal storage area when an abnormal data block occurs during the process of writing N+M data blocks of the target object file to N+M storage areas in the storage area set. The correspondences include the storage relationship between each data block of each of the aforementioned object files and each storage block of each of the aforementioned storage areas.
[0072] In one exemplary embodiment, the above-described apparatus further includes:
[0073] The first determining module is used to determine the length of each data block in the N+M data blocks of the target object file after determining the storage area to which the abnormal data block was written as an abnormal storage area when an abnormal data block occurs during the process of writing N+M data blocks of the target object file to N+M storage areas in the storage area set.
[0074] The second writing module is used to write first preset data into the abnormal storage area using the length of each of the above data blocks, so as to complete the above storage area set.
[0075] In one exemplary embodiment, the first recovery module described above includes:
[0076] The first recovery unit is used to recover the data in at least one of the abnormal data blocks when the number of abnormal data blocks is less than a preset number and the data in at least one of the abnormal data blocks is in a recoverable state, so as to obtain at least one of the target data blocks.
[0077] In one exemplary embodiment, the first recovery unit includes:
[0078] The first determining subunit is used to determine the data in other data blocks in the target object file, wherein the other data blocks are data blocks in the target object file other than the abnormal data blocks.
[0079] The first calculation subunit is used to calculate at least one of the abnormal data blocks based on the data in other data blocks in the target object file, so as to obtain at least one of the target data blocks.
[0080] In one exemplary embodiment, the first copying module described above includes:
[0081] The first establishment unit is used to establish the aforementioned target storage area;
[0082] The first copying unit is used to copy the data in the target data block to the target storage block in the target storage area, wherein the position of the target storage block in the target storage area corresponds to the abnormal storage block of the abnormal data block in the abnormal storage area;
[0083] The second copying unit is used to copy the normal data blocks already stored in the abnormal storage area to other storage blocks in the target storage area, wherein the positions of the other storage blocks in the target storage area correspond to the storage blocks of the normal data blocks in the abnormal storage area.
[0084] In one exemplary embodiment, the above-described apparatus further includes:
[0085] The first marking module is used to mark a second preset data in the target storage block in the target storage area when the number of the above-mentioned abnormal data blocks is greater than or equal to a preset number, or when the data in the above-mentioned abnormal data blocks is in an unrecoverable state, wherein the position of the above-mentioned target storage block in the target storage area corresponds to the abnormal storage block of the above-mentioned abnormal data blocks in the abnormal storage area.
[0086] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0087] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.
[0088] In this embodiment, the computer-readable storage medium described above may be configured to store a computer program for performing the above steps.
[0089] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0090] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0091] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0092] In one exemplary embodiment, the processor described above may be configured to perform the above steps via a computer program.
[0093] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0094] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0095] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A data recovery method based on SMR disks, characterized in that, include: In the process of writing N+M data blocks of the target object file to N+M storage areas in the storage area set, if an abnormal data block occurs, the storage area to which the abnormal data block was written is determined as an abnormal storage area. The target object file is any one of multiple object files that reuse the storage area set. The storage area set is set in the SMR disk. M and N are both natural numbers greater than 1. Recover the data from the abnormal data block to obtain the target data block; Copy the target data block and the normal data blocks already stored in the abnormal storage area to the target storage area, wherein the target storage area is a storage area other than the N+M storage areas; Replace the abnormal storage area with the target storage area so that multiple object files can be stored simultaneously in the set of storage areas; Before determining the storage area where the abnormal data block is written as an abnormal storage area, the method further includes: establishing a correspondence between multiple object files and the set of storage areas, wherein the correspondence includes the storage relationship between each data block of each object file and each storage block of each storage area.
2. The method according to claim 1, characterized in that, In the process of writing N+M data blocks of the target object file to N+M storage areas in the storage area set, if an abnormal data block occurs, after determining the storage area to which the abnormal data block was written as an abnormal storage area, the method further includes: Determine the length of each data block in the N+M data blocks of the target object file; First preset data is written into the abnormal storage area using the length of each data block to complete the set of storage areas.
3. The method according to claim 1, characterized in that, To recover the data from the abnormal data block and obtain the target data block, the following steps are taken: If the number of abnormal data blocks is less than a preset number, and the data in at least one of the abnormal data blocks is in a recoverable state, the data in at least one of the abnormal data blocks is recovered to obtain at least one target data block.
4. The method according to claim 3, characterized in that, If the number of abnormal data blocks is less than a preset number, and the data in at least one of the abnormal data blocks is in a recoverable state, then recover the data in at least one of the abnormal data blocks to obtain the target data block, including: Identify the data in other data blocks of the target object file, wherein the other data blocks are data blocks in the target object file other than the abnormal data block; Based on the data in other data blocks in the target object file, calculate the data in at least one of the abnormal data blocks to obtain at least one target data block.
5. The method according to claim 1, characterized in that, Copying both the target data block and the normal data blocks already stored in the abnormal storage area to the target storage area includes: Establish the target storage area; The data in the target data block is copied to the target storage block in the target storage area, wherein the position of the target storage block in the target storage area corresponds to the abnormal storage block of the abnormal data block in the abnormal storage area; The normal data blocks already stored in the abnormal storage area are copied to other storage blocks in the target storage area, wherein the positions of the other storage blocks in the target storage area correspond to the storage blocks of the normal data blocks in the abnormal storage area.
6. The method according to claim 1, characterized in that, The method further includes: If the number of abnormal data blocks is greater than or equal to a preset number, or if the data in the abnormal data blocks is in an unrecoverable state, a second preset data is marked in the target storage block in the target storage area, wherein the position of the target storage block in the target storage area corresponds to the abnormal storage block of the abnormal data block in the abnormal storage area.
7. A data recovery device based on SMR disks, characterized in that, include: The first writing module is used to determine the storage area to which the abnormal data block was written as an abnormal storage area when an abnormal data block occurs during the process of writing N+M data blocks of a target object file to N+M storage areas in the storage area set. The target object file is any one of multiple object files that reuse the storage area set. The storage area set is set in the SMR disk. M and N are both natural numbers greater than 1. The first recovery module is used to recover the data in the abnormal data block to obtain the target data block; The first copying module is used to copy the target data block and the normal data blocks already stored in the abnormal storage area to the target storage area, wherein the target storage area is a storage area other than the N+M storage areas; The first replacement module is used to replace the abnormal storage area with the target storage area, so as to store multiple object files simultaneously in the storage area set; Before determining the storage area where the abnormal data block is written as an abnormal storage area, the device further includes: a first establishment module, used to establish a correspondence between multiple object files and the storage area set before determining the storage area where the abnormal data block is written as an abnormal storage area when an abnormal data block occurs during the process of writing N+M data blocks of the target object file to N+M storage areas in the storage area set, wherein the correspondence includes the storage relationship between each data block of each object file and each storage block in each storage area.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the method described in any one of claims 1 to 6.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Shingled disk storage method and device, equipment and medium
CN113900590A
Cloud storage data recovery method and device based on SMR disk, and electronic equipment
CN114221975A