Method and system for improving raid1 write performance under linux system

By employing a conditional asynchronous write strategy in a RAID1 all-flash array, the problem of IO spikes amplification was solved, write performance was improved, data integrity was guaranteed, and service quality was enhanced.

CN120780249BActive Publication Date: 2025-11-07KYLIN CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511195705.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-26
Publication Date
2025-11-07
Estimated Expiration
2045-08-26

AI Technical Summary

Technical Problem

The RAID1 write mechanism in the Linux kernel causes IO spikes to accumulate in RAID1 all-flash arrays. Existing technologies amplify these IO spikes, impacting performance and quality of service.

Method used

A conditional asynchronous write strategy is adopted, which allows the main I/O request to be notified of completion when a partial disk I/O request is completed, ensuring the integrity of at least one mirror disk and avoiding the cumulative delay of synchronous write strategies.

Benefits of technology

It alleviates IO glitches, improves the write performance of RAID1 all-flash arrays, and ensures data integrity and service quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120780249B_ABST
    Figure CN120780249B_ABST
Patent Text Reader

Abstract

The application discloses a method and system for improving RAID1 write performance under a Linux system, and the method comprises the following steps: when a main IO request sent by an upper layer enters a RAID1 disk array, mirroring the main IO request into a corresponding number of sub IO requests and delivering the sub IO requests to each disk, initially marking the completion state of the sub IO requests as an uncompleted state, and initially marking the notification state of the main IO request as an uncompleted notification state; when each disk executes the corresponding sub IO request and the execution is completed, marking the completion state of the sub IO request of the current disk as a completed state, and notifying the RAID1 disk array of the completion of the main IO request in advance. The application aims to solve the problem that the synchronous write strategy adopted by the RAID1 write mechanism of the Linux kernel causes the IO burr problems to be superimposed and amplified in the RAID1 all-flash array, and improve the write performance of the RAID1 all-flash array.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the data storage technology in the computer field, and in particular to a method and system for improving the write performance of RAID1 under Linux system. BACKGROUND

[0002] RAID1 is a data redundancy technology, which improves data reliability through data mirroring. Its core working principle is data mirroring, which ensures that there is a complete and intact data copy on each disk. Specifically, RAID 1 writes data to two or more disks of the same capacity, and the data in these disks always remains consistent. When an application or file system initiates a write operation, an IO request is generated. For the RAID1 driver, this IO request is called a master IO request. After receiving the master IO request, the RAID1 driver program mirrors multiple sub-IO requests according to the RAID1 configuration, each sub-IO request corresponding to a disk in the RAID1 array, and submits these sub-IO requests to the device queue of each disk.

[0003] The RAID1 write mechanism of the Linux kernel adopts a simple and easy-to-implement synchronous write strategy, which notifies the upper application of the completion of the main IO request only after all the sub-IO requests mirrored by the main IO request are written and returned. This method is very efficient and suitable for traditional low-speed disks. NVMe is a high-speed storage protocol designed specifically for solid-state drives (SSDs), especially those based on PCIe buses. Compared with traditional SATA interface-based hard drives, NVMe provides higher performance and lower latency because it communicates directly with the CPU through the PCIe bus, bypassing the bottleneck of traditional storage interfaces. However, as NVMe all-flash arrays are increasingly used in various vertical industry application scenarios, the drawbacks of the synchronous write strategy adopted by the Linux kernel's RAID1 write mechanism become more pronounced for NVMe all-flash arrays using high-speed NVMe disks. The synchronous write strategy can exacerbate the occasional IO glitch problem of high-speed NVMe disks, where the delay of random individual read / write IO requests is significantly higher than the average value for a period of time. These glitches manifest as sudden and significant increases in the delay of certain read / write requests, disrupting the expected delay stability and affecting performance consistency and service quality. Especially when multiple NVMe disks form a RAID1 all-flash array, the IO glitch problem is amplified by the existing RAID1 synchronous write algorithm. The phenomenon of IO glitch amplification in the existing RAID1 all-flash array assumes that the write delay of four high-speed NVMe disks in the RAID1 all-flash array is different at different times. The Linux kernel's synchronous write strategy is synchronous, so the completion delay of each main IO request is determined by the highest completion delay of all the sub-IO requests mirrored by the main IO request. In other words, this algorithm superimposes the IO request write glitches produced by the four disks at different time points, effectively amplifying the disk IO glitch phenomenon for the RAID1 array. This phenomenon of IO glitch amplification in the RAID1 all-flash array seriously affects user experience and reduces business service quality indicators. SUMMARY

