Method and system for improving RAID1 writing performance under Linux system
By adopting a conditional asynchronous write strategy in the RAID1 all-flash array, the problem of IO glitches caused by the synchronous write strategy is solved, which improves write performance, maintains data integrity, and improves service quality.
Patent Information
- Application Number
- CN202511195705.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-26
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2045-08-26
AI Technical Summary
The Linux kernel's RAID1 write mechanism causes I/O glitches to accumulate and amplify in RAID1 all-flash arrays, impacting performance and service quality.
A conditional asynchronous write strategy is adopted to allow the completion of the main IO request to be notified in advance after the completion of some disk sub-IO requests, ensuring that the array data integrity is not affected in abnormal situations.
It alleviates the problem of IO glitch superposition and amplification, improves the write performance of RAID1 all-flash array, and maintains data integrity and service quality.
Smart Images

Figure CN120780249A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to data storage technology in the computer field, and in particular to a method and system for improving RAID1 write performance in a Linux system. Background Art
[0002] RAID 1 is a data redundancy technology that improves data reliability through data mirroring. Its core working principle is data mirroring, which ensures that each disk has a complete and intact copy of the data. Specifically, RAID 1 writes data to two or more disks of equal capacity, ensuring that the data on these disks remains consistent. When an application or file system initiates a write operation, an IO request is generated. For the RAID 1 driver, this IO request is called a primary IO request. After receiving the primary IO request, the RAID 1 driver generates multiple sub-IO requests based on the RAID 1 configuration. Each sub-IO request corresponds to a disk in the RAID 1 array, and the driver submits these sub-IO requests to the device queues of each disk.
[0003] The Linux kernel's RAID1 write mechanism uses a simple and easy-to-implement synchronous write strategy. It notifies upper-layer applications of the completion of a primary I / O request until all mirrored child I / O requests have completed and returned. This approach is highly efficient and suitable for traditional, slow disks. NVMe is a high-speed storage protocol designed specifically for solid-state drives (SSDs), particularly those based on the PCIe bus. Compared to traditional SATA-based hard drives, NVMe offers higher performance and lower latency because it communicates directly with the CPU over the PCIe bus, bypassing the bottlenecks of traditional storage interfaces. However, with the increasing adoption of NVMe all-flash arrays in various vertical industry scenarios, the synchronous write strategy used by the Linux kernel's RAID1 write mechanism has become more pronounced for NVMe all-flash arrays using high-speed NVMe drives. This synchronous write strategy can exacerbate occasional I / O glitches on high-speed NVMe drives, where the latency of individual read and write I / O requests is significantly higher than the average over a period of time. These glitches manifest as a sudden and significant increase in latency for certain read and write requests, disrupting the system's expected latency stability and impacting performance consistency and service quality. Especially when multiple NVMe drives form a RAID1 all-flash array, I / O glitches are compounded and amplified under the existing RAID1 synchronous write algorithm. This phenomenon of I / O glitches compounding and amplifying in existing RAID1 all-flash arrays is exemplified by the following: Consider the write latency of four high-speed NVMe drives in a RAID1 all-flash array. As the write process progresses, each of the four drives generates I / O glitches at different times. Because the Linux kernel uses a synchronous write strategy, the completion latency of each primary I / O request is determined by the highest completion latency of all the sub-I / O requests generated by its mirrors. In other words, this algorithm compounded the I / O glitches generated by the four drives at different times, effectively amplifying the disk I / O glitches for the RAID1 array. This compounding and amplifying of I / O glitches in RAID1 all-flash arrays severely impacts user experience and reduces service quality. Summary of the Invention
[0004] Technical problem to be solved by the present invention: In response to the above-mentioned problems of the prior art, a method and system for improving the write performance of RAID1 in a Linux system are provided. The present invention aims to solve the problem that the synchronous write strategy adopted by the RAID1 write mechanism of the Linux kernel causes the IO glitch problem in the RAID1 all-flash array to be superimposed and amplified, and to improve the write performance of the RAID1 all-flash array.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: A method for improving RAID 1 write performance in a Linux system includes the following steps: S1, declares the required data structures, including the number of disk IO requests to be synchronized, the notification status of the main IO request, and the variables required for the completion status of the sub-IO requests mirrored by the main IO request; S2, when each disk in the RAID1 disk array is initialized, the number of pending IO requests for the disk is initialized to 0; S3: When the main IO request sent by the upper layer enters the RAID1 disk array, the RAID1 disk array mirrors the main IO request into a corresponding number of sub-IO requests based on the number of disks to be written in the RAID1 disk array, and sends them to each disk. The completion status of the sub-IO requests is initially marked as incomplete, and the notification status of the main IO request is initially marked as not notified. Each disk executes the corresponding sub-IO request, and when the sub-IO request is completed, the process jumps to step S4. S4, marking the completion status of the sub-IO request of the current disk as completed; S5, determine whether all sub-IO requests mirrored by the main IO request have been completed. If they have been completed, jump to step S6; otherwise, jump to step S8; S6, determining whether the RAID1 disk array has been notified of the completion of the primary IO request. If the RAID1 disk array has been notified of the completion of the primary IO request, then the process ends and exits; otherwise, the process jumps to step S7; S7, notifies the RAID1 disk array that the main IO request is completed, ends and exits; S8, determining whether the RAID 1 disk array has been notified of the completion of the primary IO request. If so, jump to step S9; otherwise, jump to step S10; S9: Decrement the number of IO requests to be synchronized on the current disk, end, and exit; S10, determine whether the number of IO requests to be synchronized on the current disk is 0, if the number of IO requests to be synchronized on the current disk is 0, jump to step S11; otherwise, end and exit; S11, notifying the RAID 1 disk array that the main IO request is completed, and marking the notification status of the main IO request as a notification completion status; S12: For all disks whose sub-IO requests mirrored by the main IO request have not yet been completed, the number of IO requests to be synchronized is increased, and the process ends and exits.
[0006] Optionally, when declaring the required data structure in step S1, the variable for the number of disk IO requests to be synchronized is the integer variable num_sync_io defined in the data structure md_rdev used to describe the physical disk of the RAID array, the variable for the notification status of the main IO request is the integer variable is_notify_orig_io defined in the data structure r1bio used to manage RAID1 array IO operations, and the variable for the completion status of the sub-IO request mirrored by the main IO request is the unsigned long integer variable disk_remaining defined in the data structure r1bio used to manage RAID1 array IO operations, and different bits in the long integer variable disk_remaining are used to distinguish the completion status of different disk sub-IO requests.
[0007] Optionally, when the completion status of the sub-IO request is initially marked as an uncompleted state and the notification status of the main IO request is initially marked as an unnotified completion state in step S3, the process includes: executing set_bit(1< <disk,&(r1_bio→disk_remaining))将无符号长整型变量disk_remaining中磁盘编号disk对应的子IO请求的完成状态置1标记为待完成状态,其中r1_bio为用于管理RAID1阵列IO操作的数据结构,“<<”为左移位操作,“1<<disk”用于在无符号长整型变量disk_remaining中定位磁盘编号disk对应的位,“→”表示对象的属性,set_bit为用于将指定位无条件置为1的函数,&为取地址运算符;执行r1_bio→is_notify_orig_io = 1将主IO请求标记为待通知完成状态;is_notify_orig_io为定义在用于管理RAID1阵列IO操作的数据结构r1bio中的用于表示主IO请求的通知状态的变量。
[0008] Optionally, in step S4, marking the completion status of the sub-IO request of the current disk as the completion status includes executing clean_bit(1< <disk,&(r1_bio→disk_remaining))将无符号长整型变量disk_remaining中磁盘编号disk对应的子IO请求的完成状态置0标记为已完成状态,其中r1_bio为用于管理RAID1阵列IO操作的数据结构,“<<”为左移位操作,“1<<disk”用于在无符号长整型变量disk_remaining中定位磁盘编号disk对应的位,“→”表示对象的属性,&为取地址运算符,clean_bit为用于将指定位无条件置为0的函数。
[0009] Optionally, in step S5, determining whether all sub-IO requests mirrored by the main IO request have been completed refers to determining whether the unsigned long integer variable disk_remaining is 0. If it is 0, it indicates that all sub-IO requests mirrored by the main IO request have been completed. Otherwise, it indicates that all sub-IO requests mirrored by the main IO request have not yet been completed. In step S7, 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 RAID1 array IO operations, and call_bio_endio is a main IO request completion notification function for the RAID1 disk array. In step S8, determining whether the completion of the main IO request has been notified to the RAID1 disk array includes determining whether r1_bio→is_notify_orig_io is 0, wherein r1_bio is a data structure for managing RAID1 array IO operations, and is_notify_orig_io is a variable defined in the data structure r1bio for managing RAID1 array IO operations for indicating the notification status of the main IO request.
[0010] Optionally, when the number of IO requests to be synchronized on the current disk is decremented downward in step S9, the command is executed: conf→mirrors[disk].rdev→num_sync_io-- Decrement the number of pending IOs on the disk. conf is the RAID1 configuration structure struct r1conf obtained through r1_bio→mddev→private. "→" indicates the object's attributes. r1_bio is the data structure used to manage RAID1 array IO operations. 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 current number of pending IO requests for the underlying disk numbered disk. "--" indicates a decrement operation.
[0011] Optionally, in step S12, for the disks whose sub-IO requests mirrored by the main IO request have not yet been completed, increasing the number of IO requests to be synchronized upwards includes: traversing the disks in the RAID1 disk array, for each disk i obtained by the traversal, executing test_bit(1< <i,&(r1_bio→disk_remaining))来判断无符号长整型变量disk_remaining中磁盘编号为i的子IO请求是否完成,其中test_bit为判断位是否为0的函数,“<<”为左移位操作,“1<<i”用于在无符号长整型变量disk_remaining中定位磁盘编号i对应的位,r1_bio为用于管理RAID1阵列IO操作的数据结构,&为取地址运算符,“→”表示对象的属性。
[0012] In addition, this embodiment also provides a system for improving RAID1 write performance in a Linux system, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the method for improving RAID1 write performance in a Linux system.
[0013] In addition, this embodiment also provides a computer-readable storage medium, which stores a computer program or instruction. The computer program or instruction is programmed or configured to execute the method for improving RAID1 write performance in the Linux system through a processor.
[0014] In addition, this embodiment also provides a computer program product, including a computer program or instructions, which are programmed or configured to execute the method for improving RAID 1 write performance in a Linux system through a processor.
[0015] Compared with the existing technology, the present invention can mainly achieve the following beneficial effects: to address the problem of disk IO glitch superposition and amplification existing 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 will not be damaged under abnormal circumstances, the main IO request completion can be notified in advance without waiting for all disk sub-IO requests in the RAID1 array to be completed. This conditional asynchronous advance notification mechanism not only solves the problem of disk IO glitch superposition and amplification 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. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 The figure is a basic flow chart of the synchronous write strategy of RAID 1 in the prior art.
[0017] Figure 2 This is a phenomenon in which I / O glitches in existing RAID1 all-flash arrays are amplified by each other. a to d are the write delays of the four high-speed NVMe disks in the RAID1 all-flash array, and e is the overall write delay of the RAID1 all-flash array.
[0018] Figure 3 Schematic diagram of the basic process of the method of the embodiment of the present invention. DETAILED DESCRIPTION
[0019] In order to solve the existing RAID1 all-flash array Figure 1 The synchronous write strategy shown in the figure produces Figure 2 The IO glitch problem shown is a phenomenon of mutual superposition and amplification. The present invention mainly redesigns and implements the RAID1 write control algorithm of the current Linux kernel. The method of this embodiment optimizes the current RAID1 write control algorithm strategy from synchronous write to a conditional asynchronous write strategy. The core of the method is that there is no need to wait for all disk sub-IO requests of the RAID1 array to be completed before notifying the main IO request of completion. On the contrary, every time a disk sub-IO request is completed and returned, the system judges and decides whether to immediately notify the main IO request of completion; in order to ensure that when the disk sub-IO request is not fully completed, the operation of notifying its main IO request of completion will not affect the integrity of the RAID1 array data under abnormal circumstances, the main basis for judgment is that the mirror of at least one disk in the current RAID1 array is complete and reliable. In order to enable people in this technical field to better understand the technical solution of the present invention, the technical solution of the present invention will be further described in detail below in conjunction with the drawings in the embodiments of the present invention.
[0020] like Figure 3As shown, the method for improving RAID 1 write performance in a Linux system in this embodiment includes the following steps: S1, declares the required data structures, including the number of disk IO requests to be synchronized, the notification status of the main IO request, and the variables required for the completion status of the sub-IO requests mirrored by the main IO request; S2, when each disk in the RAID1 disk array is initialized, the number of pending IO requests for the disk is initialized to 0; 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 into a corresponding number of sub-IO requests based on the number of disks in the RAID1 disk array to be written, and sends them to each disk. The completion status of the sub-IO requests is initially marked as incomplete, and the notification status of the main IO request is initially marked as not notified. Each disk executes the corresponding sub-IO request and jumps to step S4 when the sub-IO request execution is completed. S4, marking the completion status of the sub-IO request of the current disk as completed; S5, determine whether all sub-IO requests mirrored by the main IO request have been completed. If they have been completed, jump to step S6; otherwise, jump to step S8; S6, determining whether the RAID1 disk array has been notified of the completion of the primary IO request. If the RAID1 disk array has been notified of the completion of the primary IO request, then the process ends and exits; otherwise, the process jumps to step S7; S7, notifies the RAID1 disk array that the main IO request is completed, ends and exits; S8, determining whether the RAID 1 disk array has been notified of the completion of the primary IO request. If so, jump to step S9; otherwise, jump to step S10; S9: Decrement the number of IO requests to be synchronized on the current disk, end, and exit; S10, determine whether the number of IO requests to be synchronized on the current disk is 0, if the number of IO requests to be synchronized on the current disk is 0, jump to step S11; otherwise, end and exit; S11, notifying the RAID 1 disk array that the main IO request is completed, and marking the notification status of the main IO request as a notification completion status; S12: For all disks whose sub-IO requests mirrored by the main IO request have not yet been completed, the number of IO requests to be synchronized is increased, and the process ends and exits.
[0021] In the step S1 of the embodiment, when the data structure required by the declaration definition is defined, the variable of the number of the IO requests to be synchronized of the disk is an integer variable num_sync_io defined in the data structure md_rdev used for describing the physical disk of the RAID array, the variable of the notification state of the primary IO request is an integer variable is_notify_orig_io defined in the data structure r1bio used for managing the IO operation of the RAID1 array, the variable of the completion state of the mirrored sub IO request of the primary 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 bits in the long variable disk_remaining are used to distinguish the completion states of the different disk sub IO requests.
[0022] The number of the IO requests to be synchronized of the disk in the step S2 refers to the number of the current disk sub IO requests which have not been completed, but the corresponding primary IO request has been asynchronously notified to be completed when the other disk sub IO request is 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 the IO requests to be synchronized 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: rdev->num_sync_io = 0; In the step S3 of the embodiment, the initial marking of the completion state of the sub IO request to the uncompleted state and the initial marking of the notification state of the primary IO request to the uncompleted state include: set_bit(1<<disk,&(r1_bio->disk_remaining)) The completion state of the sub IO request corresponding to the disk number disk in the unsigned long variable disk_remaining is marked to 1 to be the uncompleted state, wherein r1_bio is the data structure used for managing the IO operation of the RAID1 array, "<<" is the 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 the object, set_bit is a function used for unconditionally setting the specified bit to 1, and "&" is the address operator; and r1_bio->is_notify_orig_io = 1 The main IO request is marked as pending completion notification. is_notify_orig_io is a variable defined in the r1bio data structure used to manage RAID1 array IO operations, which indicates the notification status of the main IO request. Through this operation, when the RAID1 disk array receives the upper-layer main IO request and calls the raid1_write_request() function to mirror the sub-IO requests of each disk, it marks the sub-IO requests as incomplete and the main IO request as unnotified completion.
[0023] When the sub-IO request of each disk in the RAID1 disk array is completed and the raid1_end_write_request(structbio *bio) function is called back, the sub-IO request of the corresponding disk is marked as completed. Specifically, in step S4 of this embodiment, marking the completion status of the sub-IO request of the current disk as completed includes executing: clean_bit(1< <disk,&(r1_bio→disk_remaining)) The completion status of the sub-IO request corresponding to the disk number disk in the unsigned long integer variable disk_remaining is set to 0 to mark it as completed, where r1_bio is a data structure used to manage RAID1 array IO operations, "<<" is a left shift operation, "1< <disk”用于在无符号长整型变量disk_remaining中定位磁盘编号disk对应的位,“→”表示对象的属性,&为取地址运算符,clean_bit为用于将指定位无条件置为0的函数。其中,磁盘编号disk可通过执行内核函数find_bio_disk(r1_bio, bio)来获取,用于指明当前bio属于RAID1磁盘阵列中磁盘的编号。
[0024] Steps S5, S6, and S7 are similar to the synchronization algorithm currently implemented in the Linux kernel. That is, once all sub-IO requests mirrored from the main IO request have completed, the main IO request is notified of its completion. In this embodiment, determining whether all sub-IO requests mirrored from the main IO request have completed in step S5 refers to determining whether the unsigned long integer variable disk_remaining is 0. If it is 0, it indicates that all sub-IO requests mirrored from the main IO request have completed. Otherwise, it indicates that all sub-IO requests mirrored from the main IO request have not yet completed.
[0025] In step S6 of this embodiment, determining the completion notification status of the main IO request refers to determining whether r1_bio→is_notify_orig_io is 0 to know the completion notification status of the main IO request. When it is 0, it indicates that the main IO request has been completed.
[0026] In step S7 of this embodiment, notifying the RAID1 disk array of the completion of the primary IO request refers to calling the kernel function call_bio_endio(r1_bio) to notify the RAID1 disk array of the completion of the primary IO request, where r1_bio is a data structure for managing RAID1 array IO operations, and call_bio_endio is the primary IO request completion notification function of the RAID1 disk array.
[0027] In step S8 of this embodiment, when determining whether the RAID 1 disk array has been notified of the completion of the primary IO request, the determination includes determining whether r1_bio→is_notify_orig_io is 0, where r1_bio is a data structure for managing RAID 1 array IO operations, and is_notify_orig_io is a variable defined in the data structure r1bio for managing RAID 1 array IO operations and used to indicate the notification status of the primary IO request.
[0028] When step S9 is executed, it means that the main IO request corresponding to the completed sub-IO request on the current disk has been notified of completion in an asynchronous manner. At this time, the process can be ended by simply decrementing the number of IO requests to be synchronized on the current disk. In this embodiment, when decrementing the number of IO requests to be synchronized on the current disk in step S9, the command: conf→mirrors[disk].rdev→num_sync_io-- Decrement the number of pending IOs on the disk. conf is the RAID1 configuration structure struct r1conf obtained through r1_bio→mddev→private. "→" indicates the object's attributes. r1_bio is the data structure used to manage RAID1 array IO operations. 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 current number of pending IO requests for the underlying disk numbered disk. "--" indicates a decrement operation.
[0029] In step S10, the corresponding main IO request is asynchronously notified of completion only when the number of current disk pending synchronization IO requests is 0. This measure aims to ensure the integrity of the RAID 1 array data in abnormal conditions. It can be understood that when the number of current disk pending synchronization IO requests 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 RAID 1 array data recovery. In step S10, it is determined whether the number of current disk pending synchronization IO requests is 0, i.e., whether r1_bio->num_sync_io is 0. If it is not 0, the process ends, otherwise, step S11 is executed 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; and r1_bio->is_notify_orig_io = 0 is executed to indicate that the main IO request has been notified of completion.
[0030] In step S12, the number of pending synchronization IO requests of each disk in the RAID 1 array is recorded, which cooperates with step S10 to ensure that the integrity of the RAID 1 array data is maintained in abnormal conditions. In step S12 of the embodiment, for the disks whose all mirrored sub-IO requests of the main IO request have not been completed, the number of their pending synchronization IO requests is incremented by: test_bit(1<<i,&(r1_bio→disk_remaining)) to determine whether the sub-IO request of disk number i in the unsigned long variable disk_remaining is completed, wherein test_bit is a function for determining whether the bit is 0, "<<" is a left shift operation, "1<<i" is used to locate the bit corresponding to disk number i in the unsigned long variable disk_remaining, r1_bio is a data structure for managing RAID 1 array IO operations, "&" is an address operator, and "→" represents the attribute of the object.
[0031] In summary, the method of the 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 completion of the main IO request. Instead, whenever a disk sub-IO request write is completed and returned, the system judges and decides whether to immediately notify the completion of the main IO request; in order to ensure that the operation of notifying the completion of the main IO request when the disk sub-IO request is not completed does not affect the integrity of the data of the RAID1 array in abnormal cases, the main basis for the judgment is that the mirror of at least one disk in the current RAID1 array is complete and reliable. The embodiment adopts the conditional asynchronous write strategy, which can notify the completion of the main IO request in advance without waiting for all disk sub-IO requests of the RAID1 array to be completed, on the premise that the integrity of the data of the RAID1 array will not be damaged in abnormal cases. This conditional asynchronous notification mechanism not only solves the problem of disk IO burr amplification existing in the synchronous write strategy adopted by the RAID1 write mechanism of the Linux kernel, but also alleviates the IO burr phenomenon of the RAID1 to a certain extent.
[0032] In addition, the embodiment also provides a system for improving the write performance of a RAID1 under a Linux system, which comprises a microprocessor and a memory connected to each other, and the microprocessor is programmed or configured to execute the method for improving the write performance of the RAID1 under the Linux system. The embodiment also provides a computer readable storage medium, which stores a computer program or instructions programmed or configured to execute the method for improving the write performance of the RAID1 under the Linux system by a processor. The embodiment also provides a computer program product comprising a computer program or instructions programmed or configured to execute the method for improving the write performance of the RAID1 under the Linux system by a processor.
[0033] 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 block or blocks. Figure 1 one or more functions specified in the flow or flows and / or block or blocks. Figure 1 one or more functions specified in the flow or flows and / or block or blocks. Figure 1 one or more functions specified in the flow or flows and / or block or blocks. Figure 1 one or more functions specified in the flow or flows and / or block or blocks. Figure 1 one or more functions specified in the flow or flows and / or block or blocks.
[0034] The above description is only preferred embodiments of the application. The protection scope of the application is not limited to the above-mentioned embodiments. Any technical scheme falling within the concept of the application is within the protection scope of the application. It should be noted that some improvements and refinements made by those skilled in the art without departing from the principles of the application are also considered to be within the protection scope of the application.
Claims
1. A method for improving RAID 1 write performance in Linux system, characterized in that: The steps include: S1, declares the required data structures, including the number of disk IO requests to be synchronized, the notification status of the main IO request, and the variables required for the completion status of the sub-IO requests mirrored by the main IO request; S2, when each disk in the RAID1 disk array is initialized, the number of pending IO requests for the disk is initialized to 0; S3: When the main IO request sent by the upper layer enters the RAID1 disk array, the RAID1 disk array mirrors the main IO request into a corresponding number of sub-IO requests based on the number of disks to be written in the RAID1 disk array, and sends them to each disk. The completion status of the sub-IO requests is initially marked as incomplete, and the notification status of the main IO request is initially marked as not notified. Each disk executes the corresponding sub-IO request, and when the sub-IO request is completed, the process jumps to step S4. S4, marking the completion status of the sub-IO request of the current disk as completed; S5, determine whether all sub-IO requests mirrored by the main IO request have been completed. If they have been completed, jump to step S6; otherwise, jump to step S8; S6, determining whether the RAID1 disk array has been notified of the completion of the primary IO request. If the RAID1 disk array has been notified of the completion of the primary IO request, then the process ends and exits; otherwise, the process jumps to step S7; S7, notifies the RAID1 disk array that the main IO request is completed, ends and exits; S8, determining whether the RAID 1 disk array has been notified of the completion of the primary IO request. If the RAID 1 disk array has been notified of the completion of the primary IO request, jump to step S9; otherwise, jump to step S10; S9: Decrement the number of IO requests to be synchronized on the current disk, end, and exit; S10, determine whether the number of IO requests to be synchronized on the current disk is 0, if the number of IO requests to be synchronized on the current disk is 0, jump to step S11; otherwise, end and exit; S11, notifying the RAID 1 disk array that the main IO request is completed, and marking the notification status of the main IO request as a notification completion status; S12: For all disks whose sub-IO requests mirrored by the main IO request have not yet been completed, the number of IO requests to be synchronized is increased, and the process ends and exits.
2. The method for improving RAID 1 write performance in a Linux system according to claim 1, wherein: When declaring and defining the required data structures in step S1, the variable for the number of disk IO requests to be synchronized is the integer variable num_sync_io defined in the data structure md_rdev used to describe the physical disks of the RAID array; the variable for the notification status of the main IO request is the integer variable is_notify_orig_io defined in the data structure r1bio used to manage RAID1 array IO operations; the variable for the completion status of the sub-IO request mirrored by the main IO request is the unsigned long integer variable disk_remaining defined in the data structure r1bio used to manage RAID1 array IO operations, and different bits in the long integer variable disk_remaining are used to distinguish the completion status of different disk sub-IO requests.
3. The method for improving RAID 1 write performance in a Linux system according to claim 2, wherein: When the completion status of the sub-IO request is initially marked as an uncompleted state and the notification status of the main IO request is initially marked as an unnotified completion state in step S3, the method includes: executing 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 integer variable disk_remaining to 1 and mark it as a pending completion state, 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 integer variable disk_remaining, "→" represents an object attribute, set_bit is a function for unconditionally setting a specified bit to 1, and & is an address operator; executing r1_bio→is_notify_orig_io = 1 to mark the main IO request as a pending completion state; is_notify_orig_io is a variable defined in the data structure r1bio for managing RAID1 array IO operations and used to indicate the notification status of the main IO request.
4. The method for improving RAID 1 write performance in a Linux system according to claim 2, wherein: In step S4, marking the completion status of the sub-IO request of the current disk as a completed status includes executing 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 integer variable disk_remaining to 0 and mark it as a completed status, where 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 integer variable disk_remaining, "→" represents an object attribute, & is an address operator, and clean_bit is a function used to unconditionally set a specified bit to 0.
5. The method for improving RAID 1 write performance in a Linux system according to claim 2, wherein: In step S5, determining whether all sub-IO requests mirrored by the main IO request have been completed refers to determining whether the unsigned long integer variable disk_remaining is 0. If it is 0, it indicates that all sub-IO requests mirrored by the main IO request have been completed. Otherwise, it indicates that all sub-IO requests mirrored by the main IO request have not been completed. In step S7, 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 RAID1 array IO operations, and call_bio_endio is a main IO request completion notification function for the RAID1 disk array. In step S8, determining whether the main IO request has been notified to the RAID1 disk array includes determining whether r1_bio→is_notify_orig_io is 0, wherein r1_bio is a data structure for managing RAID1 array IO operations, and is_notify_orig_io is a variable defined in the data structure r1bio for managing RAID1 array IO operations for indicating the notification status of the main IO request.
6. The method for improving RAID 1 write performance in a Linux system according to claim 2, wherein: When the number of IO requests to be synchronized on the current disk is decremented in step S9, the command is executed: conf→mirrors[disk].rdev→num_sync_io-- Decrement the number of pending IO requests on the disk. conf is the RAID1 configuration structure struct r1conf obtained through r1_bio→mddev→private. "→" indicates the object's attributes. r1_bio is the data structure used to manage RAID1 array IO operations. 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 current number of pending IO requests for the underlying disk numbered disk. "--" indicates a decrement operation.
7. The method for improving RAID 1 write performance in a Linux system according to claim 2, wherein: In step S12, for the disks whose sub-IO requests mirrored by the main IO request have not yet been completed, the number of IO requests to be synchronized is increased upward, including: traversing the disks in the RAID1 disk array, and for each disk i obtained by the traversal, executing test_bit(1<< i, &(r1_bio→disk_remaining)) to determine whether the sub-IO request of the disk number i in the unsigned long integer variable disk_remaining is completed, where test_bit is a function to determine whether a bit is 0, "<<" is a left shift operation, "1<< i" is used to locate the bit corresponding to the disk number i in the unsigned long integer variable disk_remaining, r1_bio is a data structure for managing RAID1 array IO operations, & is an address operator, and "→" represents the attribute of the object.
8. A system for improving RAID 1 write performance in 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 RAID 1 write performance in a Linux system according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program or instruction stored therein, characterized in that: The computer program or instruction is programmed or configured to execute, through a processor, the method for improving RAID 1 write performance in a Linux system as recited in any one of claims 1 to 7.
10. A computer program product comprising a computer program or instructions, characterized in that The computer program or instruction is programmed or configured to execute, through a processor, the method for improving RAID 1 write performance in a Linux system as recited in any one of claims 1 to 7.
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
Method for building array by adding mirror image structure to check-based RAID and read-write system
CN104714758A
Data integrity inspection support method for disk devices, and data integrity inspection method for disk devices
US20060129876A1