How to handle server and hard disk media errors

By reallocating and rebuilding the logical block addresses of hard drives with media errors in spare sectors of the hard drive, the problem of storage resource waste caused by same-sector media errors in RAID is solved, improving user experience and system reliability.

CN120560591BActive Publication Date: 2025-10-03INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511055126.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-30
Publication Date
2025-10-03
Estimated Expiration
2045-07-30

AI Technical Summary

Technical Problem

In the prior art, when media errors occur simultaneously in the same sector of different hard disks in a redundant array of independent disks, directly replacing the RAID arrays results in a waste of storage resources and a degradation of user experience.

Method used

Reconstruction is performed by obtaining the target logical block address of the hard disk with media errors and reallocating new sectors to it in the spare sectors pre-set on the hard disk to maintain the normal operation of RAID.

Benefits of technology

It reduces storage resource waste, improves user experience, and ensures that RAID can still operate normally even when some hard disk media errors occur.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120560591B_ABST
    Figure CN120560591B_ABST
Patent Text Reader

Abstract

The present application discloses a method for handling server and hard disk media errors, and relates to the field of server technology. The server includes a controller and an independent disk redundant array connected to the controller. The independent disk redundant array includes multiple hard disks, and the same sectors of each hard disk store different data in the same strip. If the controller detects that a media error occurs in the same target sector of at least two hard disks, the target logical block address corresponding to the target sector in at least two hard disks is obtained. For any of the at least two hard disks, a new sector is reallocated to the target logical block address corresponding to the hard disk in the spare sector pre-set in the hard disk, and the new sectors allocated to the at least two hard disks are rebuilt to enable the independent disk redundant array to work normally. The present application reduces the waste of storage resources in the independent disk redundant array hard disk caused by directly replacing a new independent disk redundant array, and improves the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of server technology, and in particular to a method for processing server and hard disk medium errors. Background Art

[0002] In servers, hard drive media errors are a common problem in hard drive storage systems, which can affect data storage. Therefore, handling hard drive media errors is of great significance.

[0003] In related technology, if at least two hard drives in a Redundant Array of Independent Disks (RAID) array experience media errors in the same target sector, the RAID array itself is directly replaced. However, this approach can easily waste storage resources on the RAID array's hard drives, impacting the user experience. Summary of the Invention

[0004] The present application provides a method for handling server and hard disk media errors, which at least solves the problem in the related art of directly replacing an independent disk redundant array, resulting in waste of storage resources in the independent disk redundant array hard disk and affecting user experience.

[0005] The present application provides a server, comprising: a controller and a redundant array of independent disks connected to the controller, wherein the redundant array of independent disks includes multiple hard disks, and the same sectors of each hard disk store different data in the same stripe; the controller is configured to:

[0006] If it is detected that a medium error occurs in the same target sector of at least two hard disks, then the target logical block addresses corresponding to the target sectors in the at least two hard disks are obtained;

[0007] For any one of the at least two hard disks, reallocating a new sector for a target logical block address corresponding to the hard disk in a spare sector preset in the hard disk;

[0008] Rebuild new sectors allocated on at least two hard disks to enable the Redundant Array of Independent Disks to function properly.

[0009] This application also provides a method for handling hard disk media errors, including:

[0010] If it is detected that a medium error occurs in the same target sector of at least two hard disks, then the target logical block addresses corresponding to the target sectors in the at least two hard disks are obtained;

[0011] For any one of the at least two hard disks, reallocating a new sector for a target logical block address corresponding to the hard disk in a spare sector preset in the hard disk;

[0012] Rebuild new sectors allocated on at least two hard disks to enable the Redundant Array of Independent Disks to function properly.

[0013] The server of the present application includes a controller and an independent disk redundant array connected to the controller, wherein the independent disk redundant array includes multiple hard disks, and the same sectors of each hard disk store different data in the same stripe. If the controller detects that a media error occurs in the same target sector of at least two hard disks, the target logical block address corresponding to the target sector in at least two hard disks is obtained, and for any of the at least two hard disks, a new sector is reallocated for the target logical block address corresponding to the hard disk in the spare sector pre-set by the hard disk, and the new sectors allocated to the at least two hard disks are rebuilt to enable the independent disk redundant array to operate normally. The present application allocates new sectors to at least two hard disks that have a media error at the same time and reconstructs them, so that the independent disk redundant array can continue to be used. This reduces the waste of storage resources in the independent disk redundant array hard disk caused by directly replacing a new independent disk redundant array in the related art, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0015] Figure 1 A flowchart of a method for recovering data using the fault-tolerant mechanism of a redundant array of independent disks provided by the present application;

[0016] Figure 2 A schematic diagram of an application scenario provided in an embodiment of the present application;

[0017] Figure 3 A schematic diagram of the structure of a server provided in an embodiment of the present application;

