Metadata restoration method and device, electronic equipment and storage medium

By detecting the disk type and locating the backup area, the backup metadata is obtained and repaired, which solves the problem of difficult-to-repair bad sectors in metadata and improves the availability of metadata and the stability of the disk.

CN122067584APending Publication Date: 2026-05-19SANGFOR TECH INC
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SANGFOR TECH INC
Filing Date
2025-12-16
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

In existing technologies, bad sectors in metadata are difficult to repair in a timely manner, resulting in low metadata availability, which in turn leads to disk failure and data loss.

Method used

By detecting the disk type of the target disk, the target metadata backup area where the corresponding backup metadata is located is determined, and after the bad sector repair process is completed, the backup metadata is obtained from the backup area for repair.

Benefits of technology

It enables timely repair of metadata, improves metadata availability, reduces the risk of disk failure and data loss, and ensures stable disk operation and data integrity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122067584A_ABST
    Figure CN122067584A_ABST
Patent Text Reader

Abstract

The invention discloses a metadata restoration method and device, electronic equipment and a storage medium. The method comprises the following steps: under the condition of detecting that metadata of a target disk has a bad track, carrying out bad track repairing processing on the bad track; based on the disk category of the target disk, determining a target metadata backup area where backup metadata corresponding to the metadata is located; different disk categories correspond to respective metadata backup areas; and after the bad track repair processing is completed, performing repair processing on the metadata based on backup metadata acquired from the target metadata backup area. According to the method provided by the invention, the metadata of the target data disk can be repaired in time, so that the availability rate of the metadata is improved, and the occurrence of conditions such as target disk fault and data loss caused by bad tracks of the metadata is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic information technology, and more specifically, to a metadata repair method, apparatus, electronic device, and storage medium. Background Technology

[0002] Metadata is information used to describe, interpret, locate, manage, or utilize other data, making the data searchable, understandable, manageable, trustworthy, and long-term.

[0003] In related technologies, when bad sectors exist in metadata, it is difficult to repair the metadata in a timely manner, resulting in low metadata availability, which in turn leads to disk failure and data loss. Summary of the Invention

[0004] In view of this, embodiments of this application propose a metadata repair method, apparatus, electronic device, and storage medium.

[0005] In a first aspect, embodiments of this application provide a metadata repair method, the method comprising: performing bad sector repair processing on the bad sectors when bad sectors are detected in the metadata of the target disk; determining the target metadata backup area where the backup metadata corresponding to the metadata is located based on the disk type of the target disk; different disk types correspond to their respective metadata backup areas; and performing metadata repair processing on the metadata based on the backup metadata obtained from the target metadata backup area after the bad sector repair processing is completed.

[0006] Secondly, embodiments of this application provide a metadata repair apparatus, comprising: a task scheduling module, configured to perform bad sector repair processing on bad sectors when bad sectors are detected in the metadata of a target disk; a task scheduling module, configured to determine the target metadata backup area where the backup metadata corresponding to the metadata is located based on the disk type of the target disk; different disk types correspond to their respective metadata backup areas; and a task execution module, configured to perform metadata repair processing on the metadata based on the backup metadata obtained from the target metadata backup area after the bad sector repair processing is completed. Optionally, the task scheduling module is further configured to, if the target disk is a GPT disk type, obtain the first backup area where the backup boot sector data corresponding to the boot sector data is located; the metadata includes the boot sector data, the target metadata backup area includes the first backup area, and the first backup area is not in the target disk; from the tail area of ​​the target disk, obtain the area where the backup GPT header data corresponding to the GPT header data is located and the area where the backup DPT partition table data corresponding to the DPT partition table data is located, as the second backup area; the metadata includes the GPT header data and the DPT partition table data, and the target metadata backup area also includes the second backup area.

[0007] Optionally, the device further includes a backup module for backing up the boot sector data to a first backup area after the target disk is formatted, thereby obtaining the backup boot sector data corresponding to the boot sector data.

[0008] Optionally, the task scheduling module is also used to obtain the backup directory pointed to by the preset backup tool as the target metadata backup area if it is determined that the target disk belongs to the logical volume manager category; the backup metadata is obtained by the preset backup tool backing up the metadata to the backup directory, which is not on the target disk.

[0009] Optionally, the task scheduling module is further configured to, if it is determined that the target disk belongs to the user logical volume manager category and / or the simple file system category, detect whether all the metadata written in the metadata storage area has bad sectors; the metadata storage area is the area in the target disk used to store each metadata; if at least one of the metadata does not have bad sectors, obtain the area where the metadata without bad sectors is located from the metadata storage area as the target metadata backup area; wherein, the metadata without bad sectors is used as backup metadata; and / or, if all the metadata has bad sectors, obtain the third backup area where the redundant backup metadata corresponding to the metadata is located as the target metadata backup area; wherein, the redundant backup metadata is used as backup metadata; the third backup area and the metadata storage area do not overlap; the redundant backup metadata is obtained by backing up at least one metadata to the third backup area.