[0004] The technical problem to be solved by the present application is to provide a method and system for improving RAID1 write performance in a Linux system, which solves the problem of IO glitch amplification in the RAID1 all-flash array caused by the synchronous write strategy adopted by the Linux kernel's RAID1 write mechanism.

[0005] To solve the above technical problems, the technical scheme adopted by the present application is as follows:

[0006] A method for improving RAID1 write performance under a Linux system, comprising the following steps:

[0007] S1, declaring definition of required data structures, including the number of IO requests to be synchronized of the disks, the notification state of the main IO request, and the variables required for the completion state of the mirrored sub-IO requests of the main IO request;

[0008] S2, initializing the number of IO requests to be synchronized of the disks to 0 at the beginning of each disk of the RAID1 disk array;

[0009] S3, when the main IO request sent by the upper layer enters the RAID1 disk array, the RAID1 disk array mirrors a corresponding number of sub-IO requests according to the number of disks to be written in the RAID1 disk array and issues them to each disk, and initializes the completion state of the sub-IO requests to an uncompleted state and the notification state of the main IO request to an uncompleted notification state; each disk executes the corresponding sub-IO request, and when the sub-IO request is executed, it jumps to step S4;

[0010] S4, marking the completion state of the sub-IO request of the current disk as completed;

[0011] S5, judging whether all the sub-IO requests mirrored by the main IO request have been completed, if yes, jumping to step S6; otherwise, jumping to step S8;

[0012] S6, judging whether the completion of the main IO request has been notified to the RAID1 disk array, if yes, ending and exiting; otherwise, jumping to step S7;

[0013] S7, notifying the completion of the main IO request to the RAID1 disk array, ending and exiting;

[0014] S8, judging whether the completion of the main IO request has been notified to the RAID1 disk array, if yes, jumping to step S9; otherwise, jumping to step S10;

[0015] S9, decreasing the number of IO requests to be synchronized on the current disk, ending and exiting;

[0016] S10, judging whether the number of IO requests to be synchronized on the current disk is 0, if yes, jumping to step S11; otherwise, ending and exiting;

[0017] S11, notifying the completion of the main IO request to the RAID1 disk array, and marking the notification state of the main IO request as a completed notification state;

[0018] S12, for the disk whose all sub-IO requests mirrored from the main IO request are not completed, increasing the number of its to-be-synchronized IO requests, ending and exiting.

[0019] Optionally, when declaring and defining the data structure required in step S1, the variable of the number of to-be-synchronized IO requests of the disk is an integer variable num_sync_io defined in a data structure md_rdev used for describing the physical disk of the RAID array, the variable of the notification state of the main IO request is an integer variable is_notify_orig_io defined in a data structure r1bio used for managing the IO operation of the RAID1 array, the variable of the completion state of the sub-IO request mirrored from the main IO request is an unsigned long variable disk_remaining defined in the data structure r1bio used for managing the IO operation of the RAID1 array, and the different completion states of the sub-IO requests of different disks are distinguished by different bits in the unsigned long variable disk_remaining.

[0020] Optionally, when initially marking the completion state of the sub-IO request as the uncompleted state and the notification state of the main IO request as the un-notified completion state in step S3, the step comprises: performing set_bit(1<<disk,&(r1_bio→disk_remaining)) to mark the completion state of the sub-IO request corresponding to the disk number disk in the unsigned long variable disk_remaining as 1, i.e., as the to-be-completed state, wherein r1_bio is the data structure used for managing the IO operation of the RAID1 array, “<<” is a left shift operation, “1<<disk” is used for locating the bit corresponding to the disk number disk in the unsigned long variable disk_remaining, “→” represents the attribute of an object, set_bit is a function used for unconditionally setting the specified bit as 1, and & is an address operator; performing r1_bio→is_notify_orig_io = 1 to mark the main IO request as the to-be-notified completion state; and is_notify_orig_io is the variable defined in the data structure r1bio used for managing the IO operation of the RAID1 array and used for indicating the notification state of the main IO request.

[0021] Optionally, the marking the completion status of the sub-IO request of the current disk in step S4 to the completion status comprises executing clean_bit(1<<disk,&(r1_bio→disk_remaining)) to mark the completion status of the sub-IO request corresponding to the disk number disk in the unsigned long variable disk_remaining to 0, which indicates the completion status, wherein r1_bio is a data structure used for managing the IO operation of the RAID1 array, "<<" is a left shift operation, "1<<disk" is used for locating the bit corresponding to the disk number disk in the unsigned long variable disk_remaining, "→" indicates the attribute of the object, "&" is an address operator, and clean_bit is a function used for unconditionally setting the specified bit to 0.