[0018] Figure 4 A schematic diagram of the distribution of data blocks and check blocks provided in an embodiment of the present application;

[0019] Figure 5 A flowchart of a method for reconstructing new sectors allocated to at least two hard disks provided in an embodiment of the present application;

[0020] Figure 6 A schematic diagram of a redundant array of independent disks 5 provided in an embodiment of the present application;

[0021] Figure 7 A flowchart of a method for handling hard disk media errors provided in an embodiment of the present application;

[0022] Figure 8 A schematic diagram of the structure of a hard disk medium error processing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0024] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.

[0025] In servers, hard drive media errors are a common problem in hard drive storage systems. They can lead to data loss or corruption, making files unreadable, compromised data integrity, and cause system startup failures, slow performance, or even crashes. A media error refers to an error in the physical storage medium, such as a hard drive, that prevents the data stored therefrom from being correctly read, written, or verified due to physical damage, aging, wear, or external interference.

[0026] Optionally, the hardware can be a mechanical hard drive or a solid-state drive. A mechanical hard drive stores data by using a magnetic head to read and write magnetic media on the disk surface. When the disk rotates at high speed, the head floats above the disk surface, writing data by changing the magnetic state of the disk surface, and reading data by detecting the magnetic state. This mechanical structure makes the hard drive susceptible to factors such as physical shock, dust, and high temperature, which can easily lead to media errors. Solid-state drives use flash memory modules to store data, controlling the writing and reading of data through electronic signals. Although solid-state drives have no mechanical parts, flash memory modules gradually age after repeated erasures and writes, and media errors may also occur.

[0027] Currently, when dealing with hard disk media errors, the sector data where the media error occurred during data writing or reading can be successfully recovered through the hard disk's reallocation mechanism or by utilizing the RAID's fault tolerance mechanism.

[0028] For example, the data recovery is performed by using the fault tolerance mechanism of RAID. Figure 1 , Figure 1 The present application provides a flow chart of a method for recovering data using the fault tolerance mechanism of a redundant array of independent disks, which may include the following steps:

[0029] S101: The redundant array of independent disks controller detects that a media error occurs in only one hard disk.

[0030] S102: The redundant array of independent disks controller determines whether the redundant array of independent disks is redundant array of independent disks 1.

[0031] S103: If it is a redundant array of independent disks 1, mark the sector where the medium error occurs.

[0032] S104: Check whether there is a spare sector in the hard disk where the medium error occurs.

[0033] S105: If there is a spare sector, the mirroring principle of the redundant array of independent disks 1 is used to restore the data corresponding to the sector where the medium error occurs in the spare sector.

[0034] S106. The medium error is repaired successfully.

[0035] S107. If there is no spare sector, the medium error recovery fails.

[0036] S108: If it is a redundant array of independent disks 5 or redundant array of independent disks 6, the sector where the medium error occurs is also marked.

[0037] S109: Check whether there is a spare sector in the hard disk.

[0038] S110. If a spare sector exists, the data corresponding to the sector where the medium error occurred is recovered in the spare sector by using the parity information of the redundant array of independent disks 5 or the redundant array of independent disks 6 and the different data of the same strip stored in the same sector in the other hard disks.

[0039] S111. The media error was repaired successfully.

[0040] S112: If there is no spare sector, the media error recovery fails.

[0041] It can be seen that the above method can only recover data when a medium error occurs on one hard disk in the RAID.

[0042] However, if a media error occurs simultaneously in the same sector of the same stripe on different hard drives in a RAID, the above mechanism cannot be used to recover the data. This is because, for RAID1, recovery relies on the mirrored data of another hard drive. If an error occurs in the same sector on both hard drives, there is no intact data to reference in the mirror, making the data unrecoverable. For RAID5 or RAID6, recovery requires parity data and the same stripe data on the remaining hard drives. Errors in the same sector on multiple hard drives mean that multiple data in the same stripe are damaged. At this time, the parity data lacks sufficient intact data and cannot be reverse-calculated to determine the damaged data. As a result, even after allocating new sectors from the spare sector, data recovery cannot be completed.

[0043] In the prior art, when media errors occur simultaneously in the same sector of different hard drives within the same stripe of a RAID array, the RAID array is directly replaced with a new one. However, in cases where media errors occur simultaneously in a RAID array, although the data in the hard drive sector corresponding to the media error has been lost, the data lost in the individual stripe sectors accounts for a very small proportion of the total RAID capacity. Directly replacing the RAID array can easily waste storage resources within the redundant array of independent disks hard drives. Furthermore, replacing the RAID array can affect some stored business data, resulting in poor terminal service and, in turn, a poor user experience.