[0010] Optionally, the device further includes a task acquisition module and a task detection module; wherein, the task acquisition module is used to detect whether there are bad sectors in the metadata in response to the loading operation of the metadata; the task detection module is used to detect whether there are bad sectors in the metadata in response to a first time interval since the last detection of whether there are bad sectors in the metadata; and / or, in response to a second time interval since the last completion of the metadata repair process, detect whether there are bad sectors in the metadata.

[0011] Thirdly, embodiments of this application provide an electronic device, which includes: a processor; and a memory storing computer-readable instructions, which, when executed by the processor, implement the above-described method.

[0012] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-readable instructions that, when executed by a processor, implement the above-described method.

[0013] Fifthly, embodiments of this application provide a computer program product including computer-readable instructions that, when executed by a processor, implement the method described above.

[0014] This application provides a metadata repair method, apparatus, electronic device, and storage medium. In this application, when a metadata fault is detected in a target disk, the target metadata backup area where the backup metadata corresponding to the metadata is located is determined based on the disk type of the target disk. This allows the backup metadata to be obtained from the target metadata backup area after the bad sector repair process is completed, and the metadata repair process is performed based on the obtained backup metadata. This achieves timely repair of the metadata of the target data disk, thereby improving the availability of metadata and greatly reducing the occurrence of target disk faults and data loss caused by bad sectors in the metadata, ensuring the stable operation of the target disk and data integrity. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 A schematic diagram illustrating an application scenario applicable to the embodiments of this application is shown; Figure 2 A flowchart of a metadata repair method according to an embodiment of this application is shown; Figure 3 A flowchart of a metadata repair method according to yet another embodiment of this application is shown; Figure 4 A schematic diagram of a disk partitioning scheme according to an embodiment of this application is shown; Figure 5 It shows Figure 4 The diagram shows the structure of the disk's metadata. Figure 6 A flowchart of a metadata repair method according to another embodiment of this application is shown; Figure 7 A schematic diagram of yet another disk partitioning embodiment of this application is shown; Figure 8 A flowchart of a metadata repair method according to another embodiment of this application is shown; Figure 9 This application illustrates a schematic diagram of the metadata structure of a disk as an example. Figure 10 This application illustrates a schematic diagram of the metadata structure of yet another disk example. Figure 11 A flowchart of a metadata repair method according to another embodiment of this application is shown; Figure 12 A schematic diagram illustrating a metadata repair process in an embodiment of this application is shown; Figure 13 This illustration shows a schematic diagram of another metadata repair process in an embodiment of this application; Figure 14 A block diagram of a metadata repair apparatus according to an embodiment of this application is shown; Figure 15 A structural block diagram of an electronic device for performing a metadata repair method according to an embodiment of this application is shown. Detailed Implementation

[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0018] In the following description, the terms "first" and "second" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first" and "second" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit the application. It should be noted that "multiple" as used herein refers to two or more. "And / or" describes the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship.

[0020] The following is an explanation of the technical terms used in this application: EFS (Easy File System): A simplified file system.

[0021] TFS (Tier File System): A hierarchical file system.

[0022] HCI (Hyper Converged Infrastructure) refers to a unified resource pool that integrates not only computing, networking, storage, and server virtualization resources and technologies within a single unit, but also includes elements such as backup software, snapshot technology, deduplication, and online data compression. Multiple units can be aggregated through a network to achieve modular, seamless horizontal scaling (scale-out).

[0023] LV (Logical Volume) is a virtual disk formed by integrating physical storage resources through virtualization technology. It is used to break through the capacity limitations of traditional disk partitions and supports cross-disk combination and dynamic adjustment.

[0024] ULVM: (User Logical Volume Manager)

[0025] LVM: (Logical Volume Manager) Logical Volume Manager.

[0026] PV: (Physical Volume)

[0027] VG: (Volume Group) Volume group.

[0028] Please refer to Figure 1 The diagram illustrates an application scenario applicable to the embodiments of this application. This application scenario includes an electronic device 110 and a storage system 120.

[0029] Electronic device 110 includes devices such as smartphones, tablets, e-book readers, music players, wearable devices, smart home devices, and in-vehicle terminals. Electronic device 110 may include a metadata repair client capable of repairing the metadata of a target disk.

[0030] Storage system 120 includes disk process instances and multiple disk nodes, for example, Figure 1 In this storage system, there are three disk nodes: disk node 121, disk node 122, and disk node 123. Each disk node is a disk, which can be a physical volume, a simple file system, a hierarchical file system, or a logical volume, etc. The storage system 120 may have disk process instances that manage the various disks in the storage system 120. Each disk process instance can call the efs / ulvm interface to access the disk's metadata through the called efs / ulvm interface.

[0031] Specifically, the electronic device 110 may include a collector, a task center, an executor, and a detector. The collector, task center, executor, and detector may be functional modules in the metadata repair client or hardware modules in the electronic device 110. This application does not limit them.