[0022] Optionally, the judging whether all the sub-IO requests mirrored by the main IO request have been completed in step S5 means judging whether the unsigned long variable disk_remaining is 0, if yes, it indicates that all the sub-IO requests mirrored by the main IO request have been completed, otherwise, it indicates that all the sub-IO requests mirrored by the main IO request have not been completed; the notifying the RAID1 disk array of the completion of the main IO request in step S7 means calling the kernel function call_bio_endio(r1_bio) to notify the RAID1 disk array of the completion of the main IO request, wherein r1_bio is a data structure used for managing the IO operation of the RAID1 array, and call_bio_endio is a main IO request completion notification function of the RAID1 disk array; the judging whether the RAID1 disk array has been notified of the completion of the main IO request in step S8 comprises judging whether r1_bio→is_notify_orig_io is 0, wherein r1_bio is a data structure used for managing the IO operation of the RAID1 array, and is_notify_orig_io is a variable defined in the data structure r1_bio used for managing the IO operation of the RAID1 array and used for indicating the notification status of the main IO request.

[0023] Optionally, the decreasing the number of the IO requests to be synchronized on the current disk in step S9 comprises executing the command:

[0024] conf→mirrors[disk].rdev→num_sync_io--

[0025] decrementing the number of IOs to be synchronized on the disk, wherein conf is a RAID1 configuration structure body struct r1conf obtained through r1_bio→mddev→private, "→" represents the attribute of the object, r1_bio is a data structure for managing the IO operation of the RAID1 array, mddev and private are the device description and private data under r1_bio respectively, disk is the number of the current disk, conf→mirrors[disk].rdev→num_sync_io represents the current number of IO requests to be synchronized of the underlying disk numbered as disk, and "--" is a decrement operation.

[0026] Optionally, the step of incrementing the number of IOs to be synchronized of the disk for which all the mirrored sub-IO requests in the step S12 have not been completed comprises: traversing the disks in the RAID1 disk array, and for each disk i obtained through the traversal, judging whether the sub-IO request of the disk numbered as i in the unsigned long variable disk_remaining is completed by executing test_bit(1<<i,&(r1_bio→disk_remaining)), wherein test_bit is a function for judging whether the bit is 0, "<<" is a left shift operation, "1<<i" is used for locating the bit corresponding to the disk numbered as i in the unsigned long variable disk_remaining, r1_bio is a data structure for managing the IO operation of the RAID1 array, "&" is an address operator, and "→" represents the attribute of the object.

[0027] In addition, the embodiment further provides a system for improving the RAID1 write performance under a Linux system, which comprises a microprocessor and a memory connected with each other, and the microprocessor is programmed or configured to execute the method for improving the RAID1 write performance under the Linux system.

[0028] In addition, the embodiment further provides a computer readable storage medium, which stores a computer program or instructions, and the computer program or instructions are programmed or configured to execute the method for improving the RAID1 write performance under the Linux system by using a processor.

[0029] In addition, the embodiment further provides a computer program product, which comprises a computer program or instructions, and the computer program or instructions are programmed or configured to execute the method for improving the RAID1 write performance under the Linux system by using a processor.

[0030] Compared with existing technologies, the present invention can mainly achieve the following beneficial effects: In response to the problem of disk I / O spike amplification in the current RAID1 synchronous write algorithm on high-performance NVMe disks, the present invention adopts a conditional asynchronous write strategy. Under the premise of ensuring that the data integrity of the RAID1 array is not compromised in abnormal situations, the main I / O request can be notified in advance that it is complete without waiting for all disk sub-I / O requests of the RAID1 array to be completed. This conditional asynchronous advance notification mechanism not only solves the problem of disk I / O spike amplification in the synchronous write strategy used by the Linux kernel's RAID1 write mechanism, but also alleviates the I / O spike phenomenon in RAID1 to a certain extent. Attached Figure Description

[0031] Figure 1 This is a basic flowchart illustrating the synchronous write strategy of RAID1 in existing technologies.

[0032] Figure 2 This refers to the phenomenon where IO spikes in existing RAID1 all-flash arrays are amplified by their superposition, where a to d represent the write latency of four high-speed NVMe disks in the RAID1 all-flash array, and e represents the overall write latency of the RAID1 all-flash array.

[0033] Figure 3 This is a schematic diagram of the basic process of the method in an embodiment of the present invention. Detailed Implementation