[0044] Therefore, in response to the above-mentioned problems in the related art, during the research process, it was found that although media errors simultaneously occur in the same sector of different hard drives in the same stripe, although local data loss occurs, it only involves sectors in individual stripes, which accounts for a very small proportion of the entire RAID capacity and does not need to be discarded as a whole. Therefore, the present application proposes a new solution. Specifically, if a media error is detected in the same target sector on at least two hard drives, the target logical block addresses corresponding to the target sectors on at least two hard drives are obtained to lock the error range and reduce the mishandling of irrelevant areas. For any of the at least two hard drives, a new sector is reallocated to the target logical block address corresponding to the hard drive in the spare sectors pre-set in the hard drive. By reusing the redundancy capacity of the pre-set spare sectors in the hard drive, a new sector is reallocated to the target logical block address of each hard drive that has a media error. The sector with the media error is "isolated" and replaced with a new sector. Finally, the new sectors allocated to the at least two hard drives are rebuilt, allowing the RAID to continue to operate normally while retaining most of the storage resources.

[0045] See Figure 2 , Figure 2 A schematic diagram of an application scenario provided for an embodiment of the present application includes a controller 20 and an independent disk redundant array 21 connected to the controller 20. The independent disk redundant array includes multiple hard disks 211, and each hard disk 211 includes multiple sectors 2111.

[0046] If the controller detects that media errors occur in the same target sector of at least two hard disks, it reallocates new sectors from the pre-set spare sectors of the hard disks and rebuilds the new sectors allocated to at least two hard disks, thereby allowing the independent disk redundant array to operate normally.

[0047] It is understandable that the above examples are only for illustration, and the present application does not limit the number of controllers, independent redundant arrays of disks, hard disks, and sectors, which can be determined based on actual application conditions.

[0048] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0049] See Figure 3 , Figure 3 This is a structural diagram of a server provided in an embodiment of the present application. The server includes a controller 20 and an independent disk redundant array 21 connected to the controller 20. The independent disk redundant array 21 includes a plurality of hard disks 211.

[0050] Specifically, if the controller 20 detects that a medium error occurs in the same target sector of at least two hard disks, the controller 20 obtains the target logical block addresses corresponding to the target sectors in the at least two hard disks.

[0051] Stripe is a technology that stores data in a distributed manner across multiple hard disks. In this embodiment, the same sectors of each hard disk store different data in the same stripe.

[0052] For example, assume there is a RAID 5 consisting of three hard drives, such as hard drive A, hard drive B, and hard drive C. The stripe size can be 64KB. If the stripe contains 2 data blocks and 1 parity block, and they are stored in the same sector location on the three hard drives, such as sector 100 of the logical block addressing (LBA).

[0053] When reading or writing data in the hard disk, if the controller 20 detects that a medium error occurs in the same target sector of at least two hard disks, the controller 20 obtains the target logical block addresses corresponding to the target sectors in the at least two hard disks.

[0054] Taking the above example, sector LBA 100 of hard disk A stores data block 1 of the stripe, sector LBA 100 of hard disk B stores data block 2, and sector LBA 100 of hard disk C stores the parity block. If at least two of these three sectors simultaneously suffer data loss due to media damage, such as head scratches or bad sectors, that is, media errors simultaneously occur at the same sector location on different hard disks in the same stripe, the controller 20 obtains the logical block address corresponding to the sector where the media error occurred.

[0055] In the present application, a logical block address management table is also preset. After the controller 20 detects that a media error occurs in the same target sector of at least two hard disks, the target logical block addresses corresponding to the target sectors in at least two hard disks are stored in the preset logical block address management table, and the status corresponding to at least two hard disks in the logical block address management table is marked as an unrepaired state.

[0056] In addition to storing logical block addresses, timestamp information, error type, and status information can also be stored. As shown in Table 1, the contents of the logical block address management table include but are not limited to: sequence number, timestamp information, physical block address, error type, and status information. The physical block address can include a start address and an end address.

[0057] Table 1

[0058]

[0059] In Table 1, the timestamp information indicates the time when the controller 20 detected a media error. The logical block address indicates the logical block address of the sector where the media error occurred. The error type indicates whether the controller 20 detected the error while reading or writing data. The status information indicates whether the media error has been repaired. Typically, when a media error is first detected, it is in the unrepaired state.

[0060] In this embodiment, the mapped physical block address can also be calculated through the logical block address. For details, please refer to the following formulas. Figure 4 , Figure 4 A schematic diagram of data block and parity block distribution provided in an embodiment of the present application, taking RAID5 as an example, illustrates the data block and parity block in the physical storage device. Figure 4 The distribution logic on the "Extent" in the , where "Extent" can be a hard disk.