[0032] In some implementations, when any disk process instance triggers a request (read / write request or query request) to the target disk (the target disk is any disk node or part of the disks in the storage system 120), a task collection is triggered to detect whether there are bad sectors in the metadata of the target disk. If bad sectors are detected in the metadata of the target disk, the collector is notified to collect information. The collector collects bad sector information through remote procedure call (RPC) and transmits the bad sector information to the task center. The task center creates a metadata repair task, and then the executor executes the metadata repair task to realize the metadata repair processing.

[0033] In some other implementations, the detector can periodically check whether there are bad sectors in the metadata of the target disk. If bad sectors are detected in the metadata of the target disk, the task center creates a metadata repair task, and then the executor executes the metadata repair task to achieve metadata repair processing.

[0034] In some embodiments, the electronic device 110 may also be a virtual module or management node in the storage system 120 for implementing the metadata repair method in this application. The virtual module or management node integrates functional modules that implement the aforementioned collector, task center, executor and detector functions. Thus, the storage system 120 itself can implement the metadata repair of this application without interacting with devices outside the storage system 120, thereby reducing communication costs.

[0035] Please see Figure 2 , Figure 2 This application illustrates a flowchart of a metadata repair method according to an embodiment of the present application, which can be used for... Figure 1 The method may include: S110. If bad sectors are detected in the metadata of the target disk, perform bad sector repair processing.

[0036] As mentioned above, the target disk can refer to any disk in the storage system, or it can be a part of any disk in the storage system. The target disk can be a physical volume, a simple file system, a hierarchical file system, or a logical volume, etc.

[0037] The metadata of a target disk refers to the metadata used to describe the target disk. The metadata of a target disk may differ depending on its disk category. For example, the metadata of a physical volume differs from that of a logical volume; similarly, the metadata of a simple file system differs from that of a hierarchical file system.

[0038] In this application, the metadata of the target disk may first be checked for bad sectors. If the metadata of the target disk does not exist, no processing is performed. If the metadata of the target disk has bad sectors, the metadata of the target disk is repaired in accordance with the method of this application.

[0039] The bad sectors of the target disk's metadata can include physical bad sectors and logical bad sectors. Physical bad sectors refer to actual physical damage to the storage area where the target disk's metadata is located due to impact, aging, or manufacturing defects. Logical bad sectors refer to data write errors caused by software errors, system crashes, or sudden power outages in the storage area where the target disk's metadata is located.

[0040] When bad sectors are detected in the target disk's metadata, bad sector repair is performed. Typically, if the bad sectors in the target disk's metadata are logical bad sectors, the repair process may include repairing the logical bad sectors using repair tools or reminding staff to manually repair the logical bad sectors. If the bad sectors in the target disk's metadata are physical bad sectors, the repair process may include reminding staff to repair the physical bad sectors, for example, reminding staff to replace the disk with a new one.

[0041] S120. Based on the disk type of the target disk, determine the target metadata backup area where the backup metadata corresponding to the metadata is located.

[0042] Different disk categories have their own corresponding metadata backup areas. That is, each disk category has its own dedicated data backup area. For example, the metadata backup area for GPT disks is different from that for Logical Volume Manager disks, and similarly, the metadata backup area for Logical Volume Manager disks is different from that for User Logical Volume Manager disks.

[0043] When bad sectors are detected in the metadata of the target disk, the disk type of the target disk can be determined. Based on the disk type of the target disk, the metadata backup area where the backup metadata corresponding to the metadata of the target disk is located can be located as the target metadata backup area. This facilitates the retrieval of the backup metadata corresponding to the metadata of the target disk from the target metadata backup area.

[0044] It is worth mentioning that, when bad sectors are detected in the metadata of the target disk, S120 can be executed while performing bad sector repair on the bad sectors of the metadata of the target disk. This allows for the location of the target metadata backup area during the bad sector repair process, enabling fast and efficient location of the target metadata backup area.

[0045] S130. After the bad sector repair process is completed, the metadata is repaired based on the backup metadata obtained from the target metadata backup area.

[0046] After completing the bad sector repair process on the target disk's metadata, the backup metadata can be obtained from the target metadata backup area. Then, the backup metadata is used to overwrite the metadata on the target disk that has detected bad sectors, thereby repairing the target disk's metadata so that the target disk no longer has bad sectors after the metadata repair process.

[0047] In this embodiment, when a metadata fault is detected on the target disk, the target metadata backup area where the backup metadata corresponding to the metadata is located is determined based on the disk type of the target disk. This allows the backup metadata to be obtained from the target metadata backup area after the bad sector repair process is completed, and the metadata repair process is performed based on the obtained backup metadata. This enables timely repair of the metadata of the target data disk, thereby improving the availability of metadata and greatly reducing the occurrence of target disk faults and data loss caused by bad sectors in the metadata, ensuring the stable operation of the target disk and data integrity.

[0048] In some embodiments, such as Figure 3 As shown, S120 includes: S1211. If the target disk is a GPT disk type, obtain the first backup area where the backup boot sector data corresponding to the boot sector data is located.