[0034] To address the issues of existing RAID1 all-flash arrays... Figure 1 The synchronous write strategy shown generates Figure 2 The phenomenon of overlapping and amplified IO spikes is illustrated in this invention. This invention primarily addresses the redesign and implementation of the current Linux kernel's RAID1 write control algorithm. This embodiment optimizes the current RAID1 write control algorithm from synchronous write to a conditional asynchronous write strategy. The core of the method is that it eliminates the need to wait for all disk sub-IO requests in the RAID1 array to complete before notifying the main IO request of completion. Instead, whenever a disk sub-IO request completes and returns, the system determines whether to immediately notify the main IO request of completion. To ensure that notifying the main IO request of completion when disk sub-IO requests are not all complete does not affect the integrity of the RAID1 array data under abnormal circumstances, the main criterion for judgment is that at least one disk in the current RAID1 array has a complete and reliable image. To enable those skilled in the art to better understand the technical solution of this invention, the following will provide a more detailed description of the technical solution of this invention in conjunction with the accompanying drawings of the embodiments.

[0035] like Figure 3As shown, the method for improving the RAID1 write performance under the Linux system in the embodiment includes the following steps:

[0036] S1, declare and define the data structure required, including the number of IO requests to be synchronized of the disk, the notification state of the main IO request, and the variables required for the completion state of the mirrored sub-IO request of the main IO request;

[0037] S2, at the initial time of each disk in the RAID1 disk array, initialize the number of IO requests to be synchronized of the disk to 0;

[0038] S3, when the main IO request (dirty page write request) sent by the upper layer enters the RAID1 disk array, the RAID1 disk array mirrors the main IO request according to the number of disks to be written in the RAID1 disk array to correspond to the number of sub-IO requests and issues them to each disk, and initializes the completion state of the sub-IO request to an uncompleted state and the notification state of the main IO request to an uncompleted notification state; each disk executes the corresponding sub-IO request, and when the sub-IO request is executed, it jumps to step S4;

[0039] S4, mark the completion state of the sub-IO request of the current disk as completed;

[0040] S5, determine whether all the sub-IO requests mirrored by the main IO request have been completed, if yes, jump to step S6; otherwise, jump to step S8;

[0041] S6, determine whether the completion of the main IO request has been notified to the RAID1 disk array, if yes, end and exit; otherwise, jump to step S7;

[0042] S7, notify the completion of the main IO request to the RAID1 disk array, end and exit;

[0043] S8, determine whether the completion of the main IO request has been notified to the RAID1 disk array, if yes, jump to step S9; otherwise, jump to step S10;

[0044] S9, decrease the number of IO requests to be synchronized on the current disk, end and exit;

[0045] S10, determine whether the number of IO requests to be synchronized on the current disk is 0, if yes, jump to step S11; otherwise, end and exit;

[0046] S11, notify the completion of the main IO request to the RAID1 disk array, and mark the notification state of the main IO request as a completed notification state;

[0047] S12, for the disk whose all sub-IO requests mirrored by the main IO request are not completed, increase the number of its to-be-synchronized IO requests, end and quit.

[0048] In the step S1 of the embodiment, when declaring and defining the data structure required, the variable of the number of to-be-synchronized IO requests of the disk is an integer variable num_sync_io defined in the data structure md_rdev used to describe the physical disk of the RAID array, the variable of the notification state of the main IO request is an integer variable is_notify_orig_io defined in the data structure r1bio used to manage the IO operation of the RAID1 array, and the variable of the completion state of the sub-IO request mirrored by the main IO request is an unsigned long variable disk_remaining defined in the data structure r1bio used to manage the IO operation of the RAID1 array, and the different bits in the long variable disk_remaining are used to distinguish the completion states of the sub-IO requests of different disks.

[0049] The number of to-be-synchronized IO requests of the disk in the step S2 refers to the number of the sub-IO requests of the disk which are not completed, but the corresponding main IO request has been asynchronously notified of the completion when the other sub-IO requests are completed. In the step S2 of the embodiment, the initialization of each disk of the RAID1 disk array refers to that the RAID1 disk array calls md_rdev_init(struct md_rdev *rdev) to initialize the disk, at this time, the number of to-be-synchronized IO requests of the disk is initialized to 0, that is, the value of the integer variable num_sync_io in the data structure md_rdev is modified to 0, which can be expressed as:

[0050] rdev->num_sync_io = 0;

[0051] In the step S3 of the embodiment, the initial marking of the completion state of the sub-IO request as the uncompleted state and the initial marking of the notification state of the main IO request as the un-notified completion state include:

[0052] set_bit(1<<disk,&(r1_bio->disk_remaining))

[0053] set_bit(1 << disk, & (r1_bio→disk_remaining))

[0054] r1_bio→is_notify_orig_io = 1

[0055] Mark the main IO request as pending notification. is_notify_orig_io is a variable defined in the data structure r1_bio for managing RAID1 array IO operations, which is used to indicate the notification state of the main IO request. Through the above operation, when the RAID1 disk array receives the upper layer main IO request to call the raid1_write_request() function to mirror each disk sub-IO request, the sub-IO request is marked as uncompleted, and the main IO request is marked as uncompleted notification.

[0056] When the RAID1 disk array each disk sub-IO request is completed and the raid1_end_write_request(struct bio *bio) function is called, the sub-IO request of the corresponding disk is marked as completed. Specifically, the step S4 in the embodiment marks the completion state of the sub-IO request of the current disk as completed, which includes executing:

[0057] clean_bit(1 << disk, & (r1_bio→disk_remaining))

[0058] Mark the completion state of the sub-IO request corresponding to the disk number disk in the unsigned long variable disk_remaining as 0, indicating that it is completed. Wherein r1_bio is a data structure for managing RAID1 array IO operations, << is a left shift operation, 1 << disk is used to locate the bit corresponding to the disk number disk in the unsigned long variable disk_remaining, → indicates the attribute of the object, & is the address operator, and clean_bit is a function for unconditionally setting the specified bit to 0. Wherein, the disk number disk can be obtained by executing the kernel function find_bio_disk(r1_bio, bio), which is used to indicate the number of the disk to which the current bio belongs in the RAID1 disk array.

[0059] The step S5, the step S6 and the step S7 are similar to the synchronization algorithm implemented in the current Linux kernel, that is, after all the sub-IO requests mirrored by the main IO request are completed, the main IO request is informed of the completion. The step S5 in the embodiment is to determine whether all the sub-IO requests mirrored by the main IO request have been completed, which means to determine whether the unsigned long variable disk_remaining is 0. If yes, it means that all the sub-IO requests mirrored by the main IO request have been completed, otherwise, it means that all the sub-IO requests mirrored by the main IO request have not been completed.

[0060] The step S6 in the embodiment is to determine the completion notification state of the main IO request, which means to determine whether r1_bio→is_notify_orig_io is 0. If yes, it means that the main IO request has been completed.

[0061] The step S7 in the embodiment is to inform the RAID1 disk array of the completion of the main IO request, which means to call the kernel function call_bio_endio(r1_bio) to inform the RAID1 disk array of the completion of the main IO request, wherein r1_bio is a data structure used to manage the IO operation of the RAID1 array, and call_bio_endio is the main IO request completion notification function of the RAID1 disk array.

[0062] The step S8 in the embodiment is to determine whether the main IO request has been informed of the completion, which means to determine whether r1_bio→is_notify_orig_io is 0, wherein r1_bio is a data structure used to manage the IO operation of the RAID1 array, and is_notify_orig_io is a variable defined in the data structure r1_bio used to manage the IO operation of the RAID1 array, which is used to indicate the notification state of the main IO request.

[0063] When the step S9 is executed, it means that the main IO request corresponding to the completed sub-IO request on the current disk has been informed of the completion in an asynchronous manner, and at this time, the number of the IO requests to be synchronized on the current disk is only decreased to end the process. The step S9 in the embodiment is to decrease the number of the IO requests to be synchronized on the current disk, which includes executing the command:

[0064] conf→mirrors[disk].rdev→num_sync_io--

[0065] decrementing the number of IOs to be synchronized on the disk, wherein conf is a RAID1 configuration structure body struct r1conf obtained by r1_bio→mddev→private, "→" represents the attribute of the object, r1_bio is a data structure for managing the IO operation of the RAID1 array, mddev and private are the device description and private data under r1_bio respectively, disk is the number of the current disk, conf→mirrors[disk].rdev→num_sync_io represents the current number of IO requests to be synchronized of the underlying disk numbered as disk, and "--" is a decrement operation.

[0066] In step S10, the corresponding main IO request is asynchronously notified of completion only when the number of IO requests to be synchronized of the current disk is 0. This measure aims to ensure the integrity of the RAID1 array data in abnormal conditions. It can be understood in this way that when the number of IO requests to be synchronized of the current disk is 0, it indicates that the mirror data of the current disk is complete and reliable, and in this case, the main IO request is notified of completion, so that even if abnormal conditions such as system downtime, power failure, etc. are encountered, the mirror data of the current disk can be used for RAID1 array data recovery. In step S10, it is judged whether the number of IO requests to be synchronized of the current disk is 0, that is, whether r1_bio→num_sync_io is 0, if not, the process is ended, otherwise, step S11 is run to notify the main IO request of completion, and the main IO request is marked as having been notified of completion. In step S11, the kernel function call_bio_endio(r1_bio) is called to notify the main IO of completion; r1_bio→is_notify_orig_io = 0 is executed to indicate that the main IO request has been notified of completion.

