A disk selection method and system for RAID1 disk array read operation

By monitoring and mapping the read IO operation size and delay data of each disk in the RAID1 disk array, and combining the unfinished read IO operation size and number, we decided to find the disk that is most suitable for completing read IO operation, which solved the performance degradation caused by the all-flash RAID1 disk array requirements and sub-health disks, and improved the overall read operation performance.

CN119415044BActive Publication Date: 2025-03-25KYLIN CORP
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510006414.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-03
Publication Date
2025-03-25
Estimated Expiration
2045-01-03

AI Technical Summary

Technical Problem

The prior art cannot meet the needs of all-flash RAID1 disk arrays, and the degradation of read performance of sub-healthy disks in RAID1 disk arrays leads to a rapid decline in performance of the entire disk array.

Method used

By monitoring the read IO operation size and delay data of each disk in the RAID1 disk array, establishing and maintaining the relationship mapping table of read IO operation size and delay data, and combining the unfinished read IO operation size and number of each disk, the disk that is most suitable for completing the read IO operation when the system dispatches read IO operations.

Benefits of technology

It improves the read operation performance of RAID1 disk array, meets the needs of all-flash RAID1 disk arrays, and solves the performance degradation caused by sub-health disks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415044B_ABST
    Figure CN119415044B_ABST
Patent Text Reader

Abstract

The present invention discloses a disk selection method and system for a read operation of a RAID1 disk array. The present invention includes monitoring the read IO operation size and delay data of each disk in the RAID1 disk array, establishing and maintaining a mapping table of the relationship between the read IO operation size and delay data of each disk, and real-time monitoring the size and number of unfinished read IO operations of each disk in the RAID1 disk array; when the system dispatches a read IO operation, according to the mapping table of the relationship between the read IO operation size and delay data of each disk, and in combination with the size and number of unfinished read IO operations of each disk, a decision is made on the disk that is most suitable for completing the system read IO operation. The present invention aims to solve the problem that the current technology cannot meet the needs of a full-flash RAID1 disk array and the performance of the entire RAID1 disk array rapidly decreases due to the decrease in read performance of sub-healthy disks in the RAID1 disk array, thereby improving the read operation performance of the entire RAID1 disk array.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of storage technology, and in particular to a disk selection method and system for a RAID1 disk array read operation. Background Art

[0002] Redundant Arrays of Independent Disks (RAID) is a storage solution that combines multiple hard disks to provide data redundancy, improve performance, or both. Common RAID levels, such as RAID 0, 1, 5, and 10, provide different performance and security. Among them, RAID 1 uses disk mapping technology, which is to copy the contents of a hard disk to another or several hard disks synchronously, so it has backup and fault tolerance capabilities, and improves data reliability. In recent years, with the widespread application of various emerging technologies such as AI, cloud computing, cloud storage, and big data, the industry's demand for data storage has been growing, and the requirements for storage performance have become increasingly higher. Disk arrays have the function of improving system IO read and write speeds, while realizing redundant protection of data and ensuring data storage reliability. Therefore, disk arrays are becoming more and more widely used. At the same time, with the rapid development of SSD and NVMe disks and the rapid decline in their prices, SSD all-flash arrays and NVMe all-flash arrays should also appear and be widely used.

[0003] However, the disk selection methods for RAID1 disk array read operations proposed by the current Linux system or the industry are designed and implemented based on the characteristics of traditional mechanical disks, and can no longer meet the needs of current all-flash disk arrays. For example, the target disk is selected based on the position of the previous read operation and the position of the current read operation to reduce the seek time of traditional mechanical disks, etc. These disk selection methods are not applicable to all-flash disk arrays. At the same time, the current disk selection methods do not take into account the performance differences of the read operations of each disk in the disk array. For example, if a sub-healthy disk appears in the RAID1 disk array, the current design scheme will cause the performance of the entire RAID1 disk array to decline rapidly due to the decline in its read performance.

[0004] Based on the above reasons, it is urgent to develop and implement a new disk selection method for RAID1 disk array read operations. This method should not only meet the latest all-flash disk array requirements, but also solve the problem of rapid performance degradation of the entire disk array due to the degradation of sub-healthy disk read performance in the RAID1 disk array.

[0005] The Chinese invention patent application with application number CN201410227973.9 discloses a method, CPU system and storage device for writing RAID1 data, wherein the method includes: determining whether it is necessary to write pre-stored input and output IO data into N storage media, wherein N≥2 and N is an integer; if it is determined that the pre-stored IO data needs to be written into N storage media, constructing a network protocol IP multicast request message; sending the IP multicast request message to the N storage media through an IP switching network, and the N storage media respectively write the IO data into the storage medium according to the IP multicast request message. However, this method is used to improve the writing performance of RAID1, and cannot solve the reading performance problem of RAID1.

[0006] The Chinese invention patent application with application number CN202310443415.5 discloses a method and device for optimizing disk multi-thread performance based on RAID1, wherein the method includes the following steps: S1. Configure the storage of the server to RAID1 mode, and add a communication link between the two hard disks of each RAID1 array; S2. Perform multi-threaded read and write balance between the two disks of each RAID1 array according to the application scenario of the storage, and optimize the response speed of the storage. The method sets an auxiliary two-way communication line between the two disks of the existing RAID1 disk array, so that the RAID card has one more possible auxiliary communication line with each disk. Based on the auxiliary communication link, double bandwidth can be achieved to achieve multi-threaded read and write balance between the two disks, shorten the waiting response time, and improve the disk access speed. This method mainly solves the performance problem caused by the time-sharing of read and write operations when multiple threads read and write on the same line, and cannot solve the reading performance problem of RAID1.

[0007] The Chinese invention patent application with application number CN200910253322.6 discloses a method and device for reading RAID1 devices, which includes: an information statistics module, which counts the current status information of each member disk contained in the RAID1 device when receiving a read request for RAID1 device data; a read block division module, which divides the read block interval size of the member disk according to the size of the data requested to be read; and a read request processing module, which distributes the read request to the member disks to perform parallel data reading according to the current status information of each member disk and the read block interval size, and notifies the idle member disks to read the next interval data into the cache in advance. The device can improve the reading efficiency of the RAID1 device. The current status information of each member disk contained in the statistical RAID1 device of the device refers to the busyness of the disk and / or the current I / O position, and then the target disk is selected according to the busyness of the disk and / or the current I / O position. The device is suitable for disk arrays composed of traditional mechanical hard disks, but not for the latest all-flash disk arrays, especially all-flash disk arrays composed of NVMe disks. The performance difference between random read and sequential read of SSD hard disks in all-flash disk arrays is not very large, so the method of selecting the target disk according to the current I / O position is not applicable. In addition, NVMe disks are usually multi-queue devices that can process multiple IO requests concurrently, and the busyness of the disk (whether it is idle) cannot reflect the actual processing capacity of the device. In addition, the device cannot solve the problem of the rapid decline in the performance of the entire disk array caused by the decline in the read performance of sub-healthy disks in the disk array, or solve the problem that when there are disks with inconsistent read performance in the disk array, the read performance of the entire disk array will be determined by the disk with the worst read performance.