[0049] The metadata includes boot sector data, and the target metadata backup area includes the first backup area, which is not located on the target disk.

[0050] S1212. Obtain the area containing the backup GPT header data corresponding to the GPT header data and the area containing the backup DPT partition table data corresponding to the DPT partition table data from the tail area of ​​the target disk, and use them as the second backup area.

[0051] The metadata includes GPT header data and DPT partition table data. The target metadata backup area also includes a second backup area. GPT is an abbreviation for GUID partition table, part of the UEFI standard, used to replace the traditional MBR partition table. The GPT header data is the "central control" of the GPT disk. GPT header data typically includes signature, version number, header size, header CRC checksum, current LBA (Logical Block Addressing), backup LBA, partition table start LBA, partition table end LBA, disk GUID, partition table entry start LBA, and number of partition table entries. DPT is the traditional MBR partition table, located in the first sector of the disk (LBA 0), and is part of the MBR structure.

[0052] In other words, in this application, the target disk is a GPT disk type, and the target disk's metadata can be partition metadata. The target disk's metadata includes boot sector data, GPT header data, and DPT partition table data. In this case, such as... Figure 4 As shown, the target disk typically has only one partition. In this case, the metadata of the target disk is laid out as follows: Figure 5 As shown.

[0053] like Figure 5 When the target disk is a GPT disk type, the GPT header data and DPT partition table data are not only distributed in the header area 501 of the target disk, but also in the tail area 502 of the target disk. The tail area 502 includes at least the area where the GPT header data and DPT partition table data are located.

[0054] Typically, the GPT header data and DPT partition table data in the header area 501 are used as metadata, while the GPT header data and DPT partition table data in the tail area 502 are used as backups of the GPT header data and DPT partition table data, respectively. In other words, the GPT header data and DPT partition table data have already been backed up on the target disk.

[0055] However, the boot sector data in the target disk's metadata is only stored in the header area 501 of the target disk and is not backed up on the target disk. Therefore, the boot sector data is backed up separately in the first backup area, which is not on the target disk. This is so that if bad sectors exist in the target disk's metadata, the undamaged backup boot sector data backed up in the first backup area can be retrieved.

[0056] When bad sectors are detected in the metadata of the header region of the target disk, the first backup region and the second backup region, which includes the tail region of the target disk, are determined as the target metadata backup region. This is to facilitate the acquisition of backup boot sector data from the first backup region and backup GPT header data and backup DPT partition table data from the second backup region.

[0057] In some implementations, prior to S1211, the method further includes: after formatting the target disk, backing up the boot sector data to a first backup area to obtain the backup boot sector data corresponding to the boot sector data.

[0058] In other words, after the target disk is formatted, a backup operation is performed on the boot sector data of the target disk to back up the boot sector data to the first backup area, thus obtaining the backup boot sector data backed up in the first backup area.

[0059] In this embodiment, for GPT disks, the disk's metadata is backed up in its own tail area and on other disks. This allows for timely repair of the metadata in case of bad sectors, preventing disk failure and data loss due to unrepairable metadata. This ensures stable disk operation and data integrity.

[0060] In some embodiments, such as Figure 6 As shown, S120 also includes: S122. If it is determined that the target disk belongs to the logical volume manager category, obtain the backup directory pointed to by the preset backup tool as the target metadata backup area.

[0061] The backup metadata is obtained by backing up the metadata to the backup directory using a preset backup tool. The backup directory is not located on the target disk.

[0062] In this embodiment, the default backup tool can be lvm2, and the corresponding backup directory is / etc / lvm / backup.

[0063] Logical Volume Manager categories of disks such as Figure 7 As shown, a disk typically has only one VG, which is then divided into multiple physical volumes. Therefore, lvm2 can be used to back up the disk's metadata to the backup directory " / etc / lvm / backup" to obtain the backup metadata.

[0064] When performing metadata repair, a data repair tool can be used to retrieve backup metadata from the backup directory " / etc / lvm / backup" and then repair the disk's metadata based on this backup metadata. The data repair tool used here can be vgcfgrestore.

[0065] In this embodiment, for disks of the Logical Volume Manager category, the disk's metadata is backed up in a designated backup directory. This allows for timely repair of the metadata in the event of bad sectors, preventing disk failures and data loss due to unrepairable metadata and ensuring stable disk operation and data integrity.

[0066] In some embodiments, such as Figure 8 As shown, S120 also includes: S1231. If it is determined that the target disk belongs to the User Logical Volume Manager category and / or the Simple File System category, check whether all the metadata written in the metadata storage area has bad sectors.

[0067] The metadata storage area is the area on the target disk used to store various metadata.

[0068] Typically, disks in the User Logical Volume Manager category and disks in the Simple File System category store multiple metadata entries, each located in a different area.