[0067] In step S12, the number of IO requests to be synchronized of each disk in the RAID1 array is recorded, which cooperates with step S10 to ensure that the integrity of the RAID1 array data is maintained in abnormal conditions. In step S12 of the embodiment, for the disks on which all the sub-IO requests mirrored by the main IO request have not been completed, the number of IO requests to be synchronized is incremented by including: traversing the disks in the RAID1 disk array, for each disk i obtained by traversing, executing:

[0068] test_bit(1<<i,&(r1_bio→disk_remaining))

[0069] To determine whether the sub-IO request for disk number i in the unsigned long integer variable disk_remaining is completed, where test_bit is a function for determining whether a bit is 0, "<<" is a left shift operation, and "1<<i" is used to locate the bit corresponding to disk number i in the unsigned long integer variable disk_remaining. r1_bio is a data structure for managing RAID1 array IO operations, & is the address-of operator, and "→" represents the attributes of an object.

[0070] In summary, the method of this embodiment optimizes the write control algorithm strategy of the current RAID1 from synchronous write to conditional asynchronous write strategy, without waiting for all disk sub-IO requests of the RAID1 array to be completed before notifying the main IO request to be completed. Instead, whenever a disk sub-IO request write is completed and returns, the system judges and decides whether to immediately notify the main IO request to be completed. To ensure that when not all disk sub-IO requests are completed, the operation of notifying its main IO request to be completed will not affect the integrity of the RAID1 array data in case of an exception, the main basis for judgment is that at least one disk mirror in the current RAID1 array is complete and reliable. This embodiment adopts a conditional asynchronous write strategy. Without damaging the integrity of the RAID1 array data in case of an exception, it can notify the main IO request to be completed in advance without waiting for all disk sub-IO requests of the RAID1 array to be completed. This conditional asynchronous early notification mechanism not only solves the problem of the superposition and amplification of disk IO glitches existing in the synchronous write strategy adopted by the RAID1 write mechanism of the Linux kernel, but also alleviates the IO glitch phenomenon existing in RAID1 to a certain extent.

[0071] In addition, this embodiment also provides a system for improving the write performance of RAID1 under the Linux system, including a microprocessor and a memory connected to each other. The microprocessor is programmed or configured to execute the method for improving the write performance of RAID1 under the Linux system. This embodiment also provides a computer-readable storage medium, in which a computer program or instruction is stored. The computer program or instruction is programmed or configured to execute the method for improving the write performance of RAID1 under the Linux system through a processor. This embodiment also provides a computer program product, including a computer program or instruction, which is programmed or configured to execute the method for improving the write performance of RAID under the Linux system through a processor.

[0072] Those skilled in the art will appreciate that the technology provided herein is not limited to any particular form of implementation. The technology provided herein can be implemented in hardware, software, or a combination thereof. Those skilled in the art will appreciate that the technology provided herein can be implemented in a number of different embodiments, including method embodiments, system embodiments, and computer program product embodiments. The technology provided herein can be implemented in any combination of hardware, software, or a combination thereof. The technology provided herein can be implemented in a number of different ways, including as a computer program product stored on a computer readable storage medium, as a system on chips (SOCs), as an application specific integrated circuit (ASIC), or as a combination of the above. The technology provided herein can be implemented using any suitable hardware, software, firmware, or combination thereof. The technology provided herein can be implemented in one or more computer programs or one or more articles of manufacture that contain computer readable program code. The technology provided herein can be implemented using any suitable computer readable storage medium, including storage devices that are external or internal to a computer. Suitable computer readable storage mediums can include, but are not limited to, volatile memory, non-volatile memory, removable storage, and non-removable storage. Suitable computer readable storage mediums can include, but are not limited to, RAM, ROM, EEPROM, flash memory, or any other memory technology. Suitable computer readable storage mediums can include, but are not limited to, magnetic cassettes, magnetic tapes, magnetic disks, memory cards or sticks, optical storage media, or any other storage medium suitable for storing computer readable program code. The computer readable program code can be executed using any suitable computer processor, including a general purpose computer, a special purpose computer, an embedded computer, or any other computer. The computer readable program code can be executed using any suitable operating system, including a UNIX operating system, a LINUX operating system, a WINDOWS operating system, a MAC OS operating system, or any other operating system. The computer readable program code can be executed using any suitable computer programming language, including a high level programming language, a low level programming language, an object oriented programming language, a visual programming language, or any other computer programming language. Figure 1 one or more functions specified in the flow or flows and / or blocks Figure 1 one or more functions specified in the flow or flows and / or blocks Figure 1 one or more functions specified in the flow or flows and / or blocks Figure 1 one or more functions specified in the flow or flows and / or blocks Figure 1 one or more functions specified in the flow or flows and / or blocks Figure 1 one or more functions specified in the flow or flows and / or blocks