[0008] In summary, among the existing RAID1 disk array read operation disk selection technologies, there is no disk selection method that can both meet the latest all-flash RAID1 disk array requirements and solve the problem of rapid performance degradation of the entire disk array due to degradation of sub-healthy disk read performance in the RAID1 disk array. Summary of the invention

[0009] Technical problem to be solved by the present invention: In view of the above-mentioned problems in the prior art, a disk selection method and system for a RAID1 disk array read operation are provided. The present invention aims to solve the problem that the current technology cannot meet the needs of an all-flash RAID1 disk array and the performance of the entire RAID1 disk array rapidly degrades due to the degradation of the read performance of sub-healthy disks in the RAID1 disk array, thereby improving the read operation performance of the entire RAID1 disk array.

[0010] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0011] A disk selection method for a RAID1 disk array read operation comprises the following steps: monitoring the read IO operation size and delay data of each disk in the RAID1 disk array, establishing and maintaining a mapping table of the relationship between the read IO operation size and delay data of each disk, and simultaneously monitoring the size and quantity of uncompleted read IO operations of each disk in the RAID1 disk array in real time; when the system dispatches a read IO operation, according to the mapping table of the relationship between the read IO operation size and delay data of each disk, and in combination with the size and quantity of uncompleted read IO operations of each disk, deciding the disk that is currently most suitable for completing the system read IO operation.

[0012] Optionally, the monitoring of the read IO operation size and delay data of each disk in the RAID1 disk array, establishing and maintaining a mapping table of the relationship between the read IO operation size and delay data of each disk, and simultaneously monitoring the size and number of unfinished read IO operations of each disk in the RAID1 disk array in real time includes:

[0013] S101: preparing and initializing data structures required for real-time monitoring, wherein the data structures required for real-time monitoring include a variable for storing a start time point of a read IO operation, a variable for storing a number of unfinished IO operations, a variable for storing a mapping table of a relationship between a read IO operation size and delay data, and a variable for storing a size and number of unfinished read IO operations;

[0014] S102: when the RAID1 disk array is started, a mapping table of the relationship between the read IO operation size and the delay data of each disk is established;

[0015] S103: when a read IO operation is dispatched, the starting time point of the read IO operation and the number of unfinished IO operations on the disk are obtained, and the number of unfinished read IO operation sizes on the disk is incremented;

[0016] S104: When the read IO operation is completed, the completion time point of the read IO operation is obtained, the number of unfinished read IO operation sizes on the disk is decremented, and a mapping table of the relationship between the disk read IO operation size and delay data is maintained and updated.

[0017] Optionally, in step S101, preparing and initializing the data structure required for real-time monitoring includes: adding a variable io_delay in the structure request describing the block device IO request, which is used to store the starting time point of the read IO operation, and adding an integer type variable io_incomplete, which is used to store the number of unfinished IO operations of the current disk; adding a long integer variable length array variable mapping[] in the structure gendisk describing the disk, which is used to store the mapping between the read IO operation size and the delay data relationship, adding an integer type variable length array variable incomplete[], which is used to store the size and number of unfinished read IO operations on the disk, and adding an integer type variable vla_len, which is used to store the length of the variable length arrays mapping[] and incomplete[]; defining a constant BLANK, which is used to represent the interval size of the read IO operation for establishing the mapping between the read IO size and the delay data relationship; when the disk driver registers and initializes the structure gendisk describing the disk, the variable vla_len is initialized to be equal to:

[0018] DIV_ROUND_UP(q->limits.max_hw_sectors, BLANK)

[0019] Among them, DIV_ROUND_UP is the macro of the upward division operation implemented by the kernel, q is the struct request_queue structure that manages the IO request queue. Each disk has its own request queue. q->limits.max_hw_sectors stores the maximum IO size that the disk can operate and process, and then allocates storage space for variable-length array variables mapping[] and incomplete[] according to the variable vla_len as the length.

[0020] Optionally, in step S102, establishing a mapping table of the relationship between the read IO operation size and the delay data of each disk when the RAID1 disk array is started includes:

[0021] 1) Define an integer variable i for traversing the RAID1 disk array disks and initialize it to 0, and define an integer variable j for determining the size of the dispatched read IO operation and initialize it to 1;

[0022] 2) Take out a disk's block device structure struct block_devcie *bdev from the RAID1 disk array:

[0023] struct block_devcie *bdev = conf->mirrors[i].rdev->bdev

[0024] bdev is a struct block_device structure, which is a data structure representing a block device; conf is a structr1conf structure, which is used to store the configuration and status information of the RAID1 disk array; i represents the number of the disk in the RAID1 disk array;

[0025] 3) Determine the read IO operation size read_size that needs to be dispatched as read_size = j * BLANK, where the constant BLANK represents the interval size of the read IO operation for mapping the relationship between the read IO size and the delay data;

[0026] 4) Call the kernel functions bio_alloc() and bio_add_page() to allocate a bio with a read IO operation size of read_size;

[0027] 5) Set the operation type bi_opf of the bio operation to the read operation constant REQ_OP_READ;

[0028] 6) Set the callback function bi_end_io of the bio operation to the callback function sync_end_io();

[0029] 7) Set the target disk of the bio operation through bio_set_dev(bio, bdev), where bio_set_dev is the function for setting the target disk;

[0030] 8) Submit bio to disk through submit_bio(bio), where submit_bio() is the function of the kernel submitting bio;

[0031] 9) After the callback function sync_end_io() is executed after the bio operation is completed, the variable j is incremented by 1, and it is determined whether the variable j is greater than the variable vla_len. If so, jump to step 10), otherwise jump to step 3);

[0032] 10) Execute the variable j to be assigned 1, increment the variable i by 1, and determine whether the variable i is less than the number of disks of the RAID1 disk array recorded in conf, where conf->raid_disks represents the number of disks of the RAID1 disk array stored in the configuration and status information of the RAID1 disk array; if so, jump to step 2), otherwise end step S102.

[0033] Optionally, in step S103, when the read IO operation is dispatched, obtaining the starting time point of the read IO operation and the number of unfinished IO operations on the disk, and increasing the number of unfinished read IO operation sizes on the disk includes:

[0034] 1) Get the disk data structure: gendisk *disk = req->q->disk, where req is the struct request core structure that describes the disk IO read and write request, and its member q is the struct request_queue structure. Each disk has its own struct request_queue structure, and the member disk of the struct request_queue structure also stores the struct gendisk structure that describes the disk;