[0069] For example, for disks in the User Logical Volume Manager category, metadata includes metadata for the superblock, bad sector bitmap blocks, and address mapping table. The metadata is stored in the following manner: Figure 9 As shown, the disk includes a user logical volume manager 901, which includes a metadata storage area 9011 and a reserved area 9012. The metadata storage area 9011 stores metadata for the superblock, bad sector bitmap blocks, and address mapping table. The superblock is a key data structure stored at a fixed location on the disk (usually at the beginning), containing global metadata describing and managing the entire file system. The bad sector bitmap block is a data structure in the file system used to permanently mark and isolate physically damaged disk sectors. The address mapping table is the core translation system connecting logical data requests and physical disk locations; it is a crucial data structure used to map the "virtual addresses" seen by the operating system and file system to the actual "physical sector addresses" on the hard drive.

[0070] The metadata of the superblock, bad sector bitmap block, and address mapping table are written in the metadata storage area 9011 using an A / B backup method. The superblock area 90111 in the metadata storage area 90111 contains superblock A and superblock B, which are identical superblocks. The bad sector bitmap area 90112 in the metadata storage area 90111 contains metadata A (the first 32 bytes of 4KB data) and metadata B (the first 32 bytes of 4KB data) of the bad sector bitmap block, both written in an A / B backup method. The metadata A and metadata B of the bad sector bitmap block are identical. The address mapping table area 90113 in the metadata storage area 90111 contains metadata A and metadata B of the address mapping table, both written in an A / B backup method.

[0071] Of course, such as Figure 9 As shown, the metadata storage area can also be the area containing the metadata of super block A, super block B, bad sector bitmap block A, bad sector bitmap block B, and address mapping table A and address mapping table B in 9011. The metadata storage area does not include the area containing other data in the bad sector bitmap area except for the metadata of bad sector bitmap block A and bad sector bitmap block B, and the metadata storage area does not include the area containing other data in the address mapping table area except for the metadata of address mapping table A and address mapping table B.

[0072] For example, for disks in the simple file system category, metadata includes superblock and inode metadata (efs_disk_inode), and the metadata is stored in the following way: Figure 10 As shown, the user logical volume manager includes a metadata storage area 1001, a bitmap area 1002, and a data area 1003. The metadata storage area 1001 is used to store superblock and inode metadata. Inode metadata is data that describes all the information of a file (or directory, device, etc.), but does not include the actual content (data blocks) of the file and the file name.

[0073] In this context, superblock and inode metadata are written in metadata storage area 1001 using an A / B backup method. Superblock A and Superblock B are written in superblock area 10011 within metadata storage area 1001 using an A / B backup method; Superblock A and Superblock B are identical superblocks. Inode metadata A and inode metadata B are written in inode table area 10012 within metadata storage area 1001 using an A / B backup method; inode metadata A and inode metadata B are identical inode metadata. Inode metadata A is stored in the inode_entry (inline file) within inode table area 10012, and inode metadata B is stored in the inode_entry (other file) within inode table area 10012.

[0074] Of course, such as Figure 10 As shown, the areas containing superblock A, superblock B, inode metadata A, and inode metadata B in 1001 can also be used as metadata storage areas. The metadata storage areas do not include the areas containing other data in the superblock area 10011 except for superblock A and superblock B, and the metadata storage areas do not include the areas containing other data in the inode table area except for inode metadata A and inode metadata B.

[0075] In other words, for a target disk that stores multiple metadata belonging to the user logical volume manager category and / or simple file system category, if a defect is detected in the metadata of the target disk, it is determined whether there are bad sectors in multiple metadata stored in the metadata storage area. If not, S1232 is executed; if so, S1233 is executed.

[0076] S1232. If at least one of the metadata does not have bad sectors, obtain the region where the metadata without bad sectors is located from the metadata storage region and use it as the target metadata backup region.

[0077] Metadata without bad sectors is used as backup metadata.

[0078] In other words, if at least one piece of metadata in the metadata storage area does not have bad sectors, the area containing any one of the metadata without bad sectors is selected as the target metadata backup area. In this case, the metadata without bad sectors in the target metadata backup area is used as backup metadata. After the bad sector repair process is completed, the backup metadata is retrieved from the target metadata backup area to perform metadata repair.

[0079] S1233. If multiple metadata have bad sectors, obtain the third backup area where the redundant backup metadata corresponding to the metadata is located, and use it as the target metadata backup area.

[0080] Among them, redundant backup metadata is used as backup metadata; there is no overlap between the third backup area and the metadata storage area; the redundant backup metadata is obtained by backing up at least one metadata to the third backup area.

[0081] In other words, although the metadata storage area stores multiple metadata, it is possible to repair the metadata if one metadata has bad sectors. However, if multiple metadata stored in the metadata storage area have bad sectors, it is impossible to repair the metadata. Therefore, the metadata can be backed up to a third backup area to achieve redundant backup, and the metadata backed up in the third backup area serves as redundant backup metadata.

[0082] The redundant backup metadata of the third backup area backup can include only one metadata or multiple metadata (to achieve dual redundancy backup, so that if one metadata in the redundant backup metadata has a problem, other metadata can be used to fix it).