[0073] The above description is only preferred embodiments of the present application. The protection scope of the present application is not limited to the above-mentioned embodiments. Any technical scheme falling within the concept of the present application is within the protection scope of the present application. It should be noted that some improvements and refinements made by those skilled in the art without departing from the principle of the present application are also considered to be within the protection scope of the present application.

Claims

1. A method for improving RAID 1 write performance under a Linux system, characterized in that, The method comprises the following steps: S1, declaring and defining data structures required, including the number of IO requests to be synchronized of the disks, the notification state of the main IO request, and the variables required for the completion state of the sub IO requests mirrored from the main IO request; S2, initializing the number of IO requests to be synchronized of the disks to 0 at the beginning of the disks in the RAID1 disk array; S3, when the main IO request sent by the upper layer enters the RAID1 disk array, the RAID1 disk array mirrors a corresponding number of sub IO requests from the main IO request according to the number of disks to be written in the RAID1 disk array, and delivers the sub IO requests to each disk, and the completion state of the sub IO requests is initially marked as an uncompleted state, and the notification state of the main IO request is initially marked as an uncompleted state; each disk executes the corresponding sub IO request, and when the sub IO request is executed, step S4 is jumped to; S4, marking the completion state of the sub IO request of the current disk as a completed state; S5, judging whether all the sub IO requests mirrored from the main IO request have been completed, if yes, step S6 is jumped to; otherwise, step S8 is jumped to; S6, judging whether the completion of the main IO request has been notified to the RAID1 disk array, if yes, ending and exiting; otherwise, step S7 is jumped to; S7, notifying the completion of the main IO request to the RAID1 disk array, ending and exiting; S8, judging whether the completion of the main IO request has been notified to the RAID1 disk array, if yes, step S9 is jumped to; otherwise, step S10 is jumped to; S9, decreasing the number of IO requests to be synchronized of the current disk, ending and exiting; S10, judging whether the number of IO requests to be synchronized of the current disk is 0, if yes, step S11 is jumped to; otherwise, ending and exiting; S11, notifying the completion of the main IO request to the RAID1 disk array, and marking the notification state of the main IO request as a notified completed state; S12, for the disks whose sub IO requests mirrored from the main IO request have not been completed, increasing the number of IO requests to be synchronized of the disks, ending and exiting.

2. The method for improving the RAID 1 write performance under the Linux system according to claim 1, characterized in that, In step S1 of declaring and defining the required data structures, the variable of the number of IO requests to be synchronized of the disks is an integer variable num_sync_io defined in a data structure md_rdev used for describing the physical disks of the RAID array, the variable of the notification state of the main IO request is an integer variable is_notify_orig_io defined in a data structure r1bio used for managing the IO operations of the RAID1 array, and the variable of the completion state of the sub IO requests mirrored from the main IO request is an unsigned long variable disk_remaining defined in the data structure r1bio used for managing the IO operations of the RAID1 array, and the long variable disk_remaining distinguishes the completion states of the sub IO requests of different disks by different bits.

3. The method for improving the RAID 1 write performance under the Linux system according to claim 2, characterized in that, When the completion status of the sub-IO request is initially marked as the uncompleted status and the notification status of the main IO request is initially marked as the unnotified completion status in step S3, the step includes: performing set_bit(1 << disk, &(r1_bio→disk_remaining)) to set the completion status of the sub-IO request corresponding to the disk number disk in the unsigned long variable disk_remaining to 1 to mark the sub-IO request as the to-be-completed status, wherein r1_bio is a data structure for managing the IO operation of the RAID1 array, "<<" is a left shift operation, "1 << disk" is used to locate the bit corresponding to the disk number disk in the unsigned long variable disk_remaining, "→" represents the attribute of an object, set_bit is a function for unconditionally setting the specified bit to 1, "&" is an address-of operator; performing r1_bio→is_notify_orig_io = 1 to mark the main IO request as the to-be-notified completion status; is_notify_orig_io is a variable defined in the data structure r1_bio for managing the IO operation of the RAID1 array and used to represent the notification status of the main IO request.