[0035] 2) Get the starting time of dispatching the read IO operation: req->io_delay = ktime_get_ns(), where req->io_delay represents the starting time of the read IO operation req, and ktime_get_ns() is a function for obtaining the current time with nanosecond accuracy;

[0036] 3) Get the number of incomplete IO operations: req->io_incomplete = queue_in_flight(req->q); where req->io_incomplete represents the variable used to store the number of incomplete IO operations of the current disk in the read IO operation req, and queue_in_flight() is the function implemented by the kernel to obtain the number of incomplete IO operations of the disk;

[0037] 4) Calculate the array subscript index to be operated: index = DIV_ROUND_UP(req->__data_len,BLANK); where DIV_ROUND_UP is the macro of the upward division operation implemented by the kernel, req->__data_len is the data size of the read IO operation req, and the variable-length array variable incomplete or mapping subscript to be operated is obtained by rounding up and dividing by the constant BLANK interval size. The constant BLANK represents the interval size of the read IO operation that establishes the mapping between the read IO size and the delayed data.

[0038] 5) According to the array index to be operated, the number of incomplete read IO operation sizes on the disk is incremented: disk->incomplete[index]++, where disk->incomplete[index] represents the number of incomplete read IO operation sizes on the disk disk. The incomplete read IO operation size is determined by the array index, and "++" indicates an increment operation.

[0039] Optionally, when the read IO operation is completed in step S104, obtaining the completion time point of the read IO operation, decrementing the number of unfinished read IO operation sizes on the disk, and maintaining and updating the disk read IO operation size and delay data relationship mapping table includes:

[0040] 1) Get the disk data structure: gendisk *disk = req->q->disk, where req is the struct reqeust core structure that describes the disk IO read and write request;

[0041] 2) Calculate the array subscript index to be operated: index = DIV_ROUND_UP(req->__data_len,BLANK), where DIV_ROUND_UP is the macro of the round-up division operation implemented by the kernel, req->__data_len is the data size of the read IO operation req, and the variable-length array variable incomplete or mapping subscript to be operated is obtained by rounding up and dividing by the constant BLANK interval size. The constant BLANK represents the interval size of the read IO operation that establishes the mapping between the read IO size and the delayed data.

[0042] 3) According to the array index to be operated, the number of incomplete read IO operations on the disk is decremented: disk->incomplete[index]--, where disk->incomplete[index] indicates the number of incomplete read IO operations on the disk disk. The incomplete read IO operation size is determined by the array index, and "--" indicates a decrement operation;

[0043] 4) Determine whether req->io_incomplete is 0, where req is a read IO operation, and io_incomplete is a variable for storing the number of unfinished IO operations of the current disk of the read IO operation req. If yes, execute step 5), otherwise, terminate step S104;

[0044] 5) Calculate the read IO operation delay data: req->io_delay = ktime_get_ns() - req->io_delay, where req->io_delay represents the starting time point of the read IO operation req, and ktime_get_ns() is a function for obtaining the current time with an accuracy of nanoseconds;

[0045] 6) Maintain and update the mapping relationship table between read IO operation size and delay data: disk->mapping[index] =req->io_delay, where mapping is the mapping relationship table between read IO operation size and delay data of disk disk, index is the array index to be operated, and req->iodelay is the read IO operation delay data calculated in step 5).

[0046] Optionally, when the system dispatches a read IO operation, according to the mapping table of the relationship between the read IO operation size and the delay data of each disk, and in combination with the size and number of unfinished read IO operations of each disk, the disk that is currently most suitable for completing the system read IO operation is determined, including:

[0047] S201: Prepare and initialize the data structure required by the decision module, including: define a variable-length array dd_trend[] for storing the inferred completion delay data of the current read IO operation on each disk in the disk array, the array length is the number of disks in the disk array, define an integer type variable i for traversing the disk array, define a struct gendisk type variable disk for temporarily storing the disks in the traversal process; define an integer type variable j for traversing the variable-length arrays mapping[] and incomplete[]; define an integer type variable io_size for saving the current read IO operation size, define an integer type variable index for storing the array index to be operated; initialize variables i and j to 0, and allocate dd_trend storage space;

[0048] S202: inferring the completion delay data of the current read IO operation on each disk in the RAID1 disk array, including: traversing all disks in the RAID1 disk array, and calculating the completion delay data of the current read IO operation on each disk based on the size and number of unfinished read IO operations on each disk, and combining the mapping table of the relationship between the read IO operation size and delay data of each disk, including:

[0049] 1) Get the current read IO operation size io_size: io_size = bio->bi_iter.bi_size; bio is the current read IO operation, bio->bi_iter.bi_size stores the data size of the current read IO operation;

[0050] 2) Calculate the array index to be operated: index = DIV_ROUND_UP(io_size, BLANK), where DIV_ROUND_UP is the macro of the round-up division operation implemented by the kernel, and the constant BLANK represents the interval size of the read IO operation that establishes the mapping between the read IO size and the delay data;

[0051] 3) Take out a disk disk from the disk array: disk = conf->mirrors[i].rdev->bdev->bd_disk, where conf is the struct r1conf structure, which is used to store the configuration and status information of the RAID1 disk array, and i represents the number of the disk in the RAID1 disk array;

[0052] 4) Calculate the latency data of the disk's incomplete read IO operations: dd_trend[i] = dd_trend[i] + disk->mapping[j] * disk->incomplete[j], where dd_trend[i] is the i-th element in the variable-length array dd_trend[], disk->mapping[j] is the j-th element in the variable-length array variable mapping[] of the disk disk, and disk->incomplete[j] is the j-th element in the variable-length array variable incomplete[] of the disk disk;

[0053] 5) Increment the variable j upwards, and then determine whether the variable j is less than disk->vla_len, where disk->vla_len is the length of the variable-length array variable mapping or incomplete. If so, run step 4), otherwise assign the variable j to 0 and run step 6);

[0054] 6) Infer the completion delay data of the current read IO operation: dd_trend[i] = dd_trend[i] + disk->mapping[index], where disk->mapping[index] is the index-th element in the variable-length array variable mapping[] of the disk disk, and index is the array index to be operated;

[0055] 7) Prepare to traverse the next disk in the disk array and increment the variable i by 1;

[0056] 8) Determine whether i is less than conf->raid_disks, where conf->raid_disks represents the number of disks of the RAID1 disk array recorded in conf that stores the configuration and status information of the RAID1 disk array. If so, jump to step 3), otherwise end step S202;