[0083] In some implementations, when the target disk belongs to the user logical volume manager category, the third backup area is not in the target disk. That is, the redundant backup metadata is obtained by backing up the metadata of the target disk on a separate disk that is different from the target disk.

[0084] In some other implementations, when the target disk belongs to the simplified file system category, the third backup area includes a first sub-area and a second sub-area. The first sub-area is contained within the target disk, while the second sub-area is not. The superblock in the redundant backup metadata is stored in the first sub-area, and the inode metadata in the redundant backup metadata is stored in the second sub-area. That is, a part of the redundant backup metadata is a portion of the metadata of the target disk that is backed up within one area of ​​the target disk, and the other part is a portion of the metadata that is backed up on other independent disks. The second sub-area can be another disk in the storage system that is different from the target disk.

[0085] For example, such as Figure 10 As shown, redundant backup metadata can back up the superblock in the first sub-region 1004, which can be located between the bitmap region 1002 and the data region 1003, or between the bitmap region 1002 and the metadata storage region 1001. Correspondingly, the inode metadata can be backed up on other disks.

[0086] Of course, in disks of the simplified file system category, although redundant backup metadata is also metadata, it is backed up separately for the purpose of repairing metadata. Therefore, the area where the superblock in the redundant backup metadata is located is the first sub-area, not the metadata storage area.

[0087] In this embodiment, for disks of the User Logical Volume Manager category and / or Simple File System category, the disk metadata is backed up in a designated third backup area. This allows for timely repair of the metadata in the event of bad sectors, preventing disk failure and data loss due to unrepairable metadata and ensuring stable disk operation and data integrity.

[0088] In some embodiments, such as Figure 11 As shown, before S110, the method further includes: S010. In response to the first time elapsed since the last detection of whether there are bad sectors in the metadata, detect whether there are bad sectors in the metadata. S020. In response to the second time elapsed since the last completion of metadata repair processing, detect whether there are bad sectors in the metadata. S030. In response to the loading operation of metadata, detect whether there are bad sectors in the metadata.

[0089] The first and second durations can be set based on requirements, such as the first duration being 12 hours and the second duration being 24 hours.

[0090] In other words, in this application, the events that trigger the detection of whether the target disk's metadata has bad sectors can include the three types mentioned above.

[0091] Typically, when a request for the target disk is received, the metadata of the target disk can be loaded. This request for the target disk can be a read request or a write request.

[0092] For example, when a request triggers a metadata check of the target disk, the metadata repair process is as follows: Figure 12 As shown, in response to a request, the distributed file system loads the metadata of the target disk. If it is determined that the metadata loading of the target disk fails, it is determined that there are bad sectors in the metadata of the target disk. The bad sectors are reported to the collection service. The collection service generates bad sector information of the metadata of the target disk and reports it to the bad sector information task scheduling center. At the same time, it replies to the distributed file system: bad sector information collection is complete. After that, the task scheduling center issues a repair strategy to the collection service. The collection service executes the repair strategy to complete the bad sector repair. After that, the distributed file system can perform metadata repair.

[0093] For example, when a metadata check of the target disk is triggered by a scheduled check, the metadata repair process is as follows: Figure 13 As shown.

[0094] 1. Status Awareness: The management center notifies the awareness center to perform status awareness; 2. Sensing whether the scanning time has been reached: The sensing center senses whether the detection cycle has been reached (the time since the last detection of whether bad sectors exist in the metadata has reached the first time, or the time since the last completion of metadata repair processing has reached the second time). If it senses this, it returns the result to the management center (the dotted line represents the returned result). 3. Add a scan task: The management center adds a scan task to the task center. The task center creates the scan task (a task used to detect whether there are bad sectors in the metadata) and returns the result to the management center after successful creation (the dotted line represents the result returned to the management center). 4. Add worker thread: The management center (after receiving the result of successful scan task creation) notifies the worker thread pool to trigger the worker thread; 5. Obtaining Scan Tasks: The allocation thread in the worker thread pool obtains scan tasks from the task center and submits them to the task center; 6. Assign scan tasks: The task center assigns scan tasks to specified threads and then transfers the scan tasks to specified threads in the worker thread pool; 7. Call the scan interface: Specify the thread to call the scan interface to scan tasks; 8. Perform a scan: After calling the scan interface, execute the scan task to perform a scan of metadata; 9. Scan Results: After completing the scan, obtain the scan results and return them to the assigned thread in the worker thread pool; 10. Add execution results: The assigned thread in the worker thread pool adds the execution results to the result queue; 11. Read Results: The task execution module reads the scan results from the results queue; 12. Repair bad sectors: If the scan results indicate that there are bad sectors in the metadata of the target disk, the task execution module repairs the bad sectors; 13. Retrieve Scan Results: The management module retrieves the scan results from the result queue and returns the corresponding scan results via the result column (dashed lines indicate the returned scan results); 14. Metadata Repair Processing: If the scan results indicate that there are bad sectors in the metadata of the target disk, the exact operation of the metadata repair process is performed so that the metadata repair process is completed when the bad sector repair is finished.

