RAID (Redundant Array of Independent Disks) power-down IO (Input / Output) data recovery method, system and equipment and medium
By dividing the IO data processing stage of RAID array and recording the status, the data loss problem caused by power failure of RAID array is solved, accurate data recovery and consistency are achieved, and the stability and performance of the system are improved.
Patent Information
- Application Number
- CN202411336174.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2024-12-20
AI Technical Summary
RAID arrays may cause data loss or corruption when powered off abnormally, especially in writeback mode. Data that has been returned but not written to be stored will be lost after powered off, affecting data consistency and reliability.
Data recovery is achieved by dividing the IO data processing process of the RAID array into clear stages and recording the IO status and context information of each stage into nonvolatile storage. The specific steps include dividing the IO stages in the write-back mode and the write-through mode, defining the IO context structure, saving and restoring the state during the IO data processing process, ensuring that the data processing state can be accurately restored and unfinished IO operations can be completed after power failure. .
Effectively avoid data loss and damage caused by power failure, ensure data integrity and consistency, improve the stability and reliability of RAID arrays, especially in complex configurations, which can accurately track IO operation status and improve system performance. .
Smart Images

Figure CN119166426A_ABST
Abstract
Description
Background Art
[0002] RAID is the abbreviation of Redundant Array of Independent Disks, which is an array of independent disks with redundancy. RAID is a data storage virtualization technology that combines multiple hard disk drives into a logical unit. RAID can improve data reliability, performance and capacity. In a RAID array, data read and write operations can be performed in parallel to improve performance. In some RAID configurations, in order to reduce the host's waiting time and reduce IO latency, when the host sends a write request to the RAID array, the RAID controller will adopt a write-back mode IO strategy, sending a response to the host before the data is actually written to the hard disk. The advantage of this method is that it can reduce the host's waiting time and improve overall performance, but the disadvantage of this method is that if the system suddenly loses power, the data that only exists in the cache but has not been written to the storage will be lost. Another write-through mode IO strategy can ensure data consistency. When the CPU performs a write operation, the data will not only be written to the cache, but also to the back-end storage, thereby achieving data consistency. However, the disadvantage of this method is that each write operation requires access to the cache and storage, which increases the latency of the write operation and affects storage performance.
[0003] At present, whether in write-through mode or write-back mode, if power is lost during IO writing, there may be a risk of data loss or damage. For example, when writing, the raid controller loses power abnormally, causing some disks to fail to write, resulting in inconsistent data in the stripe and data damage. Especially in write-back mode, after the response has been returned to the host, but before the IO data has time to be written to the disk, if the raid controller loses power abnormally, data loss will occur.
[0004] This is a shortcoming of the prior art. Therefore, in view of the above-mentioned defects in the prior art, it is very necessary to provide a RAID array power-off IO data recovery method, system, device and medium. Summary of the invention
[0005] In view of the defect that data loss may occur in the current RAID array when the raid controller loses power abnormally, the present invention provides a RAID array power-off IO data recovery method, system, device and medium to solve the above technical problem.
[0006] In a first aspect, the present invention provides a method for recovering IO data from a power failure of a RAID array, comprising the following steps: S1. pre-dividing the IO data processing process of the RAID array into stages, and defining the IO state corresponding to each stage;
[0007] S2. Record the stage in the IO data processing process and save the IO status of each stage and the context information of the host IO data to non-volatile storage;
[0008] S3. When the RAID array recovers from abnormal power failure, the stage of the IO data processing process before the power failure is determined according to the real-time IO status, and the IO data is restored according to the stage.
[0009] Furthermore, the specific steps of step S1 are as follows:
[0010] S11. The write-back mode of the RAID array is pre-divided into four stages: receiving write IO stage, moving data stage, replying host response stage and writing disk stage;
[0011] S12. The starting state of the write IO receiving phase of the write-back mode is defined as the idle state, the end state of the write IO receiving phase is defined as the pre-response state, the end state of the host response phase is defined as the pre-write state, the starting state of the disk writing phase is defined as the write state, and the end state of the disk writing state is defined as the idle state; S13. The write-through mode of the RAID array is pre-divided into three phases: the write IO receiving phase, the data moving phase, and the disk writing phase;
[0012] S14. Define the starting state of the write IO phase of the write-through mode as the idle state, define the end state of the write IO as the pre-response state, define the starting state of the write disk phase as the write state, and define the end state of the write disk phase as the idle state. By defining the IO processing stages and state transitions of the RAID array in the write-back and write-through modes in detail, each step of the IO data processing process has a clear status identification. This refined stage division and state management not only helps to understand the processing flow of IO data, but also provides a basis for subsequent exception handling and data recovery. Especially in complex RAID configurations, the ability to accurately track the specific status of each IO operation is of great significance for ensuring data security and improving system performance.
[0013] Furthermore, the specific steps of step S2 are as follows:
[0014] S21. Predefine an IO context structure, and after obtaining an IO request, obtain an idle IO context structure from non-volatile storage;
[0015] S22. Apply for IO data storage space from non-volatile storage, write IO data into cache and write into each disk, and save the IO status of each stage in the IO data processing process and the context information of the host IO data into the IO context structure according to the RAID array mode. By defining the IO context structure and recording the processing status and context information of IO data in real time, comprehensive monitoring and recording of the IO operation process is achieved. The present invention enables the RAID array to quickly recover to the processing state before power failure after power failure, and continue to complete the unfinished IO operation; at the same time, by applying for IO data storage space from non-volatile storage, the persistence and reliability of data are guaranteed, and the risk of data loss due to power failure is avoided.
[0016] Furthermore, the specific steps of step S21 are as follows:
[0017] S211. Predefine the IO context structure including the IO start logical address, IO length, stripe number, data address, IO status and several fields of disk write information;
[0018] S212. Predefine each disk write information field including disk ID, disk start logical address, disk write length, write data address offset and disk write status subfield;
[0019] S213. After obtaining the IO request, obtain an idle IO context structure, fill in the IO starting logical address and IO length information in the IO context structure, and record the IO status as the pre-response stage;
[0020] S214. Apply for IO data cache space from non-volatile storage, and write the applied address into the data address field of the IO context structure. The present invention provides information support for the recovery of IO data by defining the fields of the IO context structure in detail. These fields fully consider the complexity and diversity of IO operations and can accurately record the key information of each IO operation; at the same time, by obtaining an idle IO context structure and filling in relevant information, it is prepared for subsequent IO data processing and recording.
[0021] Furthermore, the specific steps of step S22 are as follows:
[0022] S221. Use the host to directly access the memory unit to move the data to be written to the requested IO data cache space;
[0023] S222. Determine the RAID array mode;
[0024] When it is in write-back mode, go to step S223;
[0025] When it is write-through mode, go to step S224;
[0026] S223. After the host directly accesses the memory unit and the data is moved, a successful write response is restored to the host, and the IO state is recorded as a pre-write state;
[0027] S224. Calculate the check block of the IO data, divide the IO data into each disk, write the check block to the preset location of the disk, and update the disk write information in the IO context structure;
[0028] S225. Before starting to write to the disk in the write phase, record the IO status as the write status, and record the status of each disk as the write status;
[0029] S226. After receiving the write response from the disk, record the disk status as the write success status, and after all disks have completed writing, record the IO status as the idle status, and release the IO context structure. By describing the processing flow of IO data in different RAID modes in detail, different processing paths are selected according to the mode of the RAID array to ensure the accuracy and reliability of IO operations; in the disk writing stage, by recording the disk status and IO status, it provides strong support for subsequent exception processing and data recovery.
[0030] Furthermore, the specific steps of step S3 are as follows:
[0031] S31. After the RAID controller is powered on, determine whether it is an abnormal power-off restart;
[0032] If yes, start IO recovery and go to step S32;
[0033] If not, return to step S22;
[0034] S32. Traverse all IO context structures to identify the number of IO context structures and locate an IO context structure;
[0035] S33. Get the IO status of the located IO context structure;
[0036] When the IO state is idle or pre-response, go to step S34;
[0037] When the IO state is writing state, go to step S35;
[0038] When the IO state is the pre-write state, go to step S36;
[0039] S34. It is determined that the host response has not been replied and the disk writing has not started, there is no risk of stripe inconsistency, and no IO data recovery is required, and the process proceeds to step S37;
[0040] S35. Determine that the IO data has been segmented and the checksum has been calculated, but there is a risk of inconsistent stripes, traverse the disk write information fields in the IO context structure, rewrite the disk that has not been successfully written, and enter step S37;
[0041] S36. It is determined that the host response has been replied, but the IO data may not be cut and the check value may not be calculated. The check value is recalculated and the IO data is cut, and the disk write operation is performed, and the process proceeds to step S37;
[0042] S37. Determine whether the IO context structure is located;
[0043] If yes, go to step S38;
[0044] If not, locate the next IO context structure and return to step S33;
[0045] S38. Initialize the IO context structure and mark all IO context structures as idle. By determining whether the RAID controller is restarted due to abnormal power failure and starting the IO recovery process accordingly, the data recovery capability of the RAID array after power failure is effectively guaranteed. In the recovery process, by traversing the IO context structure and identifying the IO state, corresponding recovery measures are taken according to different states. The recovery strategy of the present invention can cope with a variety of abnormal situations and ensure the integrity and consistency of the data. At the same time, by initializing the IO context structure and marking it as idle, it is prepared for subsequent IO operations.
[0046] Furthermore, the specific steps of step S35 are as follows:
[0047] S351. Obtain the segmented IO data and the calculated checksum value;
[0048] S352. Traverse the disk write information field in the IO context structure, identify the number of disk write information fields, and locate a disk write information field;
[0049] S353. The disk corresponding to the located write disk information field is used as the located disk;
[0050] S354. Write the data of the segmented IO data according to the disk ID, disk start logical address, disk write length, write data address offset and write disk status subfields corresponding to the write disk information field. By describing in detail the specific steps of data recovery when the IO state is the write state, by obtaining the segmented IO data and the calculated check value, and traversing the write disk information field to rewrite the data, it is ensured that the disk that failed to write the disk can be recovered in time. The targeted recovery measures of the present invention can effectively solve the risk of inconsistent stripes and ensure the data security of the RAID array. At the same time, through precise data writing operations, the consistency of the recovered data with the original data is ensured.
[0051] In a second aspect, the present invention provides a RAID array power-off IO data recovery system, comprising: an IO data processing stage division module, for pre-dividing the IO data processing process of the RAID array into stages and defining the IO state corresponding to each stage;
[0052] The IO status and IO data context information recording module is used to record the stage in the IO data processing process and save the IO status of each stage and the context information of the host IO data into non-volatile storage;
[0053] The IO data recovery module is used to determine the stage of the IO data processing process before the power failure according to the real-time IO status after the RAID array is restored from abnormal power failure, and perform IO data recovery according to the stage.
[0054] Furthermore, the IO data processing stage division module includes:
[0055] The write-back mode phase division unit is used to pre-divide the write-back mode of the RAID array into four phases: receiving write IO phase, moving data phase, replying host response phase and writing disk phase;
[0056] The write-back mode IO state recording unit is used to define the starting state of the write IO receiving phase of the write-back mode as the idle state, define the end state of the write IO receiving phase as the pre-response state, define the end state of the host response phase as the pre-write state, define the starting state of the disk writing phase as the write state, and define the end state of the disk writing state as the idle state;
[0057] A write-through mode phase division unit is used to pre-divide the write-through mode of the RAID array into three phases: a write IO receiving phase, a data moving phase, and a disk writing phase;
[0058] The write-through mode IO state recording unit is used to define the starting state of the write IO phase of the write-through mode as the idle state, define the end state of the write IO as the pre-response state, define the starting state of the disk write phase as the write state, and define the end state of the disk write phase as the idle state.
[0059] Furthermore, the IO status and IO data context information recording module includes:
[0060] An IO context structure definition and application unit, used to predefine an IO context structure and obtain an idle IO context structure from a non-volatile storage after obtaining an IO request;
[0061] The IO status and context information recording unit is used to apply for IO data storage space from non-volatile storage, write IO data into cache and write to each disk, and save the IO status of each stage of IO data processing and the context information of host IO data into the IO context structure according to the RAID array mode.
[0062] Furthermore, the IO context structure definition and application unit include:
[0063] The IO context structure definition subunit is used to predefine the IO context structure including the IO start logical address, IO length, stripe number, data address, IO status and several fields of disk writing information;
[0064] The disk writing information definition subunit is used to predefine each disk writing information field including a disk ID, a disk start logical address, a disk writing length, a write data address offset, and a disk writing status subfield;
[0065] The IO status recording subunit is used to obtain an idle IO context structure after obtaining the IO request, fill in the IO starting logical address and IO length information in the IO context structure, and record the IO status as the pre-response stage;
[0066] The cache data address writing subunit is used to apply for IO data cache space from the non-volatile storage and write the applied address into the data address field of the IO context structure.
[0067] Furthermore, the IO status and context information recording unit includes:
[0068] The data moving subunit is used to move the data to be written to the requested IO data cache space by using the host to directly access the memory unit;
[0069] A RAID array mode determination subunit, used to determine the mode of the RAID array;
[0070] The pre-write status recording subunit is used to restore the write success response to the host after the data migration is completed when the host directly accesses the memory unit in the write-back mode, and record the IO status as the pre-write status;
[0071] The disk write information recording subunit is used to calculate the check block of IO data after completing the data migration in the write-back mode and the write-through mode, split the IO data into each disk, write the check block to the preset position of the disk, and update the disk write information in the IO context structure;
[0072] The write status recording subunit is used to record the IO status as the write status and the status of each disk as the write status before starting to write to the disk in the write stage;
[0073] The idle state recording subunit is used to record the disk state as a write success state after receiving a write response from the disk, and after all disks have completed writing, record the IO state as an idle state and release the IO context structure.
[0074] Furthermore, the IO data recovery module includes:
[0075] An abnormal power-off restart judgment unit is used to judge whether it is an abnormal power-off restart after the RAID controller is powered on;
[0076] The IO context positioning unit is used to start IO recovery after abnormal power failure and restart, traverse all IO context structures to identify the number of IO context structures, and locate an IO context structure;
[0077] An IO status acquisition unit, used to acquire the IO status of the located IO context structure;
[0078] No IO data recovery unit is required. When the IO status is idle or pre-response, it is determined that the host response has not been replied and the disk writing has not started. There is no risk of stripe inconsistency and no IO data recovery is required.
[0079] The re-writing unit is used to determine that the IO data has completed segmentation and checksum calculation when the IO state is the writing state, but there is a risk of stripe inconsistency, traverse each disk writing information field in the IO context structure, and perform a re-writing operation on the disk that has not been successfully written;
[0080] The re-data segmentation and disk writing unit is used to determine that the host response has been replied, but there is a possibility that the IO data has not been segmented and the check value has not been calculated when the IO state is the pre-write state, recalculate the check value and segment the IO data, and then write to the disk;
[0081] An IO context structure positioning judgment unit, used to judge whether the IO context structure has been positioned;
[0082] The next IO context structure positioning unit is used to position the next IO context structure when the IO context structure has not been completely positioned;
[0083] The IO context structure release unit is used to initialize the IO context structure and mark all IO context structures as idle.
[0084] In a third aspect, the present invention provides an electronic device, including a processor and a memory;
[0085] The memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the electronic device executes the method described in the first aspect above.
[0086] In a fourth aspect, the present invention provides a storage medium,
[0087] The storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method described in the first aspect.
[0088] The beneficial effects of the present invention are:
[0089] The RAID array power-off IO data recovery method, system, device and medium provided by the present invention accurately select the IO data recovery method by recording the disk writing status in the IO context structure, so that the disk that has been successfully written is avoided during the IO data recovery process, the recovery speed is optimized, and the data integrity can still be guaranteed when power failure occurs again during the IO power-off recovery process.
[0090] In addition, the invention has a reliable design principle, a simple structure and a very broad application prospect.
[0091] It can be seen that compared with the prior art, the present invention has outstanding substantive features and significant progress, and the beneficial effects of its implementation are also obvious. BRIEF DESCRIPTION OF THE DRAWINGS
[0092] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0093] Figure 1 The present invention is a flowchart of a method for recovering IO data when a RAID array loses power.
[0094] Figure 2 It is a schematic diagram of the RAID array power failure IO data recovery system of the present invention. DETAILED DESCRIPTION
[0095] The RAID array power-off IO data recovery method can be applied to one or more electronic devices, wherein the electronic device is an electronic device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a programmable gate array (Field-Programmable Gate Array, FPGA), a digital processor (Digital Signal Processor, DSP), an embedded device, etc.
[0096] An electronic device can be any electronic product that can interact with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), an interactive network television (IPTV), etc. The network in which the electronic device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.
[0097] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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 ordinary technicians in this field without creative work should fall within the scope of protection of the present invention. Please refer to Figure 1 The figure shows a specific implementation of a RAID array power failure IO data recovery method, including the following steps:
[0098] S1. Divide the IO data processing process of the RAID array into stages in advance and define the IO state corresponding to each stage;
[0099] S2. Record the stage in the IO data processing process and save the IO status of each stage and the context information of the host IO data to non-volatile storage;
[0100] S3. When the RAID array recovers from abnormal power failure, the stage of the IO data processing process before the power failure is determined according to the real-time IO status, and the IO data is restored according to the stage.
[0101] The present invention effectively improves the data recovery capability of the RAID array in the event of an abnormal power failure by pre-dividing the RAID array IO data processing stages and defining the states of each stage; by saving the key IO states and IO context information in the IO processing process to non-volatile storage, even in the event of a sudden power failure, the processing state before the power failure can be accurately restored, thereby ensuring the integrity and consistency of the data. The present invention significantly enhances the stability and reliability of the RAID array, and is particularly suitable for application scenarios with high requirements for data security.
[0102] In this embodiment, the specific steps of step S1 are as follows:
[0103] S11. The write-back mode of the RAID array is pre-divided into four stages: receiving write IO stage, moving data stage, replying host response stage and writing disk stage;
[0104] S12. The starting state of the write IO receiving phase of the write-back mode is defined as the idle state, the end state of the write IO receiving phase is defined as the pre-response state, the end state of the host response phase is defined as the pre-write state, the starting state of the disk writing phase is defined as the write state, and the end state of the disk writing state is defined as the idle state; S13. The write-through mode of the RAID array is pre-divided into three phases: the write IO receiving phase, the data moving phase, and the disk writing phase;
[0105] S14. The starting state of the write IO phase received in the write-through mode is defined as the idle state, the end state of the write IO is defined as the pre-response state, the starting state of the write disk phase is defined as the write state, and the end state of the write disk phase is defined as the idle state;
[0106] The specific steps of step S2 are as follows:
[0107] S21. Predefine the IO context structure, and after obtaining the IO request, obtain the idle IO context structure from the non-volatile storage; the specific steps of step S21 are as follows:
[0108] S211. Predefine the IO context structure including the IO start logical address, IO length, stripe number, data address, IO status and several fields of disk write information;
[0109] S212. Predefine each disk write information field including disk ID, disk start logical address, disk write length, write data address offset and disk write status subfield;
[0110] S213. After obtaining the IO request, obtain an idle IO context structure, fill in the IO starting logical address and IO length information in the IO context structure, and record the IO status as the pre-response stage;
[0111] S214. Apply for IO data cache space from non-volatile storage, and write the applied address into the data address field of the IO context structure; the non-volatile storage may be a capacitor-protected RAM;
[0112] S22. Apply for IO data storage space from non-volatile storage, write IO data into cache and write to each disk, and save the IO status of each stage of IO data processing and the context information of host IO data into the IO context structure according to the RAID array mode; the specific steps of step S22 are as follows:
[0113] S221. Use the host to directly access the memory unit to move the data to be written to the requested IO data cache space;
[0114] S222. Determine the RAID array mode;
[0115] When it is in write-back mode, go to step S223;
[0116] When it is write-through mode, go to step S224;
[0117] S223. After the host directly accesses the memory unit and the data is moved, a successful write response is restored to the host, and the IO state is recorded as a pre-write state;
[0118] S224. Calculate the check block of the IO data, divide the IO data into each disk, write the check block to the preset location of the disk, and update the disk write information in the IO context structure;
[0119] S225. Before starting to write to the disk in the write phase, record the IO status as the write status, and record the status of each disk as the write status;
[0120] S226. After receiving the write response from the disk, record the disk status as the write success status, and after all disks have completed writing, record the IO status as the idle status, and release the IO context structure;
[0121] The specific steps of step S3 are as follows:
[0122] S31. After the RAID controller is powered on, determine whether it is an abnormal power-off restart;
[0123] If yes, start IO recovery and go to step S32;
[0124] If not, return to step S22;
[0125] S32. Traverse all IO context structures to identify the number of IO context structures and locate an IO context structure;
[0126] S33. Get the IO status of the located IO context structure;
[0127] When the IO state is idle or pre-response, go to step S34;
[0128] When the IO state is writing state, go to step S35;
[0129] When the IO state is the pre-write state, go to step S36;
[0130] S34. It is determined that the host response has not been replied and the disk writing has not started, there is no risk of stripe inconsistency, and no IO data recovery is required, and the process proceeds to step S37;
[0131] S35. Determine that the IO data has been segmented and the checksum has been calculated, but there is a risk of inconsistent stripes, traverse the disk write information fields in the IO context structure, rewrite the disk that has not been successfully written, and enter step S37;
[0132] The specific steps of step S35 are as follows:
[0133] S351. Obtain the segmented IO data and the calculated checksum value;
[0134] S352. Traverse the disk write information field in the IO context structure, identify the number of disk write information fields, and locate a disk write information field;
[0135] S353. The disk corresponding to the located write disk information field is used as the located disk;
[0136] S354. Write the split IO data according to the subfields of the disk ID, disk start logical address, disk write length, write data address offset, and disk write status corresponding to the disk write information field;
[0137] S36. It is determined that the host response has been replied, but the IO data may not be cut and the check value may not be calculated. The check value is recalculated and the IO data is cut, and the disk write operation is performed, and the process proceeds to step S37;
[0138] S37. Determine whether the IO context structure is located;
[0139] If yes, go to step S38;
[0140] If not, locate the next IO context structure and return to step S33;
[0141] S38. Initialize the IO context structure and mark all IO context structures as idle.
[0142] It should be understood that the order of execution of the steps in the above embodiment does not mean that the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0143] The following is an embodiment of a RAID array power failure IO data recovery system provided by an embodiment of the present disclosure. The device and the RAID array power failure IO data recovery method of the above-mentioned embodiments belong to the same inventive concept. For details not fully described in the embodiment of the RAID array power failure IO data recovery system, reference can be made to the embodiment of the above-mentioned RAID array power failure IO data recovery method.
[0144] like Figure 2 As shown, the system includes:
[0145] O data processing stage division module, used to divide the IO data processing process of the RAID array into stages in advance and define the IO state corresponding to each stage;
[0146] The IO status and IO data context information recording module is used to record the stage in the IO data processing process and save the IO status of each stage and the context information of the host IO data into non-volatile storage;
[0147] The IO data recovery module is used to determine the stage of the IO data processing process before the power failure according to the real-time IO status after the RAID array is restored from abnormal power failure, and perform IO data recovery according to the stage.
[0148] In this embodiment, the IO data processing stage division module includes:
[0149] The write-back mode phase division unit is used to pre-divide the write-back mode of the RAID array into four phases: receiving write IO phase, moving data phase, replying host response phase and writing disk phase;
[0150] The write-back mode IO state recording unit is used to define the starting state of the write IO receiving phase of the write-back mode as the idle state, define the end state of the write IO receiving phase as the pre-response state, define the end state of the host response phase as the pre-write state, define the starting state of the disk writing phase as the write state, and define the end state of the disk writing state as the idle state;
[0151] A write-through mode phase division unit is used to pre-divide the write-through mode of the RAID array into three phases: a write IO receiving phase, a data moving phase, and a disk writing phase;
[0152] The write-through mode IO state recording unit is used to define the starting state of the write IO receiving phase of the write-through mode as the idle state, define the end state of the write IO as the pre-response state, define the starting state of the disk writing phase as the write state, and define the end state of the disk writing phase as the idle state;
[0153] The IO status and IO data context information recording module includes:
[0154] An IO context structure definition and application unit, used to predefine an IO context structure and obtain an idle IO context structure from a non-volatile storage after obtaining an IO request;
[0155] The IO context structure definition and application unit include:
[0156] The IO context structure definition subunit is used to predefine the IO context structure including the IO start logical address, IO length, stripe number, data address, IO status and several fields of disk writing information;
[0157] The disk writing information definition subunit is used to predefine each disk writing information field including a disk ID, a disk start logical address, a disk writing length, a write data address offset, and a disk writing status subfield;
[0158] The IO status recording subunit is used to obtain an idle IO context structure after obtaining the IO request, fill in the IO starting logical address and IO length information in the IO context structure, and record the IO status as the pre-response stage;
[0159] The cache data address writing subunit is used to apply for IO data cache space from the non-volatile storage and write the applied address into the data address field of the IO context structure;
[0160] The IO status and context information recording unit is used to apply for IO data storage space from non-volatile storage, write IO data into cache and each disk, and save the IO status of each stage of IO data processing and the context information of host IO data into the IO context structure according to the RAID array mode; the IO status and context information recording unit includes:
[0161] The data moving subunit is used to move the data to be written to the requested IO data cache space by using the host to directly access the memory unit;
[0162] A RAID array mode determination subunit, used to determine the mode of the RAID array;
[0163] The pre-write status recording subunit is used to restore the write success response to the host after the data migration is completed when the host directly accesses the memory unit in the write-back mode, and record the IO status as the pre-write status;
[0164] The disk write information recording subunit is used to calculate the check block of IO data after completing the data migration in the write-back mode and the write-through mode, split the IO data into each disk, write the check block to the preset position of the disk, and update the disk write information in the IO context structure;
[0165] The write status recording subunit is used to record the IO status as the write status and the status of each disk as the write status before starting to write to the disk in the write stage;
[0166] The idle state recording subunit is used to record the disk state as a write success state after receiving a write response from the disk, and after all disks have completed writing, record the IO state as an idle state and release the IO context structure;
[0167] The IO data recovery module includes:
[0168] An abnormal power-off restart judgment unit is used to judge whether it is an abnormal power-off restart after the RAID controller is powered on;
[0169] The IO context positioning unit is used to start IO recovery after abnormal power failure and restart, traverse all IO context structures to identify the number of IO context structures, and locate an IO context structure;
[0170] An IO status acquisition unit, used to acquire the IO status of the located IO context structure;
[0171] No IO data recovery unit is required. When the IO status is idle or pre-response, it is determined that the host response has not been replied and the disk writing has not started. There is no risk of stripe inconsistency and no IO data recovery is required.
[0172] The re-writing unit is used to determine that the IO data has completed segmentation and checksum calculation when the IO state is the writing state, but there is a risk of stripe inconsistency, traverse each disk writing information field in the IO context structure, and perform a re-writing operation on the disk that has not been successfully written;
[0173] The re-data segmentation and disk writing unit is used to determine that the host response has been replied, but there is a possibility that the IO data has not been segmented and the check value has not been calculated when the IO state is the pre-write state, recalculate the check value and segment the IO data, and then write to the disk;
[0174] An IO context structure positioning judgment unit, used to judge whether the IO context structure has been positioned;
[0175] The next IO context structure positioning unit is used to position the next IO context structure when the IO context structure has not been completely positioned;
[0176] The IO context structure release unit is used to initialize the IO context structure and mark all IO context structures as idle.
[0177] The RAID array power-off IO data recovery method provided by the present invention is a module and algorithm step of each example described in combination with the embodiments disclosed herein, and can be implemented by electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0178] Those skilled in the art will appreciate that various aspects of the RAID array power-off IO data recovery method provided by the present invention can be implemented as a system, method or program product. Therefore, various aspects of the present disclosure can be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software, which can be collectively referred to as a "circuit", "module" or "system" here.
[0179] In the non-transitory computer-readable storage medium storing the RAID array power-off IO data recovery method, it can be but not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0180] Although the present invention has been described in detail with reference to the accompanying drawings and in combination with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, a person of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions shall be within the scope of the present invention. Any person of ordinary skill in the art may easily think of changes or substitutions within the technical scope disclosed by the present invention, and these shall be within the scope of protection of the present invention.
Claims
1. A method for recovering IO data from a RAID array after power failure, characterized in that: The steps include: S1. Divide the IO data processing process of the RAID array into stages in advance and define the IO state corresponding to each stage; S2. Record the stage in the IO data processing process and save the IO status of each stage and the context information of the host IO data to non-volatile storage; S3. When the RAID array recovers from abnormal power failure, the stage of the IO data processing process before the power failure is determined according to the real-time IO status, and the IO data is restored according to the stage.
2. The RAID array power failure IO data recovery method according to claim 1, characterized in that: The specific steps of step S1 are as follows: S11. The write-back mode of the RAID array is pre-divided into four stages: receiving write IO stage, moving data stage, replying host response stage and writing disk stage; S12. The starting state of the write IO phase received in the write-back mode is defined as the idle state, the end state of the write IO received is defined as the pre-response state, the end state of the reply host response phase is defined as the pre-write state, the starting state of the write disk phase is defined as the write state, and the end state of the write disk state is defined as the idle state; S13 pre-write RAID array mode is divided into three stages: receiving write IO stage, moving data stage, and writing disk stage; S14. The starting state of the write IO phase of the write-through mode is defined as the idle state, the end state of the write IO is defined as the pre-response state, the starting state of the write disk phase is defined as the write state, and the end state of the write disk phase is defined as the idle state.
3. The RAID array power failure IO data recovery method as claimed in claim 2, characterized in that: The specific steps of step S2 are as follows: S21. Predefine an IO context structure, and after obtaining an IO request, obtain an idle IO context structure from non-volatile storage; S22. Apply for IO data storage space from non-volatile storage, write IO data into cache and each disk, and save the IO status of each stage of IO data processing and the context information of host IO data into the IO context structure according to the RAID array mode.
4. The RAID array power failure IO data recovery method as claimed in claim 3, characterized in that: The specific steps of step S21 are as follows: S211. Predefine the IO context structure including the IO start logical address, IO length, stripe number, data address, IO status and several fields of disk write information; S212. Predefine each disk write information field including disk ID, disk start logical address, disk write length, write data address offset and disk write status subfield; S213. After obtaining the IO request, obtain an idle IO context structure, fill in the IO starting logical address and IO length information in the IO context structure, and record the IO status as the pre-response stage; S214. Apply for IO data cache space from non-volatile storage, and write the applied address into the data address field of the IO context structure.
5. The RAID array power failure IO data recovery method as claimed in claim 3, characterized in that: The specific steps of step S22 are as follows: S221. Use the host to directly access the memory unit to move the data to be written to the requested IO data cache space; S222. Determine the RAID array mode; When it is in write-back mode, go to step S223; When it is write-through mode, go to step S224; S223. After the host directly accesses the memory unit and the data is moved, a successful write response is restored to the host, and the IO state is recorded as a pre-write state; S224. Calculate the check block of the IO data, divide the IO data into each disk, write the check block to the preset location of the disk, and update the disk write information in the IO context structure; S225. Before starting to write to the disk in the write phase, record the IO status as the write status, and record the status of each disk as the write status; S226. After receiving the write response from the disk, record the disk status as the write success status, and after all disks complete the write, record the IO status as the idle status, and release the IO context structure.
6. The RAID array power failure IO data recovery method as claimed in claim 3, characterized in that: The specific steps of step S3 are as follows: S31. After the RAID controller is powered on, determine whether it is an abnormal power-off restart; If yes, start IO recovery and go to step S32; If not, return to step S22; S32. Traverse all IO context structures to identify the number of IO context structures and locate an IO context structure; S33. Get the IO status of the located IO context structure; When the IO state is idle or pre-response, go to step S34; When the IO state is the write state, go to step S35; When the IO state is the pre-write state, go to step S36; S34. It is determined that the host response has not been replied and the disk writing has not started, there is no risk of stripe inconsistency, and no IO data recovery is required, and the process proceeds to step S37; S35. Determine that the IO data has been segmented and the checksum has been calculated, but there is a risk of inconsistent stripes, traverse the disk write information fields in the IO context structure, rewrite the disk that has not been successfully written, and enter step S37; S36. It is determined that the host response has been replied, but the IO data may not be cut and the check value may not be calculated. The check value is recalculated and the IO data is cut, and the disk write operation is performed, and the process proceeds to step S37; S37. Determine whether the IO context structure is located; If yes, go to step S38; If not, locate the next IO context structure and return to step S33; S38. Initialize the IO context structure and mark all IO context structures as idle.
7. The RAID array power failure IO data recovery method as claimed in claim 6, characterized in that: The specific steps of step S35 are as follows: S351. Obtain the segmented IO data and the calculated checksum value; S352. Traverse the disk write information field in the IO context structure, identify the number of disk write information fields, and locate a disk write information field; S353. The disk corresponding to the located write disk information field is used as the located disk; S354. Write the divided IO data according to the subfields of the disk ID, disk start logical address, disk write length, write data address offset and disk write status corresponding to the disk write information field.
8. A RAID array power failure IO data recovery system, characterized in that: include: The IO data processing stage division module is used to divide the IO data processing process of the RAID array into stages in advance and define the IO state corresponding to each stage; The IO status and IO data context information recording module is used to record the stage in the IO data processing process and save the IO status of each stage and the context information of the host IO data into non-volatile storage; The IO data recovery module is used to determine the stage of the IO data processing process before the power failure according to the real-time IO status after the RAID array is restored from abnormal power failure, and perform IO data recovery according to the stage.
9. An electronic device, characterized in that: including a processor and a memory; The memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the electronic device executes the method described in any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method described in any one of claims 1 to 7.
Citation Information
Cited By
Data writing method and device, electronic equipment and storage medium
CN119847816A