[0057] S203: traverse the completion delay data of the current read IO operation on each disk of the RAID1 disk array and select the disk with the smallest delay data to complete the current read IO operation, including: traverse the variable length array dd_trend[], find the array subscript k of the minimum value in the variable length array dd_trend[], the found array subscript k is the most suitable disk number, and use the found array subscript k to set the read IO operation disk: bio_set_dev(read_bio, conf->mirror[k]->rdev->bdev), where bio_set_dev() is a function used by the kernel to set the target disk for the IO operation, read_bio is the read operation bio to be completed, conf is a struct r1conf structure, which is used to store the configuration and status information of the RAID1 disk array, and k represents the number of the disk in the RAID1 disk array.

[0058] In addition, this embodiment also provides a disk selection system for a RAID1 disk array read operation, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the disk selection method for the RAID1 disk array read operation.

[0059] In addition, this embodiment further 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 disk selection method of the RAID1 disk array read operation through a processor.

[0060] In addition, this embodiment also provides a computer program product, including a computer program or instruction, which is programmed or configured to execute the disk selection method for the RAID1 disk array read operation through a processor.

[0061] Compared with the prior art, the present invention mainly has the following advantages: the disk selection method for the read operation of the RAID1 disk array of the present invention includes first establishing a mapping table of the relationship between the read IO operation size and the delay data of each disk in the RAID1 disk array, and then when the system performs a read IO operation, the disk that is most suitable for completing the current read IO operation is selected according to the size and number of the unfinished read IO operations of each disk in the RAID1 disk array and in combination with the mapping table of the relationship between the read IO operation size and the delay data. The disk selection method for the read operation of the RAID1 disk array of the present invention can not only solve the problem that the current technology cannot meet the needs of the all-flash disk array, but also solve the problem that the performance of the entire disk array is rapidly reduced due to the reduction in the read performance of the sub-healthy disk in the disk array, thereby improving the read operation performance of the entire RAID1 disk array. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 Schematic diagram of the basic principle of the method of the embodiment of the present invention.

[0063] Figure 2 The figure is a flow chart of real-time data monitoring in an embodiment of the present invention.

[0064] Figure 3 Schematic diagram of the decision-making process in an embodiment of the present invention. DETAILED DESCRIPTION

[0065] The embodiments of the present invention are described in detail below with reference to the accompanying drawings. In the description process, unnecessary details and functions for the present invention are omitted to avoid confusion in understanding the present invention.

[0066] like Figure 1 As shown, this embodiment provides a disk selection method for RAID1 disk array read operation, including the following steps: monitoring the read IO operation size and delay data of each disk in the RAID1 disk array, establishing and maintaining a mapping table of the relationship between the read IO operation size and delay data of each disk, and monitoring the size and number of unfinished read IO operations of each disk in the RAID1 disk array in real time; when the system dispatches a read IO operation, according to the mapping table of the relationship between the read IO operation size and delay data of each disk, and in combination with the size and number of unfinished read IO operations of each disk, a decision is made on the disk that is currently most suitable for completing the system read IO operation. Figure 1 In this embodiment, a real-time monitoring module and a decision module are specifically designed. The real-time monitoring module is used to monitor the read IO operation size and delay data of each disk in the RAID1 disk array, establish and maintain a mapping table of the relationship between the read IO operation size and delay data, and monitor the size and number of unfinished read IO operations of each disk in the RAID1 disk array in real time. When the system dispatches a read IO operation, the decision module determines the disk that is currently most suitable for completing the system read IO operation based on the mapping table of the relationship between the read IO operation size and delay data of each disk in the RAID1 disk array provided by the monitoring module, and in combination with the current unfinished read IO operation size and number of each disk in the RAID1 disk array monitored in real time by the monitoring module.

[0067] like Figure 2 As shown, in this embodiment, the read IO operation size and delay data of each disk in the RAID1 disk array are monitored, a mapping table of the relationship between the read IO operation size and delay data of each disk is established and maintained, and the size and number of unfinished read IO operations of each disk in the RAID1 disk array are monitored in real time, including:

[0068] S101: preparing and initializing data structures required for real-time monitoring, wherein the data structures required for real-time monitoring include a variable for storing a start time point of a read IO operation, a variable for storing a number of unfinished IO operations, a variable for storing a mapping table of a relationship between a read IO operation size and delay data, and a variable for storing a size and number of unfinished read IO operations;

[0069] S102: when the RAID1 disk array is started, a mapping table of the relationship between the read IO operation size and the delay data of each disk is established;

[0070] S103: when a read IO operation is dispatched, the starting time point of the read IO operation and the number of unfinished IO operations on the disk are obtained, and the number of unfinished read IO operation sizes on the disk is incremented;

[0071] S104: When the read IO operation is completed, the completion time point of the read IO operation is obtained, the number of unfinished read IO operation sizes on the disk is decremented, and a mapping table of the relationship between the disk read IO operation size and delay data is maintained and updated.

[0072] In step S101, it is necessary to add a variable for storing the start time point of the read IO operation and a variable for storing the number of incomplete IO operations in the data structure representing the IO operation, and to add a variable for storing the mapping table of the relationship between the read IO operation size and the delay data and a variable for storing the size and number of incomplete read IO operations in the data structure representing the disk; specifically, in step S101 of this embodiment, the preparation and initialization of the data structure required for real-time monitoring include: adding a variable io_delay (unsigned long type) in the structure request (struct request) describing the block device IO request, which is used to store the start time point of the read IO operation, and adding an integer type (int type) variable io_incomplete, which is used to store the number of incomplete IO operations of the current disk; adding a variable length array variable mapping[] (unsigned long type) in the structure gendisk (struct gendisk) describing the disk long type), used to store the mapping between the read IO operation size and the delay data, add the integer type (int type) variable length array variable incomplete[], used to store the size and number of unfinished read IO operations on the disk, add the integer type (int type) variable vla_len, used to store the length of the variable length arrays mapping[] and incomplete[]; define the constant BLANK, used to represent the interval size of the read IO operation that establishes the mapping between the read IO size and the delay data; when the disk driver registers and initializes the structure gendisk that describes the disk, the variable vla_len is initialized to be equal to:

[0073] DIV_ROUND_UP(q->limits.max_hw_sectors, BLANK)

[0074] Among them, DIV_ROUND_UP is the macro of the kernel's implementation of the round-up division operation, q is the struct request_queue structure that manages the IO request queue. Each disk has its own request queue. q->limits.max_hw_sectors stores the maximum IO size that the disk can operate and process, and then allocates the storage space of the variable-length array variables mapping[] and incomplete[] according to the variable vla_len as the length. Among them, the structure request that describes the block device IO request represents the request of the block device driver layer. When the bio request from the general block layer is submitted to the block device driver, the corresponding block device driver layer request request needs to be constructed and inserted into the block device request queue.

