A disk stripe inspection method, device, computer equipment and storage medium
By reading and comparing the data chunking and verification chunking of RAID stripes, the error chunking is accurately identified and repaired, the problem of data error expansion caused by inconsistency of RAID stripes is solved, and the reliability of data storage is improved.
Patent Information
- Application Number
- CN202411180373.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-08-27
AI Technical Summary
The prior art cannot accurately determine which blocks are incorrect when RAID stripes are inconsistent, resulting in the inability to perform automatic reconstruction and repair, further expanding the data error.
By reading the data chunking and verification chunking on the disk, computing the verification chunking information, and comparing it with the information saved on the disk, identifying the wrong chunking, repairing and reconstructing, and ensuring data consistency.
Accurate error recognition and automatic repair of RAID stripes are realized, avoiding the expansion of data errors and improving the reliability of data storage.
Smart Images

Figure CN118708397B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing technology, and in particular to a disk stripe inspection method, device, computer equipment and storage medium. Background Art
[0002] In cloud computing data centers, various technologies have been developed to protect user data in order to store data securely, such as RAID (Redundant Array of Independent Disks) technology based on redundancy check, erasure code technology, and multiple copy technology. Among them, in RAID technology based on redundancy check, multiple disks are combined into a RAID array, each disk is cut into blocks of the same size, and blocks on different disks form a stripe. According to the RAID formation algorithm, a stripe can have zero, one, or two redundant blocks, and redundant data is used to provide fault recovery to ensure data security. If a disk fails, the RAID algorithm uses redundant data to recover it. The check block can be calculated from the stripe data block, and a certain data block can also be calculated from the check block and other data blocks. This ensures that data recovery can be performed when a certain disk fails.
[0003] There are various unpredictable errors in the system, such as memory reversal, disk silence, link transmission error, software bug, etc. During the reading and writing operation, data needs to go through a complex transmission and data access process. The entire process has to go through many components, various transmission channels and complex software processing logic. If an error occurs in any of the links, the data will be destroyed, which may cause data errors. If some data blocks or check blocks of the RAID stripe are wrong in the storage path, the RAID stripe may be in an inconsistent state, that is, the check block data calculated by the data of the stripe data block is different from the check block data on the disk. If a disk failure occurs at this time, using redundant data to recover the disk block may further expand the erroneous data block. Therefore, how to check the consistency of the stripe, find the erroneous stripe and data, and repair the erroneous data of the stripe is a problem that needs to be solved urgently by people in this field. Summary of the invention
[0004] In view of this, the present invention provides a disk stripe inspection method, device, computer equipment and storage medium to solve the problem that the current inspection scheme cannot accurately determine which blocks have errors when the RAID stripes are inconsistent, and thus cannot perform automatic reconstruction and repair, and the problem of other failures such as reconstruction causing data errors to expand.
[0005] In a first aspect, the present invention provides a disk stripe inspection method, the method comprising:
[0006] Patrolling a first stripe on a disk, reading a plurality of blocks on the first stripe, wherein the first stripe is one of a plurality of stripes on the disk, the plurality of blocks include data blocks and check blocks, the data blocks and the check blocks each have a corresponding block check area, and each of the block check areas stores check area data;
[0007] Calculate corresponding check block information according to the data information on at least one data block read;
[0008] Determine whether the verification block information is consistent with the information in the verification block stored on the disk;
[0009] If they are inconsistent, calculating the inspection area data corresponding to each block on the first stripe, and comparing the inspection area data corresponding to each block with the inspection area data stored in the respective inspection area of the block to see whether they are the same;
[0010] If there is a difference, it is determined that an error occurs in the data block or the check block corresponding to the current different check area data, and the erroneous data block on the first stripe is repaired and reconstructed.
[0011] In combination with the first aspect, in a possible implementation manner, determining that an error occurs in a data block or a check block corresponding to the current different check area data, and repairing and reconstructing the erroneous data block on the first stripe includes:
[0012] Count the number of data blocks or check blocks where errors occur;
[0013] If the number is within the redundancy range, a stripe reconstruction process is started to restore the erroneous data blocks on the first stripe so that the information of each block on the restored first stripe is the same as the check area data;
[0014] If the number is outside the redundancy range, error information is reported, and the check data corresponding to the erroneous data block is reconstructed so that the information of each block on the first stripe after reconstruction is temporarily the same as the check area data.
[0015] In combination with the first aspect, in another possible implementation, the determining whether the check block information is consistent with information in the check block stored on the disk further includes:
[0016] If they are consistent, it is determined that the data on each block of the first stripe is correct, and the second stripe on the disk is continued to be inspected to determine whether there is an error in the data block or check block on the second stripe; the inspection process of the second stripe is the same as the inspection process of the first stripe.
[0017] In combination with the first aspect, in yet another possible implementation manner, before inspecting the first stripe on the disk, the method further includes:
[0018] Build a RAID disk, divide the RAID disk into disk blocks according to fixed sizes, and number each disk block;
[0019] Grouping disk blocks with the same number into RAID stripes, one of the RAID stripes being the first stripe;
[0020] Divide each of the disk blocks into N sectors, the block inspection area corresponds to one sector, N ≥ 2 and is a positive integer;
[0021] Determine a block inspection area corresponding to the stripe according to the data of the N sectors;
[0022] According to the at least one data block and the corresponding inspection area data, the inspection area data in the block inspection area and the inspection area data of the verification block are calculated.
[0023] In combination with the first aspect, in yet another possible implementation, the calculating, according to the at least one data block and the corresponding inspection area data, the inspection area data in the block inspection area and the inspection area data of the verification block includes:
[0024] Calculating the inspection area data in the block inspection area by a first relational expression according to the at least one data block and the corresponding inspection area data;
[0025] The first relation is: P = D0 D1 D2 ...... D (n-1) ;
[0026] Where P represents the check block, D0, D1, D2, ... D (n-1) Represents N data blocks on a stripe, is an XOR operation;
[0027] Calculating the inspection area data of the verification block P by a second relational expression according to the at least one data block and the corresponding inspection area data;
[0028] The second relational expression is: p =M0 M1 ...... M (n-1) ;
[0029] Among them, M p Indicates the check area data of the check block P, M0, M1..., M (n-1)Indicates the inspection area data corresponding to N data blocks.
[0030] In combination with the first aspect, in yet another possible implementation, the method further includes:
[0031] When new data is written to the target data block on the first stripe, the check block where the target data block is located is updated; and the block check area of the target data block corresponding to the target data block and the block check area of the check block are updated; the target data is any one of at least one data block on the first stripe.
[0032] In combination with the first aspect, in yet another possible implementation, updating the check block where the target data block is located includes:
[0033] Read the original data D in the target data block old ;
[0034] The new data D to be written new With the original data D old Perform XOR operation to obtain the intermediate check value P delta ;
[0035] Read the original verification data P stored in the block inspection area corresponding to the target data block old ;
[0036] The original verification data P old With the intermediate check value P delta Perform XOR operation to get the new check value P new ;
[0037] The new data D new Write the target data block on the first stripe, and write the new check value P new Write the check block where the target data block is located.
[0038] In combination with the first aspect, in another possible implementation, updating the block check area of the target data block corresponding to the target data block and the block check area of the verification block includes:
[0039] Calculate the inspection data of the block inspection area of the target data block according to the new data written;
[0040] Performing an XOR operation on the inspection data of the block inspection area and the inspection data of the block inspection area calculated before writing the new data to obtain intermediate inspection data;
[0041] Read out original inspection data from the block inspection area of the disk, and calculate new inspection data using the original inspection data and the intermediate inspection data;
[0042] The new inspection data is written into the block inspection area of the verification block.
[0043] In combination with the first aspect, in yet another possible implementation, before performing an XOR operation on the inspection data of the block inspection area and the inspection data of the block inspection area calculated before writing the new data to obtain the intermediate inspection data, the method further includes:
[0044] When N=4, the original data on 4 sectors are read, and the original data on the 4 sectors are A 0old , A 1old , A 2old and A 3old ;
[0045] Obtaining inspection data of the block inspection area by calculation according to the original data on the four sectors;
[0046] The calculation formula is: 0olddata =A 0old A 1old A 2old A 3old ;
[0047] Among them, M 0olddata is the inspection data of the block inspection area, It is an XOR operation.
[0048] In combination with the first aspect, in yet another possible implementation, the method further includes:
[0049] According to the original verification data P old Calculate by sector to obtain the corresponding inspection area data;
[0050] The check data is calculated by sectors according to the new check blocks;
[0051] The original verification data P old The corresponding inspection area data and the inspection data obtained by calculating the new check block are XORed to obtain new check block inspection data.
[0052] In combination with the first aspect, in another possible implementation, updating the block inspection area of the verification block specifically includes: writing the new verification block inspection data into the block inspection area of the verification block.
[0053] In a second aspect, the present invention further provides a disk stripe inspection device, the device comprising:
[0054] An inspection module is used to inspect a first stripe on the disk and read a plurality of blocks on the first stripe, wherein the first stripe is one of a plurality of stripes on the disk, the plurality of blocks include data blocks and check blocks, the data blocks and the check blocks each have a corresponding block inspection area, and each of the block inspection areas stores inspection area data;
[0055] A calculation module, used to calculate corresponding check block information according to the data information on at least one data block read;
[0056] A judging module, used to judge whether the information of the check block is consistent with the information in the check block stored on the disk;
[0057] a comparison module, configured to calculate the inspection area data corresponding to each block on the first stripe through the calculation module when the judgment module determines that the check block information is inconsistent, and compare whether the inspection area data corresponding to each block is the same as the inspection area data stored in the respective block inspection area;
[0058] The determination module is used to determine that the data blocks or check blocks corresponding to the current different inspection area data have errors when the comparison module has different comparison conditions, and repair and reconstruct the erroneous data blocks on the first stripe.
[0059] In a third aspect, the present invention further provides a computer device, comprising a memory and a processor, wherein the memory and the processor are connected, and computer instructions are stored in the memory. The processor executes the disk strip inspection method described in the first aspect or any embodiment of the first aspect by executing the computer instructions.
[0060] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, wherein the computer instructions are used to enable a computer to execute the disk strip inspection method described in the first aspect or any one of the embodiments of the first aspect.
[0061] In addition, the present invention also provides a computer program product, including computer instructions, which, when executed on a computer, enable the computer to execute the disk stripe inspection method described in the first aspect or any one of the embodiments of the first aspect.
[0062] The present invention provides a disk strip inspection method and device, which first divide each disk into a fixed strip inspection area for storing inspection data of the component blocks divided into RAID stripes on the disk. Each block of each stripe uses a disk block of a sector size as a block inspection area, and performs XOR calculation on a block in the stripe from front to back according to the sector number to obtain the inspection area data. When the IO updates the stripe data, the corresponding inspection area data is updated accordingly. In the process of inspecting any stripe on the disk, by reading the data information on at least one data block on the stripe, it is determined whether the corresponding check block information is consistent with the information in the check block stored on the disk. When there is inconsistency, the inspection area data corresponding to each block is compared with the inspection area data stored in the respective block inspection area to determine whether they are the same, thereby determining the data block or check block with error on the current stripe, realizing the identification of the error block, and automatically reconstructing and repairing the block to avoid other faults from expanding the data error. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0064] Figure 1 is a schematic diagram of a stripe structure according to an embodiment of the present invention;
[0065] Figure 2 is a schematic diagram of a structure of N stripes according to an embodiment of the present invention;
[0066] Figure 3 It is a flowchart of a disk stripe inspection method according to an embodiment of the present invention;
[0067] Figure 4 is a flow chart of another disk stripe inspection method according to an embodiment of the present invention;
[0068] Figure 5 is a structural block diagram of a disk stripe inspection device according to an embodiment of the present invention;
[0069] Figure 6 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0070] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0071] The technical solution provided by the embodiment of the present invention is applied to the field of disk striping technology. When periodically inspecting RAID to check the consistency of RAID stripes, stripe check comparison is used to determine whether it is an error in the check block. Among them, RAID is a data storage virtualization technology that combines multiple physical disk drives into one or more logical units to improve data reliability, performance and capacity, while ensuring that data access is not affected when a disk fails.
[0072] A method for periodically checking the consistency of RAID stripes during the storage usage cycle. Since a RAID can be as small as tens of TB or as large as hundreds of TB, in order not to affect the performance of the system IO (input and output), the inspection completion cycle is usually set to one week or more. In an inspection cycle, a certain strip is inspected at fixed intervals. During each inspection, the data blocks and check blocks of the stripe are read out separately, and the check value is calculated using the data blocks, and then the calculated check value is compared with the check block. If the comparison results are consistent, it means that they are consistent. If there are multiple check blocks, the entire stripe is consistent only after all the check blocks are verified to be consistent, otherwise it is judged to be inconsistent.
[0073] If the stripe is inconsistent, if there are multiple redundancy checks, some of the redundancy check comparison results are consistent, for example, the P check block calculated using the data block is consistent with the P block result read from the disk. At the same time, some of the redundancy check comparison results are inconsistent, for example, the Q check block calculated using the data block is inconsistent with the Q block result read from the disk. This means that the data block and the P block are correct, and the Q block is incorrect. At this time, the Q check block can be restored using the data block.
[0074] If the stripe is inconsistent and the results of multiple redundant check comparisons are inconsistent, it is impossible to determine whether the data block or the check block is wrong, and it is even more impossible to accurately determine which block is wrong. At this time, the stripe cannot be repaired.
[0075] Therefore, at present, the RAID stripe inspection scheme can only determine whether the stripe is consistent. When the stripe is inconsistent, if the data block and the check block are inconsistent, it is impossible to determine whether the data block is wrong, the check block is wrong, or both the data block and the check block are wrong, and it is even more impossible to accurately determine which block has an error. As a result, the stripe cannot be repaired and the data is destroyed. If the stripe data inconsistency error cannot be repaired immediately, other failures such as reconstruction may be superimposed to expand the data error.
[0076] In order to solve the above technical problems, an embodiment of the present invention provides a disk stripe inspection method. Figure 1 As shown, it is a schematic diagram of a stripe structure of an embodiment of the present invention, and the stripe includes at least one data block and a check block. Among them, the data block stores the data information of the stripe, and the check block stores the redundant check information of the stripe. For example, the number of data blocks is 4, which can be located on different disks respectively, and the 4 data block identifiers are D0_1, D0_2, D0_3 and D0_4 respectively. The check block generated by these 4 data blocks is P.
[0077] In addition, in the embodiment of the present invention, a block inspection area is set for each block, that is, the data block and the verification block have corresponding block inspection area information. For example, the four block inspection areas corresponding to the above-mentioned four data blocks are: D0_1 inspection area, D0_2 inspection area, D0_3 inspection area and D0_4 inspection area, and the inspection area corresponding to the verification block P0 is the P0 inspection area.
[0078] It should be understood that each stripe may also include more or fewer data blocks, and two or more check blocks, and this embodiment does not impose any limitation on this.
[0079] For the convenience of description, this embodiment uses RAID5, in which a stripe consists of four data blocks and one check block, for description, and the same is true for RAID6 and other RAID types. Figure 2 The figure shows a schematic diagram of the structure including stripes 0 to N. The data block of stripe 0 is represented as D0, data block 1 is represented as D0_1, data block 2 is represented as D0_2, data block 3 is represented as D0_3, data block 4 is represented as D0_4, and the parity block of stripe 0 is represented as P0, and so on.
[0080] Similarly, the data block of stripe 1 is represented as D1, and the corresponding four data blocks are represented as D1_1, D1_2, D1_3 and D1_4, and the parity block of stripe 1 is represented as P1. The data block of stripe 2 is represented as D2, and the corresponding four data blocks are represented as D2_1, D2_2, D2_3 and D2_4, and the parity block of stripe 2 is represented as P2. The data block of stripe N is represented as DN, and the corresponding four data blocks are represented as DN_1, DN_2, DN_3 and DN_4, and the parity block of stripe N is represented as PN.
[0081] Each data block and verification block has a corresponding block inspection area, in which inspection area data is stored. The inspection area data can be used to p "express.
[0082] The present invention provides an embodiment of a disk stripe inspection method. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0083] Figure 3 This is a flow chart of a disk stripe inspection method according to an embodiment of the present invention. A periodic inspection task is executed according to the configuration. The periodic inspection task periodically performs inspections of a certain number of stripes. If a stripe consistency error is found during the inspection, the inspection area can be used to determine which block is wrong, and the stripe can be reconstructed and repaired. The process includes the following steps:
[0084] Step S101: inspect the first stripe on the disk and read multiple blocks on the first stripe.
[0085] The first stripe is one of the multiple stripes on the disk. The multiple blocks include data blocks and check blocks. The data blocks and check blocks each have a corresponding block check area. Each block check area stores check area data.
[0086] Step S102: Calculate corresponding check block information based on the data information on at least one data block read.
[0087] For example, Figure 1 In the stripe structure shown, four data blocks, D0_1, D0_2, D0_3 and D0_4, can be read. Based on the four data blocks, the check block P0 is calculated according to a preset algorithm, that is, the corresponding check block information is obtained.
[0088] Step S103: Determine whether the check block information is consistent with the information in the check block stored on the disk.
[0089] The check block information is the information calculated in step S102, and the check block saved on the disk is pre-stored information, and it is determined whether the two are the same.
[0090] If they are consistent, it is determined that the data on each block of the first stripe is correct, and the second stripe on the disk is inspected to determine whether there is an error in the data block or check block on the second stripe; the inspection process of the second stripe is the same as the inspection process of the first stripe.
[0091] Step S104: If they are inconsistent, then calculating the inspection area data corresponding to each block on the first stripe.
[0092] If they are not the same, it indicates that the stripes are inconsistent, that is, the check data calculated for the current stripe is different from the check data pre-stored on the disk. It may be that an error occurs in a block data in the stripe, and step S105 is executed.
[0093] Step S105: comparing the inspection area data corresponding to each block with the inspection area data stored in the respective block inspection area to see whether they are the same.
[0094] This step is to further detect whether errors occur in each data block or check block on the strip. One detection method is: compare the data on the current 4 data blocks and 1 check block with the check area data stored in the block check area, and determine whether the data is the same as the corresponding check area data.
[0095] If they are the same, it is determined that the data block or the check block is correct; otherwise, if they are not the same, it is determined that an error occurs in the data on the data block or the check block.
[0096] Step S106: If there is a difference, it is determined that an error occurs in the data block or the check block corresponding to the current different check area data, and the erroneous data block on the first stripe is repaired and reconstructed.
[0097] For example, if the data block D0_1 on stripe 0 is different from the data on the corresponding D0_1 check area, it is determined that the data block D0_1 is erroneous. If the data of the two are the same, it is determined that the data block D0_1 is correct. Similarly, the data blocks D0_2, D0_3 and D0_4, as well as the check block P0 are determined one by one. If they are the same, it is determined that the data on the current stripe is correct, that is, the first stripe inspected is normal.
[0098] The method provided in this embodiment updates the corresponding check area data when IO updates the stripe data. During the inspection of any stripe on the disk, by reading the data information on at least one data block on the stripe, it is determined whether the corresponding check block information is consistent with the information in the check block stored on the disk. When there is inconsistency, the check area data corresponding to each block is compared with the check area data stored in the respective block check area to determine whether the erroneous data block or check block on the current stripe is determined, thereby realizing the identification of the erroneous block, and automatically reconstructing and repairing the block to avoid other faults from expanding the data error.
[0099] In some possible implementations of the present invention, a periodic inspection task is executed according to the configuration, and the periodic inspection task regularly performs inspections of a certain number of stripes. If the inspection finds a stripe consistency error, the inspection area can be used to determine which block is wrong and reconstruct and repair the stripe.
[0100] The scheduled inspection task inspects all data on the RAID at a set period (for example, one week) and performs inspections on a certain number of stripes at a set interval (for example, one minute). Each inspection reads out the old data, calculates the check value, and compares it with the check value on the disk to determine whether the stripe data is consistent. The specific process is as follows: Figure 4 shown.
[0101] See also Figure 4 , is a flow chart of a disk stripe inspection method provided by another embodiment of the present invention, the method is used to periodically inspect RAID stripes and automatically repair stripes with errors. The method includes:
[0102] Step S201: inspect the RAID stripe, read the stripe data blocks, calculate the check blocks, and compare them with the check blocks stored on the disk.
[0103] This step corresponds to steps S101 to S103 of the aforementioned embodiment. For the specific process, please refer to the description of the aforementioned embodiment and will not be repeated here.
[0104] Step S202: determine whether the stripe data is consistent.
[0105] The specific process is the same as the aforementioned step S103, for example, determining whether the check block P0 is the same as the check block data pre-stored on the disk. If the judgment is consistent, it is determined that the data on the current stripe 0 is normal, and the next stripe is inspected, such as stripe 1. If it is inconsistent, it is determined that the data on the current stripe 0 is wrong, and step S203 is executed.
[0106] Step S203: When the stripe data is inconsistent, calculate the inspection area data of all the blocks of the stripe and compare it with the read inspection area data. This step corresponds to steps S104 and S105 of the above embodiment.
[0107] The inspection area data read out is pre-stored data, that is, the inspection area data stored in each block inspection area. For example, the inspection area data corresponding to each data block is calculated as M0 to M3 for each of the four data blocks, and the inspection area data read out are M 0read ~M 3read , the inspection area data corresponding to a check block P0 is M P0 The read inspection area data are M P0read .
[0108] Compare whether they are the same, including: respectively compare M0 and M 0read Compare M1 with M 1read Compare M2 with M 2read Compare the M3 and M 3read In contrast, M P0 With M P0read Compare and determine whether they are the same. If there are differences, such as M1 and M 1read If the comparison is different, it is determined that the data block corresponding to M1 is erroneous, and it is set as a reconstructed data block and waits for recovery. If the other comparison results are the same, it is determined that the data on the other data blocks and the check blocks are correct.
[0109] Step S204: Compare whether the number of errors in the check area data of the blocks is within the redundancy range.
[0110] The number of data blocks or check blocks with errors is counted, and the counted number is compared with the redundant range, and the redundant range can be the same as the number of check blocks, such as 1 or 2. For example, according to this embodiment, 1 check block is calculated for each stripe, and the redundant data is 1. If the number of errors is 1, it is within the redundant data range, and step S207 is executed. If the number of erroneous data is 2 or more, it exceeds the redundant data range 1, and steps S205 and S206 are executed.
[0111] Step S205: When the number is outside the redundant range, report error information, and reconstruct the check data corresponding to the erroneous data block so that the information of each block on the current stripe (such as the first stripe) after reconstruction is temporarily the same as the check area data, temporarily restoring the stripe consistency.
[0112] Step S206: Restore data using backup data, snapshots, etc.
[0113] Step S207: When the number is within the redundancy range, stripe reconstruction is started to automatically restore stripe data consistency.
[0114] Specifically, it includes: starting the stripe reconstruction process, restoring the erroneous data blocks on the current stripe (such as the first stripe), making the information of each block on the restored first stripe consistent with the inspection area data, and jumping to step S201 to perform inspection of the next stripe.
[0115] The method provided in this embodiment can use the inspection area data to determine which stripe block has an error after a stripe inconsistency problem is found during RAID inspection, and automatically reconstruct and repair it to repair the stripe data consistency, thereby effectively preventing the error from further expanding.
[0116] The stripe division and data update process before stripe inspection in this embodiment is described in detail below.
[0117] In another embodiment of the present invention, step S101, before inspecting the first stripe on the disk, further includes:
[0118] First, a RAID disk is constructed, the RAID disk is divided into disk blocks of fixed size, and each disk block is numbered; disk blocks with the same number are assembled into RAID stripes, one of the RAID stripes is the first stripe; each disk block is divided into N sectors, a block check area corresponds to one sector, and N ≥ 2 and is a positive integer.
[0119] Then, the block check area corresponding to the stripe is determined according to the data of the N sectors; and the check area data in the block check area and the check area data of the verification block are calculated according to the at least one data block and the corresponding check area data.
[0120] Specifically, a fixed stripe check area is allocated for each disk to store the check data of the blocks that are divided into RAID stripes on the disk. Each block of each stripe uses a disk block of the size of a sector as the block check area, and a block in the stripe is XORed from the front to the back according to the sector number to obtain the check area data.
[0121] like Figure 2 As shown in the figure, when building a RAID, the disk is divided into disk blocks of fixed size, and then the disk blocks with the same number are used to build a RAID stripe. The minimum operation unit of a disk block is a sector. Assuming that the stripe disk block size is N sectors, the stripe block check area is one sector.
[0122] Each stripe consists of multiple data blocks and check blocks; the data block stores the data information of the stripe, and the check block stores the redundant check information of the stripe. Both the data block and the check block have corresponding block check area information. The data of N sectors of the stripe block is represented as A0~A (n-1) , a sector data block of the corresponding stripe block check area is represented as M, and the stripe block check area calculation formula is as follows:
[0123] M=A0 A1 ...... A (n-1)
[0124] That is, the stripe block check area is obtained by performing XOR calculation on all the sector numbers of the stripe block from the front to the back.
[0125] The stripe data block is represented as D, the data block 1 of stripe 0 is represented as D0_1, the data block 2 of stripe 0 is represented as D0_2, and so on. The corresponding inspection area data is represented as M D0_1 、M D0_2 etc.; the check block data is represented by P, and its corresponding check area data is represented by M p .
[0126] According to the at least one data block and the corresponding inspection area data, the inspection area data in the block inspection area is calculated by a first relational expression; the first relational expression is:
[0127] P = D0 D1 D2 ...... D (n-1)
[0128] Where P represents the check block, D0, D1, D2, ... D (n-1) Represents N data blocks on a stripe, is the XOR operator symbol, and n is the number of data blocks.
[0129] Similarly, according to at least one data block and the corresponding inspection area data, the inspection area data of the verification block P is calculated by a second relational expression; the second relational expression is:
[0130] M p =M0 M1 ...... M (n-1)
[0131] Among them, M p Indicates the check area data of the check block P, M0, M1..., M (n-1)Indicates the inspection area data corresponding to N data blocks, Is the exclusive OR operator symbol.
[0132] The implementation method of a data update process includes: when new data is written to the target data block on the first stripe, updating the check block where the target data block is located; and updating the block check area of the target data block and the block check area of the check block corresponding to the target data block; the target data is any one of at least one data block on the first stripe. That is, when a data block D is written, the check block P needs to be updated; then, the corresponding data block check area M is also updated accordingly. d Sum check block check area M p .
[0133] Update the check block where the target data block is located, including: writing new data D new Before that, read the original data D in the target data block old ; New data D to be written new With the original data D old Perform XOR operation to obtain the intermediate check value P delta ; Then read the original verification data P stored in the block check area corresponding to the target data block old ; The original verification data P old and the intermediate check value P delta Perform XOR operation to get the new check value P new ; Finally, the new data D new Write the target data block on the first stripe and the new checksum P new Write the check block where the target data block is located. The update steps are as follows:
[0134] Step 1: Read out the old data block D old ;
[0135] Step 2: Original data D old and the new data D to be written new , XOR to get the intermediate check value P delta ;
[0136] P delta = D old D new
[0137] Step 3: Read out the original verification data P old and the intermediate check value P delta , XOR calculation to get the new check value P new ;
[0138] P new =Pold P delta
[0139] Step 4: New data D of data segmentation new Write to disk.
[0140] Step 5: Verify the new checksum P of the block new Write to disk.
[0141] The above is the method flow of stripe update. In addition, this embodiment also includes: updating the block check area of the target data block and the block check area of the verification block corresponding to the target data block. Update the stripe check area data, and the subsequent operation update steps include the following:
[0142] Step 6: According to the new data D to be written new Calculate the inspection data M of the block inspection area of the target data block write .
[0143] Assume that 2KB of data is written in data block 0, and a sector is 512 bytes, then 4 sectors of data are written. Assume that the sector data are represented by A0, A1, A2, and A3 respectively. First, calculate the check data M of the newly written data. 0write The calculation formula is: M 0write = A0 A1 A2 A3.
[0144] The inspection data M of the block inspection area 0write The check data M calculated before writing new data into the block check area olddata Perform XOR operation to obtain the intermediate check data M 0delta ;
[0145] Among them, the inspection data M of the block inspection area 0write The check data M calculated before writing new data into the block check area olddata Perform XOR operation to obtain the intermediate check data M 0delta Previously, it also included:
[0146] When N=4, the original data on 4 sectors are read, and the original data on the 4 sectors are A 0old , A 1old , A 2old and A 3old .
[0147] Step 7: Based on the original data on the four sectors, the inspection data M of the block inspection area is obtained by calculation olddata ;
[0148] As in the example in step 6, assuming that 2KB of data is written in data block 0, the old data A of the 4 sectors to be written 0old , A 1old , A 2old and A 3old Read out and calculate its checksum M 0olddata The calculation formula is:
[0149] M 0olddata =A 0old A 1old A 2old A 3old
[0150] Among them, M 0olddata For inspection data of block inspection area, It is an XOR operation.
[0151] Step 8: Write the new data M in step 6 0write Checksum calculated by sector to obtain the check data M write , XOR the original data in step 7 and calculate the checksum according to the sector to obtain the check data M olddata , and obtain the intermediate check value M 0delta The calculation formula is:
[0152] M 0delta = M 0write M 0olddata
[0153] Step 9: Read the original inspection data M from the block inspection area of the disk 0old , and the original inspection data M 0old and intermediate inspection data M 0delta , calculate the new inspection data M 0new . Where M 0delta Used to update the data in the inspection area on P0. The new inspection data M 0new The calculation formula is:
[0154] M 0new =M 0old M 0delta
[0155] Step 10: The new inspection data M 0new The chunk check area where the check chunk is written.
[0156] The method further comprises:
[0157] Step 11: Read the original verification data P according to step 3 above oldCalculate the corresponding inspection area data M by sector pold ; The above step 3 calculates the inspection data M according to the new check block by sector pnewdelta .
[0158] Step 12: The original verification data P old Corresponding inspection area data M pold , and the new check block is calculated to obtain the check data M pnewdelta Perform XOR operation to obtain the new check block check data M pnew The calculation formula is:
[0159] M pnew = M 0delta M pold
[0160] Step 13: Check the new check block data M pnew The chunk check area where the check chunk is written.
[0161] In this embodiment, each disk is first divided into a fixed stripe inspection area for storing the inspection data of the blocks that are divided into RAID stripes on the disk. Each block of each stripe uses a disk block of the size of a sector as the block inspection area, and a block in the stripe is XOR-calculated from front to back according to the sector number to obtain the inspection area data. When the IO updates the stripe data, the corresponding inspection area data is updated accordingly, so as to provide a basis for the subsequent RAID stripe inspection to determine the data block with errors.
[0162] In this embodiment, a disk strip inspection device is also provided, which is used to implement the above embodiments and preferred implementation modes, and will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0163] This embodiment provides a disk strip inspection device, which is used to implement the above Figure 3 or Figure 4 Part or all of the method steps of the inspection method for the disk stripe shown. Figure 5 As shown, the device includes: an inspection module 510, a calculation module 520, a judgment module 530, a comparison module 540 and a determination module 550. In addition, the device may also include other more or fewer modules, such as a storage module, which is not limited in this embodiment.
[0164] The inspection module 510 is used to inspect the first stripe on the disk and read multiple blocks on the first stripe, wherein the first stripe is one of the multiple stripes on the disk, and the types of the multiple blocks include data blocks and check blocks. The data blocks and the check blocks each have their own corresponding block inspection areas, and each block inspection area stores inspection area data.
[0165] The calculation module 520 is used to calculate the corresponding check block information according to the data information on at least one data block read.
[0166] The judgment module 530 is used to judge whether the information of the check block is consistent with the information in the check block stored on the disk.
[0167] The comparison module 540 is used to calculate the inspection area data corresponding to each block on the first stripe through the calculation module 520 when the judgment module 530 determines that the verification block information is inconsistent, and compare whether the inspection area data corresponding to each block is the same as the inspection area data stored in the respective block inspection area.
[0168] The determination module 550 is used to determine whether the data blocks or check blocks corresponding to the current different check area data have errors when the comparison module 540 has different comparison conditions, and repair and reconstruct the erroneous data blocks on the first stripe.
[0169] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0170] The inspection device for the disk strip in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0171] The embodiment of the present invention also provides a computer device having the above Figure 5 The inspection device of the disk stripe is shown.
[0172] See also Figure 6, is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common motherboard or in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface).
[0173] In some optional embodiments, if desired, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Multiple computer devices can also be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.
[0174] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0175] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the disk stripe inspection method shown in the above embodiment.
[0176] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0177] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0178] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0179] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device may be a touch screen.
[0180] The computer device may also include at least one communication interface. Figure 6 Not shown in the figure, it is used for the computer device to communicate with other devices or communication networks.
[0181] An embodiment of the present invention also provides a computer-readable storage medium, and the above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented by downloading through a network and originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware.
[0182] The storage medium may be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid state drive, etc.; further, the storage medium may also include a combination of the above-mentioned types of memories. It is understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by the computer, processor or hardware, the disk strip inspection method shown in the above embodiment is implemented.
[0183] Embodiments of the present application may also provide a computer program product, including computer program instructions, which, when executed by a processor, cause the processor to perform the steps in the above method. Wherein, the computer program product may be written in any combination of one or more programming languages to perform program codes for performing the operations of the disclosed embodiments, wherein the programming languages include object-oriented programming languages, such as Java, C++, etc., and also include conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on a user computing device, partially on a user device, as an independent software package, partially on a user computing device, partially on a remote computing device, or entirely on a remote computing device or server.
[0184] The above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, rather than to limit them. Although the embodiments of the present invention are described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some of the technical features therein by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A disk stripe inspection method, characterized in that: The method comprises: Patrolling a first stripe on a disk, reading a plurality of blocks on the first stripe, wherein the first stripe is one of a plurality of stripes on the disk, the plurality of blocks include data blocks and check blocks, the data blocks and the check blocks each have a corresponding block check area, and each of the block check areas stores check area data; Calculate corresponding check block information according to the data information on at least one data block read; Determine whether the verification block information is consistent with the information in the verification block stored on the disk; If they are inconsistent, calculating the inspection area data corresponding to each block on the first stripe, and comparing the inspection area data corresponding to each block with the inspection area data stored in the respective inspection area of the block to see whether they are the same; If there is a difference, it is determined that an error occurs in the data block or the check block corresponding to the current different check area data, and the erroneous data block on the first stripe is repaired and reconstructed.
2. The method according to claim 1, characterized in that: The step of determining that an error occurs in a data block or a check block corresponding to the current different check area data, and repairing and reconstructing the data block having the error on the first stripe, includes: Count the number of data blocks or check blocks where errors occur; If the number is within the redundancy range, a stripe reconstruction process is started to restore the erroneous data blocks on the first stripe so that the information of each block on the restored first stripe is consistent with the check area data; If the number is outside the redundancy range, error information is reported, and the check data corresponding to the erroneous data block is reconstructed so that the information of each block on the first stripe after reconstruction is temporarily the same as the check area data.
3. The method according to claim 1, characterized in that The step of determining whether the check block information is consistent with the information in the check block stored on the disk further includes: If they are consistent, it is determined that the data on each block of the first stripe is correct, and the second stripe on the disk is continued to be inspected to determine whether there is an error in the data block or check block on the second stripe; the inspection process of the second stripe is the same as the inspection process of the first stripe.
4. The method according to any one of claims 1 to 3, characterized in that: Before inspecting the first stripe on the disk, the method further includes: Build a RAID disk, divide the RAID disk into disk blocks according to fixed sizes, and number each disk block; Grouping disk blocks with the same number into RAID stripes, one of the RAID stripes being the first stripe; Divide each of the disk blocks into N sectors, the block inspection area corresponds to one sector, and N ≥ 2 and is a positive integer; Determine a block inspection area corresponding to the stripe according to the data of the N sectors; According to the at least one data block and the corresponding inspection area data, the inspection area data in the block inspection area and the inspection area data of the verification block are calculated.
5. The method according to claim 4, characterized in that The calculating, according to the at least one data block and the corresponding inspection area data, the inspection area data in the block inspection area and the inspection area data of the verification block comprises: Calculating the inspection area data in the block inspection area by a first relational expression according to the at least one data block and the corresponding inspection area data; The first relation is: P = D0 D1 D2 ...... D (n-1) ; Where P represents the check block, D0, D1, D2, ..., D (n-1) Represents N data blocks on a stripe, is an XOR operation; Calculating the inspection area data of the verification block P by a second relational expression according to the at least one data block and the corresponding inspection area data; The second relational expression is: p =M0 M1 ...... M (n-1) ; Among them, M p Represents the check area data of the check block P, M0, M1, ..., M (n-1) Indicates the inspection area data corresponding to N data blocks.
6. The method according to claim 4, characterized in that The method further comprises: When new data is written to the target data block on the first stripe, updating the check block where the target data block is located; and, The block check area of the target data block corresponding to the target data block and the block check area of the verification block are updated; the target data is any one of at least one data block on the first stripe.
7. The method according to claim 6, characterized in that The updating of the check block where the target data block is located includes: Read the original data D in the target data block old ; The new data D to be written new With the original data D old Perform XOR operation to obtain the intermediate check value P delta ; Read the original verification data P stored in the block inspection area corresponding to the target data block old ; The original verification data P old With the intermediate check value P delta Perform XOR operation to get the new check value P new ; The new data D new Write the target data block on the first stripe, and write the new check value P new Write the check block where the target data block is located.
8. The method according to claim 7, characterized in that The updating of the block check area of the target data block corresponding to the target data block and the block check area of the verification block includes: Calculate the inspection data of the block inspection area of the target data block according to the new data written; Performing an XOR operation on the inspection data of the block inspection area and the inspection data of the block inspection area calculated before writing the new data to obtain intermediate inspection data; Reading original inspection data from the block inspection area of the disk, and calculating new inspection data based on the original inspection data and the intermediate inspection data; The new inspection data is written into the block inspection area of the verification block.
9. The method according to claim 8, characterized in that Before performing an XOR operation on the inspection data of the block inspection area and the inspection data of the block inspection area calculated before writing the new data to obtain the intermediate inspection data, the method further includes: When N=4, the original data on 4 sectors are read, and the original data on the 4 sectors are A 0old , A 1old , A 2old and A 3old ; Obtaining inspection data of the block inspection area by calculation according to the original data on the four sectors; The calculation formula is: 0olddata =A 0old A 1old A 2old A 3old ; Among them, M 0olddata is the inspection data of the block inspection area, It is an XOR operation.
10. The method according to claim 8, characterized in that The method further comprises: According to the original verification data P old Calculate by sector to obtain the corresponding inspection area data; The check data is calculated by sectors according to the new check blocks; The original verification data P old The corresponding inspection area data and the inspection data obtained by calculating the new check block are XORed to obtain new check block inspection data.
11. The method according to claim 10, characterized in that The updating of the block inspection area of the verification block includes: The new check block check data is written into the block check area of the check block.
12. A disk strip inspection device, characterized in that: The device comprises: An inspection module is used to inspect a first stripe on the disk and read a plurality of blocks on the first stripe, wherein the first stripe is one of a plurality of stripes on the disk, the plurality of blocks include data blocks and check blocks, the data blocks and the check blocks each have a corresponding block inspection area, and each of the block inspection areas stores inspection area data; A calculation module, used to calculate corresponding check block information according to the data information on at least one data block read; A judging module, used to judge whether the information of the check block is consistent with the information in the check block stored on the disk; a comparison module, configured to calculate the inspection area data corresponding to each block on the first stripe through the calculation module when the judgment module determines that the check block information is inconsistent, and compare whether the inspection area data corresponding to each block is the same as the inspection area data stored in the respective block inspection area; The determination module is used to determine that the data blocks or check blocks corresponding to the current different inspection area data have errors when the comparison by the comparison module is different, and repair and reconstruct the erroneous data blocks on the first stripe.
13. A computer device, characterized in that: The invention comprises a memory and a processor, wherein the memory and the processor are connected, the memory stores computer instructions, and the processor executes the disk strip inspection method according to any one of claims 1 to 11 by executing the computer instructions.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the disk strip inspection method according to any one of claims 1 to 11.
15. A computer program product, characterized in that The method comprises computer instructions, which, when executed on a computer, enable the computer to execute the disk stripe inspection method as claimed in any one of claims 1 to 11.