[0061] exist Figure 4In the example, the virtual disk presents unified logical storage to upper-layer applications, consisting of sequentially numbered data blocks 0-15, which are mapped to the stripe structure of the underlying physical storage. The physical storage device has five extents: the first, second, third, fourth, and fifth hard drives, corresponding to a parity rotation level (PRL) of 05. The PRL is the actual carrier of data blocks and parity blocks. Stripes are horizontal groupings of data blocks and parity blocks, each distributed across multiple hard drives. For example, the first stripe includes stripes (0,0) to (4,0) from the first to fifth hard drives. Parallel reading and writing of data within a stripe improves performance. Stripes are also layered vertically by depth (the first, second, and third stripes represent different depth levels), creating a multidimensional storage structure.

[0062] Each stripe, for example, stripe (0,0) to stripe (4,0) of the first stripe, contains data blocks and parity blocks. The parity block position cyclic offset can be as follows: Figure 4 As shown in the figure, in the first stripe, stripe (4,0) on the fifth drive is a parity block, used to protect data blocks in other extents within the first stripe. In the second stripe, stripe (3,1) on the fourth drive is a parity block. In the third stripe, stripe (2,2) on the third drive is a parity block. This round-robin distribution evenly distributes the parity load across different extents, reducing the long-term parity write pressure on a single drive and improving overall reliability and performance.

[0063] Determine the index of the extended segment where the parity block of a given stripe is located using formula (1) :

[0064]

[0065] in, Indicates the number of extended segments in the virtual disk, i.e. the number of hard disks included; Indicates the logical block address; Indicates the size of the blocks in the stripe; Indicates floor operation; Represents the modulo operation.

[0066] Determine the index of the extended segment using formula (2) :

[0067]

[0068] Determine the data block by formula (3) :

[0069]

[0070] Determine the check block by formula (4) :

[0071]

[0072] in, Indicates the offset of the starting position of the block in the stripe; Indicates the index of the stripe.

[0073] Optionally, the values ​​of the relevant parameters in the above formula may be as shown in Table 2.

[0074] Table 2

[0075]

[0076] Among them, M represents the number of data blocks, M must be able to be Divisible.

[0077] Therefore, in this embodiment, the physical block address corresponding to the logical block address may also be supplemented in the logical block address management table.

[0078] Specifically, for any one of the at least two hard disks, the controller 20 reallocates a new sector for the target logical block address corresponding to the hard disk in the spare sectors preset by the hard disk.

[0079] In this embodiment, spare sectors are pre-set in each hard disk, and different sectors correspond to different physical block addresses.

[0080] One possible implementation method is to obtain the current number of erase and write times and error correction rate of each spare sector in the spare sectors pre-set on the hard disk, and determine the sector whose number of erase and write times is less than the preset erase and write number threshold and whose error correction rate is less than the preset error correction rate threshold as the new sector to be reallocated to the target logical block address corresponding to the hard disk.

[0081] In this application, a physical block address management table is also preset. After the controller 20 determines the new sector to be reallocated for the target logical block address corresponding to the hard disk, it obtains the physical block addresses corresponding to at least two new sectors of the hard disk, which can also be called remapped physical block addresses, and stores them in the preset physical block address management table.

[0082] In addition to storing physical block addresses, it can also store timestamp information, logical block addresses, status flags, and status information. As shown in Table 3, the contents in the physical block address management table include but are not limited to: sequence number, timestamp information, logical block address, status flags, and status information.

[0083] Table 3

[0084]

[0085] In Table 3, the timestamp information refers to the time when the controller 20 allocated the new sector. The logical block address refers to the logical block address of the sector where the media error occurred. The status flag indicates whether the error was newly discovered by the controller 20 or has already been resolved. The remapped physical block address refers to the physical block address of the newly allocated sector. The status information indicates whether the media error has been repaired, including unresolved and resolved states.

[0086] Specifically, the controller 20 reconstructs the new sectors allocated to at least two hard disks, so that the redundant array of independent disks 21 operates normally.

[0087] The process of the controller 20 rebuilding the new sectors allocated to at least two hard disks will be described in the following embodiments. Please refer to the following embodiments.

[0088] Optionally, in this embodiment, the controller 20 may be a processor. The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), or application-specific integrated circuits (ASICs). The general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the application may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.

[0089] In the above embodiment of the present application, the server includes a controller 20 and an independent disk array 21 connected to the controller 20. The independent disk array 21 includes multiple hard disks, and the same sectors of each hard disk store different data in the same stripe. Among them, if the controller 20 detects that at least two hard disks have a media error in the same target sector, it obtains the target logical block address corresponding to the target sector in the at least two hard disks. For any of the at least two hard disks, a new sector is reallocated from the pre-set spare sector of the hard disk for the target logical block address corresponding to the hard disk, and the new sectors allocated to the at least two hard disks are rebuilt to enable the normal operation of the independent disk array 21. The present application allocates new sectors to at least two hard disks that have experienced media errors at the same time and rebuilds them, so that the independent disk array 21 can continue to be used. This reduces the waste of storage resources in the independent disk array 21 hard disk caused by directly replacing a new independent disk array 21 in the related art, thereby improving the user experience.