[0095] Please see Figure 14 , Figure 14This illustration shows a block diagram of a metadata repair apparatus according to an embodiment of this application. The metadata repair apparatus 800 includes: The task scheduling module 810 is used to perform bad sector repair when bad sectors are detected in the metadata of the target disk. The task scheduling module 810 is used to determine the target metadata backup area where the backup metadata corresponding to the metadata is located based on the disk type of the target disk; different disk types correspond to their respective metadata backup areas; Task execution module 820 is used to repair metadata based on backup metadata obtained from the target metadata backup area after the bad sector repair process is completed. Optionally, the task scheduling module 810 is further configured to, if the target disk is a GPT disk type, obtain the first backup area where the backup boot sector data corresponding to the boot sector data is located; the metadata includes the boot sector data, the target metadata backup area includes the first backup area, and the first backup area is not in the target disk; from the tail area of ​​the target disk, obtain the area where the backup GPT header data corresponding to the GPT header data is located and the area where the backup DPT partition table data corresponding to the DPT partition table data is located, as the second backup area; the metadata includes the GPT header data and the DPT partition table data, and the target metadata backup area also includes the second backup area.

[0096] Optionally, the device further includes a backup module for backing up the boot sector data to a first backup area after the target disk is formatted, thereby obtaining the backup boot sector data corresponding to the boot sector data.

[0097] Optionally, the task scheduling module 810 is also used to obtain the backup directory pointed to by the preset backup tool as the target metadata backup area if it is determined that the target disk belongs to the logical volume manager category; the backup metadata is obtained by the preset backup tool backing up the metadata to the backup directory, and the backup directory is not in the target disk.

[0098] Optionally, the task scheduling module 810 is further configured to, if it is determined that the target disk belongs to the user logical volume manager category and / or the simple file system category, detect whether all the metadata written in the metadata storage area has bad sectors; the metadata storage area is the area in the target disk used to store each metadata; if at least one of the metadata does not have bad sectors, obtain the area where the metadata without bad sectors is located from the metadata storage area as the target metadata backup area; wherein, the metadata without bad sectors is used as backup metadata; and / or, if all the metadata has bad sectors, obtain the third backup area where the redundant backup metadata corresponding to the metadata is located as the target metadata backup area; wherein, the redundant backup metadata is used as backup metadata; the third backup area and the metadata storage area do not overlap; the redundant backup metadata is obtained by backing up at least one metadata to the third backup area.

[0099] Optionally, the device further includes a task acquisition module and a task detection module; wherein, the task acquisition module is used to detect whether there are bad sectors in the metadata in response to the loading operation of the metadata; the task detection module is used to detect whether there are bad sectors in the metadata in response to a first time interval since the last detection of whether there are bad sectors in the metadata; and / or, in response to a second time interval since the last completion of the metadata repair process, detect whether there are bad sectors in the metadata.

[0100] It should be noted that the device embodiments in this application correspond to the aforementioned method embodiments. The specific principles in the device embodiments can be found in the content of the aforementioned method embodiments, and will not be repeated here.

[0101] Figure 15 A structural block diagram of an electronic device for performing a metadata repair method according to an embodiment of this application is shown. The electronic device may be... Figure 1 Regarding electronic equipment such as 110, it should be noted that... Figure 15 The computer system 1200 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0102] like Figure 15As shown, the computer system 1200 includes a Central Processing Unit (CPU) 1201, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on programs stored in Read-Only Memory (ROM) 1202 or programs loaded from storage portion 1208 into Random Access Memory (RAM) 1203. The RAM 1203 also stores various programs and data required for system operation. The CPU 1201, ROM 1202, and RAM 1203 are interconnected via a bus 1204. An Input / Output (I / O) interface 1205 is also connected to the bus 1204.

[0103] The following components are connected to I / O interface 1205: an input section 1206 including a keyboard, mouse, etc.; an output section 1207 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to I / O interface 1205 as needed. Removable media 1211, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1210 as needed so that computer programs read from them can be installed into storage section 1208 as needed.

[0104] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1209, and / or installed from removable medium 1211. When the computer program is executed by central processing unit (CPU) 1201, it performs various functions defined in the system of this application.

[0105] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0106] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer-readable instructions.

[0107] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.

[0108] In another aspect, this application also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable storage medium carries computer-readable instructions that, when executed by a processor, implement the methods in any of the above embodiments.

[0109] According to one aspect of the embodiments of this application, a computer program product is provided, the computer program product including computer-readable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer-readable instructions from the computer-readable storage medium, and the processor executes the computer-readable instructions, causing the electronic device to perform the methods of any of the above embodiments.

[0110] In the embodiments of this application, the terms "module" or "unit" refer to a part of a computer program with a predetermined function, which works together with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (e.g., processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that functions as a whole.

[0111] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0112] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause an electronic device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the methods according to the embodiments of this application.