[0075] In step S102, there is no need to establish a mapping table between all disk read IO operation sizes and latency data, because the disk has a minimum operation unit (for example, the NVMe protocol stipulates that the minimum read and write unit of the NVMe disk is 2KB or 4KB, etc.). If the minimum read and write unit of the disk is 4KB, then the latency data of reading 1KB size data and reading 4KB size data are the same. Therefore, a relationship mapping table can be established with a certain IO size as an interval. For example, with a 4KB size as an interval, the IO size in the range of (0,4KB] is classified as the 4KB IO size, and the IO size in the range of (4KB, 8KB] is classified as the 8KB IO size. IO size, and so on. Therefore, the relationship mapping table can be stored through an array, the subscript of the array represents the read IO operation size, the array content stores the read IO operation delay data, and the length of the array is determined by the maximum IO size that the disk can operate and process. If the maximum IO size that the disk can operate is 512Kb, then the length of the array is 128 (512Kb / 4Kb), where array subscript 0 stores the delay data of the read IO size of 4Kb, and array subscript 1 stores the delay data of the read IO size of 8Kb, and so on. Similarly, storing the size and number of unfinished read IO operations of the disk is also completed through an array, the subscript of the array represents the size of the unfinished read IO operation, and the array content is the number of the unfinished read IO operation size. Specifically, in step S102 of this embodiment, when the RAID1 disk array is started, the read IO operation size and delay data relationship mapping table of each disk is established, including:

[0076] 1) Define an integer variable i for traversing the RAID1 disk array disks and initialize it to 0, and define an integer variable j for determining the size of the dispatched read IO operation and initialize it to 1;

[0077] 2) Take out a disk's block device structure struct block_devcie *bdev from the RAID1 disk array:

[0078] struct block_devcie *bdev = conf->mirrors[i].rdev->bdev

[0079] bdev is a struct block_device structure, which is a data structure representing a block device; conf is a structr1conf structure, which is used to store the configuration and status information of the RAID1 disk array; i represents the number of the disk in the RAID1 disk array;

[0080] 3) Determine the read IO operation size read_size that needs to be dispatched as read_size = j * BLANK, where the constant BLANK represents the interval size of the read IO operation for mapping the relationship between the read IO size and the delay data;

[0081] 4) Call the kernel functions bio_alloc() and bio_add_page() to allocate a bio with a read IO operation size of read_size; the bio operation is represented by a request from the general block layer, which represents a request from the upper-layer application software. The upper-layer application has data to write to the disk, or has data to read from the disk, which will eventually be converted into a bio request at the general block layer. The bio contains important information such as the starting sector number of the block I / O operation on the disk, the read and write I / O operation flags, and the number of bytes to be transferred;

[0082] 5) Set the operation type bi_opf of the bio operation to the read operation constant REQ_OP_READ;

[0083] 6) Set the callback function bi_end_io of the bio operation to the callback function sync_end_io();

[0084] 7) Set the target disk of the bio operation through bio_set_dev(bio, bdev), where bio_set_dev is the function for setting the target disk;

[0085] 8) Submit bio to disk through submit_bio(bio), where submit_bio() is the function of the kernel submitting bio;

[0086] 9) After the callback function sync_end_io() is executed after the bio operation is completed, the variable j is incremented by 1, and it is determined whether the variable j is greater than the variable vla_len. If so, jump to step 10), otherwise jump to step 3);

[0087] 10) Execute variable j and assign it to 1, increment variable i by 1, and determine whether variable i is less than conf->raid_disks, where conf->raid_disks represents the number of disks in the RAID1 disk array recorded in conf that stores the configuration and status information of the RAID1 disk array; if it is less than conf->raid_disks, jump to step 2), otherwise end step S102. In step S102, when the RAID1 disk array is started, read IO operations of different sizes are dispatched to each disk in the disk array, and the number of IOs dispatched each time is 1, and the establishment of the mapping table of the relationship between the read IO operation size and delay data of each disk can be completed through steps S103 and S104.

[0088] In step S103, the starting time point of the read IO operation is the moment when the read IO operation is submitted to the disk. In the Linux kernel, the function blk_mq_start_request() is called to submit IO to the disk, so the starting time point can be recorded in the function blk_mq_start_request(). The number of unfinished IO operations on the disk is obtained to determine whether the IO operation is suitable for maintaining and updating the disk read IO operation size and delay data mapping relationship table. When the number of unfinished IO operations is 0, it is suitable; specifically, in step S103 of this embodiment, when the read IO operation is dispatched, the starting time point of the read IO operation and the number of unfinished IO operations on the disk are obtained, and the number of unfinished read IO operation sizes on the disk is incremented, including:

[0089] 1) Get the disk data structure: gendisk *disk = req->q->disk, where req is the struct request core structure that describes the disk IO read and write request, and its member q is the struct request_queue structure. Each disk has its own struct request_queue structure, and the member disk of the struct request_queue structure also stores the struct gendisk structure that describes the disk;

[0090] 2) Get the starting time of dispatching the read IO operation: req->io_delay = ktime_get_ns(), where req->io_delay represents the starting time of the read IO operation req, and ktime_get_ns() is a function for obtaining the current time with nanosecond accuracy;

[0091] 3) Get the number of incomplete IO operations: req->io_incomplete = queue_in_flight(req->q); where req->io_incomplete represents the variable used to store the number of incomplete IO operations of the current disk in the read IO operation req, and queue_in_flight() is the function implemented by the kernel to obtain the number of incomplete IO operations of the disk;

[0092] 4) Calculate the array subscript index to be operated: index = DIV_ROUND_UP(req->__data_len,BLANK); where DIV_ROUND_UP is the macro of the upward division operation implemented by the kernel, req->__data_len is the data size of the read IO operation req, and the variable-length array variable incomplete or mapping subscript to be operated is obtained by rounding up and dividing by the constant BLANK interval size. The constant BLANK represents the interval size of the read IO operation that establishes the mapping between the read IO size and the delayed data.

[0093] 5) According to the array index to be operated, the number of incomplete read IO operation sizes on the disk is incremented: disk->incomplete[index]++, where disk->incomplete[index] represents the number of incomplete read IO operation sizes on the disk disk. The incomplete read IO operation size is determined by the array index, and "++" indicates an increment operation.

[0094] In step S104, the completion time of the read IO operation is the moment when the read IO operation is completed and returned on the disk. In the Linux kernel, the unified callback function when the IO operation is completed is blk_complete_request(), so the end time point can be recorded in the function blk_complete_request(). Specifically, in step S104 of this embodiment, when the read IO operation is completed, the completion time point of the read IO operation is obtained, the number of unfinished read IO operation sizes on the disk is decremented, and the disk read IO operation size and delay data relationship mapping table is maintained and updated, including:

[0095] 1) Get the disk data structure: gendisk *disk = req->q->disk, where req is the struct reqeust core structure that describes the disk IO read and write request;