[0090] Furthermore, based on the above embodiment, the process of rebuilding new sectors allocated to at least two hard disks is described.

[0091] See Figure 5 , Figure 5 A flowchart of a method for reconstructing new sectors allocated to at least two hard disks provided in an embodiment of the present application is provided below. Figure 6 , Figure 6 A schematic diagram of a redundant array of independent disks 5 provided in an embodiment of the present application, illustrating Figure 5 The method may include the following steps:

[0092] S501: Write preset data into new sectors allocated to at least two hard disks.

[0093] like Figure 6 As shown, it is assumed that RAID5 includes 4 hard disks, namely the first hard disk, the second hard disk, the third hard disk, and the fourth hard disk. The first hard disk stores a check block, which can also be called check data, the second hard disk stores data block D0, the third hard disk stores data block D1, and the fourth hard disk is the hard disk to be rebuilt. Assume that a media error occurs in the LBA 0x100 sector of the first hard disk, that is, a media error of the check block. When the data reconstruction of the fourth hard disk proceeds to D2, because a parity check has occurred at the same sector position of the first hard disk, that is, a media error caused by the check block, the data D2 cannot be recovered by the preset check algorithm of RAID5. Therefore, the controller 20 is required to reallocate new sectors.

[0094] The controller 20 marks the sectors with the same media errors in the first hard disk and the fourth hard disk as preset marks, wherein the preset marks are used to indicate that the sectors are "bad blocks". Specifically, the logical block addresses corresponding to the "bad blocks" in the first hard disk and the fourth hard disk are marked and recorded in a preset logical block address management table.

[0095] After detecting that a media error has occurred in the same target sector of at least two hard drives, the controller 20 can also use a preset long write command (Write Long) to mark the target sectors corresponding to the at least two hard drives as a pseudo unrecovered error. This pseudo unrecovered error flag indicates that a media error has occurred in the target sectors corresponding to the at least two hard drives. Any read or write operations involving these sectors will fail and return a media error prompt.

[0096] After the controller 20 allocates new sectors to at least two hard disks, it writes preset data, for example, 0, into the allocated new sectors.

[0097] S502: Calculate a target checksum based on preset data written in new sectors allocated to at least two hard disks and different data in the same stripe stored in the same sectors of other hard disks included in the redundant array of independent disks.

[0098] One possible implementation method is to use a checksum algorithm preset in the redundant array of independent disks 21, input preset data written in new sectors allocated to at least two hard disks, and different data in the same stripe stored in the same sectors of other hard disks included in the redundant array of independent disks 21, into the checksum algorithm to obtain a target checksum value.

[0099] Taking RAID 5 as an example, the preset check algorithm may be an XOR algorithm. The above data is input into the XOR algorithm to finally obtain a target check value.

[0100] S503: Determine a target hard disk storing an initial check value from the redundant array of independent disks.

[0101] by Figure 6 Taking the example of as an example, since the hard disk storing the check value, ie, the check block, has been determined in advance, it can be determined that the target hard disk storing the initial check value is the first hard disk.

[0102] S504: Update the initial checksum in the target hard disk to the target checksum, so as to complete the reconstruction of the new sectors allocated to at least two hard disks.

[0103] The controller 20 updates the initial check value to the target check value to complete the reconstruction of the new sectors allocated to the at least two hard disks.

[0104] It is understandable that if more hard disks encounter media errors in the same sector, the reconstruction process can refer to the above steps in this embodiment.

[0105] RAID 6 has a hard drive redundancy of two hard drives. When a RAID 6 media error exceeds two hard drives, the processing is similar to that of RAID 5. Both update the logical block address management table and the physical block address management table, use the writelong command to mark a pseudo unrecovered error, determine a newly allocated sector from the spare sector of the hard drive where the media error occurred, and write preset data, such as 0, to the newly allocated sector. RAID 6 differs from RAID 5 in that it needs to calculate and update two checksums.

[0106] Because RAID 1 achieves data redundancy through mirroring, it doesn't require a parity check algorithm for data recovery or data checksum updates. Therefore, when a hard drive's media errors exceed the hard drive's redundancy, only the logical block address management table and the physical block address management table are updated. A pseudo-unrecovered error is marked using the write long command. A newly allocated sector is identified from the spare sectors of the hard drive where the media error occurred, and preset data (e.g., 0) is written to the newly allocated sector.

[0107] After the controller 20 reconstructs the new sectors allocated to at least two hard disks, the controller 20 is also used to receive the data modified to the repaired state and split the data in the new stripe to obtain multiple data, and then store the multiple data in the new sectors of the at least two hard disks and the original sectors of other hard disks included in the independent disk redundant array 21.

[0108] After the storage is completed, the unrepaired state corresponding to at least two hard disks in the logical block address management table is changed to the repaired state.