[0113] Other embodiments of this application will readily conceive of by those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. It should be understood that this application is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A metadata repair method, characterized in that, The method includes: If bad sectors are detected in the metadata of the target disk, bad sector repair processing is performed on the bad sectors. Based on the disk type of the target disk, the target metadata backup area where the backup metadata corresponding to the metadata is located is determined; different disk types correspond to their respective metadata backup areas; After the bad sector repair process is completed, the metadata is repaired based on the backup metadata obtained from the target metadata backup area.

2. The method according to claim 1, characterized in that, The step of determining the target metadata backup area where the backup metadata corresponding to the metadata is located based on the disk category of the target disk includes: If the target disk is a GPT disk type, obtain the first backup area where the backup boot sector data corresponding to the boot sector data is located; the metadata includes the boot sector data, the target metadata backup area includes the first backup area, and the first backup area is not in the target disk; From the tail region of the target disk, obtain the region containing the backup GPT header data corresponding to the GPT header data and the region containing the backup DPT partition table data corresponding to the DPT partition table data, as the second backup region; the metadata includes the GPT header data and the DPT partition table data, and the target metadata backup region also includes the second backup region.

3. The method according to claim 2, characterized in that, If the target disk is a GPT disk type and the metadata is the partition metadata of the target disk, before obtaining the first backup area where the backup boot sector data corresponding to the boot sector data is located, the method further includes: After the target disk is formatted, the boot sector data is backed up to the first backup area to obtain the backup boot sector data corresponding to the boot sector data.

4. The method according to claim 1, characterized in that, The step of determining the target metadata backup area where the backup metadata corresponding to the metadata is located based on the disk category of the target disk includes: If the target disk is determined to belong to the logical volume manager category, the backup directory pointed to by the preset backup tool is obtained as the target metadata backup area; the backup metadata is obtained by backing up the metadata to the backup directory through the preset backup tool, and the backup directory is not in the target disk.

5. The method according to claim 1, characterized in that, The step of determining the target metadata backup area where the backup metadata corresponding to the metadata is located based on the disk category of the target disk includes: If it is determined that the target disk belongs to the User Logical Volume Manager category and / or the Simple File System category, check whether all of the metadata written in the metadata storage area have bad sectors; the metadata storage area is the area in the target disk used to store each of the metadata. If at least one of the metadata items does not have bad sectors, the region containing the metadata without bad sectors is obtained from the metadata storage region and used as the target metadata backup region; wherein, the metadata without bad sectors is used as the backup metadata; and / or, If multiple metadata entries have bad sectors, a third backup region containing the redundant backup metadata corresponding to the metadata is obtained as the target metadata backup region; wherein, the redundant backup metadata is used as the backup metadata; the third backup region and the metadata storage region do not overlap; the redundant backup metadata is obtained by backing up at least one of the metadata entries to the third backup region.

6. The method according to claim 1, characterized in that, When the target disk belongs to the user logical volume manager category, the third backup area is not in the target disk; When the target disk belongs to the simplified file system category, the third backup area includes a first sub-area and a second sub-area. The first sub-area is contained in the target disk, and the second sub-area is not in the target disk. The superblock in the redundant backup metadata is stored in the first sub-area, and the inode metadata in the redundant backup metadata is stored in the second sub-area.

7. The method according to claim 1, characterized in that, Before performing bad sector repair processing on the bad sectors when bad sectors are detected in the metadata of the target disk, the method includes: In response to a first time elapsed since the last detection of bad sectors in the metadata, a detection is performed to check if bad sectors exist in the metadata; and / or, In response to a second time elapsed since the last completion of metadata repair processing, the presence of bad sectors in the metadata is detected; and / or, In response to the loading operation of the metadata, the presence of bad sectors in the metadata is detected.

8. A metadata repair device, characterized in that, The device includes: The task scheduling module is used to perform bad sector repair processing when bad sectors are detected in the metadata of the target disk. The task scheduling module is also used to determine the target metadata backup area where the backup metadata corresponding to the metadata is located based on the disk type of the target disk; different disk types correspond to their respective metadata backup areas; The task execution module is used to repair the metadata based on the backup metadata obtained from the target metadata backup area after the bad sector repair process is completed.

9. The apparatus according to claim 8, characterized in that, The device also includes a task acquisition module and a task detection module; The task acquisition module is used to detect whether bad sectors exist in the metadata in response to the loading operation of the metadata. The task detection module is configured to detect whether the metadata has bad sectors when the time elapsed since the last detection of whether the metadata has bad sectors reaches a first time elapsed; and / or, when the time elapsed since the last completion of metadata repair processing reaches a second time elapsed, detect whether the metadata has bad sectors.

10. An electronic device, characterized in that, The electronic device includes: processor; A memory storing computer-readable instructions that, when executed by the processor, implement the method as described in any one of claims 1-7.

11. A computer-readable storage medium, characterized in that, It stores computer-readable instructions that, when executed by a processor, implement the method as described in any one of claims 1-7.

12. A computer program product, characterized in that, It includes computer-readable instructions that, when executed by a processor, implement the method of any one of claims 1-7.