4. The method for improving the RAID 1 write performance under the Linux system according to claim 2, characterized in that, In step S4, marking the completion status of the sub-IO request of the current disk as the completed status includes performing clean_bit(1 << disk, &(r1_bio→disk_remaining)) to set the completion status of the sub-IO request corresponding to the disk number disk in the unsigned long variable disk_remaining to 0 to mark the sub-IO request as the completed status, wherein r1_bio is a data structure for managing the IO operation of the RAID1 array, "<<" is a left shift operation, "1 << disk" is used to locate the bit corresponding to the disk number disk in the unsigned long variable disk_remaining, "→" represents the attribute of an object, "&" is an address-of operator, and clean_bit is a function for unconditionally setting the specified bit to 0.

5. The method for improving the RAID 1 write performance under the Linux system according to claim 2, characterized in that, The step S5 of judging whether all the sub IO requests mirrored by the main IO request have been completed refers to judging whether the unsigned long variable disk_remaining is 0. If yes, it indicates that all the sub IO requests mirrored by the main IO request have been completed. Otherwise, it indicates that all the sub IO requests mirrored by the main IO request have not been completed. The step S7 of notifying the RAID1 disk array of the completion of the main IO request refers to calling the kernel function call_bio_endio(r1_bio) to notify the RAID1 disk array of the completion of the main IO request, wherein r1_bio is a data structure for managing the RAID1 array IO operation, and call_bio_endio is a main IO request completion notification function of the RAID1 disk array. The step S8 of judging whether the main IO request has been notified to the RAID1 disk array refers to judging whether r1_bio->is_notify_orig_io is 0, wherein r1_bio is a data structure for managing the RAID1 array IO operation, and is_notify_orig_io is a variable defined in the data structure r1_bio for managing the RAID1 array IO operation and used for indicating the notification state of the main IO request.

6. The method for improving the RAID 1 write performance under the Linux system according to claim 2, characterized in that, The step S9 of decreasing the number of IO requests to be synchronized on the current disk refers to executing the command: conf->mirrors[disk].rdev->num_sync_io--. The number of IO requests to be synchronized on the disk is decreased, wherein conf is the RAID1 configuration structure body struct r1conf obtained through r1_bio->mddev->private, "→" indicates the attribute of an object, r1_bio is a data structure for managing the RAID1 array IO operation, mddev and private are the device description and private data under r1_bio respectively, disk is the number of the current disk, conf->mirrors[disk].rdev->num_sync_io indicates the number of current IO requests to be synchronized of the underlying disk numbered as disk, and "--" is a decrement operation. ​ ​ 7. The method for improving the RAID 1 write performance under the Linux system according to claim 2, characterized in that, The step of increasing the number of IO requests to be synchronized for the disks whose all sub-IO requests mirrored in the step S12 for the main IO request are not completed comprises: traversing the disks in the RAID1 disk array, for each disk i obtained by the traversal, judging whether the sub-IO request of the disk numbered i in the unsigned long variable disk_remaining is completed by executing test_bit(1<< i, &(r1_bio→disk_remaining)), wherein test_bit is a function of judging whether a bit is 0, "<<" is a left shift operation, "1<< i" is used for locating the bit corresponding to the disk number i in the unsigned long variable disk_remaining, r1_bio is a data structure for managing the IO operation of the RAID1 array, "&" is an address operator, and "→" represents the attribute of an object.

8. A system for improving RAID 1 write performance under a Linux system, comprising a microprocessor and a memory connected to each other, characterized in that, The microprocessor is programmed or configured to execute the method for improving the RAID1 write performance under the Linux system according to any one of claims 1-7.

9. A computer-readable storage medium having stored therein a computer program or instructions, characterized in that, The computer program or instruction is programmed or configured to execute the method for improving the RAID1 write performance under the Linux system according to any one of claims 1-7 by the processor.

10. A computer program product comprising computer programs or instructions, characterized in that, The computer program or instruction is programmed or configured to execute the method for improving the RAID1 write performance under the Linux system according to any one of claims 1-7 by the processor.

Citation Information

Patent Citations

  • Method for optimizing writing performance of redundant array of independent disk (RAID5)-grade disk array

    CN102184079A

  • RAID5 (redundant array of independent disk 5) write IO optimization processing method

    CN103049222A