[0109] For example, when controller 20 reads data from the same sector on different hard drives within the same stripe in a RAID array, a multi-disk media error can occur. The logical block address of the media error is recorded in the logical block address management table. The bad block is not repaired, and a Write Long command is sent to mark the bad block of the hard drive with the media error as containing a pseudo unrecovered error. A media error message is reported each time the bad block is read.

[0110] For example, when controller 20 writes data to the same sector on different hard drives within the same stripe in a RAID array, a multi-disk media error can occur. The logical block address of the media error is recorded in the logical block address management table. New sectors corresponding to the logical block addresses of the media error on each hard drive are reassigned, and any write operations involving the media error sector are redirected to the new sector for data writing. After the data is successfully written, the status information in the logical block address management table is changed to "repaired," and the corresponding checksum is updated.

[0111] In the above-mentioned embodiment of the present application, preset data is written to the new sectors allocated to at least two hard disks, and a target check value is calculated based on the preset data written to the new sectors allocated to at least two hard disks and the different data in the same stripe stored in the same sectors of other hard disks included in the independent disk redundant array 21. And from the independent disk redundant array 21, the target hard disk storing the initial check value is determined, and then the initial check value in the target hard disk is updated to the target check value to complete the reconstruction of the new sectors allocated to at least two hard disks. In this embodiment, after the preset data is written to the new sector, the target check value is calculated and the initial check value is updated in combination with other data in the same stripe. This not only verifies the logical correlation between the new data and the existing data through the check algorithm, but also synchronously updates the redundancy benchmark of the RAID, so that the reconstructed sector can be better integrated into the RAID storage system, thereby improving the reliability of the RAID after sector-level fault repair.

[0112] Below, based on any of the above embodiments, the content of this application is briefly described through specific examples.

[0113] In this embodiment, the server includes a controller 20. The hard drive experiencing the media error can be located in slot 4 of the server, along with multiple normal hard drives. These hard drives form a RAID array and are installed with an operating system capable of executing the specific implementation steps. To minimize interference during the process, the original hard drive located in slot 7 of the server can be removed and replaced with a new hard drive, which then undergoes a rebuild.

[0114] Assume that a media error occurs in a sector of the hard drive in slot 4 while the hard drive in slot 7 is being rebuilt. The following steps are performed to resolve the issue:

[0115] The hard drive in slot 7 is being rebuilt. The following code indicates the rebuild progress.

[0116] 25-04-17,7:27:04 BG Work:Rebuild progress on PD 0e(e0x86 / s7) is38.12%(14572s)

[0117] The code content indicates: at the time point 25-04-17, 7:27:04, background task: hard disk rebuild process, hardware rebuild marked as 0e, the rebuild progress is 38.12%, and it has lasted for 14572 seconds.

[0118] 25-04-17,7:29:06 BG Work:Rebuild progress on PD 0e(e0x86 / s7) is39.18%(14694s)

[0119] The code content indicates: At the time point 25-04-17, 7:29:06, background task: hard disk rebuild process, hardware rebuild marked as 0e, the rebuild progress is 39.18%, and it has lasted for 14694 seconds.

[0120] A medium error occurred on the hard drive in slot 4 at sector 0x196609a. The following code indicates a medium error.

[0121] 25-04-17,09:28:37 FATAL:Unrecoverable medium error during recovery onPD 0a(e0x86 / s4) at 196609a

[0122] This code indicates that at 25-04-17, 09:28:37, a critical error occurred: During recovery, an unrecoverable medium error occurred at address 196609a on drive 0a. "FATAL" indicates a severe error, while "Unrecoverable medium error" indicates physical damage at that location on the drive that cannot be repaired by RAID redundancy or error correction mechanisms.

[0123] The hard disk in slot 7 is marked as a pseudo unrecovered error in the same sector and a medium error is returned. At the same time, the RAID logical block address 0x1176269a is marked as a medium error. This is specifically achieved through the following code content.

[0124] 25-04-17,09:28:38 FATAL:Uncorrectable medium error logged for VD 01 / 1at 1176269a (on PD 0e(e0x86 / s7) at 196609a)

[0125] The code content indicates: At the time point 25-04-17, 09:28:38, a serious error occurred: the virtual disk (VD 01 / 1) recorded an uncorrectable medium error at the logical block address 1176269a. The error is associated with the hard disk with the identifier 0e and the physical block address 196609a.

[0126] After a successful rebuild, a full write operation is performed on the RAID. The media error corresponding to the logical block address 0x1176269a is repaired and marked as repaired in the logical block address management table. This is achieved using the following code.

[0127] 25-04-18,12:56:36 Info:Medium error corrected on VD 01 / 1 at 1176269a

[0128] This code indicates that at 25-04-18, 12:56:36, a media error at logical block address 1176269a on a virtual disk (VD 01 / 1) was repaired. "Info" indicates that this is an informational record.