[0096] 2) Calculate the array subscript index to be operated: index = DIV_ROUND_UP(req->__data_len,BLANK), where DIV_ROUND_UP is the macro of the round-up division operation implemented by the kernel, req->__data_len is the data size of the read IO operation req, and the variable-length array variable incomplete or mapping subscript to be operated is obtained by rounding up and dividing by the constant BLANK interval size. The constant BLANK represents the interval size of the read IO operation that establishes the mapping between the read IO size and the delayed data.

[0097] 3) According to the array index to be operated, the number of incomplete read IO operations on the disk is decremented: disk->incomplete[index]--, where disk->incomplete[index] indicates the number of incomplete read IO operations on the disk disk. The incomplete read IO operation size is determined by the array index, and "--" indicates an increment operation;

[0098] 4) Determine whether req->io_incomplete is 0, where req is a read IO operation, and io_incomplete is a variable for storing the number of unfinished IO operations of the current disk of the read IO operation req. If yes, execute step 5), otherwise, terminate step S104;

[0099] 5) Calculate the read IO operation delay data: req->io_delay = ktime_get_ns() - req->io_delay, where req->io_delay represents the starting time point of the read IO operation req, and ktime_get_ns() is a function for obtaining the current time with an accuracy of nanoseconds;

[0100] 6) Maintain and update the mapping relationship table between read IO operation size and delay data: disk->mapping[index] =req->io_delay, where mapping is the mapping relationship table between read IO operation size and delay data of disk disk, index is the array index to be operated, and req->iodelay is the read IO operation delay data calculated in step 5).

[0101] like Figure 3As shown, in this embodiment, when the system dispatches a read IO operation, according to the mapping table of the relationship between the read IO operation size and the delay data of each disk, and in combination with the size and number of the unfinished read IO operations of each disk, the disk that is currently most suitable for completing the system read IO operation is determined to include:

[0102] S201: Prepare and initialize the data structure required by the decision module, including: define a variable-length array dd_trend[] for storing the inferred completion delay data of the current read IO operation on each disk in the disk array, the array length is the number of disks in the disk array, define an integer type variable i for traversing the disk array, define a struct gendisk type variable disk for temporarily storing the disks in the traversal process; define an integer type variable j for traversing the variable-length arrays mapping[] and incomplete[]; define an integer type variable io_size for saving the current read IO operation size, define an integer type variable index for storing the array index to be operated; initialize variables i and j to 0, and allocate dd_trend storage space;

[0103] S202: inferring the completion delay data of the current read IO operation on each disk in the RAID1 disk array, including: traversing all disks in the RAID1 disk array, and calculating the completion delay data of the current read IO operation on each disk based on the size and number of unfinished read IO operations on each disk, and combining the mapping table of the relationship between the read IO operation size and delay data of each disk, including:

[0104] 1) Get the current read IO operation size io_size: io_size = bio->bi_iter.bi_size; bio is the current read IO operation, bio->bi_iter.bi_size stores the data size of the current read IO operation;

[0105] 2) Calculate the array index to be operated: index = DIV_ROUND_UP(io_size, BLANK), where DIV_ROUND_UP is the macro of the round-up division operation implemented by the kernel, and the constant BLANK represents the interval size of the read IO operation that establishes the mapping between the read IO size and the delay data;

[0106] 3) Take out a disk disk from the disk array: disk = conf->mirrors[i].rdev->bdev->bd_disk, where conf is the struct r1conf structure, which is used to store the configuration and status information of the RAID1 disk array, and i represents the number of the disk in the RAID1 disk array;

[0107] 4) Calculate the latency data of the disk's incomplete read IO operations: dd_trend[i] = dd_trend[i] + disk->mapping[j] * disk->incomplete[j], where dd_trend[i] is the i-th element in the variable-length array dd_trend[], disk->mapping[j] is the j-th element in the variable-length array variable mapping[] of the disk disk, and disk->incomplete[j] is the j-th element in the variable-length array variable incomplete[] of the disk disk;

[0108] 5) Increment the variable j upwards, and then determine whether the variable j is less than disk->vla_len, where disk->vla_len is the length of the variable-length array variable mapping or incomplete. If so, run step 4), otherwise assign the variable j to 0 and run step 6);

[0109] 6) Infer the completion delay data of the current read IO operation: dd_trend[i] = dd_trend[i] + disk->mapping[index], where disk->mapping[index] is the index-th element in the variable-length array variable mapping[] of the disk disk, and index is the array index to be operated;

[0110] 7) Prepare to traverse the next disk in the disk array and increment the variable i by 1;

[0111] 8) Determine whether i is less than conf->raid_disks, where conf->raid_disks represents the number of disks of the RAID1 disk array recorded in conf that stores the configuration and status information of the RAID1 disk array. If so, jump to step 3), otherwise end step S202;

[0112] S203: traverse the completion delay data of the current read IO operation on each disk of the RAID1 disk array and select the disk with the smallest delay data to complete the current read IO operation, including: traverse the variable length array dd_trend[], find the array subscript k of the minimum value in the variable length array dd_trend[], the found array subscript k is the most suitable disk number, and use the found array subscript k to set the read IO operation disk: bio_set_dev(read_bio, conf->mirror[k]->rdev->bdev), where bio_set_dev() is a function used by the kernel to set the target disk for the IO operation, read_bio is the read operation bio to be completed, conf is a struct r1conf structure, which is used to store the configuration and status information of the RAID1 disk array, and k represents the number of the disk in the RAID1 disk array.

[0113] In summary, the disk selection method for the read operation of the RAID1 disk array of this embodiment first establishes a mapping table of the relationship between the read IO operation size and the delay data of each disk in the RAID1 disk array, and then when the system performs a read IO operation, the disk that is most suitable for completing the current read IO operation is selected according to the size and number of the unfinished read IO operations of each disk in the RAID1 disk array and in combination with the mapping table of the relationship between the read IO operation size and the delay data. The disk selection method for the read operation of the RAID1 disk array of this embodiment can not only solve the problem that the current technology cannot meet the needs of the all-flash disk array, but also solve the problem that the performance of the entire disk array is rapidly reduced due to the degradation of the read performance of the sub-healthy disks in the disk array, thereby improving the read operation performance of the entire RAID1 disk array.

[0114] In addition, this embodiment also provides a disk selection system for a RAID1 disk array read operation, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the disk selection method for the RAID1 disk array read operation.

[0115] In addition, this embodiment further 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 disk selection method of the RAID1 disk array read operation through a processor.

[0116] In addition, this embodiment also provides a computer program product, including a computer program or instruction, which is programmed or configured to execute the disk selection method for the RAID1 disk array read operation through a processor.

