A data writing method, device, electronic device and storage medium
By determining the data writing method according to the exception mode in the write back mode of RAID technology, the IO data or sub-IO data is backed up to the data sub-region in the reserved area, solving the problem of data failure to fall from the disk caused by burst abnormal disks, and improving data security and backup and recovery efficiency.
Patent Information
- Application Number
- CN202510344500.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2045-03-24
AI Technical Summary
In the write-back mode of independent disk redundant array (RAID) technology, if the number of burst abnormal disks is greater than the number of check disks in RAID, and the IO data is originally going to fall on the disk with burst abnormality, the IO data cannot be dropped on the disk, resulting in data security being insured.
A data writing method is provided, in response to the abnormal state of RAID, determines the exception mode, and determines the backup parameters of IO data or sub-IO data based on different exception modes (non-write disk stage or write disk stage), backups the data to the data sub-region in the reserved area, and stores the backup parameters to the parameter sub-region.
By adopting different backup and recovery solutions in the event of disk abnormalities, the security of IO data is improved and the efficiency of IO data backup and recovery process is ensured.
Smart Images

Figure CN119847816B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and particularly to a data writing method, apparatus, electronic device, and storage medium. Background Art
[0002] Redundant Array of Independent Disks (RAID) is a storage technology that improves storage performance and reliability by increasing the parity redundancy capability. In RAID technology, when Input / Output (IO) data is written to the disk, to improve the IO execution efficiency, usually when the IO is moved from the host to the cache and has not been written to the disk yet, the host will be replied with completion. This mode is usually called the Write Back (WB) mode. Then, the data is continuously calculated until it is written to the disk. Thus, while the previous IO is being written to the disk, the host can issue the next IO and move the data of the next IO to the cache, thereby increasing the number of Input / Output Operations Per Second (IOPS) and reducing the write latency.
[0003] However, in the WB mode of traditional RAID technology, when the IO data is being written to the disk, if the number of suddenly abnormal disks is greater than the number of parity disks in the RAID and the IO data was originally to be written to the suddenly abnormal disks, then this IO data cannot be written to the disk, and the data of this disk cannot be recovered from the data of other disks. At this time, the writing of the IO data cannot be completed. And because the host has been replied with completion, the host believes that this IO has been successfully written to the disk, but the actual writing is not completed. Subsequently, even if the failed disks return to normal, this IO data will be lost, resulting in the lack of guarantee of data security.
[0004] Therefore, how to ensure data security in the WB mode of RAID technology is an urgent problem to be solved. Summary of the Invention
[0005] The present disclosure provides a data writing method, apparatus, electronic device, and storage medium to at least solve the above technical problems existing in the prior art.
[0006] According to a first aspect of the present disclosure, a data writing method is provided, including: in response to a redundant array of independent disks (RAID) being in an abnormal state, determining an abnormal mode of the RAID; the abnormal state indicating that the number of abnormal disks among multiple disks of the RAID is greater than a first threshold; in response to the abnormal mode being a first mode, determining a first backup parameter of input / output (IO) data; the first mode indicating that a disk has an abnormality during a non-writing disk stage, and the first backup parameter including a backup start position of the IO data in a data sub-region of a reserved area of the RAID; backing up the IO data to the data sub-region based on the first backup parameter, and storing the first backup parameter to a parameter sub-region in the reserved area; in response to the abnormal mode being a second mode, determining a second backup parameter of sub-IO data corresponding to each disk in the IO data that has not been written to the disk; the second mode indicating that a disk has an abnormality during a writing disk stage, and the second backup parameter including a backup start position of the sub-IO data in the data sub-region; backing up the sub-IO data to the data sub-region based on the second backup parameter, and storing the second backup parameter to the parameter sub-region.
[0007] In an implementable manner, the determining the first backup parameter of the input / output (IO) data includes: determining a start position of the data sub-region in the reserved area; determining a start position of the latest IO data in the data sub-region and a length of the latest IO data from a backup parameter record table; and determining a backup start position of the IO data in the data sub-region based on the start position of the data sub-region in the reserved area, the start position of the latest IO data in the data sub-region, and the length of the latest IO data.
[0008] In an implementable manner, the backing up the IO data to the data sub-region based on the first backup parameter includes: writing the IO data from a cache to the data sub-region, and a start position of the writing being the backup start position of the IO data in the data sub-region.
[0009] In an implementable manner, the storing the first backup parameter to the parameter sub-region in the reserved area includes: determining a number of backup parameters stored in the parameter sub-region from a backup parameter record table; determining a storage start position of the first backup parameter in the parameter sub-region based on the start position of the parameter sub-region in the reserved area, the number of backup parameters, and a length of the backup parameter; and writing the first backup parameter to the parameter sub-region, and a start position of the writing being the storage start position of the first backup parameter in the parameter sub-region.
[0010] In an implementable manner, after storing the first backup parameter into the parameter sub-region of the reserved area, the method further includes: incrementing the number of backup parameters in the backup parameter record table by 1; updating the starting position of the latest IO data in the backup parameter record table to the sum of the original starting position of the latest IO data and the length of the original latest IO data; and updating the length of the latest IO data in the backup parameter record table to the length of the IO data.
[0011] In an implementable manner, the first backup parameter further includes at least one of an effectiveness identifier of the first backup parameter, an exception mode identifier, a starting position of the IO data in the RAID, and a length of the IO data.
[0012] In an implementable manner, the second backup parameter further includes at least one of an effectiveness identifier of the second backup parameter, an exception mode identifier, a disk identifier corresponding to the sub-IO data, a starting position of the sub-IO data in the corresponding disk, and a length of the sub-IO data.
[0013] In an implementable manner, a data writing method further includes: in response to the abnormal disk returning to normal, sequentially reading the backup parameters in the parameter sub-region; based on the backup starting position in the read target backup parameter and the length of the IO data or sub-IO data, reading the target IO data or target sub-IO data from the data sub-region into a cache; and based on the exception mode identifier in the target backup parameter, writing the target IO data or target sub-IO data in the cache into a target area of the RAID.
[0014] In an implementable manner, the writing the target IO data or target sub-IO data in the cache into the target area of the RAID based on the exception mode identifier in the target backup parameter includes: in response to the exception mode identifier in the target backup parameter representing a first mode, writing the target IO data in the cache into the target area of the RAID based on the starting position of the IO data in the RAID and the length of the IO data in the target backup parameter; or, in response to the exception mode identifier in the target backup parameter representing a second mode, writing the target sub-IO data in the cache into the target area of the disk corresponding to the target sub-IO data based on the disk identifier corresponding to the sub-IO data, the starting position of the sub-IO data in the corresponding disk, and the length of the sub-IO data in the target backup parameter.
[0015] In an implementable manner, before writing the target IO data in the cache into the target area of the RAID, the method further includes: calculating a check data block based on the target IO data in the cache and writing the check data block into the cache.
[0016] In an implementable embodiment, a data writing device further includes: clearing the IO data and / or sub-IO data in the data sub-region; clearing the backup parameters in the parameter sub-region.
[0017] According to a second aspect of the present disclosure, there is provided a data writing device, including: a determining module, configured to determine an abnormal mode of a redundant array of independent disks (RAID) in response to the RAID being in an abnormal state; the abnormal state indicating that the number of abnormal disks among a plurality of disks of the RAID is greater than a first threshold; the determining module is further configured to determine a first backup parameter of input / output (IO) data in response to the abnormal mode being a first mode; the first mode indicating that a disk is abnormal during a non-writing disk stage, and the first backup parameter including a backup start position of the IO data in a data sub-region of a reserved area of the RAID; a backup module, configured to backup the IO data to the data sub-region based on the first backup parameter and store the first backup parameter in a parameter sub-region in the reserved area; the determining module is further configured to determine a second backup parameter of sub-IO data corresponding to each disk in the IO data that has not been written to the disk in response to the abnormal mode being a second mode; the second mode indicating that a disk is abnormal during a writing disk stage, and the second backup parameter including a backup start position of the sub-IO data in the data sub-region; the backup module is further configured to backup the sub-IO data to the data sub-region based on the second backup parameter and store the second backup parameter in the parameter sub-region.
[0018] In an implementable embodiment, the determining module is further configured to: determine a start position of the data sub-region in the reserved area; determine a start position and a length of the latest IO data in the data sub-region from a backup parameter record table; determine a backup start position of the IO data in the data sub-region based on the start position of the data sub-region in the reserved area, the start position of the latest IO data in the data sub-region, and the length of the latest IO data.
[0019] In an implementable embodiment, the backup module is further configured to: write the IO data from a cache to the data sub-region, and a start position of the writing is the backup start position of the IO data in the data sub-region.
[0020] In an implementable embodiment, the backup module is further configured to: determine a quantity of backup parameters stored in the parameter sub-region from a backup parameter record table; determine a storage start position of the first backup parameter in the parameter sub-region based on the start position of the parameter sub-region in the reserved area, the quantity of the backup parameters, and a length of the backup parameters; write the first backup parameter to the parameter sub-region, and a start position of the writing is the storage start position of the first backup parameter in the parameter sub-region.
[0021] In an implementable manner, the data writing device further includes an updating module, configured to: increment by 1 the number of backup parameters in the backup parameter record table; update the starting position of the latest IO data in the backup parameter record table to be the sum of the starting position of the original latest IO data and the length of the original latest IO data; and update the length of the latest IO data in the backup parameter record table to be the length of the IO data.
[0022] In an implementable manner, the first backup parameter further includes at least one of the validity identifier of the first backup parameter, the abnormal mode identifier, the starting position of the IO data in the RAID, and the length of the IO data.
[0023] In an implementable manner, the second backup parameter further includes at least one of the validity identifier of the second backup parameter, the abnormal mode identifier, the disk identifier corresponding to the sub-IO data, the starting position of the sub-IO data in the corresponding disk, and the length of the sub-IO data.
[0024] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0025] at least one processor; and
[0026] a memory communicatively connected to the at least one processor; wherein,
[0027] the memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the method described in the present disclosure.
[0028] According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to cause a computer to execute the method described in the present disclosure.
[0029] A data writing method, apparatus, electronic device, and storage medium according to the present disclosure. When the RAID is in an abnormal state, if a disk fails during a non-writing disk stage, the entire IO data is directly backed up to a data sub-region based on the backup parameters of the IO data, and the backup parameters of the IO data are stored in a parameter sub-region. If a disk fails during a writing disk stage, the IO data that has not been written to the disk is divided into multiple sub-IO data according to the corresponding disks, and then the multiple sub-IO data are respectively backed up to the data sub-region based on the backup parameters of each sub-IO data, and the backup parameters of the sub-IO data are stored in the parameter sub-region. Thus, when a disk fails, the present disclosure adopts different backup and recovery schemes based on the stage at which the failure occurs, and the reserved area for backup includes a data sub-region and a parameter sub-region. Through the memory design of the reserved area, free space can be quickly found to back up IO data during backup; during recovery, the target IO data can be quickly accessed for recovery, so that the security of IO data can be improved and the efficiency of the IO data backup and recovery process can be ensured in the face of disk failures at different stages.
[0030] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] By referring to the accompanying drawings and reading the following detailed description, the above and other objects, features, and advantages of the exemplary embodiments of the present disclosure will become easily understood. In the drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, wherein:
[0032] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0033] Figure 1 Shows the flowchart of a data writing method according to an embodiment of the present disclosure Figure 1 ;
[0034] Figure 2 Shows the flowchart of a data writing method according to an embodiment of the present disclosure Figure 2 ;
[0035] Figure 3 Shows the scenario diagram of a data writing method according to an embodiment of the present disclosure Figure 1 ;
[0036] Figure 4 Shows the scenario diagram of a data writing method according to an embodiment of the present disclosure Figure 2 ;
[0037] Figure 5 Shows the scenario diagram of a data writing method according to an embodiment of the present disclosureFigure 3 ;
[0038] Figure 6 Shows a scenario schematic of a data writing method according to an embodiment of the present disclosure Figure 4 ;
[0039] Figure 7 Shows a scenario schematic of a data writing method according to an embodiment of the present disclosure Figure 5 ;
[0040] Figure 8 Shows a scenario schematic of a data writing method according to an embodiment of the present disclosure Figure 6 ;
[0041] Figure 9 Shows a scenario schematic of a data writing method according to an embodiment of the present disclosure Figure 7 ;
[0042] Figure 10 Shows a structural schematic diagram of a data writing device according to an embodiment of the present disclosure;
[0043] Figure 11 Shows a composition structural schematic diagram of an electronic device according to an embodiment of the present disclosure. Detailed implementation manners
[0044] To make the objectives, features, and advantages of the present disclosure more obvious and understandable, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present disclosure.
[0045] Figure 1 Shows a flow schematic of a data writing method according to an embodiment of the present disclosure Figure 1 , as Figure 1 shown, a data writing method includes:
[0046] Step S101, in response to the redundant array of independent disks RAID being in an abnormal state, determine the abnormal mode of the RAID.
[0047] In this embodiment, an abnormal state indicates that the number of abnormal disks among multiple disks of a RAID is greater than a first threshold, where the first threshold can be determined based on the number of RAID parity disks. The RAID parity disks are used to store parity information so that data can be restored when a disk fails. For any type of RAID, when the number of abnormal disks does not exceed the number of RAID parity disks, the data in the abnormal disks can be restored by other disks; when the number of abnormal disks exceeds the number of RAID parity disks, the data in the failed disks cannot be restored by other disks. In one example, in RAID5, there is 1 parity disk, so the first threshold can be 1; in RAID6, there are 2 parity disks, so the first threshold can be 2.
[0048] In this embodiment, the abnormal mode of the RAID is determined based on the stage of the abnormal disk failure. If all the IO data has not been written to the corresponding disk yet, it is considered that the abnormal disk fails in the non-write disk stage, and this abnormal mode is called the first mode; if the IO data has been partially written to the corresponding disk, it is considered that the abnormal disk fails in the write disk stage, and this abnormal mode is called the second mode.
[0049] Step S102, in response to the abnormal mode being the first mode, determine the first backup parameter of the input / output (IO) data.
[0050] In this embodiment, the first mode indicates that the disk has an abnormality in the non-write disk stage. At this time, all the IO data has not been written to the corresponding disk yet, that is, the IO data is complete. Therefore, the IO data can be backed up as a whole. Before backing up, it is necessary to determine the first backup parameter of the input / output IO data. The first backup parameter includes the backup start position of the IO data in the data sub-region of the reserved area of the RAID.
[0051] Figure 6 Shows a scenario schematic of a data writing method according to an embodiment of the present disclosure Figure 4 , such as Figure 6 shown, in the present disclosure, a reserved area is set for backing up IO data. The reserved area includes a parameter sub-region and a data sub-region. The parameter sub-region is used to store the backup parameters of the IO data. For example, Figure 6 header0, header1, ……, header256n in Figure 6 are the backup parameters of an IO data respectively, and the data sub-region is used to store the IO data. For example, data in , so the memory size allocated to the header area is 8nK, and the size of the data area is nM. Among them, n is the maximum amount of data that can be stored in the reserved area, M is the megabyte, M is the unit of n, and K is the kilobyte.
[0052] Step S103: Back up the IO data to the data sub-area based on the first backup parameter, and store the first backup parameter in the parameter sub-area in the reserved area.
[0053] In this embodiment, the IO data can be backed up to the data sub-area based on the first backup parameter. The starting position of the IO data in the data sub-area is the backup starting position determined in step S102. The first backup parameter can also be stored in the parameter sub-area in the reserved area for subsequent extraction of the IO data in the data sub-area.
[0054] Figure 3 Shows the scenario schematic of a data writing method according to an embodiment of the present disclosure Figure 1 , such as Figure 3 shown, Figure 3 Taking RAID5 as an example, RAID5 includes 4 disks, namely disk 0, disk 1, disk 2, and disk 3. Disk 1 and disk 2 are abnormal disks. The data blocks with a single quote in the disks of RAID5 indicate the positions where the IO data will be written to the disk. The dark data blocks in the disks of RAID5 are the positions where the IO data has been written to the disk. The host puts the IO data stream into the cache, such as step ①, and then the cache replies to the host to complete, such as step ②. After that, the IO data stream is written from the cache to RAID5, such as step ③. In step ③, it is found that disk 1 and disk 2 are abnormal, and the IO data stream that should have been written to positions 14' to 22' in RAID5 cannot be written to the disk. At this time, there is no dark data block in the disks of RAID5, which proves that the IO data stream has not been written to the corresponding disk at all, and the IO data stream is complete. Therefore, the IO data stream from positions 14' to 22' is backed up to the data sub-area as a whole, such as step ④.
[0055] Figure 4 Shows the scenario schematic of a data writing method according to an embodiment of the present disclosure Figure 2 , such as Figure 4 shown, if disk 1 and disk 2 are normal, that is, RAID5 returns to the normal state, then the IO data stream from positions 14' to 22' is read from the data sub-area to the cache, such as step ①, and then 4 corresponding parity data blocks P' in disk 2 are calculated based on the IO data stream from positions 14' to 22', and the IO data stream from positions 14' to 22' is written from the cache to the corresponding positions in RAID5, such as step 2.
[0056] Step S104: In response to the abnormal mode being the second mode, determine the second backup parameter of the sub-IO data corresponding to each disk in the IO data that has not been written to the disk.
[0057] In this embodiment, the second mode indicates that an exception occurs during the disk writing stage. At this time, the IO data has been partially written into the corresponding disk, and the partially written IO data on the disk will be released in the cache. The IO data is incomplete. Since the disk writing operation of the IO data is disk-based, the unwritten IO data can be segmented into sub-IO data corresponding to the disks, and all sub-IO data are backed up separately. Before backing up, it is necessary to determine the second backup parameter of the sub-IO data corresponding to each disk. The second backup parameter includes the backup start position of the sub-IO data in the data sub-region.
[0058] Step S105: Back up the sub-IO data to the data sub-region based on the second backup parameter, and store the second backup parameter in the parameter sub-region.
[0059] In this embodiment, the sub-IO data can be backed up to the data sub-region based on the second backup parameter. The start position of the sub-IO data in the data sub-region is the backup start position determined in step S104. The second backup parameter can also be stored in the parameter sub-region in the reserved area for subsequent extraction of the sub-IO data in the data sub-region.
[0060] Figure 5 Shows a scenario schematic of a data writing method according to an embodiment of the present disclosure Figure 3 , such as Figure 5As shown, the host puts the IO data stream into the cache, as in step ①, and then the cache replies to the host to indicate completion, as in step ②. After that, the IO data stream is written from the cache to RAID5, as in step ③. In step ③, it is found that disks 1 and 2 are abnormal. At this time, data blocks 14’ and 15’ in the disks of RAID5 are dark data blocks, proving that data blocks 14’ and 15’ have been successfully written to the disks, and the data corresponding to data blocks 14’ and 15’ has been released from the cache. Then, the data corresponding to the remaining IO data from 16’ to 22’ needs to be split into sub-IO data in units of the corresponding disks, that is, the data corresponding to 16’ to 19’ in disk 1 is a sub-IO data, and the data corresponding to 20’ to 22’ in disk 3 is a sub-IO data. And because the data corresponding to data blocks 14’ and 15’ has been released from the cache, the parity data block cannot be calculated from the backup data, and the parity data block in the cache also needs to be backed up, that is, the data corresponding to the 4 P’ parity data blocks in disk 2 is used as a sub-IO data. Then, the data corresponding to 16’ to 19’ in disk 1 is backed up as IO1 to the data sub-region, the data corresponding to the 4 P’ parity data blocks in disk 2 is backed up as IO2 to the data sub-region. For easy distinction, the 4 P’ parity data blocks can be labeled as P0’, P1’, P2’, and P3’ respectively, and the data corresponding to 20’ to 22’ in disk 3 is backed up as IO3 to the data sub-region, as in step ④. After RAID5 returns to the normal state, IO1, IO2, and IO3 in the data sub-region can also be read from the data sub-region to the cache, and IO1, IO2, and IO3 are written from the cache to the corresponding positions in RAID5.
[0061] In the present disclosure, when a disk is abnormal, different backup and recovery schemes are adopted based on the stage at which the abnormality occurs. Moreover, the reserved area for backup includes a data sub-region and a parameter sub-region. Through the memory design of the reserved area, free space can be quickly found to back up IO data during backup; during recovery, the target IO data can be quickly accessed for recovery, so that the security of IO data can be improved in the face of disk abnormalities at different stages, and the efficiency of the IO data backup and recovery process can be guaranteed.
[0062] In another embodiment, "determining the first backup parameter of the input / output IO data" in step S102 includes:
[0063] Determining the starting position of the data sub-region in the reserved area;
[0064] Determining the starting position and length of the latest IO data in the data sub-region from the backup parameter record table;
[0065] Determine the backup start position of the IO data in the data sub-region based on the start position of the data sub-region in the reserved area, the start position of the latest IO data in the data sub-region, and the length of the latest IO data.
[0066] In this embodiment, the backup parameter record table records the aggregated backup parameters. The fields and sizes included in the backup parameter record table are shown in Table 1 below:
[0067] Table 1
[0068]
[0069] Among them, is_valid is used to represent whether the data is valid. 0X5A5A5A5A represents valid, and others represent invalid. is_valid is 8 bytes; num represents the number of valid backup parameters stored in the parameter sub-region, and num is 4 bytes; last_slba represents the start position of the latest IO data backed up in the data sub-region, and last_slba is 8 bytes; last_nlb represents the length of the latest IO data backed up in the data sub-region, and last_nlb is 4 bytes.
[0070] In this embodiment, the start position of the data sub-region in the reserved area can be determined first. The start position of the data sub-region in the reserved area is fixed and can be represented by slba_data0. Then, the values of the last_slba field and the last_nlb field are read from the backup parameter record table to obtain the start position of the latest IO data in the data sub-region and the length of the latest IO data. Finally, based on slba_data0, last_slba, and last_nlb, the backup start position of the IO data in the data sub-region is determined. The calculation formula for the backup start position save_slba of the IO data in the data sub-region is as shown in Formula 1:
[0071] Formula 1
[0072] It should be emphasized that the process of "determining the second backup parameter of the sub-IO data corresponding to each disk in the IO data not yet written to the disk" in step S104 is similar to the process of "determining the first backup parameter of the input / output IO data" in step S102, and will not be elaborated here.
[0073] In another embodiment, "backing up the IO data to the data sub-region based on the first backup parameter" in step S103 includes:
[0074] Write the IO data from the cache to the data sub-region, and the start position of the write is the backup start position of the IO data in the data sub-region.
[0075] In this embodiment, after determining the backup start position of the IO data in the data sub-region, the IO data can be extracted from the cache and the extracted IO data is written into the data sub-region, and the start position of the writing is the backup start position of the IO data in the data sub-region.
[0076] It should be emphasized that the implementation details of "backing up the sub-IO data to the data sub-region based on the second backup parameter" in step S105 are similar to those of "backing up the IO data to the data sub-region based on the first backup parameter" in step S103, and will not be elaborated here.
[0077] In another embodiment, "storing the first backup parameter in the parameter sub-region in the reserved area" in step S103 includes:
[0078] Determining the number of backup parameters stored in the parameter sub-region from the backup parameter record table;
[0079] Based on the start position of the parameter sub-region in the reserved area, the number of backup parameters, and the length of the backup parameter, determining the storage start position of the first backup parameter in the parameter sub-region;
[0080] Writing the first backup parameter into the parameter sub-region, and the start position of the writing is the storage start position of the first backup parameter in the parameter sub-region.
[0081] In this embodiment, to determine the storage start position of the first backup parameter in the parameter sub-region first, the value of the num field can be extracted from the backup parameter record table first, that is, the number of valid backup parameters stored in the parameter sub-region, and the start position of the parameter sub-region in the reserved area is determined. The start position of the parameter sub-region in the reserved area is also fixed and can be set to addr_header0, and the length of each backup parameter is also the same and can be set to Len_Par. Then the calculation formula for the storage start position save_Par of the first backup parameter in the parameter sub-region is as shown in Formula Two:
[0082] Formula Two
[0083] In an example, the length Len_Par of each backup parameter can be 32 bytes.
[0084] In this embodiment, after determining the storage start position of the first backup parameter in the parameter sub-region, the first backup parameter can be written into the parameter sub-region, and the start position of the writing is the storage start position of the first backup parameter in the parameter sub-region.
[0085] It should be emphasized that the implementation details of "storing the second backup parameter in the parameter sub-region" in step S105 are similar to those of "storing the first backup parameter in the parameter sub-region in the reserved area" in step S103, and will not be elaborated here.
[0086] In another embodiment, after "storing the first backup parameter into the parameter sub-region in the reserved area" in step S103, a data writing method further includes:
[0087] Incrementing the number of backup parameters in the backup parameter record table by 1;
[0088] Updating the starting position of the latest IO data in the backup parameter record table to the sum of the original starting position of the latest IO data and the length of the original latest IO data;
[0089] Updating the length of the latest IO data in the backup parameter record table to the length of the IO data.
[0090] In this embodiment, after backing up the IO data to the data sub-region based on the first backup parameter and storing the first backup parameter into the parameter sub-region in the reserved area, it is necessary to update the backup parameter record table. The value of the num field in the backup parameter record table as shown in Table 1 can be incremented by 1, that is, the number of backup parameters is incremented by 1; the starting position of the latest IO data in the backup parameter record table as shown in Table 1 can also be updated to the sum of the original starting position of the latest IO data and the length of the original latest IO data. For example, if the original starting position of the latest IO data is , and the length of the original latest IO data is , then the value of the last_slba field in the backup parameter record table as shown in Table 1 is updated to ; the last_nlb field in the backup parameter record table as shown in Table 1 can also be updated to the length of the IO data, that is, the length of the latest IO data in the backup parameter record table is updated to the length of the IO data stored this time.
[0091] It should be emphasized that after step S105 "backing up the sub-IO data to the data sub-region based on the second backup parameter and storing the second backup parameter into the parameter sub-region", the data in the backup parameter record table will also be updated. The update process is similar to the update after "storing the first backup parameter into the parameter sub-region in the reserved area" in step S103, which will not be elaborated here.
[0092] In another embodiment, the first backup parameter further includes at least one of the validity flag of the first backup parameter, the exception mode flag, the starting position of the IO data in the RAID, and the length of the IO data.
[0093] In another embodiment, the second backup parameter further includes at least one of the validity flag of the second backup parameter, the exception mode flag, the disk identifier corresponding to the sub-IO data, the starting position of the sub-IO data in the corresponding disk, and the length of the sub-IO data.
[0094] In the present disclosure, the structure of each backup parameter is shown in Table 2 below:
[0095] Table 2
[0096]
[0097] Among them, is_vaid is used to represent whether the data is valid, that is, the validity flag. 0X5A5A5A5A indicates valid, and others indicate invalid. is_valid is 8 bytes;
[0098] io_type represents the abnormal mode of RAID, that is, the abnormal mode flag. In the first mode, the value of io_type is 1, and in the second mode, the value of io_type is 0. io_type is 1 byte;
[0099] disk_id represents the disk identifier corresponding to the sub-IO data. disk_id is only valid when the value of io_type is 0. disk_id is 1 byte;
[0100] When the value of io_type is 1, slba represents the starting position of the IO data in RAID. When the value of io_type is 0, slba represents the starting position of the sub-IO data on the corresponding disk. As Figure 5 shown, if the value of io_type is 1, then the slba of data block 14' in RAID is 14. If the value of io_type is 0, then the slba of data block 14' on disk 0 is 6. slba is 8 bytes;
[0101] When the value of io_type is 1, nlb represents the length of the IO data. When the value of io_type is 0, nlb represents the length of the sub-IO data;
[0102] When the value of io_type is 1, save_slba represents the backup starting position of the IO data in the data sub-region. When the value of io_type is 0, save_slba represents the backup starting position of the sub-IO data in the data sub-region;
[0103] reserve is a reserved field that does not store any content and is used to round up to 32 bytes so that the backup parameter can be divisible by 4K. Since data access and storage are in units of 4K, this can ensure 4K alignment and avoid a backup parameter spanning two 4K.
[0104] Figure 2 shows the flow diagram of a data writing method according to an embodiment of the present disclosure Figure 2 , as Figure 2 shown, a data writing method includes:
[0105] Step S201, in response to the redundant array of independent disks (RAID) being in an abnormal state, determine the abnormal mode of the RAID.
[0106] Step S202, in response to the abnormal mode being the first mode, determine the first backup parameter of the input / output (IO) data.
[0107] Step S203, based on the first backup parameter, back up the IO data to a data sub-region and store the first backup parameter in a parameter sub-region in a reserved area.
[0108] Step S204, in response to the abnormal mode being the second mode, determine the second backup parameter of the sub-IO data corresponding to each disk in the IO data that has not been written to the disk.
[0109] Step S205, based on the second backup parameter, back up the sub-IO data to a data sub-region and store the second backup parameter in the parameter sub-region.
[0110] The specific implementation details of steps S201 - S205 are similar to those of steps S101 - S105 and will not be elaborated here.
[0111] Step S206, in response to the abnormal disk returning to normal, sequentially read the backup parameters in the parameter sub-region.
[0112] Step S207, based on the backup start position in the read target backup parameter and the length of the IO data or sub-IO data, read the target IO data or target sub-IO data from the data sub-region into the cache.
[0113] Step S208, based on the abnormal mode identifier in the target backup parameter, write the target IO data or target sub-IO data in the cache into the target area of the RAID.
[0114] In this embodiment, if the abnormal disk returns to normal and the data backed up in the data sub-region needs to be rewritten to the disks of the RAID, first, the backup parameters in the parameter sub-region need to be read. Then, based on the backup start position in the read target backup parameter and the length of the IO data or sub-IO data, the target IO data or target sub-IO data is read from the data sub-region into the cache, and based on the abnormal mode identifier in the target backup parameter, the target IO data or target sub-IO data in the cache is written into the target area of the RAID.
[0115] In another embodiment, step S208 "Based on the abnormal mode identifier in the target backup parameter, write the target IO data or target sub-IO data in the cache into the target area of the RAID" includes:
[0116] In response to the exception mode identifier in the target backup parameter representing the first mode, based on the starting position of the IO data in the RAID and the length of the IO data in the target backup parameter, write the target IO data in the cache to the target area of the RAID; or,
[0117] In response to the exception mode identifier in the target backup parameter representing the second mode, based on the disk identifier corresponding to the sub-IO data, the starting position of the sub-IO data in the corresponding disk, and the length of the sub-IO data in the target backup parameter, write the target sub-IO data in the cache to the target area of the disk corresponding to the target sub-IO data.
[0118] In this embodiment, if the exception mode identifier in the target backup parameter represents the first mode, that is, non-write phase exception, at this time the target IO data is complete, the parity data block can be calculated based on the target IO data in the cache and written into the cache, and then based on the starting position of the IO data in the RAID and the length of the IO data in the target backup parameter, write the target IO data in the cache to the target area of the RAID. The target area is the position where the target IO data should originally be written in the RAID, and based on the position of the parity data block corresponding to it in the RAID, write the parity data block to the disk.
[0119] In this embodiment, if the exception mode identifier in the target backup parameter represents the second mode, that is, write phase exception, then based on the disk identifier corresponding to the sub-IO data, the starting position of the sub-IO data in the corresponding disk, and the length of the sub-IO data in the target backup parameter, write the target sub-IO data in the cache to the target area of the disk corresponding to the target sub-IO data. The target area is the position where the sub-IO data should originally be written in the corresponding disk.
[0120] In another embodiment, a data writing method further includes: clearing the IO data and / or sub-IO data in the data sub-area; clearing the backup parameters in the parameter sub-area.
[0121] In this embodiment, after rewriting the backed-up data in the data sub-area to the disk of the RAID, it is necessary to clear the IO data and / or sub-IO data in the data sub-area, and clear the backup parameters in the parameter sub-area. In one example, if the data is directly overwritten when writing the IO data or sub-IO data to the data sub-area, then there is no need to clear the data sub-area; when clearing the backup parameters in the parameter sub-area, all values of the backup parameters can be written as 0; it is also necessary to write all values in the backup parameter record table as 0.
[0122] For the convenience of understanding the present disclosure, the following is based on Figure 7 、 Figure 8 、 Figure 9 to explain a data writing method in the present disclosure:
[0123] Figure 7 illustrates the scenario diagram of a data writing method according to an embodiment of the present disclosure Figure 5 , Figure 8 illustrates the scenario diagram of a data writing method according to an embodiment of the present disclosure Figure 6 , Figure 9 illustrates the scenario diagram of a data writing method according to an embodiment of the present disclosure Figure 7 , assuming that the starting position of the data sub - area in the reserved area is slba0, and there are three IO inputs being written when the disk is abnormal.
[0124] The first IO data has a disk abnormality in the non - disk - writing stage, and the IO data falls at the positions of data blocks 2' to 6' in the RAID. After the first IO data is backed up, the situation of the IO data flow path, the data sub - area and parameter sub - area in the reserved area, and the backup parameter record table is as Figure 7 shown, where Figure 7 Header_contex in is the backup parameter record table, and IO1 is the IO data corresponding to the positions of data blocks 2' to 6' being backed up.
[0125] The second IO data has a disk abnormality in the disk - writing stage, and the IO data falls at the positions of data blocks 14' to 22' in the RAID. And in the disk - writing stage, data blocks 14' to 15' have been written to the disk. Then, when backing up, the data corresponding to data blocks 16' to 22' needs to be divided into sub - IO data corresponding to data blocks 16' to 19' (data in disk 1) and sub - IO data corresponding to data blocks 20' to 22' (data in disk 3) according to the disk. Then, the sub - IO data corresponding to data blocks 16' to 19', the sub - IO data corresponding to data blocks 20' to 22', and 4 parity data blocks P' in disk 2 are respectively backed up to the data sub - area. After the backup is completed, the situation of the IO data flow path, the data sub - area and parameter sub - area in the reserved area, and the backup parameter record table is as Figure 8 shown, where Figure 8 IO2 in is the sub - IO data corresponding to data blocks 16' to 19' being backed up, IO3 is the 4 parity data blocks P' in disk 2 being backed up, and IO3 is the sub - IO data corresponding to data blocks 20' to 22' being backed up. In addition, for the convenience of distinction, the 4 P' parity data blocks in IO3 are respectively labeled as P0', P1', P2', and P3'.
[0126] The third IO has a disk abnormality in the non - disk - writing stage, and the IO data falls at the positions of data blocks 29' to 34' in the RAID. After the third IO data is backed up, the situation of the IO data flow path, the data sub - area and parameter sub - area in the reserved area, and the backup parameter record table is as Figure 9 shown, where Figure 9The IO5 in it is the IO data corresponding to the positions of the backup data blocks 29' to 34'.
[0127] When restoring the IO data backed up in the data sub-region, then according to Figure 9 the first backup parameter in the parameter sub-region, write IO1 into data blocks 2' to 6' of the RAID; according to the second backup parameter in the parameter sub-region, write IO2 into data blocks 4 to 7 in disk 1, that is, data blocks 16' to 19' of the RAID; according to the third backup parameter in the parameter sub-region, write IO3 into data blocks 4 to 7 in disk 2; according to the fourth backup parameter in the parameter sub-region, write IO4 into data blocks 4 to 6 in disk 3, that is, data blocks 20' to 22' of the RAID; according to the fifth backup parameter in the parameter sub-region, write IO5 into data blocks 29' to 34' of the RAID.
[0128] Figure 10 The figure shows a schematic structural diagram of a data writing device according to an embodiment of the present disclosure, as Figure 10 described, a data writing device includes:
[0129] A determination module 10, configured to determine an abnormal mode of a redundant array of independent disks (RAID) in response to the RAID being in an abnormal state; the abnormal state indicates that the number of abnormal disks among multiple disks of the RAID is greater than a first threshold; the determination module 10 is further configured to determine a first backup parameter of input / output (IO) data in response to the abnormal mode being a first mode; the first mode indicates that a disk has an abnormality during a non-writing disk stage, and the first backup parameter includes a backup start position of the IO data in a data sub-region of a reserved area in the RAID; a backup module 20, configured to back up the IO data to the data sub-region based on the first backup parameter, and store the first backup parameter in a parameter sub-region in the reserved area; the determination module 10 is further configured to determine a second backup parameter of sub-IO data corresponding to each disk in the IO data that has not been written to the disk in response to the abnormal mode being a second mode; the second mode indicates that a disk has an abnormality during a writing disk stage, and the second backup parameter includes a backup start position of the sub-IO data in the data sub-region; the backup module 20 is further configured to back up the sub-IO data to the data sub-region based on the second backup parameter, and store the second backup parameter in the parameter sub-region.
[0130] In an implementable manner, the determination module 10 is further configured to: determine a start position of the data sub-region in the reserved area; determine a start position and a length of the latest IO data in the data sub-region from a backup parameter record table; and determine a backup start position of the IO data in the data sub-region based on the start position of the data sub-region in the reserved area, the start position of the latest IO data in the data sub-region, and the length of the latest IO data.
[0131] In an implementable manner, the backup module 20 is further configured to write the IO data from the cache into the data sub-region, and the starting position of the writing is the backup starting position of the IO data in the data sub-region.
[0132] In an implementable manner, the backup module 20 is further configured to determine the number of backup parameters stored in the parameter sub-region from the backup parameter record table; determine the storage starting position of the first backup parameter in the parameter sub-region based on the starting position of the parameter sub-region in the reserved region, the number of backup parameters, and the length of the backup parameter; write the first backup parameter into the parameter sub-region, and the starting position of the writing is the storage starting position of the first backup parameter in the parameter sub-region.
[0133] In an implementable manner, the data writing device further includes an update module, configured to: increment the number of backup parameters in the backup parameter record table by 1; update the starting position of the latest IO data in the backup parameter record table to the sum of the original starting position of the latest IO data and the length of the original latest IO data; update the length of the latest IO data in the backup parameter record table to the length of the IO data.
[0134] In an implementable manner, the first backup parameter further includes at least one of the validity identifier of the first backup parameter, the abnormal mode identifier, the starting position of the IO data in the RAID, and the length of the IO data.
[0135] In an implementable manner, the second backup parameter further includes at least one of the validity identifier of the second backup parameter, the abnormal mode identifier, the disk identifier corresponding to the sub-IO data, the starting position of the sub-IO data in the corresponding disk, and the length of the sub-IO data.
[0136] In an implementable manner, the data writing device further includes a recovery module, configured to: in response to the abnormal disk returning to normal, sequentially read the backup parameters in the parameter sub-region; based on the backup starting position in the read target backup parameter and the length of the IO data or sub-IO data, read the target IO data or target sub-IO data from the data sub-region to the cache; based on the abnormal mode identifier in the target backup parameter, write the target IO data or target sub-IO data in the cache into the target area of the RAID.
[0137] In one implementable manner, the recovery module is further configured to: in response to the exception mode identifier in the target backup parameter indicating the first mode, write the target IO data in the cache into the target area of the RAID based on the starting position of the IO data in the RAID and the length of the IO data in the target backup parameter; or, in response to the exception mode identifier in the target backup parameter indicating the second mode, write the target sub-IO data in the cache into the target area of the disk corresponding to the target sub-IO data based on the disk identifier corresponding to the sub-IO data, the starting position of the sub-IO data in the corresponding disk, and the length of the sub-IO data in the target backup parameter.
[0138] In one implementable manner, the recovery module is further configured to: calculate a check data block based on the target IO data in the cache and write the check data block into the cache.
[0139] In one implementable manner, the data writing device further includes a clearing module, configured to: clear the IO data and / or sub-IO data in the data sub-region; clear the backup parameter in the parameter sub-region.
[0140] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device and a readable storage medium.
[0141] Figure 11 FIG. shows a schematic block diagram of an exemplary electronic device 800 that can be used to implement the embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0142] As Figure 11 shown, the device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 802 or the computer program loaded from the storage unit 808 into the random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. The input / output (I / O) interface 805 is also connected to the bus 804.
[0143] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as a keyboard, mouse, etc.; output unit 807, such as various types of displays, speakers, etc.; storage unit 808, such as a disk, optical disc, etc.; and communication unit 809, such as a network card, modem, wireless communication transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0144] Computing unit 801 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of computing unit 801 include but are not limited to a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Computing unit 801 executes the various methods and processes described above, such as a data writing method. For example, in some embodiments, a data writing method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed onto device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by computing unit 801, one or more steps of the data writing method described above can be executed. Alternatively, in other embodiments, computing unit 801 can be configured to execute a data writing method in any other suitable way (e.g., by means of firmware).
[0145] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGA), application-specific integrated circuits (ASIC), application-specific standard products (ASSP), system-on-chip systems (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special or general-purpose programmable processor, receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0146] The program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, a special purpose computer, or other programmable data processing device, such that the program codes, when executed by the processor or controller, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine, or entirely on the remote machine or server.
[0147] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0148] In order to provide interaction with a user, the systems and techniques described herein may be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0149] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), and the Internet.
[0150] A computer system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client - server relationship is created by computer programs running on the respective computers and having a client - server relationship with each other. The server can be a cloud server, a server of a distributed system, or a server incorporating blockchain.
[0151] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in this disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. There is no limitation herein.
[0152] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" can explicitly or implicitly include at least one of such features. In the description of this disclosure, "a plurality" means two or more, unless otherwise specifically defined.
[0153] As described above, the above are only specific embodiments of this disclosure, but the protection scope of this disclosure is not limited thereto. Any person skilled in the art within the technical scope disclosed by this disclosure can easily think of changes or substitutions, which should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be subject to the protection scope of the claims.
Claims
1. A data writing method, characterized in that: The method comprises: In response to a redundant array of independent disks RAID being in an abnormal state, determining an abnormal mode of the RAID; the abnormal state indicating that the number of abnormal disks among the plurality of disks of the RAID is greater than a first threshold; In response to the abnormal mode being the first mode, determining a first backup parameter of the input / output IO data; the first mode indicates that an abnormality occurs in the disk during a non-write phase, and the first backup parameter includes a backup start position of the IO data in a data sub-area of a reserved area of the RAID; Backing up the IO data to the data sub-area based on the first backup parameter, and storing the first backup parameter to the parameter sub-area in the reserved area; In response to the abnormal mode being the second mode, determining a second backup parameter of the sub-IO data corresponding to each disk in the IO data that has not been written to the disk; the second mode indicates that an abnormality occurs in the disk writing phase, and the second backup parameter includes a backup start position of the sub-IO data in the data sub-area; Backing up the sub-IO data to the data sub-area based on the second backup parameter, and storing the second backup parameter to the parameter sub-area; The step of determining the first backup parameter of the input and output IO data includes: Determine a starting position of the data sub-area in the reserved area; Determine the starting position of the latest IO data in the data sub-area and the length of the latest IO data from the backup parameter record table; Determine a backup starting position of the IO data in the data sub-area based on a starting position of the data sub-area in the reserved area, a starting position of the latest IO data in the data sub-area, and a length of the latest IO data; The step of backing up the IO data to the data sub-area based on the first backup parameter includes: Writing the IO data from the cache into the data sub-area, where the starting position of writing is the backup starting position of the IO data in the data sub-area; The step of storing the first backup parameter in the parameter sub-area in the reserved area includes: Determining the number of backup parameters stored in the parameter sub-area from the backup parameter record table; Determine a storage starting position of the first backup parameter in the parameter sub-area based on a starting position of the parameter sub-area in the reserved area, the number of the backup parameters, and the length of the backup parameters; The first backup parameter is written into the parameter sub-area, and the writing start position is the storage start position of the first backup parameter in the parameter sub-area.
2. The method according to claim 1, characterized in that After storing the first backup parameter in the parameter sub-area in the reserved area, the method further includes: Add 1 to the number of backup parameters in the backup parameter record table; Update the starting position of the latest IO data in the backup parameter record table to the starting position of the original latest IO data plus the length of the original latest IO data; The length of the latest IO data in the backup parameter record table is updated to the length of the IO data.
3. The method according to claim 1, characterized in that The first backup parameter also includes at least one of a validity identifier of the first backup parameter, an abnormal mode identifier, a starting position of the IO data in the RAID, and a length of the IO data.
4. The method according to claim 1, characterized in that: The second backup parameter also includes at least one of a validity identifier of the second backup parameter, an abnormal mode identifier, a disk identifier corresponding to the sub-IO data, a starting position of the sub-IO data in the corresponding disk, and a length of the sub-IO data.
5. The method according to claim 1, characterized in that The method further comprises: In response to the abnormal disk returning to normal, reading the backup parameters in the parameter sub-area in sequence; Based on the backup start position in the read target backup parameters and the length of the IO data or the sub-IO data, read the target IO data or the target sub-IO data from the data sub-area into the cache; Based on the abnormal mode identifier in the target backup parameter, the target IO data or the target sub-IO data in the cache is written into the target area of the RAID.
6. The method according to claim 5, characterized in that The step of writing the target IO data or the target sub-IO data in the cache into the target area of the RAID based on the abnormal mode identifier in the target backup parameter comprises: In response to the abnormal mode identifier in the target backup parameter representing the first mode, based on the starting position of the IO data in the target backup parameter in the RAID and the length of the IO data, the target IO data in the cache is written into the target area of the RAID; or, In response to the abnormal mode identifier in the target backup parameters representing the second mode, based on the disk identifier corresponding to the sub-IO data in the target backup parameters, the starting position of the sub-IO data in the corresponding disk and the length of the sub-IO data, the target sub-IO data in the cache is written into the target area of the disk corresponding to the target sub-IO data.
7. The method according to claim 6, characterized in that Before writing the target IO data in the cache into the target area of the RAID, the method further includes: A check data block is calculated based on the target IO data in the cache, and the check data block is written into the cache.
8. The method according to claim 7, characterized in that The method further comprises: Clearing the IO data and / or sub-IO data in the data sub-area; Clear the backup parameters in the parameter sub-area.
9. A data writing device, characterized in that: The device comprises: A determination module, configured to determine an abnormal mode of the RAID in response to a redundant array of independent disks RAID being in an abnormal state; the abnormal state indicates that the number of abnormal disks among the multiple disks of the RAID is greater than a first threshold; The determination module is further configured to determine a first backup parameter of input / output IO data in response to the abnormal mode being a first mode; the first mode indicates that an abnormality occurs in the disk during a non-write phase, and the first backup parameter includes a backup start position of the IO data in a data sub-area of a reserved area of the RAID; A backup module, configured to back up the IO data to the data sub-area based on the first backup parameter, and store the first backup parameter to the parameter sub-area in the reserved area; The determination module is further configured to determine, in response to the abnormal mode being the second mode, a second backup parameter of the sub-IO data corresponding to each disk in the IO data that has not yet been written to the disk; the second mode indicates that an abnormality occurs in the disk writing phase, and the second backup parameter includes a backup start position of the sub-IO data in the data sub-area; The backup module is further used to back up the sub-IO data to the data sub-area based on the second backup parameter, and store the second backup parameter to the parameter sub-area; Wherein, the determining module is further used for: Determine a starting position of the data sub-area in the reserved area; Determine the starting position of the latest IO data in the data sub-area and the length of the latest IO data from the backup parameter record table; Determine a backup starting position of the IO data in the data sub-area based on a starting position of the data sub-area in the reserved area, a starting position of the latest IO data in the data sub-area, and a length of the latest IO data; Wherein, the backup module is also used for: Writing the IO data from the cache into the data sub-area, where the starting position of writing is the backup starting position of the IO data in the data sub-area; Wherein, the backup module is also used for: Determining the number of backup parameters stored in the parameter sub-area from the backup parameter record table; Determine a storage starting position of the first backup parameter in the parameter sub-area based on a starting position of the parameter sub-area in the reserved area, the number of the backup parameters, and the length of the backup parameters; The first backup parameter is written into the parameter sub-area, and the writing start position is the storage start position of the first backup parameter in the parameter sub-area.
10. The device according to claim 9, characterized in that The data writing device further includes an updating module, which is used for: Add 1 to the number of backup parameters in the backup parameter record table; Update the starting position of the latest IO data in the backup parameter record table to the starting position of the original latest IO data plus the length of the original latest IO data; The length of the latest IO data in the backup parameter record table is updated to the length of the IO data.
11. The device according to claim 9, characterized in that The first backup parameter also includes at least one of a validity identifier of the first backup parameter, an abnormal mode identifier, a starting position of the IO data in the RAID, and a length of the IO data.
12. The device according to claim 9, characterized in that The second backup parameter also includes at least one of a validity identifier of the second backup parameter, an abnormal mode identifier, a disk identifier corresponding to the sub-IO data, a starting position of the sub-IO data in the corresponding disk, and a length of the sub-IO data.
13. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
14. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to make a computer execute the method according to any one of claims 1-8.
Citation Information
Patent Citations
Array access method and device, storage equipment and machine readable storage medium
CN112181298A
Data writing method and device, equipment and medium
CN118069056A