[0129] For the specific implementation process and technical effects of this embodiment, please refer to any of the above embodiments. To avoid redundancy, the description will not be repeated.

[0130] This application also provides a method for handling hard disk media errors, see Figure 7 , Figure 7 This is a flow chart of a method for handling a hard disk medium error provided in an embodiment of the present application. The method may be executed by the controller 20 in the server. The method may include the following steps:

[0131] S701: If it is detected that a medium error occurs in the same target sector of at least two hard disks, obtain target logical block addresses corresponding to the target sectors in the at least two hard disks.

[0132] S702: For any one of the at least two hard disks, reallocate a new sector in a spare sector preset by the hard disk for a target logical block address corresponding to the hard disk.

[0133] S703: Rebuild the new sectors allocated to at least two hard disks to enable the redundant array of independent disks to work normally.

[0134] The specific implementation methods of the above steps are described in the above multiple embodiments. Please refer to the above multiple embodiments. To avoid redundancy, the description will not be repeated.

[0135] In the above-mentioned embodiment of the present application, although data loss may occur in the sector corresponding to the medium error, the hard disk having the medium error can still be in a usable state without replacing the entire independent disk array, thereby improving the availability and reliability of the independent disk array having the medium error, and reducing business interruption or downtime caused by replacing the independent disk array, thereby improving user experience.

[0136] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0137] Figure 8 This is a schematic diagram of a hard disk medium error processing device provided in an embodiment of the present application. Figure 8 Shown, including:

[0138] The acquisition module 801 is configured to acquire target logical block addresses corresponding to the target sectors in the at least two hard disks if a media error is detected in the same target sector in at least two hard disks.

[0139] The processing module 802 is configured to reallocate a new sector for a target logical block address corresponding to any one of the at least two hard disks in a spare sector preset in the hard disk.

[0140] The processing module 802 is further configured to reconstruct the new sectors allocated to at least two hard disks so that the redundant array of independent disks can operate normally.

[0141] In one possible implementation, after detecting that at least two hard disks have medium errors in the same target sector, the processing module 802 is further configured to:

[0142] The target sectors corresponding to at least two hard disks are marked as pseudo unrecovered error flags through a preset long write instruction. The pseudo unrecovered error flags are used to indicate that medium errors occur in the target sectors corresponding to the at least two hard disks.

[0143] In one possible implementation, the processing module 802 is specifically configured to:

[0144] In the spare sectors pre-set on the hard disk, the current number of erase and write times and error correction rate of each spare sector are obtained.

[0145] A sector whose erase count is less than a preset erase count threshold and whose error correction rate is less than a preset error correction rate threshold is determined as a new sector reallocated to the target logical block address corresponding to the hard disk.

[0146] In one possible implementation, the processing module 802 is specifically configured to:

[0147] The preset data is written to new sectors allocated to at least two hard disks.

[0148] A target checksum is calculated based on preset data written in new sectors allocated to at least two hard disks and different data in the same stripe stored in the same sectors of other hard disks included in the redundant array of independent disks.

[0149] From the redundant array of independent disks, determine the target hard disk where the initial checksum value is stored.

[0150] The initial checksum value in the target hard disk is updated to the target checksum value to complete the reconstruction of the new sectors allocated to the at least two hard disks.

[0151] In one possible implementation, the processing module 802 is specifically configured to:

[0152] Based on a verification algorithm preset by an independent disk redundant array, preset data written into new sectors allocated by at least two hard disks, as well as different data in the same stripe stored in the same sectors of other hard disks included in the independent disk redundant array, are input into the verification algorithm to obtain a target verification value.

[0153] In one possible implementation, the processing module 802 is further configured to:

[0154] Get the physical block addresses corresponding to at least two new sectors of the hard disk.

[0155] The physical block addresses corresponding to at least two new sectors of the hard disk are stored in a preset physical block address management table.

[0156] In one possible implementation, the processing module 802 is further configured to:

[0157] The target logical block addresses corresponding to the target sectors in at least two hard disks are stored in a preset logical block address management table.

[0158] The states corresponding to at least two hard disks in the logical block address management table are marked as unrepaired.

[0159] In one possible implementation, after rebuilding the new sectors allocated to at least two hard disks, the processing module 802 is further configured to:

[0160] Receive data in a new stripe.

[0161] The data in the new stripe is split to obtain multiple data.

[0162] The plurality of data are respectively stored in new sectors of at least two hard disks and original sectors of other hard disks included in the redundant array of independent disks.

[0163] In one possible implementation, after storing the plurality of data in the new sectors of the at least two hard disks and the original sectors of the other hard disks included in the redundant array of independent disks, the processing module 802 is further configured to:

[0164] Change the unrepaired state of at least two hard disks in the logical block address management table to the repaired state.

