IO scheduling method, electronic device, storage medium and program product
By identifying and scheduling IO requests in a distributed storage system, and utilizing data management unit splitting and mutually exclusive linked list management, the problem of low IO request concurrency in the existing technology is solved, system performance is improved, and data inconsistency is avoided.
Patent Information
- Application Number
- CN202410962881.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-07-18
AI Technical Summary
Existing IO scheduling methods cannot effectively improve the IO request concurrency of distributed storage systems, resulting in insufficient overall performance.
By obtaining pending IO requests, identifying the target request data, determining its location and data volume in the storage device, and placing it in the appropriate IO request processing queue for scheduling based on this information, it supports data management unit splitting and interaction. Exclusion linked list management to achieve parallel processing and avoid data inconsistency problems.
It improves the IO request performance of the distributed storage system, enhances IO concurrency, and avoids performance bottlenecks and data inconsistencies caused by waiting for the previous request to be completed.
Smart Images

Figure CN118502680B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of IO scheduling, and in particular to an IO scheduling method, an electronic device, a storage medium and a program product. Background Art
[0002] The storage resources of the distributed storage system are shared by all clients. Therefore, the distributed storage system will receive IO requests from different clients. These IO requests may be about the same byte range of the same LUN (Logical Unit Number), different byte ranges of the same LUN, or different byte ranges of different LUNs.
[0003] In order to improve the management efficiency of distributed storage systems, OBJ (object, the smallest data management unit of distributed storage systems) is usually used as the smallest management unit of storage resources, and a LUN is composed of several OBJs. However, in the prior art, the pending IO requests are usually placed in the same IO request processing queue, and then scheduled in sequence. However, the IO scheduling method in the prior art cannot greatly improve the concurrency of IO scheduling.
[0004] It can be seen that how to further improve the concurrency of IO requests and enhance the performance of distributed storage systems is an urgent problem to be solved by those skilled in the art. Summary of the invention
[0005] In view of this, the present invention provides an IO scheduling method, an electronic device, a storage medium and a program product to solve the problem of IO scheduling.
[0006] In a first aspect, the present invention provides an IO scheduling method, the method comprising:
[0007] Get the current pending IO request;
[0008] Identify the current pending IO request and determine the target request data corresponding to the current pending IO request;
[0009] Determine a requested location of target request data in a storage device and a requested data volume corresponding to the target request data;
[0010] According to the request position and the request data volume corresponding to the target request data, the current pending IO request is put into the target IO request processing queue, and the current pending IO request is scheduled.
[0011] The IO scheduling method provided in the embodiment of the present application obtains the current pending IO request; identifies the current pending IO request, determines the target request data corresponding to the current pending IO request, and ensures the accuracy of the determined target request data. Determine the request position of the target request data in the storage device and the request data volume corresponding to the target request data, put the current pending IO request into the target IO request processing queue according to the request position and request data volume corresponding to the target request data, schedule the current pending IO request, ensure the accuracy of putting the current pending IO request into the target IO request processing queue, and then schedule the current pending IO request from the target IO request processing queue, ensure the accuracy of scheduling the current pending IO request. In this way, it is possible to process the pending IO requests in multiple IO request processing queues simultaneously, and then there is no need to wait for the previous pending IO request to be completed before scheduling the next pending IO request, thereby further improving the overall IO request performance of the distributed storage system.
[0012] In an optional implementation, according to the request position and the request data amount corresponding to the target request data, placing the current pending IO request into the target IO request processing queue includes:
[0013] Determine the number of target data management units corresponding to the target request data according to the request position and the request data amount corresponding to the target request data;
[0014] If the number of the target data management unit is 1, the current to-be-processed IO request is placed in the target IO request processing queue corresponding to the target data management unit according to the target data management unit.
[0015] The IO scheduling method provided in the embodiment of the present application determines the number of target data management units corresponding to the target request data according to the request position and the amount of request data corresponding to the target request data, thereby ensuring the accuracy of the number of target data management units corresponding to the determined target request data. If the number of target data management units is 1, then according to the target data management unit, the current pending IO request is placed in the target IO request processing queue corresponding to the target data management unit, thereby ensuring the accuracy of placing the current pending IO request in the target IO request processing queue corresponding to the target data management unit.
[0016] In an optional implementation, according to the request position and the request data amount corresponding to the target request data, the current pending IO request is placed in the target IO request processing queue, further comprising:
[0017] If the number of target data management units is greater than 1, the current pending IO request is split according to the number of target data management units to obtain multiple sub-pending IO requests; the number of sub-pending IO requests is consistent with the number of target data management units;
[0018] According to the target data management unit corresponding to each sub-to-be-processed IO request, each sub-to-be-processed IO request is put into the corresponding target IO request processing queue to schedule each sub-to-be-processed IO request.
[0019] The IO scheduling method provided in the embodiment of the present application, if the number of target data management units is greater than 1, then the current pending IO request is split according to the number of target data management units to obtain multiple sub-pending IO requests, thereby ensuring the accuracy of splitting the current pending IO request to obtain multiple sub-pending IO requests. According to the target data management unit corresponding to each sub-pending IO request, each sub-pending IO request is placed in the corresponding target IO request processing queue to schedule each sub-pending IO request, thereby ensuring the accuracy of placing each sub-pending IO request in the corresponding target IO request processing queue to schedule each sub-pending IO request, thereby further improving the overall IO request performance of the distributed storage system.
[0020] In an optional implementation, there are multiple IO request processing queues, and placing the current pending IO request into the target IO request processing queue includes:
[0021] Get the queue number corresponding to the IO request processing queue;
[0022] Obtain identification information of the target data management unit corresponding to the currently pending IO request;
[0023] According to the queue quantity and identification information, the current pending IO request is placed in the target IO request processing queue.
[0024] The IO scheduling method provided in the embodiment of the present application obtains the queue number corresponding to the IO request processing queue; obtains the identification information of the target data management unit corresponding to the current pending IO request; and puts the current pending IO request into the target IO request processing queue according to the queue number and the identification information, thereby ensuring the accuracy of putting the current pending IO request into the target IO request processing queue.
[0025] In an optional implementation, the identification information of the target data management unit is a position sequence identification of the target data management unit in the corresponding logical unit, and the logical unit is a unit for storing data in a storage device. According to the number of queues and the identification information, the current pending IO request is placed in the target IO request processing queue, including:
[0026] The number of queues is calculated modulo using the position sequence identifier;
[0027] According to the calculation result, a target IO request processing queue corresponding to the currently pending IO request is determined from each IO request processing queue;
[0028] Put the current pending IO request into the target IO request processing queue.
[0029] The IO scheduling method provided in the embodiment of the present application uses the position sequence identifier to perform a modulo calculation on the number of queues; according to the calculation result, the target IO request processing queue corresponding to the current pending IO request is determined from each IO request processing queue, thereby ensuring the accuracy of the determined target IO request processing queue. The current pending IO request is placed in the target IO request processing queue, thereby ensuring the accuracy of placing the current pending IO request in the target IO request processing queue.
[0030] In an optional implementation, placing the current pending IO request into the target IO request processing queue includes:
[0031] Obtain historical request data corresponding to each historical pending IO request in the target IO request processing queue;
[0032] Determine, from the target IO request processing queue, each first historical IO request to be compared whose historical request data is in the target data management unit;
[0033] Compare the target request data with the first historical request data to be compared corresponding to each first historical IO request to be compared;
[0034] According to the comparison result, the current pending IO request is placed in the target IO request processing queue.
[0035] The IO scheduling method provided in the embodiment of the present application obtains the historical request data corresponding to each historical pending IO request in the target IO request processing queue; determines from the target IO request processing queue each first historical IO request to be compared whose historical request data is in the target data management unit, thereby ensuring that the historical request data corresponding to each first historical IO request to be compared and the target request data are both in the target data management unit, so that overlapping data may exist between the historical request data corresponding to each first historical IO request to be compared and the target request data. The target request data is compared with the first historical request data to be compared corresponding to each first historical IO request to be compared, thereby ensuring the accuracy of the comparison result. Based on the comparison result, the current pending IO request is placed in the target IO request processing queue, thereby ensuring the accuracy of placing the current pending IO request in the target IO request processing queue.
[0036] In an optional implementation, according to the comparison result, placing the current pending IO request into the target IO request processing queue includes:
[0037] If there is no overlapping data between the target request data and each of the first historical request data to be compared, the current IO request to be processed is put into the target IO request processing queue.
[0038] The IO scheduling method provided in the embodiment of the present application puts the current pending IO request into the target IO request processing queue if there is no overlapping data between the target request data and each first historical request data to be compared, thereby ensuring that when processing each first historical request data to be compared, there is no pending IO request with overlapping data with each first historical IO request to be compared, thereby avoiding the situation where an IO request operation for a certain address is not completed yet, and an IO request operation for the address is often added, thereby causing data inconsistency.
[0039] In an optional implementation, according to the comparison result, placing the current pending IO request into the target IO request processing queue further includes:
[0040] If there is overlapping data between the target request data and each first historical request data to be compared, the first historical IO request to be compared having overlapping data with the target request data is determined as the target historical IO request;
[0041] Put the current pending IO request into the first target mutually exclusive linked list corresponding to the target historical IO request;
[0042] When the target historical IO request is processed, the current pending IO request is placed in the target IO request processing queue.
[0043] The IO scheduling method provided in the embodiment of the present application, if there is overlapping data between the target request data and each first historical request data to be compared, then the first historical IO request to be compared with the target request data is determined as the target historical IO request, thereby ensuring the accuracy of the determined target historical IO request. The current pending IO request is placed in the first target mutually exclusive linked list corresponding to the target historical IO request, thereby avoiding the problem of data inconsistency caused by the addition of the current pending IO request when processing the target historical IO request. When the target historical IO request is processed, the current pending IO request is placed in the target IO request processing queue, thereby avoiding the problem of data inconsistency.
[0044] In an optional implementation, when the target historical IO request is processed, the current pending IO request is placed in the target IO request processing queue, including:
[0045] When the target historical IO request is processed, each second historical IO request to be compared is obtained from the target IO request processing queue again; the historical request data corresponding to the second historical IO request to be compared is in the target data management unit;
[0046] Comparing the target request data with the second historical request data to be compared corresponding to the second historical IO request to be compared;
[0047] If there is no overlapping data between the target request data and each of the second historical request data to be compared, the current IO request to be processed is placed in the target IO request processing queue;
[0048] If there is overlapping data between the target request data and each second historical request data to be compared, the current pending IO request is placed in the second target mutually exclusive linked list, wherein the second target mutually exclusive linked list is a mutually exclusive linked list corresponding to the second historical request data to be compared that has overlapping data with the target request data.
[0049] The IO scheduling method provided by the embodiment of the present application, when the target historical IO request is processed, obtains each second historical IO request to be compared from the target IO request processing queue again, ensuring that the second historical request data to be compared and the target request data corresponding to each second historical IO request to be compared are both in the target data management unit. The target request data is compared with the second historical request data to be compared corresponding to the second historical IO request to be compared; if there is no overlapping data between the target request data and each second historical request data to be compared, the current IO request to be processed is placed in the target IO request processing queue. If there is overlapping data between the target request data and each second historical request data to be compared, the current IO request to be processed is placed in the second target mutually exclusive linked list. This avoids the situation where an IO request for a certain address has not yet been completed, and an IO request operation for the address is often added, resulting in data inconsistency problems.
[0050] In an optional implementation, comparing the target request data with the first historical request data to be compared corresponding to each first historical IO request to be compared includes:
[0051] Determine the target position offset of the target request data in the target data management unit according to the request position corresponding to the target request data;
[0052] Obtaining a historical position offset and a historical data volume of the first historical request data to be compared in the target data management unit;
[0053] According to the relationship between the target position offset, the request data volume, the historical position offset and the historical data volume, the target request data is compared with the first historical request data to be compared corresponding to each first historical IO request to be compared.
[0054] The IO scheduling method provided in the embodiment of the present application determines the target position offset of the target request data in the target data management unit according to the request position corresponding to the target request data, thereby ensuring the accuracy of the determined target position offset. The historical position offset and historical data volume of the first historical request data to be compared in the target data management unit are obtained; based on the relationship between the target position offset, the request data volume, the historical position offset and the historical data volume, the target request data is compared with the first historical request data to be compared corresponding to each first historical IO request to be compared, thereby ensuring the accuracy of the comparison result obtained.
[0055] In an optional implementation, according to the relationship between the target position offset, the request data volume, the historical position offset and the historical data volume, comparing the target request data with the first historical request data to be compared corresponding to each first historical IO request to be compared, including:
[0056] Calculate the sum of the historical position offset and the historical data volume to obtain a first total offset;
[0057] Calculate the sum of the target position offset and the requested data amount to obtain a second total offset;
[0058] comparing the target position offset with the first total offset;
[0059] Compare the historical position offset with the second total offset;
[0060] If the target position offset is greater than the first total offset, or the historical position offset is greater than the second total offset, it is determined that there is no overlapping data between the target request data and each first historical request data to be compared.
[0061] The IO scheduling method provided in the embodiment of the present application calculates the sum of the historical position offset and the amount of historical data to obtain a first total offset, thereby ensuring the accuracy of the calculated first total offset. The sum of the target position offset and the amount of requested data is calculated to obtain a second total offset, thereby ensuring the accuracy of the calculated second total offset. The target position offset is compared with the first total offset; the historical position offset is compared with the second total offset; if the target position offset is greater than the first total offset, or the historical position offset is greater than the second total offset, then it is determined that there is no overlapping data between the target request data and each first historical request data to be compared, thereby ensuring the accuracy of the determined target request data and each first historical request data to be compared.
[0062] In an optional implementation, scheduling the currently pending IO request includes:
[0063] The target processing thread is used to schedule the current pending IO request in the target IO request processing queue; the target processing thread is any one of the multiple processing threads.
[0064] The IO scheduling method provided in the embodiment of the present application utilizes a target processing thread to schedule the current pending IO request in the target IO request processing queue; the target processing thread is any one of multiple processing threads, thereby ensuring the accuracy of scheduling the current pending IO request and realizing parallel scheduling of multiple pending IO requests, further improving the overall IO request performance of the distributed storage system.
[0065] In a second aspect, the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the IO scheduling method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0066] In a third aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the IO scheduling method of the first aspect or any corresponding embodiment thereof.
[0067] In a fourth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the IO scheduling method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0069] Figure 1 is a schematic diagram of the architecture of a distributed storage system according to an embodiment of the present invention;
[0070] Figure 2 is a flow chart of a first IO scheduling method according to an embodiment of the present invention;
[0071] Figure 3 is a flow chart of a second IO scheduling method according to an embodiment of the present invention;
[0072] Figure 4 is a flow chart of a third IO scheduling method according to an embodiment of the present invention;
[0073] Figure 5 is a flow chart showing that there is no overlapping data between the first target request data and each first historical request data to be compared according to an embodiment of the present invention;
[0074] Figure 6 is a flow chart showing that there is no overlapping data between the second target request data and each first historical request data to be compared according to an embodiment of the present invention;
[0075] Figure 7 is a schematic diagram of placing a currently pending IO request into a target IO request processing queue according to an embodiment of the present invention;
[0076] Figure 8 is a flow chart showing that there is overlapping data between the first target request data and each first historical request data to be compared according to an embodiment of the present invention;
[0077] Fig. 9 is a flow chart showing that there is overlapping data between the second target request data and each first historical request data to be compared according to an embodiment of the present invention;
[0078] Fig.10 is a flow chart of mutually exclusive linked list adding logic according to an embodiment of the present invention;
[0079] Fig.11 is a flowchart of mutually exclusive linked list removal logic according to an embodiment of the present invention;
[0080] Fig.12 is a schematic diagram showing that overlapping data exists between a current to-be-processed IO request and a plurality of target historical IO requests according to an embodiment of the present invention;
[0081] Fig.13 is a schematic diagram of splitting the currently pending IO request according to an embodiment of the present invention;
[0082] Fig.14 is a schematic diagram of optimizing an IO request processing queue according to an embodiment of the present invention;
[0083] Fig.15 is an example schematic diagram of an IO scheduling method according to an embodiment of the present invention;
[0084] Fig.16 is a structural block diagram of an IO scheduling device according to an embodiment of the present invention;
[0085] Fig.17 It is a schematic diagram of the hardware structure of the electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0086] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0087] For a hyper-converged server, the final data reading and writing occurs on the distributed storage system, so the performance of the distributed storage system is of vital importance to the performance of the entire hyper-converged server. The distributed storage system provides iSCSI target services to the outside world and supports multiple iSCSI clients to initiate connection requests at the same time, that is, the storage resources of the distributed storage system are shared by all clients. Therefore, the distributed storage system will receive IO requests from different clients. These IO requests may be about the same byte interval of the same logical unit, or about different byte intervals of the same logical unit, or about the byte intervals of different logical units.
[0088] In order to improve the management efficiency of distributed storage systems, data management units are usually used as the minimum management unit of storage resources. A logical unit is composed of several data management units. The data management unit in a distributed storage system is similar to the concept of sectors in a physical disk. The smaller the data management unit, the smaller the management granularity of storage resources, the higher the IO concurrency, but the greater the disk loss (each data management unit corresponds to a metadata. Under the same disk capacity, the smaller the data management unit, the more data management units there are, the more metadata there are, the larger the disk space occupied by metadata, and the smaller the available disk space), and the lower the management efficiency; the larger the data management unit, the larger the management granularity of storage resources, the lower the IO concurrency, but the smaller the disk loss, the higher the management efficiency. At present, the industry usually sets the data management unit to 4MB.
[0089] In order to improve the IO concurrency of the distributed storage system, IO requests to different logical units and IO requests to different areas of the same logical unit can be processed concurrently to increase IO concurrency because the storage resources are independent of each other.
[0090] However, for IO requests with overlapping storage resources, for data consistency considerations, all IO requests are executed in a FIFO manner in the request processing queue, and the IO request data block is used as the granularity of IO scheduling. This execution method does solve the data consistency problem at the IO scheduling level, but it is not friendly to the overall performance of the distributed storage system, because different IO requests for the same logical unit may not be read-write related or write-write related. These requests can be scheduled for execution earlier without waiting for the requests that arrived before them to be executed.
[0091] As the parallelism of IO requests increases day by day, additional IO requests for a certain address are often made before the IO for that address is completed. In order to avoid data inconsistency, the current traditional solution must wait until the previous IO request is completed before scheduling the next IO request. In scenarios with high IO pressure, especially when there are a large number of read and write accesses to the same storage resource at the same time, the IO scheduling strategy of the traditional solution can be further optimized, and there is still room for improvement in IO concurrency, and the overall IO performance of the distributed storage system can be further improved.
[0092] Based on this, an embodiment of the present application provides an IO scheduling method, which is applied to a distributed storage system, such as Figure 1 As shown in the figure, the architecture of the distributed storage system is composed of the protocol layer, IO scheduling layer, storage engine layer, device driver layer, and physical disk from top to bottom. The protocol layer is used to receive and parse connection requests and IO requests initiated by each client. There is no mutual exclusion of storage resources involved here, so it can be carried out concurrently to the greatest extent. The IO scheduling layer no longer uses the entire IO request as the minimum scheduling unit, but processes IO requests with the data management unit as the minimum scheduling unit.
[0093] Specifically, Figure 2As shown, the processing flow of the IO scheduling method. Obtain the current pending IO request; identify the current pending IO request, determine the target request data corresponding to the current pending IO request, and ensure the accuracy of the determined target request data. Determine the request position of the target request data in the storage device and the request data volume corresponding to the target request data. When the data length of an IO request is greater than the length of a data management unit or spans two adjacent data management units aligned with 4MB (the size of the data management unit), the requested data length is divided into multiple different data management units according to 4MB alignment for concurrent scheduling. The specific implementation is described below; when there are multiple IO requests for data in the same data management unit at the same time, the concurrent IO scheduling granularity is reduced according to the overlap of the data interval in each IO request, thereby increasing the IO concurrency. The storage engine layer is used to manage physical disks (multiple data on a logical unit may be distributed on multiple disks). The device driver layer is used to connect physical disks and software operating systems. Physical disks are used to store user data.
[0094] It should be noted that the IO scheduling method provided in the embodiment of the present application may be executed by an IO scheduling device, which may be implemented as part or all of an electronic device through software, hardware, or a combination of software and hardware, wherein the electronic device may be a server or a terminal, wherein the server in the embodiment of the present application may be a single server or a server cluster composed of multiple servers, and the terminal in the embodiment of the present application may be a smart phone, a personal computer, a tablet computer, a wearable device, an intelligent robot, or other intelligent hardware devices. In the following method embodiments, the execution subject is an electronic device as an example for explanation.
[0095] According to an embodiment of the present invention, an IO scheduling method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0096] In this embodiment, an IO scheduling method is provided, which can be used for the above-mentioned electronic device. Figure 3 is a flow chart of an IO scheduling method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0097] Step S101, obtaining the currently pending IO request.
[0098] Specifically, the electronic device may receive the current pending IO request input by the user, or may receive the current pending IO request sent by other devices. The embodiment of the present application does not specifically limit the manner in which the electronic device obtains the current pending IO request.
[0099] Step S102: Identify the current pending IO request and determine the target request data corresponding to the current pending IO request.
[0100] Specifically, the electronic device may identify the current pending IO request and determine the target request data corresponding to the current pending IO request.
[0101] Step S103: determine the requested position of the target requested data in the storage device and the requested data volume corresponding to the target requested data.
[0102] Specifically, the electronic device identifies the target request data corresponding to the currently-to-be-processed IO request, and determines the request position of the target request data in the storage device and the request data volume corresponding to the target request data.
[0103] Step S104: according to the request position and the request data volume corresponding to the target request data, the current pending IO request is put into the target IO request processing queue, and the current pending IO request is scheduled.
[0104] Optionally, the electronic device may compare the request data volume corresponding to the target request data with a preset request data volume threshold.
[0105] If the request data volume corresponding to the target request data is not greater than the preset request data volume threshold, the current pending IO request is placed in the target IO request processing queue according to the request position corresponding to the target request data, and the current pending IO request is scheduled.
[0106] If the request data volume corresponding to the target request data is greater than the preset request data volume threshold, the current pending IO request is split according to the target request data to obtain multiple sub-pending IO requests. Then, according to the sub-request position corresponding to the sub-target data corresponding to each sub-pending IO request, each sub-pending IO request is placed in the corresponding target IO request processing queue, and the multiple sub-pending IO requests are scheduled.
[0107] The IO scheduling method provided in the embodiment of the present application obtains the current pending IO request; identifies the current pending IO request, determines the target request data corresponding to the current pending IO request, and ensures the accuracy of the determined target request data. Determine the request position of the target request data in the storage device and the request data volume corresponding to the target request data, put the current pending IO request into the target IO request processing queue according to the request position and request data volume corresponding to the target request data, schedule the current pending IO request, ensure the accuracy of putting the current pending IO request into the target IO request processing queue, and then schedule the current pending IO request from the target IO request processing queue, ensure the accuracy of scheduling the current pending IO request. In this way, it is possible to process the pending IO requests in multiple IO request processing queues simultaneously, and then there is no need to wait for the previous pending IO request to be completed before scheduling the next pending IO request, thereby further improving the overall IO request performance of the distributed storage system.
[0108] In this embodiment, an IO scheduling method is provided, which can be used for the above-mentioned electronic device. Figure 4 is a flow chart of an IO scheduling method according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:
[0109] Step S201, obtaining the currently pending IO request.
[0110] For more information about this step, see Figure 3 The introduction of step S101 is not repeated here.
[0111] Step S202: Identify the current pending IO request and determine the target request data corresponding to the current pending IO request.
[0112] For more information about this step, see Figure 3 The introduction of step S102 is not repeated here.
[0113] Step S203: determine the requested position of the target requested data in the storage device and the requested data volume corresponding to the target requested data.
[0114] For more information about this step, see Figure 3 The introduction of step S103 is not repeated here.
[0115] Step S204: according to the request position and the request data volume corresponding to the target request data, the current pending IO request is put into the target IO request processing queue, and the current pending IO request is scheduled.
[0116] Specifically, the above step S204 of “putting the current pending IO request into the target IO request processing queue according to the request position and the request data volume corresponding to the target request data” may include the following steps:
[0117] Step S2041, determining the number of target data management units corresponding to the target request data according to the request position and the request data amount corresponding to the target request data.
[0118] Specifically, the electronic device may determine the number of target data management units corresponding to the target request data according to the request position and the request data amount corresponding to the target request data.
[0119] Among them, the target data management unit is the smallest data management unit of the distributed storage system, and each target data management unit has unique identification information. The distributed storage system may include many logical units, and each logical unit includes many data management units. The data storage capacity corresponding to each data management unit can be 4M, 3M, or other storage capacities. The embodiment of the present application does not specifically limit the data storage capacity corresponding to each data management unit.
[0120] Specifically, the electronic device can determine the target logical unit corresponding to the target request data and the offset of the target request position in the target logical unit according to the request position corresponding to the target request data, thereby determining the data management unit corresponding to the starting address of the target request data, and then determine the data management unit corresponding to the ending address of the target request data according to the data volume corresponding to the target request data. If they correspond to the same data management unit, the number of target data management units is 1. If the starting address and the ending address of the target request data correspond to different data management units, the number of target data management units is not 1.
[0121] Step S2042: if the number of the target data management unit is 1, then according to the target data management unit, the current to-be-processed IO request is placed into the target IO request processing queue corresponding to the target data management unit.
[0122] In an optional implementation of the present application, there are multiple IO request processing queues, and the above step S2042 may include the following steps:
[0123] Step a1, obtaining the queue number corresponding to the IO request processing queue.
[0124] Specifically, the electronic device can receive the queue number corresponding to the IO request processing queue set by the user, and can also receive the queue number corresponding to the IO request processing queue sent by other devices. The electronic device can also calculate the queue number corresponding to the IO request processing queue based on the number of logical units in the distributed storage system and the number of data management units included in each logical unit.
[0125] Exemplarily, for the same logical unit, the number of data management units included in each logical unit is divided by 3 to obtain the number of queues corresponding to the IO request processing queue.
[0126] Step a2, obtaining identification information of the target data management unit corresponding to the currently pending IO request.
[0127] Specifically, the electronic device may determine the target data management unit and the identification information of the target data management unit according to the start address and the end address of the target request data.
[0128] Step a3: according to the queue quantity and identification information, the currently pending IO request is placed in the target IO request processing queue.
[0129] Specifically, the identification information of the target data management unit is the position sequence identification of the target data management unit in the corresponding logical unit. The logical unit is a unit for storing data in the storage device. The above step a3 may include the following steps:
[0130] Step a31, performing modulo calculation on the number of queues using the position sequence identifier.
[0131] Specifically, the electronic device uses the position sequence identifier to perform a modulo calculation on the number of queues.
[0132] Step a32: According to the calculation result, a target IO request processing queue corresponding to the currently pending IO request is determined from each IO request processing queue.
[0133] Specifically, the electronic device determines, from each IO request processing queue, a target IO request processing queue corresponding to the currently pending IO request according to the calculation result.
[0134] Exemplarily, assuming that the number of queues is 3, the electronic device uses the position sequence of the target data management unit in the corresponding logical unit to identify, and the logical unit is a unit for storing data in the storage device, and takes the remainder after dividing by 3. If the remainder is 0, the target IO request processing queue corresponding to the current pending IO request is determined from each IO request processing queue to be IO request processing queue 0; if the remainder is 1, the target IO request processing queue corresponding to the current pending IO request is determined from each IO request processing queue to be IO request processing queue 1; if the remainder is 2, the target IO request processing queue corresponding to the current pending IO request is determined from each IO request processing queue to be IO request processing queue 2.
[0135] Step a33, putting the current pending IO request into the target IO request processing queue.
[0136] Optionally, after determining the target IO request processing queue corresponding to the currently pending IO request, the currently pending IO request may be placed in the target IO request processing queue.
[0137] Specifically, the above step a33 may include the following steps:
[0138] Step a331, obtaining historical request data corresponding to each historical pending IO request in the target IO request processing queue.
[0139] Specifically, the electronic device can obtain each historical pending IO request in the target IO request processing queue from the target IO request processing queue, identify each historical pending IO request, and determine the historical request data corresponding to each historical pending IO request and the historical data management unit corresponding to the historical request data.
[0140] Step a332: determine, from the target IO request processing queue, each first historical IO request to be compared whose historical request data is in the target data management unit.
[0141] Specifically, the electronic device compares the historical data management unit corresponding to the historical request data corresponding to each historical IO request to be processed with the target data management unit. Then, the first historical IO requests to be compared whose historical request data are in the target data management unit are determined from the target IO request processing queue. That is, the historical data management unit corresponding to the historical request data corresponding to each first historical IO request to be compared is consistent with the target data management unit corresponding to the target request data.
[0142] Step a333: compare the target request data with the first historical request data to be compared corresponding to each first historical IO request to be compared.
[0143] Specifically, the above step a333 may include the following steps:
[0144] Step a3331, determining the target position offset of the target request data in the target data management unit according to the request position corresponding to the target request data.
[0145] Specifically, the electronic device may determine the target position offset of the target request data in the target data management unit according to the request position corresponding to the target request data.
[0146] Step a3332, obtaining the historical position offset and historical data volume of the first historical request data to be compared in the target data management unit.
[0147] Specifically, the electronic device may identify the first historical request data to be compared corresponding to the first historical IO request to be compared, and determine the historical position offset and historical data volume of the first historical request data to be compared in the target data management unit.
[0148] Step a3333, comparing the target request data with the first to-be-compared historical request data corresponding to each first to-be-compared historical IO request according to the relationship between the target position offset, the request data volume, the historical position offset and the historical data volume.
[0149] Specifically, the above step a3333 may include the following steps:
[0150] Step a33331, calculate the sum of the historical position offset and the historical data volume to obtain the first total offset.
[0151] Specifically, the electronic device calculates the sum of the historical position offset and the historical data volume to obtain a first total offset.
[0152] Step a33332, calculate the sum of the target position offset and the requested data amount to obtain the second total offset.
[0153] Specifically, the electronic device calculates the sum of the target position offset and the requested data amount to obtain a second total offset.
[0154] Step a33333, compare the target position offset with the first total offset.
[0155] Step a33334, compare the historical position offset with the second total offset.
[0156] Step a33335: if the target position offset is greater than the first total offset, or the historical position offset is greater than the second total offset, it is determined that there is no overlapping data between the target request data and each first historical request data to be compared.
[0157] Specifically, the electronic device compares the target position offset with the first total offset, and compares the historical position offset with the second total offset.
[0158] If the target position offset is greater than the first total offset, or the historical position offset is greater than the second total offset, it is determined that there is no overlapping data between the target request data and each first historical request data to be compared.
[0159] Exemplarily, as Figure 5 shown, it is a schematic diagram of the case where the historical position offset is greater than the second total offset. Figure 5 In it, the upper part is the current IO request to be processed, and the lower part is the first historical IO request to be compared. Among them, the end position of the target data corresponding to the current IO request to be processed is smaller than the start position of the first historical request data of the first historical IO request to be compared, that is, a_offset + a_len < b_offset, then it is determined that there is no overlapping data between the target request data and each first historical request data to be compared.
[0160] As Figure 6 shown, it is a schematic diagram of the case where the target position offset is greater than the first total offset. Figure 6 In it, the upper part is the current IO request to be processed, and the lower part is the first historical IO request to be compared. Among them, the start position of the target data corresponding to the current IO request to be processed is greater than the end position of the first historical request data of the first historical IO request to be compared, that is, a_offset > b_offset + b_len, then it is determined that there is no overlapping data between the target request data and each first historical request data to be compared.
[0161] Step a334, according to the comparison result, put the current IO request to be processed into the target IO request processing queue.
[0162] Specifically, the above step a334 may include the following steps:
[0163] Step a3341, if there is no overlapping data between the target request data and each first historical request data to be compared, then put the current IO request to be processed into the target IO request processing queue.
[0164] Specifically, if there is no overlapping data between the target request data and each first historical request data to be compared, then put the current IO request to be processed into the target IO request processing queue.
[0165] Exemplarily, as Figure 7 shown, if there is no overlapping data between the target request data and each first historical request data to be compared, then it is a schematic diagram of putting the current IO request to be processed into the target IO request processing queue.
[0166] Step a3342: if there is overlapping data between the target request data and each of the first historical request data to be compared, the first historical IO request to be compared that has overlapping data with the target request data is determined as the target historical IO request.
[0167] Specifically, if there is overlapping data between the target request data and each first historical request data to be compared, the first historical IO request to be compared having overlapping data with the target request data is determined as the target historical IO request.
[0168] Step a3343, putting the current pending IO request into the first target mutually exclusive linked list corresponding to the target historical IO request.
[0169] Specifically, the electronic device puts the current to-be-processed IO request into the first target mutually exclusive linked list corresponding to the target historical IO request according to the identification information corresponding to the target historical IO request.
[0170] like Figure 8 As shown, obj_1c is the current pending IO request, and obj_1a is the target historical IO request. Since the target request data of the current pending IO request overlaps with the data interval of the first first historical IO request to be compared in the target data management unit in the target IO request processing queue, that is, there is a storage resource competition mutual exclusion, it is necessary to first hang the current pending IO request on the mutually exclusive linked list of the first first historical IO request to be compared with the overlapping data interval, and after the processing is completed, the current pending IO request on the mutually exclusive linked list will be re-attempted to be added to the target IO request processing queue.
[0171] like Fig. 9 As shown, obj_1c is the current pending IO request, and obj_1b is the target historical IO request. Since the target request data of the current pending IO request overlaps with the data interval of the first historical IO request to be compared in the target data management unit in the target IO request processing queue, that is, there is no storage resource competition and mutual exclusion, the two can be processed concurrently. However, the data interval of the second first historical IO request to be compared in the target data management unit in the target IO request processing queue overlaps, that is, there is storage resource competition and mutual exclusion, so it is necessary to first hang the current pending IO request on the mutually exclusive linked list of the second first historical IO request to be compared with the data interval overlap, and after its processing is completed, the current pending IO request on the mutually exclusive linked list will be retried to be added to the target IO request processing queue.
[0172] In an optional embodiment of the present application, Fig.10As shown, it is a flowchart for adding logic to a mutually exclusive linked list. First, determine the type of the OBJ request. If the OBJ request is not a read-write IO request, then end directly, because other IO requests such as management and query do not require real IO read-write processing, so there is no need to execute the relevant logic involved in this method. If the OBJ request is a read-write IO request, then determine whether the target IO request processing queue is empty. If it is empty, add it directly to the end of the queue. Otherwise, it is necessary to traverse the target IO request processing queue in order from the head to the end of the queue. If it is found that there is a target historical IO request on the target IO request processing queue that has the same oid as the current pending IO request (that is, both are in the target data management unit) and has an overlapping data interval, then further determine whether the linked list of the target historical IO request has been initialized. If not, initialize it and use it as the linked list head of the mutually exclusive linked list, then add the current pending IO request to the end of the mutually exclusive linked list, and end. If no target historical IO request with the same OID as the current pending IO request and overlapping data interval is found in the target IO request processing queue, the current pending IO request is added to the tail of the IO request processing queue and the process ends.
[0173] The mutually exclusive linked list supports multiple pending requests at the same time. OBJ requests are required to be placed at the end of the linked list in chronological order. Inserting pending requests in the middle of the linked list is not allowed.
[0174] Step a3344, when the target historical IO request is processed, the current pending IO request is placed in the target IO request processing queue.
[0175] In an optional implementation of the present application, when the target historical IO request is processed, it is necessary to remove the target historical IO request from the target IO request processing queue, and at the same time remove the current pending IO request with overlapping data intervals from the mutually exclusive linked list corresponding to the target historical IO request, and try to re-join the target IO request processing queue. The specific implementation logic is as follows: Fig.11 shown. Fig.11This is a flowchart of the mutex list removal logic. For the target historical IO request that is about to be dequeued, first determine whether the mutex list of the target historical IO request has been initialized and is not empty. If the mutex list on the target historical IO request has not been initialized, it means that the target historical IO request has no history of data area overlap, and the target historical IO request can be directly removed from the target IO request processing queue; if the mutex list on the target historical IO request has been initialized, but the list is empty, it means that the target historical IO request has a history of data area overlap, but there is currently no storage resource mutual exclusion, and it can be directly removed from the target IO request processing queue; if the mutex list on the target historical IO request has been initialized and is not empty, the following processing is required. First, use a temporary linked list header to temporarily store the mutex linked list on the target historical IO request (to prevent the loss of IO mutex linked list information on the target historical IO request), then remove the target historical IO request from the mutex linked list, and then remove the target historical IO request from the target IO request processing queue, and then traverse the previously stored mutex linked list through the temporary linked list header, and perform the following operations on other pending IO requests on the exclusion list in sequence: remove the other pending IO requests from the mutex linked list, and try to re-add them to the target IO request processing queue according to the mutex linked list addition logic in the previous article.
[0176] Specifically, the above step a3344 may include the following steps:
[0177] Step a33441: when the target historical IO request is processed, the second historical IO requests to be compared are obtained again from the target IO request processing queue.
[0178] The historical request data corresponding to the second historical IO request to be compared is in the target data management unit.
[0179] Specifically, when the target historical IO request is processed, each second historical IO request to be compared is obtained again from the target IO request processing queue.
[0180] Step a33442, comparing the target request data with the second historical request data to be compared corresponding to the second historical IO request to be compared.
[0181] Specifically, the electronic device compares the target request data with the second historical request data to be compared corresponding to the second historical IO request to be compared.
[0182] Step a33443: if there is no overlapping data between the target request data and each of the second historical request data to be compared, the current IO request to be processed is placed in the target IO request processing queue.
[0183] Specifically, if there is no overlapping data between the target request data and each of the second historical request data to be compared, the electronic device puts the current IO request to be processed into the target IO request processing queue.
[0184] Step a33444: if there is overlapping data between the target request data and each second historical request data to be compared, the current pending IO request is put into the second target mutually exclusive linked list.
[0185] The second target mutually exclusive linked list is a mutually exclusive linked list corresponding to the second historical request data to be compared that has overlapping data with the target request data.
[0186] Specifically, if there is overlapping data between the target request data and each second historical request data to be compared, the current IO request to be processed is put into the second target mutually exclusive linked list.
[0187] For example, Fig.12 As shown, there is a schematic diagram of overlapping data between the current pending IO request and multiple target historical IO requests. Since the target request data of the current pending IO request overlaps with the data interval of the first first historical IO request to be compared in the target data management unit in the target IO request processing queue, that is, there is competition and mutual exclusion for storage resources, it is necessary to first hang the current pending IO request on the mutually exclusive linked list of the first first historical IO request to be compared with the overlapping data interval, and after its processing is completed, the current pending IO request on the mutually exclusive linked list will be re-attempted to be added to the target IO request processing queue. The reason for choosing to hang on the first first historical IO request to be compared here is: when traversing the target IO request processing queue, follow the traversal order from beginning to end. When an overlap is found, there is no need to continue traversing to improve performance.
[0188] Then, when the target historical IO request is processed, each second historical IO request to be compared is obtained from the target IO request processing queue again. The target request data is compared with the second historical request data to be compared corresponding to the second historical IO request to be compared. If there is overlapping data between the target request data and each second historical request data to be compared, the current IO request to be processed is placed in the second target mutually exclusive linked list.
[0189] Step S2043: if the number of target data management units is greater than 1, the current pending IO request is split according to the number of target data management units to obtain multiple sub-pending IO requests.
[0190] The number of the sub-to-be-processed IO requests is consistent with the number of the target data management units.
[0191] For example, Fig.13As shown in the figure, the logical unit is composed of several data management units. If the target request data is a data block with an offset of offset and a length of len on the logical unit, and the data block falls on 3 data management units after being divided according to 4MB alignment, then the current pending IO request is split into requests for 3 different data management units, which can participate in the IO scheduling strategy of the distributed storage system respectively. Therefore, the number of target data management units is 3.
[0192] Step S2044: according to the target data management unit corresponding to each sub-to-be-processed IO request, each sub-to-be-processed IO request is placed into the corresponding target IO request processing queue to schedule each sub-to-be-processed IO request.
[0193] Specifically, the process of placing each sub-pending IO request into the corresponding target IO request processing queue can refer to the process in the above implementation mode of "if the number of target data management units is 1, then according to the target data management unit, the current pending IO request is placed in the target IO request processing queue corresponding to the target data management unit", which will not be repeated here.
[0194] Specifically, the "scheduling the current pending IO request" in the above step S204 may include the following steps:
[0195] Step S2045: use the target processing thread to schedule the current pending IO request in the target IO request processing queue.
[0196] The target processing thread is any one of the multiple processing threads.
[0197] For example, Fig.14 As shown in the figure, it is a schematic diagram of optimizing the IO request processing queue. Each IO request processing queue is managed by a thread (not a worker thread in the thread pool), which is mainly responsible for traversing the IO request processing queue, enqueuing and dequeuing the data management unit request, and managing the mutually exclusive linked list. When a new data management unit request comes to the IO scheduling layer, a modulo operation is performed on its oid (i.e., the remainder of the oid number divided by 3 is calculated). If the result is 0, the data management unit request is placed on the first IO request processing queue for processing. If the result is 1, the data management unit request is placed on the second IO request processing queue for processing. If the result is 2, the data management unit request is placed on the third IO request processing queue for processing. In this way, the IO request processing queue is split from the original one into three, which can shorten the length of the IO request processing queue and reduce the time spent on traversing the IO request processing queue, thereby improving the management efficiency of the IO request processing queue. The management method of each IO request processing queue is consistent, as mentioned above.
[0198] By default, worker threads in the thread pool are evenly distributed to each IO request processing queue to process data management unit requests. When the load of IO request processing queues is uneven, the worker threads in the thread pool can be dynamically balanced among multiple IO request processing queues to maximize the concurrent processing capabilities of the thread pool and try to ensure the processing speed of each queue.
[0199] The IO scheduling method provided in the embodiment of the present application determines the number of target data management units corresponding to the target request data according to the request position and the amount of request data corresponding to the target request data, thereby ensuring the accuracy of the number of target data management units corresponding to the determined target request data. If the number of target data management units is 1, the number of queues corresponding to the IO request processing queue is obtained; the identification information of the target data management unit corresponding to the currently pending IO request is obtained; the number of queues is calculated modulo using the position sequence identification; and according to the calculation result, the target IO request processing queue corresponding to the currently pending IO request is determined from each IO request processing queue, thereby ensuring the accuracy of the determined target IO request processing queue.
[0200] Obtain the historical request data corresponding to each historical pending IO request in the target IO request processing queue; determine from the target IO request processing queue the historical request data of each first historical IO request to be compared in the target data management unit, ensuring that the historical request data and the target request data corresponding to each first historical IO request to be compared are both in the target data management unit, so that overlapping data may exist between the historical request data and the target request data corresponding to each first historical IO request to be compared. According to the request position corresponding to the target request data, determine the target position offset of the target request data in the target data management unit, ensuring the accuracy of the determined target position offset. Obtain the historical position offset and the historical data volume of the first historical request data to be compared in the target data management unit; calculate the sum of the historical position offset and the historical data volume to obtain the first total offset, ensuring the accuracy of the calculated first total offset. Calculate the sum of the target position offset and the request data volume to obtain the second total offset, ensuring the accuracy of the calculated second total offset. The target position offset is compared with the first total offset; the historical position offset is compared with the second total offset; if the target position offset is greater than the first total offset, or the historical position offset is greater than the second total offset, it is determined that there is no overlapping data between the target request data and each first historical request data to be compared, thereby ensuring the accuracy of the determination that there is no overlapping data between the target request data and each first historical request data to be compared.
[0201] If there is no overlapping data between the target request data and each first historical request data to be compared, the current pending IO request will be placed in the target IO request processing queue, thereby ensuring that when processing each first historical request data to be compared, there is no pending IO request with overlapping data with each first historical IO request to be compared, thereby avoiding the situation where an IO request operation for a certain address is frequently added when the IO request for the address has not yet been completed, thereby causing data inconsistency problems.
[0202] If there is overlapping data between the target request data and each first historical request data to be compared, the first historical IO request to be compared with the target request data will be determined as the target historical IO request, thereby ensuring the accuracy of the determined target historical IO request. The current pending IO request is placed in the first target mutually exclusive linked list corresponding to the target historical IO request, thereby avoiding the problem of data inconsistency caused by the addition of the current pending IO request when processing the target historical IO request. When the target historical IO request is processed, the current pending IO request is placed in the target IO request processing queue, thereby avoiding the problem of data inconsistency.
[0203] When the target historical IO request is processed, each second historical IO request to be compared is obtained from the target IO request processing queue again, ensuring that the second historical request data to be compared and the target request data corresponding to each second historical IO request to be compared are both in the target data management unit. Compare the target request data with the second historical request data to be compared corresponding to the second historical IO request to be compared; if there is no overlapping data between the target request data and each second historical request data to be compared, put the current IO request to be processed into the target IO request processing queue. If there is overlapping data between the target request data and each second historical request data to be compared, put the current IO request to be processed into the second target mutually exclusive linked list. This avoids the situation where an IO request for a certain address has not yet been completed, and an additional IO request operation for the address is often performed, resulting in data inconsistency.
[0204] If the number of target data management units is greater than 1, the current pending IO request is split according to the number of target data management units to obtain multiple sub-pending IO requests, thereby ensuring the accuracy of splitting the current pending IO request to obtain multiple sub-pending IO requests. According to the target data management unit corresponding to each sub-pending IO request, each sub-pending IO request is placed in the corresponding target IO request processing queue to schedule each sub-pending IO request, thereby ensuring the accuracy of placing each sub-pending IO request in the corresponding target IO request processing queue to schedule each sub-pending IO request, thereby further improving the overall IO request performance of the distributed storage system.
[0205] The target processing thread is used to schedule the current pending IO request in the target IO request processing queue; the target processing thread is any one of multiple processing threads, thereby ensuring the accuracy of scheduling the current pending IO request and realizing parallel scheduling of multiple pending IO requests, further improving the overall IO request performance of the distributed storage system.
[0206] In order to better introduce the IO scheduling method introduced in the embodiment of the present application, the embodiment of the present application provides a specific implementation method of a concurrent IO scheduling method based on data interval mutual exclusion. Fig.15 Take the example to describe the implementation of the technology of the present invention in detail.
[0207] Assume that the total capacity of the target logical unit to be accessed is 12MB, which is composed of three data management units of 4MB (obj_size) in size (numbered starting from 0 and increasing in sequence), namely obj_0, obj_1, and obj_2. Their corresponding oids are 0x0000123400000000, 0x0000123400000001, and 0x0000123400000002. Two IO read and write requests IO_req1 and IO_req2 are performed consecutively. The offset offset_1 of IO_req1 request is 3MB, and the length len_1 is 3MB. The offset offset_2 of IO_req2 request is 5MB, and the length len_2 is 4MB.
[0208] When the distributed storage system is initialized, the first threshold worker_num is configured to 3, that is, the maximum number of worker threads in the thread pool is 3, numbered from 0. The multiple IO request processing queue feature is enabled, and the second threshold queue_num is configured to 3, that is, there are 3 IO request processing queues at the same time, numbered from 0. At the same time, the thread pool balancing technology is enabled by default, and the 3 worker threads worker_num are evenly distributed on the 3 IO request processing queues to process IO requests.
[0209] First, the distributed storage system receives the IO write request IO_req1 and checks to find that the requested data interval spans two data management units and needs to be split. The checking and splitting methods are as follows:
[0210] (1) Calculate the data management unit where the starting address of the requested data block is located;
[0211] offset_1 / obj_size=3 / 4=0……3;
[0212] That is, the starting address is located at the 0th data management unit, namely obj_0.
[0213] (2) Calculate in which data management unit the end address of the requested data block is located;
[0214] (offset_1+len_1) / obj_size=(3+3) / 4=1……2;
[0215] That is, the end address is located at the first data management unit, namely obj_1.
[0216] (3) Determine whether the IO request needs to be split;
[0217] The data management unit where the start address is located and the data management unit where the end address is located are not on the same data management unit, so they need to be aligned according to obj_size, and the IO request is split into two data management unit requests for separate IO scheduling.
[0218] The first sub-IO_req1 request is obj_0a_p1, the offset offset_a_p1 in obj_0 is 3MB, and the length len_a_p1 is 1MB;
[0219] The second sub-IO_req1 request is obj_1a_p2, the offset offset_a_p2 in obj_1 is 0, and the length len_a_p2 is 2MB;
[0220] Then the two sub-IO requests obj_0a_p1 and obj_1a_p2 are put on the IO request processing queue for scheduling. Here is a supplementary explanation of the naming: "obj_0" means the target data management unit is obj_0, "a" means the first concurrent IO request, "p1", "p2" means splitting the IO request into two data management unit requests.
[0221] (4) Perform a modulo operation on the oid of the data management unit to be accessed by the first data management unit request obj_0a_p1:
[0222] oid%queue_num=0x0000123400000000 / 3=0
[0223] That is, the first sub-IO_req1 request obj_0a_p1 should be placed on the 0th IO request processing queue. Since the sub-IO_req1 is a read-write IO request and the IO request processing queue 0 is empty at this time, it can be directly queued.
[0224] (5) Perform a modulo operation on the oid of the data management unit to be accessed by the second data management unit request obj_1a_p2:
[0225] oid%queue_num=0x0000123400000001 / 3=1
[0226] That is, the second sub-IO_req1obj_1a_p2 should be placed on the first IO request processing queue. Since the sub-IO_req1 request is a read-write IO request and the IO request processing queue 1 is empty at this time, it can be directly queued.
[0227] Then, the sub-IO_req1 request is scheduled by IO, and the worker thread in the thread pool starts processing IO.
[0228] Before the IO write request IO_req1 is processed, the distributed storage system concurrently receives the IO read request IO_req2. After checking, it is found that the requested data interval spans two data management units and needs to be split. The checking and splitting methods are as follows:
[0229] (6) Calculate in which data management unit the starting address of the requested data block is located;
[0230] offset_2 / obj_size=5 / 4=1……1
[0231] That is, the starting address is located at the first data management unit, namely obj_1.
[0232] (7) Calculate in which data management unit the end address of the requested data block is located;
[0233] (offset_1+len_1) / obj_size=(5+4) / 4=2I……1
[0234] That is, the end address is located at the second data management unit, namely obj_2.
[0235] (8) Determine whether the IO request needs to be split;
[0236] The data management unit where the start address is located and the data management unit where the end address is located are not on the same data management unit, so they need to be aligned according to obj_size, and the IO request is split into two data management unit requests for separate IO scheduling.
[0237] The first sub-IO_req2 request is obj_1b_p1, the offset offset_b_p1 in obj_1 is 1MB, and the length len_b_p1 is 3MB;
[0238] The second sub-IO_req2 request is obj_2b_p2, the offset offset_b_p2 in obj_2 is 0, and the length len_b_p2 is 1MB;
[0239] Then the two sub-IO_req2 requests obj_1b_p1 and obj_2b_p2 are placed on the IO request processing queue for scheduling.
[0240] (9) Perform a modulo operation on the oid of the data management unit to be accessed by the first sub-IO_req2 request obj_1b_p1:
[0241] oid%queue_num=0x0000123400000001%3=1
[0242] That is, the first data management unit request obj_1b_p1 should be placed on the first IO request processing queue.
[0243] The data management unit request is a read-write IO request. At this time, the IO request processing queue 1 is not empty, so it is necessary to traverse the IO request processing queue 1 first to check whether there is already a data management unit request on the target IO request processing queue that overlaps with the data interval of the new data management unit request. It is found that the existing data management unit request obj_1a_p2 and the new data management unit request obj_1b_p1 both need to access the obj_1 storage resource with oid 0x0000123400000001, so it is necessary to further determine whether the data intervals of the two data management unit requests overlap, that is, determine the size of the start address and end address of the data intervals of the two data management unit requests in obj_1:
[0244] The starting address of obj_1a_p2 in obj_1: offset_a_p2 = 0 (MB)
[0245] The data end address of obj_1a_p2 in obj_1: offset_a_p2+len_a_p2=0+2=2(MB)
[0246] That is, the data range of obj_1a_p2 in obj_1 is: [0,2]MB
[0247] The starting address of obj_1b_p1 in obj_1: offset_b_p1=1(MB)
[0248] The data end address of obj_1b_p1 in obj_1: offset_b_p2+len_b_p2=1+3=4(MB)
[0249] That is, the data range of obj_1b_p1 in obj_1 is: [1,4]MB
[0250] The data interval [0,2]MB overlaps with the data interval [1,4]MB, so you need to first hang obj_1b_p1 on the IO mutex list. The specific operations are as follows:
[0251] If it is found that the linked list of obj_1a_p2 is not initialized, the linked list is aligned and initialized, and used as the head of the IO mutual exclusion linked list, and then the new data management unit request obj_1b_p1 is added to the tail of the IO mutual exclusion linked list. At this time, the new data management unit request obj_1b_p1 does not participate in the IO scheduling. It is necessary to wait for the data management unit request obj_1a_p2 to be completed before trying to add the new data management unit request obj_1b_p1 to the IO request processing queue for scheduling.
[0252] (10) Perform a modulo operation on the oid of the data management unit to be accessed by the second data management unit request obj_2b_p2:
[0253] oid%queue_num=0x0000123400000002%3=2
[0254] That is, the second data management unit request obj_2b_p2 should be placed on the second IO request processing queue. However, the data management unit request is a read-write IO request and the IO request processing queue 2 is empty at this time, so it can be directly queued.
[0255] Since then, one data management unit request on each of the three IO request processing queues is being processed concurrently by the worker thread in the thread pool, and there is another data management unit request on IO request processing queue 1 waiting for scheduling.
[0256] When the data management unit request obj_0a_p1 on the IO request processing queue 0 is processed, the data management unit request needs to be removed from the IO request processing queue. The specific process is as follows: Checking and finding that the linked list on the data management unit request is not initialized, the data management unit request can be directly removed from the IO request processing queue.
[0257] When the data management unit request obj_1a_p2 on the IO request processing queue 1 is processed, the data management unit request needs to be removed from the IO request processing queue 1. The specific process is as follows: Check and find that the linked list on the data management unit request has been initialized and is not empty. First, use a temporary linked list header to temporarily store the data management unit request, then remove the data management unit request from the IO mutual exclusion linked list, and then remove the data management unit request from the IO request processing queue 1. Then traverse the IO mutual exclusion linked list through the temporary linked list header, take out the data management unit request obj_1b_p1 on the IO mutual exclusion linked list (that is, remove the data management unit request from the IO mutual exclusion linked list), and then try to re-add it to the IO request processing queue 1. At this time, the IO request processing queue 1 is empty, and it can be directly added to the end of the queue. At this time, the IO mutual exclusion linked list traversal is completed and ends here. At this time, the two data management unit requests obj_0a_p1 and obj_1a_p2 split from the IO write request IO_req1 have been processed, and the results can be merged and returned to the user.
[0258] When the data management unit request obj_2a_p2 on the IO request processing queue 2 is processed, the data management unit request needs to be removed from the IO request processing queue. The specific process is as follows: Checking and finding that the linked list on the data management unit request is not initialized, the data management unit request can be directly removed from the IO request processing queue.
[0259] At this time, there is only the data management unit request obj_1b_p1 on the IO request linked list. After the data management unit request is completed, the two data management unit requests obj_1b_p1 and obj_2b_p2 split from the IO read request IO_req2 have been processed and the results are merged and returned to the user.
[0260] In this embodiment, an IO scheduling device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0261] This embodiment provides an IO scheduling device, such as Fig.16 As shown, including:
[0262] The acquisition module 501 is used to acquire the current pending IO request;
[0263] A first determination module 502 is used to identify the current pending IO request and determine the target request data corresponding to the current pending IO request;
[0264] A second determination module 503 is used to determine the request position of the target request data in the storage device and the request data volume corresponding to the target request data;
[0265] The scheduling module 504 is used to put the current pending IO request into a target IO request processing queue according to the request position and the request data volume corresponding to the target request data, and schedule the current pending IO request.
[0266] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0267] The IO scheduling device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0268] The embodiment of the present invention also provides an electronic device having the above Fig.17 The IO scheduling device shown.
[0269] See also Fig.17 , Fig.17 is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present invention, such as Fig.17 As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.17 A processor 10 is taken as an example.
[0270] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0271] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0272] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0273] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0274] The electronic device further includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Fig.17 The example of connecting through bus is taken in the following.
[0275] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0276] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0277] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0278] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. An IO scheduling method, characterized in that: The method comprises: Get the current pending IO request; Identify the current pending IO request and determine the target request data corresponding to the current pending IO request; Determine a request position of the target request data in a storage device and a request data volume corresponding to the target request data; According to the request position and the request data amount corresponding to the target request data, the current pending IO request is placed into a target IO request processing queue, and the current pending IO request is scheduled; The step of placing the current pending IO request into a target IO request processing queue according to the request position and the request data volume corresponding to the target request data includes: Determining the number of target data management units corresponding to the target request data according to the request position and the request data amount corresponding to the target request data; If the number of the target data management unit is 1, then according to the target data management unit, the current pending IO request is placed in the target IO request processing queue corresponding to the target data management unit; If the number of the target data management units is greater than 1, the current pending IO request is split according to the number of the target data management units to obtain a plurality of sub-pending IO requests; the number of the sub-pending IO requests is consistent with the number of the target data management units; According to the target data management unit corresponding to each of the sub-pending IO requests, each of the sub-pending IO requests is placed into the corresponding target IO request processing queue to schedule each of the sub-pending IO requests; There are multiple IO request processing queues, and according to the target data management unit, placing the current pending IO request into the target IO request processing queue corresponding to the target data management unit includes: Get the number of queues corresponding to the IO request processing queue; Obtaining identification information of the target data management unit corresponding to the currently pending IO request; According to the queue quantity and the identification information, the current pending IO request is placed in the target IO request processing queue; The identification information of the target data management unit is a position sequence identification of the target data management unit in the corresponding logical unit, and the logical unit is a unit for storing data in the storage device, and the current pending IO request is placed in the target IO request processing queue according to the queue quantity and the identification information, including: Using the position sequence identifier, a modulo calculation is performed on the number of queues; According to the calculation result, determining the target IO request processing queue corresponding to the currently pending IO request from each of the IO request processing queues; The currently pending IO request is placed in the target IO request processing queue.
2. The method according to claim 1, characterized in that The step of placing the currently pending IO request into the target IO request processing queue includes: Obtaining historical request data corresponding to each historical pending IO request in the target IO request processing queue; Determine from the target IO request processing queue the first historical IO requests to be compared of which the historical request data is in the target data management unit; Comparing the target request data with the first historical request data to be compared corresponding to each of the first historical IO requests to be compared; According to the comparison result, the current pending IO request is put into the target IO request processing queue.
3. The method according to claim 2, characterized in that The step of placing the current pending IO request into the target IO request processing queue according to the comparison result includes: If there is no overlapping data between the target request data and each of the first historical request data to be compared, the current IO request to be processed is put into the target IO request processing queue.
4. The method according to claim 2, characterized in that: The step of placing the current pending IO request into the target IO request processing queue according to the comparison result further includes: If there is overlapping data between the target request data and each of the first historical request data to be compared, determining the first historical IO request to be compared that has overlapping data with the target request data as the target historical IO request; Put the current pending IO request into the first target mutually exclusive linked list corresponding to the target historical IO request; When the target historical IO request is processed, the current pending IO request is put into the target IO request processing queue.
5. The method according to claim 4, characterized in that When the target historical IO request is processed, placing the current pending IO request into the target IO request processing queue includes: When the target historical IO request is processed, each second historical IO request to be compared is obtained from the target IO request processing queue again; the historical request data corresponding to the second historical IO request to be compared is in the target data management unit; Comparing the target request data with second historical request data to be compared corresponding to the second historical IO request to be compared; If there is no overlapping data between the target request data and each of the second historical request data to be compared, placing the current IO request to be processed into the target IO request processing queue; If there is overlapping data between the target request data and each of the second historical request data to be compared, the current pending IO request is placed in a second target mutually exclusive linked list, wherein the second target mutually exclusive linked list is a mutually exclusive linked list corresponding to the second historical request data to be compared that has overlapping data with the target request data.
6. The method according to claim 2, characterized in that The comparing the target request data with the first historical request data to be compared corresponding to each of the first historical IO requests to be compared includes: Determining a target position offset of the target request data in the target data management unit according to the request position corresponding to the target request data; Acquire the historical position offset and historical data volume of the first historical request data to be compared in the target data management unit; According to the relationship between the target position offset, the request data volume, the historical position offset and the historical data volume, the target request data is compared with the first historical request data to be compared corresponding to each of the first historical IO requests to be compared.
7. The method according to claim 6, characterized in that The comparing the target request data with the first to-be-compared historical request data corresponding to each of the first to-be-compared historical IO requests according to the relationship between the target position offset, the request data volume, the historical position offset, and the historical data volume includes: Calculate the sum of the historical position offset and the historical data amount to obtain a first total offset; Calculate the sum of the target position offset and the requested data amount to obtain a second total offset; comparing the target position offset with the first total offset; Comparing the historical position offset with the second total offset; If the target position offset is greater than the first total offset, or the historical position offset is greater than the second total offset, it is determined that there is no overlapping data between the target request data and each of the first historical request data to be compared.
8. The method according to claim 1, characterized in that The scheduling of the currently pending IO request includes: The current pending IO request in the target IO request processing queue is scheduled by using a target processing thread; the target processing thread is any one of a plurality of processing threads.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the IO scheduling method according to any one of claims 1 to 8 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the IO scheduling method according to any one of claims 1 to 8.
11. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the IO scheduling method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Data processing method, related device and storage system
CN107423301A
Optimization method and device for I / O scheduling, storage medium and intelligent terminal
CN109783028A