[0117] Those skilled in the art should understand that the technical solutions provided by the embodiments of the present application may be in the form of methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the process Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0118] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. A disk selection method for a RAID1 disk array read operation, characterized in that: The method comprises the following steps: monitoring the read IO operation size and delay data of each disk in the RAID1 disk array, establishing and maintaining a mapping table of the relationship between the read IO operation size and delay data of each disk, and monitoring the size and number of unfinished read IO operations of each disk in the RAID1 disk array in real time; when the system dispatches a read IO operation, according to the mapping table of the relationship between the read IO operation size and delay data of each disk, and in combination with the size and number of unfinished read IO operations of each disk, deciding the disk that is currently most suitable for completing the system read IO operation; the monitoring of the read IO operation size and delay data of each disk in the RAID1 disk array, establishing and maintaining a mapping table of the relationship between the read IO operation size and delay data of each disk, and monitoring the size and number of unfinished read IO operations of each disk in the RAID1 disk array in real time comprises: S101: preparing and initializing data structures required for real-time monitoring, wherein the data structures required for real-time monitoring include a variable for storing a start time point of a read IO operation, a variable for storing a number of unfinished IO operations, a variable for storing a mapping table of a relationship between a read IO operation size and delay data, and a variable for storing a size and number of unfinished read IO operations; S102: when the RAID1 disk array is started, a mapping table of the relationship between the read IO operation size and the delay data of each disk is established; S103: when a read IO operation is dispatched, the start time point of the read IO operation and the number of unfinished IO operations on the disk are obtained, and the number of unfinished read IO operation sizes on the disk is incremented; S104: When the read IO operation is completed, the completion time point of the read IO operation is obtained, the number of unfinished read IO operation sizes on the disk is decremented, and a mapping table of the relationship between the disk read IO operation size and delay data is maintained and updated.

2. The disk selection method for RAID1 disk array read operation according to claim 1, characterized in that: In step S101, the data structure required for real-time monitoring is prepared and initialized, including: adding a variable io_delay to the structure request describing the block device IO request, which is used to store the starting time point of the read IO operation, and adding an integer type variable io_incomplete to store the number of unfinished IO operations of the current disk; adding a long integer variable length array variable mapping[] to the structure gendisk describing the disk, which is used to store the mapping between the read IO operation size and the delay data, adding an integer type variable length array variable incomplete[] to store the size and number of unfinished read IO operations on the disk, and adding an integer type variable vla_len to store the length of the variable length arrays mapping[] and incomplete[]; defining a constant BLANK to represent the interval size of the read IO operation for establishing the mapping between the read IO size and the delay data; when the disk driver registers and initializes the structure gendisk describing the disk, the variable vla_len is initialized to be equal to: DIV_ROUND_UP(q->limits.max_hw_sectors, BLANK), Among them, DIV_ROUND_UP is the macro of the upward division operation implemented by the kernel, q is the struct request_queue structure that manages the IO request queue. Each disk has its own request queue. q->limits.max_hw_sectors stores the maximum IO size that the disk can operate and process, and then allocates storage space for variable-length array variables mapping[] and incomplete[] according to the variable vla_len as the length.

3. The disk selection method for RAID1 disk array read operation according to claim 2, characterized in that: In step S102, when the RAID1 disk array is started, a mapping table of the relationship between the read IO operation size and the delay data of each disk is established, including: 1) Define an integer variable i for traversing the RAID1 disk array disks and initialize it to 0, and define an integer variable j for determining the size of the dispatched read IO operation and initialize it to 1; 2) Take out a disk's block device structure struct block_devcie *bdev from the RAID1 disk array: struct block_devcie *bdev = conf->mirrors[i].rdev->bdev Among them, bdev is the struct block_device structure, which is a data structure representing a block device, conf is the structr1conf structure, which is used to store the configuration and status information of the RAID1 disk array, and i represents the number of the disk in the RAID1 disk array; 3) Determine the read IO operation size read_size that needs to be dispatched as read_size = j * BLANK, where the constant BLANK represents the interval size of the read IO operation for mapping the relationship between the read IO size and the delay data; 4) Call the kernel functions bio_alloc() and bio_add_page() to allocate a bio with a read IO operation size of read_size; 5) Set the operation type bi_opf of the bio operation to the read operation constant REQ_OP_READ; 6) Set the callback function bi_end_io of the bio operation to the callback function sync_end_io(); 7) Set the target disk of the bio operation through bio_set_dev(bio, bdev), where bio_set_dev is the function for setting the target disk; 8) Submit bio to disk through submit_bio(bio), where submit_bio() is the function of the kernel submitting bio; 9) After the callback function sync_end_io() is executed after the bio operation is completed, the variable j is incremented by 1, and it is determined whether the variable j is greater than the variable vla_len. If so, jump to step 10), otherwise jump to step 3); 10) Execute the variable j to be assigned 1, increment the variable i by 1, and determine whether the variable i is less than conf->raid_disks, where conf->raid_disks represents the number of disks of the RAID1 disk array recorded in conf that stores the configuration and status information of the RAID1 disk array; if it is less than conf->raid_disks, jump to step 2), otherwise end step S102.

4. The disk selection method for RAID1 disk array read operation according to claim 3, characterized in that: In step S103, when the read IO operation is dispatched, the starting time point of the read IO operation and the number of unfinished IO operations on the disk are obtained, and the number of unfinished read IO operation sizes on the disk is incremented, including: 1) Get the disk data structure: struct gendisk *disk = req->q->disk, where req is the struct request core structure that describes the disk IO read and write request, and its member q is the struct request_queue structure. Each disk has its own struct request_queue structure, and the member disk of the struct request_queue structure also stores the struct gendisk structure that describes the disk; 2) Get the starting time of dispatching the read IO operation: req->io_delay = ktime_get_ns(), where req->io_delay represents the starting time of the read IO operation req, and ktime_get_ns() is a function for obtaining the current time with nanosecond accuracy; 3) Get the number of incomplete IO operations: req->io_incomplete = queue_in_flight(req->q); where req->io_incomplete represents the variable used to store the number of incomplete IO operations of the current disk in the read IO operation req, and queue_in_flight() is the function implemented by the kernel to obtain the number of incomplete IO operations of the disk; 4) Calculate the array subscript index to be operated: index = DIV_ROUND_UP(req->__data_len, BLANK); where DIV_ROUND_UP is the macro of the upward division operation implemented by the kernel, req->__data_len is the data size of the read IO operation req, and the variable-length array variable incomplete or mapping subscript to be operated is obtained by rounding up and dividing by the constant BLANK interval size. The constant BLANK represents the interval size of the read IO operation that establishes the mapping between the read IO size and the delayed data. 5) According to the array index to be operated, the number of incomplete read IO operation sizes on the disk is incremented: disk->incomplete[index]++, where disk->incomplete[index] represents the number of incomplete read IO operation sizes on the disk disk. The incomplete read IO operation size is determined by the array index, and "++" indicates an increment operation.