[0165] For the description of the features in the embodiment corresponding to the hard disk medium error processing device, reference can be made to the relevant description of the embodiment corresponding to the hard disk medium error processing method, which will not be repeated here.

[0166] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned hard disk medium error processing method embodiments when running.

[0167] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0168] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned hard disk medium error processing method embodiments are implemented.

[0169] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps in any of the above-mentioned hard disk medium error processing method embodiments.

[0170] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0171] The above describes in detail a method for handling server and hard disk media errors provided by this application. This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only intended to help understand the method and core ideas of this application. It should be noted that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the scope of protection of the claims of this application.

Claims

1. A server, characterized in that: include: A controller and a redundant array of independent disks connected to the controller, wherein the redundant array of independent disks includes multiple hard disks, and the same sectors of each hard disk store different data in the same stripe; the controller is used to: If it is detected that a medium error occurs in the same target sector of at least two hard disks, obtaining target logical block addresses corresponding to the target sectors in the at least two hard disks; For any of the at least two hard disks, obtaining a current number of writes and erases and an error correction rate of each spare sector pre-set in the hard disk; determining a sector having a number of writes and erases less than a preset write number threshold and an error correction rate less than a preset error correction rate threshold as a new sector to be reallocated to a target logical block address corresponding to the hard disk; Writing preset data to the new sectors allocated to the at least two hard disks; calculating a target checksum based on the preset data written to the new sectors allocated to the at least two hard disks and different data in the same stripe stored in the same sectors of other hard disks included in the redundant array of independent disks; Determining a target hard disk storing an initial check value from the redundant array of independent disks; The initial check value in the target hard disk is updated to the target check value to complete the reconstruction of the new sectors allocated to the at least two hard disks, so that the redundant array of independent disks can work normally.

2. The server according to claim 1, wherein: After detecting that a medium error occurs in the same target sector on at least two hard disks, the controller is further configured to: The target sectors corresponding to the at least two hard disks are marked as pseudo unrecovered error identifiers through a preset long write instruction, and the pseudo unrecovered error identifiers are used to indicate that a medium error occurs in the target sectors corresponding to the at least two hard disks.

3. The server according to claim 2, wherein: When calculating a target parity value based on the preset data written in the new sectors allocated to the at least two hard disks and different data in the same stripe stored in the same sectors of other hard disks included in the redundant array of independent disks, the controller is specifically configured to: Based on a verification algorithm preset by an independent disk redundant array, the preset data written in the new sectors allocated to the at least two hard disks, as well as different data in the same stripe stored in the same sectors of other hard disks included in the independent disk redundant array, are input into the verification algorithm to obtain the target verification value.

4. The server according to claim 3, wherein: The controller is also used for: Obtaining physical block addresses corresponding to the at least two new sectors of the hard disk; The physical block addresses corresponding to the at least two new sectors of the hard disk are stored in a preset physical block address management table.

5. The server according to claim 1, wherein: The controller is also used for: storing the target logical block addresses corresponding to the target sectors in the at least two hard disks in a preset logical block address management table; The states corresponding to the at least two hard disks in the logical block address management table are marked as unrepaired states.

6. The server according to claim 5, wherein: After the controller rebuilds the new sectors allocated to the at least two hard disks, the controller is further configured to: Receive data in a new stripe; Splitting the data in the new stripe to obtain multiple data; The plurality of data are stored in new sectors of the at least two hard disks and original sectors of other hard disks included in the redundant array of independent disks.

7. The server according to claim 6, wherein: After storing the plurality of data in the new sectors of the at least two hard disks and the original sectors of other hard disks included in the redundant array of independent disks, the controller is further configured to: The unrepaired status corresponding to the at least two hard disks in the logical block address management table is modified to a repaired status.

8. A method for handling hard disk medium errors, characterized in that: include: If it is detected that a medium error occurs in the same target sector of at least two hard disks, then obtaining target logical block addresses corresponding to the target sectors in the at least two hard disks; For any of the at least two hard disks, obtaining a current number of writes and erases and an error correction rate of each spare sector pre-set in the hard disk; determining a sector having a number of writes and erases less than a preset write number threshold and an error correction rate less than a preset error correction rate threshold as a new sector to be reallocated to a target logical block address corresponding to the hard disk; Writing preset data to the new sectors allocated to the at least two hard disks; calculating a target checksum based on the preset data written to the new sectors allocated to the at least two hard disks and different data in the same stripe stored in the same sectors of other hard disks included in the redundant array of independent disks; Determining a target hard disk storing an initial check value from the redundant array of independent disks; The initial check value in the target hard disk is updated to the target check value to complete the reconstruction of the new sectors allocated to the at least two hard disks, so that the redundant array of independent disks can work normally.

Citation Information

Patent Citations

  • Disk bad block processing method based on soft RAID (redundant array of independent disks)

    CN102508724A

  • Data reconstruction method and device, storage medium and program product

    CN119336536A