5. The disk selection method for RAID1 disk array read operation according to claim 4, characterized in that: When the read IO operation is completed in step S104, the completion time point of the read IO operation is obtained, the number of unfinished read IO operation sizes on the disk is decremented, and the disk read IO operation size and delay data relationship mapping table is maintained and updated, including: 1) Get the disk data structure: gendisk *disk = req->q->disk, where req is the struct reqeust core structure that describes the disk IO read and write request; 2) Calculate the array subscript index to be operated: index = DIV_ROUND_UP(req->__data_len, BLANK), where DIV_ROUND_UP is the macro of the upward division operation implemented by the kernel, req->__data_len is the data size of the read IO operation req, and the variable-length array variable incomplete or mapping subscript to be operated is obtained by rounding up and dividing by the constant BLANK interval size. The constant BLANK represents the interval size of the read IO operation that establishes the mapping between the read IO size and the delayed data. 3) According to the array index to be operated, the number of incomplete read IO operations on the disk is decremented: disk->incomplete[index]--, where disk->incomplete[index] indicates the number of incomplete read IO operations on the disk disk. The incomplete read IO operation size is determined by the array index, and "--" indicates a decrement operation; 4) Determine whether req->io_incomplete is 0, where io_incomplete is a variable for storing the number of unfinished IO operations of the current disk in the read IO operation req. If yes, execute step 5), otherwise, terminate step S104; 5) Calculate the read IO operation delay data: req->io_delay = ktime_get_ns() - req->io_delay, where req->io_delay represents the starting time point of the read IO operation req, and ktime_get_ns() is a function for obtaining the current time with an accuracy of nanoseconds; 6) Maintain and update the mapping relationship table between read IO operation size and delay data: disk->mapping[index] = req->io_delay, where mapping is the mapping relationship table between read IO operation size and delay data of disk disk, index is the array index to be operated, and req->iodelay is the read IO operation delay data calculated in step 5).

6. The disk selection method for RAID1 disk array read operation according to claim 5, characterized in that: When the system dispatches a read IO operation, the disk that is currently most suitable for completing the system read IO operation is determined based on the mapping table of the relationship between the read IO operation size and the delay data of each disk, and combined with the size and number of the unfinished read IO operations of each disk: S201: Prepare and initialize the data structure required by the decision module, including: define a variable-length array dd_trend[] for storing the inferred completion delay data of the current read IO operation on each disk in the disk array, the array length is the number of disks in the disk array, define an integer type variable i for traversing the disk array, define a struct gendisk type variable disk for temporarily storing the disks in the traversal process; define an integer type variable j for traversing the variable-length arrays mapping[] and incomplete[]; define an integer type variable io_size for saving the current read IO operation size, define an integer type variable index for storing the array index to be operated; initialize variables i and j to 0, and allocate dd_trend storage space; S202: inferring the completion delay data of the current read IO operation on each disk in the RAID1 disk array, including: traversing all disks in the RAID1 disk array, and calculating the completion delay data of the current read IO operation on each disk based on the size and number of unfinished read IO operations on each disk, and combining the mapping table of the relationship between the read IO operation size and delay data of each disk, including: 1) Get the current read IO operation size io_size: io_size = bio->bi_iter.bi_size; bio is the current read IO operation, bio->bi_iter.bi_size stores the data size of the current read IO operation; 2) Calculate the array index to be operated: index = DIV_ROUND_UP(io_size, BLANK), where DIV_ROUND_UP is the macro of the round-up division operation implemented by the kernel, and the constant BLANK represents the interval size of the read IO operation that establishes the mapping between the read IO size and the delay data; 3) Take out a disk disk from the disk array: disk = conf->mirrors[i].rdev->bdev->bd_disk, where conf is the struct r1conf structure, which is used to store the configuration and status information of the RAID1 disk array, and i represents the number of the disk in the RAID1 disk array; 4) Calculate the latency data of the disk's incomplete read IO operations: dd_trend[i] = dd_trend[i] + disk->mapping[j] * disk->incomplete[j], where dd_trend[i] is the i-th element in the variable-length array dd_trend[], disk->mapping[j] is the j-th element in the variable-length array variable mapping[] of the disk disk, and disk->incomplete[j] is the j-th element in the variable-length array variable incomplete[] of the disk disk; 5) Increment the variable j upwards, and then determine whether the variable j is less than disk->vla_len, where disk->vla_len is the length of the variable-length array variable mapping or incommplete. If so, run step 4), otherwise assign the variable j to 0 and run step 6); 6) Infer the completion delay data of the current read IO operation: dd_trend[i] = dd_trend[i] + disk->mapping[index], where disk->mapping[index] is the index-th element in the variable-length array variable mapping[] of the disk disk, and index is the array index to be operated; 7) Prepare to traverse the next disk in the disk array and increment the variable i by 1; 8) Determine whether i is less than conf->raid_disks, where conf->raid_disks represents the number of disks of the RAID1 disk array recorded in conf that stores the configuration and status information of the RAID1 disk array. If so, jump to step 3), otherwise end step S202; S203: traverse the completion delay data of the current read IO operation on each disk of the RAID1 disk array and select the disk with the smallest delay data to complete the current read IO operation, including: traverse the variable length array dd_trend[], find the array subscript k of the minimum value in the variable length array dd_trend[], the found array subscript k is the most suitable disk number, and use the found array subscript k to set the read IO operation disk: bio_set_dev(read_bio, conf->mirror[k]->rdev->bdev), where bio_set_dev() is a function used by the kernel to set the target disk for the IO operation, read_bio is the read operation bio to be completed, conf is a struct r1conf structure, which is used to store the configuration and status information of the RAID1 disk array, and k represents the number of the disk in the RAID1 disk array.

7. A disk selection system for a RAID 1 disk array read operation, comprising a microprocessor and a memory connected to each other, characterized in that: The microprocessor is programmed or configured to execute the disk selection method for the RAID1 disk array read operation as described in any one of claims 1 to 6.

8. 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 the disk selection method for the RAID1 disk array read operation as described in any one of claims 1 to 6 through a processor.

9. A computer program product comprising a computer program or instructions, characterized in that The computer program or instruction is programmed or configured to execute the disk selection method for the RAID1 disk array read operation as described in any one of claims 1 to 6 through a processor.

Citation Information

Patent Citations

  • Method and device for reading RAID1 (Redundant Array of Inexpensive Disk 1) equipment

    CN102081509A

  • A method for writing raid 1 data, CPU system and storage device

    CN104020962B

  • RAID1-based disk multi-thread performance optimization method and device

    CN116627322A

  • Method for building array by adding mirror image structure to check-based RAID and read-write system

    CN104714758A

  • Data processing apparatus and data processing method

    CN117377940A