Read-write request processing method and device, computer equipment, medium and product
By using a controller independent of the CPU to perform hardware-accelerated sorting and dispatching of read and write requests, the performance impact caused by CPU sorting is resolved, thereby improving the read and write performance of HDDs and the processing efficiency of the CPU.
Patent Information
- Application Number
- CN202511470772.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-14
- Publication Date
- 2026-01-30
AI Technical Summary
In existing technologies, in order to improve the read and write performance of HDD disks, the CPU of computer devices needs to sort read and write requests, which affects CPU processing performance. Especially in scenarios where mechanical hard drives and solid-state drives are used in combination, the CPU cannot effectively distinguish the request type, resulting in redundant sorting processing.
Design a controller independent of the central processing unit to sort and dispatch read and write requests through hardware acceleration. The controller deploys queues corresponding to various disks, inserts read and write requests into ordered queues according to their addresses, and dispatches them to the target disk.
It improves the read and write performance of mechanical hard drives, reduces the CPU's processing load, enhances the CPU's processing performance, and improves IOPS performance by more than 20% in scenarios with mixed sequential read and write operations with small IO requests.
Smart Images

Figure CN121433570A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a read-write request processing method and device, computer equipment, medium and product. BACKGROUND
[0002] For an HDD (Hard Disk Drive) disk, if the LBAs (Logical Block Addresses) of multiple read-write requests received by the HDD disk are continuous, the read-write performance of the HDD disk is better; if the LBAs of the multiple read-write requests received by the HDD disk are random, the read-write performance of the HDD disk is poorer.
[0003] In related technologies, in order to improve the read-write performance of the HDD disk, the CPU (Central Processing Unit) of the computer equipment usually sorts all the read-write requests according to the order of the LBAs before the read-write requests are sent to the disk, so as to ensure the continuity of the LBAs of the multiple read-write requests received by the HDD disk.
[0004] However, the method for sorting the read-write requests in related technologies has a great impact on the processing performance of the CPU. SUMMARY
[0005] Therefore, it is necessary to provide a read-write request processing method, device, computer equipment, medium and product, which can improve the processing performance of the CPU.
[0006] In a first aspect, the present application provides a read-write request processing method, applied to a controller in a computer equipment, the controller and a central processing unit in the computer equipment are independently arranged, used for sorting and dispatching read-write requests, and the method comprises the following steps:
[0007] In response to a read-write request to be written into a target disk, the read-write request is inserted into a queue corresponding to the target disk according to the address of the read-write request, to obtain an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and the controller is deployed with queues corresponding to multiple disks;
[0008] According to the ordered queue corresponding to the target disk, the read-write request is dispatched to the target disk.
[0009] In one embodiment, the read-write request is inserted into the queue corresponding to the target disk according to the address of the read-write request, to obtain the ordered queue corresponding to the target disk, comprising:
[0010] determining an insertion position of the read-write request from the queue according to an address of the read-write request;
[0011] inserting the read-write request at the insertion position to obtain the ordered queue.
[0012] In one of the embodiments, the determining the insertion position of the read-write request from the queue according to the address of the read-write request comprises:
[0013] determining target addresses of a plurality of target requests in the queue by using a dichotomy method;
[0014] comparing the address of the read-write request with the plurality of target addresses to obtain a comparison result;
[0015] if the comparison result is that the address of the read-write request is greater than a first target address in the plurality of target addresses and the address of the read-write request is less than a second target address in the plurality of target addresses, then taking a next position of the first target address as the insertion position of the read-write request.
[0016] In one of the embodiments, the controller comprises an arbitration unit and an instruction obtaining unit, and the dispatching the read-write request to the target disk according to the ordered queue corresponding to the target disk comprises:
[0017] if a disk currently dispatched by the arbitration unit is the target disk, then notifying the instruction obtaining unit to obtain the ordered queue corresponding to the target disk from the queues corresponding to the plurality of disks by the arbitration unit;
[0018] receiving the ordered queue corresponding to the target disk sent by the instruction obtaining unit by the arbitration unit;
[0019] dispatching each read-write request in the ordered queue to the target disk according to a waiting time length of the plurality of read-write requests in the ordered queue by the arbitration unit.
[0020] In one of the embodiments, the dispatching each read-write request in the ordered queue to the target disk according to the waiting time length of the plurality of read-write requests in the ordered queue by the arbitration unit comprises:
[0021] detecting, by the arbitration unit, whether a waiting time length of a current read-write request in the plurality of read-write requests exceeds a preset time length threshold;
[0022] if the waiting time length of the current read-write request exceeds the preset time length threshold, then dispatching the current read-write request to the target disk by the arbitration unit;
[0023] If the waiting time of the current read-write request does not exceed the preset time threshold, the arbitration unit determines a next read-write request in the order queue from the head to the tail, and returns to execute the step of detecting the waiting time of the current read-write request in the plurality of read-write requests by the arbitration unit.
[0024] In one of the embodiments, the controller further comprises an allocation unit, and the dispatching of the current read-write request to the target disk by the arbitration unit comprises:
[0025] The current read-write request is sent to the instruction acquisition unit by the arbitration unit.
[0026] The current read-write request is sent to the allocation unit by the instruction acquisition unit.
[0027] The current read-write request is dispatched to the target disk by the allocation unit.
[0028] In one of the embodiments, the method further comprises:
[0029] In response to the read-write request, it is determined whether the read-write request is a read-write request of a mechanical hard disk.
[0030] If the read-write request is not a read-write request of a mechanical hard disk, the read-write request is dispatched to the disk corresponding to the read-write request.
[0031] If the read-write request is a read-write request of a mechanical hard disk, the address of the read-write request is acquired.
[0032] In one of the embodiments, the method further comprises:
[0033] In the case of acquiring the address of the read-write request, the end position of the last dispatched read-write request is acquired.
[0034] If the absolute value of the difference between the initial position of the read-write request and the end position of the last dispatched read-write request is greater than a preset difference threshold, or if the initial position of the read-write request is equal to the end position of the last dispatched read-write request, the read-write request is dispatched to the target disk.
[0035] In a second aspect, the application further provides a read-write request processing device, which is applied to a controller in a computer device, the controller is independently arranged with a central processing unit in the computer device, and is used for sorting and dispatching read-write requests, and the device comprises:
[0036] The sorting module is used to respond to read / write requests to be written to the target disk, and insert the read / write request into the queue corresponding to the target disk according to the address of the read / write request, so as to obtain an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and the controller deploys queues corresponding to various disks;
[0037] The dispatch module is used to dispatch the read / write request to the target disk according to the ordered queue corresponding to the target disk.
[0038] Thirdly, this application also provides a computer device, including a controller and a central processing unit, wherein the controller and the central processing unit are independently configured, and the controller is used to sort and dispatch read and write requests.
[0039] The controller is configured to respond to a read / write request to be written to a target disk by inserting the read / write request into the queue corresponding to the target disk according to the address of the read / write request, thereby obtaining an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and the controller deploys queues corresponding to various disks.
[0040] The controller is further configured to dispatch the read / write request to the target disk according to the ordered queue corresponding to the target disk.
[0041] Fourthly, embodiments of this application also provide a computer-readable storage medium. This computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the method in any of the embodiments of the first aspect described above.
[0042] Fifthly, embodiments of this application also provide a computer program product. This computer program product includes a computer program that, when executed by a processor, implements the steps of the method in any of the embodiments of the first aspect described above.
[0043] The processing method and device of the read-write request, the computer device, the medium and the product, in response to the read-write request to be written into the target disk, the read-write request is inserted into the queue corresponding to the target disk according to the address of the read-write request, and the ordered queue corresponding to the target disk is obtained; the target disk is a mechanical hard disk, and the queue corresponding to a plurality of disks is deployed in the controller; the read-write request is dispatched to the target disk according to the ordered queue corresponding to the target disk. Since the controller independent of the central processing unit is specially designed in the embodiment of the application, the read-write request of the mechanical hard disk can be sorted and dispatched by the controller in the hardware acceleration mode, so that the continuity of the LBA of the plurality of read-write requests received by the mechanical hard disk can be improved, and the read-write performance of the mechanical hard disk can be improved; and the central processing unit is not required to realize the processing process of the read-write request, so that the processing performance of the CPU can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the description of the embodiments of the present application or the related art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other related drawings can be obtained by those skilled in the art without creative labor.
[0045] Figure 1 It is a structural schematic diagram of a computer device in an embodiment;
[0046] Figure 2 It is a flowchart of a read-write request processing method in an embodiment;
[0047] Figure 3 It is a flowchart of a sorting step in an embodiment;
[0048] Figure 4 It is a schematic diagram of a binary method in an embodiment;
[0049] Figure 5 It is a schematic diagram of an insertion queuing algorithm in an embodiment;
[0050] Figure 6 It is a flowchart of a dispatching step in an embodiment;
[0051] Figure 7 It is a flowchart of a dispatching step in another embodiment;
[0052] Figure 8 It is a flowchart of a read-write request processing method in another embodiment;
[0053] Figure 9 It is a structural block diagram of a read-write request processing device in an embodiment. DETAILED DESCRIPTION
[0054] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not intended to limit the present application.
[0055] It should be noted that the terms "first", "second", and the like used in the present application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "include" and "have" and any variations thereof used in the present application are intended to cover non-exclusive inclusion. The term "a plurality of" used in the present application refers to two or more. The term "and / or" used in the present application refers to one of the options or any combination of a plurality of options.
[0056] For HDD (Hard Disk Drive, mechanical hard disk), when the mechanical hard disk executes a read-write request, the internal magnetic head needs time to move to the target track. For random read-write requests, the magnetic head needs to move constantly, resulting in a time spent on head seeking, thereby affecting the read-write performance. Based on this, if the LBAs (Logical Block Address) of a plurality of read-write requests (i.e. IO requests, Input / Output requests) received by the HDD disk are continuous, the read-write performance of the HDD disk is better; if the LBAs of the plurality of read-write requests received by the HDD disk are random, the read-write performance of the HDD disk is poorer.
[0057] In the related art, in order to better adapt to the HDD disk and improve the read-write performance of the HDD disk, the CPU (Central Processing Unit, central processor) of the computer device usually sorts all the read-write requests according to the order of the LBA before the read-write request is sent to the disk, so as to improve the continuity of the LBAs of the plurality of read-write requests received by the HDD disk.
[0058] However, on the one hand, adding the aforementioned sorting process to the host CPU, which is a software processing step, increases CPU overhead. On the other hand, in scenarios where HDDs and SSDs (Solid State Disks or Solid State Drives) are used interchangeably, the host CPU cannot effectively distinguish between HDD and SSD I / O requests. This causes the CPU to sort all I / O requests, but SSDs can efficiently handle random I / O requests, so sorting is unnecessary. Therefore, the aforementioned sorting process is redundant and detrimental to SSD performance. Thus, the methods used in related technologies for sorting read and write requests have a significant impact on CPU processing performance.
[0059] Having described the background technology of the read / write request processing method provided in the embodiments of this application, the implementation environment involved in the read / write request processing method provided in the embodiments of this application will be briefly described below. For example... Figure 1 As shown, Figure 1 This is a schematic diagram of the structure of a computer device in one embodiment. The read / write request processing method provided in this application embodiment can be applied to, for example... Figure 1 The computer device shown includes a controller 11 and a central processing unit 12. The controller 11 and the central processing unit 12 are independently configured. The controller 11 is used to sort and dispatch read and write requests.
[0060] Controller 11 is used to respond to read / write requests to be written to the target disk, insert the read / write request into the queue corresponding to the target disk according to the address of the read / write request, and obtain an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and the controller deploys queues corresponding to various disks;
[0061] The controller 11 is also used to dispatch read and write requests to the target disk according to the ordered queue corresponding to the target disk.
[0062] The computer device can be a host, or a server, or a terminal. Of course, the specific structure of the computer device is not limited in the embodiments of the present application. For example, the server can be a single physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. For example, the terminal can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, unmanned aerial vehicles, low-altitude flying vehicles, Internet of Things devices, and portable wearable devices. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle-mounted device, a projection device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc.
[0063] Those skilled in the art can understand that Figure 1 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0064] The technical scheme of the present application and how the technical scheme of the present application solves the above technical problems will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described again in some embodiments. The embodiments of the present application will be described below with reference to the drawings.
[0065] In one embodiment, as Figure 2 shown, a read-write request processing method is provided. The method is applied to a controller in a computer device in Figure 1 The method includes the following steps:
[0066] S201, in response to a read-write request to be written to a target disk, inserting the read-write request into a queue corresponding to the target disk according to the address of the read-write request, to obtain an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and the controller is deployed with queues corresponding to multiple disks.
[0067] The target disk refers to a disk that needs to process a read-write request, the target disk is a mechanical hard disk, the read-write request refers to an IO request, and the address of the read-write request refers to an LBA (Logical Block Address) of the read-write request. A plurality of queues corresponding to the disks are deployed in the controller, that is, a queue cache storing ordered IO requests is implemented for each HDD in the hardware module in the controller, a plurality of read-write requests are included in each queue, and the ordered queue refers to a queue obtained by sorting the queue corresponding to the target disk.
[0068] In the embodiment of the application, the controller can receive at least one read-write request sent / delivered by a computer device or a central processing unit, and in the case that a read-write request to be written into a target disk is received, the controller can obtain the address of the read-write request of the target disk, and insert the read-write request into the queue corresponding to the target disk according to the address of the read-write request, that is, the plurality of read-write requests in the queue corresponding to the target disk can be sorted according to the address of the read-write request, so as to obtain the ordered queue corresponding to the target disk. For example, the controller can insert the read-write request into the queue corresponding to the target disk according to the order from small to large of the address of the read-write request, so as to realize the sorting of the plurality of read-write requests in the queue corresponding to the target disk, and obtain the ordered queue corresponding to the target disk.
[0069] S202, according to the ordered queue corresponding to the target disk, the read-write request is dispatched into the target disk.
[0070] In the embodiment of the application, optionally, the controller can batch dispatch the sorted read-write request into the target disk according to the ordered queue corresponding to the target disk. Alternatively, the controller can also simultaneously dispatch the sorted read-write request into the target disk according to the ordered queue corresponding to the target disk. Alternatively, the controller can also dispatch the sorted read-write request into the target disk according to the ordered queue corresponding to the target disk in a preset order, wherein the preset order can be set according to actual conditions. Of course, the embodiment of the application does not limit the specific implementation mode of the read-write request dispatched into the target disk.
[0071] In the method for processing the read-write request, in response to the read-write request to be written into a target disk, the read-write request is inserted into a queue corresponding to the target disk according to an address of the read-write request, so as to obtain an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and a plurality of queues corresponding to disks are deployed in the controller; and the read-write request is dispatched to the target disk according to the ordered queue corresponding to the target disk. Since the controller independent of the central processing unit is specially designed, the read-write request of the mechanical hard disk can be sorted and dispatched by the controller in a hardware acceleration mode, so that the continuity of the LBA of the plurality of read-write requests received by the mechanical hard disk can be improved, and the read-write performance of the mechanical hard disk can be improved; and the central processing unit is not required to be used to implement the processing process of the read-write request, so that the processing performance of the CPU can be improved.
[0072] In one embodiment, an implementation of inserting a read-write request into a queue corresponding to a target disk is provided, that is, the "inserting the read-write request into the queue corresponding to the target disk according to the address of the read-write request to obtain an ordered queue corresponding to the target disk" in S201, as shown in Figure 3 , comprising:
[0073] S301, determining an insertion position of the read-write request in the queue according to the address of the read-write request.
[0074] In the embodiment, optionally, the controller can compare the address of the read-write request with each address in the queue in sequence to determine the insertion position of the read-write request in the queue. Alternatively, the controller can determine target addresses of a plurality of target requests in the queue by using a binary search method, and then determine the insertion position of the read-write request in the queue according to the address of the read-write request and the target addresses of the plurality of target requests. Of course, the specific implementation of determining the insertion position of the read-write request is not limited in the embodiment.
[0075] In one embodiment, S301 comprises:
[0076] The binary search method is used to determine the target addresses of the plurality of target requests in the queue.
[0077] The address of the read-write request is compared with the plurality of target addresses to obtain a comparison result.
[0078] If the comparison result is that the address of the read-write request is greater than a first target address in the plurality of target addresses and the address of the read-write request is less than a second target address in the plurality of target addresses, a next position of the first target address is taken as the insertion position of the read-write request.
[0079] In the embodiments of the present application, the cache IO queue depth of each mechanical hard disk accessed in the hardware module of the controller is generally large, and generally, the ordered IO queue depth is usually greater than or equal to the number of the maximum pending IO requests of a disk, that is, 128 or 256. Therefore, when the IO requests to be sorted are compared, at least 128 or 256 comparisons are required, resulting in a very large time overhead. Therefore, in order to speed up the comparison operation in the insertion sort, the controller can use binary search to achieve fast search in the embodiments of the present application. For example, as shown in Figure 4 Figure 4 is a schematic diagram of binary search in an embodiment.
[0080] Specifically, the controller can use binary search to determine the target addresses of the plurality of target requests in the queue. For example, the target addresses of the plurality of target requests can include, but are not limited to, the address corresponding to Node63, the address corresponding to Node31, the address corresponding to Node15, the address corresponding to Node7, the address corresponding to Node127, and the like, wherein each Node represents a read-write request. Thus, the controller can compare the address of the read-write request with the plurality of target addresses to obtain a comparison result. If the comparison result is that the address of the read-write request is greater than a first target address in the plurality of target addresses and less than a second target address in the plurality of target addresses, the controller can determine the next position of the first target address as the insertion position of the read-write request. For example, assuming that the comparison result is that the address of the read-write request is greater than the address corresponding to Node7 and less than the address corresponding to Node8, the controller can determine the next position of the first target address (i.e., Node7) as the insertion position of the read-write request.
[0081] S302, inserting the read-write request into the insertion position to obtain an ordered queue.
[0082] In the embodiments of the present application, the controller can use the insertion queuing algorithm to directly insert the read-write request into the insertion position, that is, to obtain an ordered queue. For example, as shown in Figure 5 Figure 5 is a schematic diagram of the insertion queuing algorithm in an embodiment. In this way, the IO requests can be sequentially inserted into the queue cache in the order of increasing LBA by using the insertion queuing algorithm.
[0083] In addition, the accelerated comparison method based on binary search can also maintain the index or address information of the nth8-1 (n>0) node of the current ordered IO queue for each mechanical hard disk, that is, the controller can also save each read-write request in the ordered queue and the address corresponding to each read-write request.
[0084] In this embodiment, the insertion position of the read-write request can be determined from the queue according to the address of the read-write request, and the accelerated comparison can be realized based on the dichotomy to speed up the comparison operation in the insertion sorting. Thus, the read-write request can be inserted into the insertion position, and the IO request can be stored in the queue cache in the order of the LBA from small to large, that is, the ordered queue corresponding to the target disk can be obtained.
[0085] In one embodiment, the controller includes an arbitration unit and an instruction acquisition unit, based on which an implementation of dispatching the read-write request to the target disk is provided, that is, the "dispatching the read-write request to the target disk according to the ordered queue corresponding to the target disk" in S202, as shown in the following figure, includes: Figure 6
[0086] S401, in the case that the disk currently dispatched by the arbitration unit is the target disk, the instruction acquisition unit is informed by the arbitration unit to acquire the ordered queue corresponding to the target disk from the queues corresponding to the plurality of disks.
[0087] In the embodiment of the present application, after the queue corresponding to each disk (that is, the ordered IO queue) is formed, the controller can poll the queues corresponding to the n disks in real time through the arbitration unit. Thus, in the case that the disk currently polled / presently dispatched by the arbitration unit is the target disk, the instruction acquisition unit can be informed by the arbitration unit to acquire the ordered queue corresponding to the target disk from the queues corresponding to the plurality of disks.
[0088] S402, the ordered queue corresponding to the target disk sent by the instruction acquisition unit is received by the arbitration unit.
[0089] In the embodiment of the present application, the controller can send the ordered queue corresponding to the target disk to the arbitration unit through the instruction acquisition unit, so that the ordered queue corresponding to the target disk sent by the instruction acquisition unit can be received by the arbitration unit.
[0090] S403, the read-write requests in the ordered queue are dispatched to the target disk by the arbitration unit according to the waiting time of the plurality of read-write requests in the ordered queue.
[0091] In the embodiment of the present application, the controller can determine the waiting time length of each read-write request in the ordered queue through the arbitration unit, so that the controller can dispatch each read-write request in the ordered queue to the target disk according to the waiting time length of the plurality of read-write requests in the ordered queue. Optionally, the controller can dispatch each read-write request in the ordered queue to the target disk in the order from large to small according to the waiting time length of the plurality of read-write requests in the ordered queue through the arbitration unit; or the controller can determine whether the waiting time length of the plurality of read-write requests in the ordered queue exceeds a preset time length threshold through the arbitration unit, and dispatch the read-write request whose waiting time length exceeds the preset time length threshold to the target disk. Of course, the embodiment of the present application does not limit the specific implementation manner of dispatching each read-write request in the ordered queue to the target disk.
[0092] In the embodiment, in the case that the disk currently dispatched by the arbitration unit is the target disk, the arbitration unit can notify the instruction acquisition unit to acquire the ordered queue corresponding to the target disk from the plurality of queues corresponding to the plurality of disks, so that the arbitration unit can receive the ordered queue corresponding to the target disk sent by the instruction acquisition unit. Then, the arbitration unit can accurately dispatch each read-write request in the ordered queue to the target disk according to the waiting time length of the plurality of read-write requests in the ordered queue.
[0093] In one embodiment, an implementation manner of dispatching each read-write request in the ordered queue to the target disk is provided, i.e., the "dispatching each read-write request in the ordered queue to the target disk according to the waiting time length of the plurality of read-write requests in the ordered queue through the arbitration unit" in S403 described above, as shown in FIG. 5, which includes the following steps. Figure 7
[0094] S501, determining whether the waiting time length of the current read-write request in the plurality of read-write requests exceeds a preset time length threshold through the arbitration unit.
[0095] S502, if the waiting time length of the current read-write request exceeds the preset time length threshold, dispatching the current read-write request to the target disk through the arbitration unit.
[0096] S503, if the waiting time length of the current read-write request does not exceed the preset time length threshold, determining the next read-write request in the ordered queue in the direction from the queue head to the queue tail through the arbitration unit, and taking the next read-write request as a new current read-write request, and returning to execute S501.
[0097] In the embodiment of the present application, the controller can traverse and query / detect whether the waiting time of the current read-write request in the plurality of read-write requests exceeds the preset time threshold from the head to the tail of the ordered queue corresponding to the target disk through the arbitration unit. The preset time threshold can be denoted as wait_min_time, and the preset time threshold can be set according to actual conditions, and the embodiment of the present application does not limit the specific value of the preset time threshold.
[0098] If it is detected that the waiting time of the current read-write request exceeds the preset time threshold, the query can be paused, and the current read-write request can be dispatched to the target disk through the arbitration unit. Then, the waiting time of the next read-write request of the current read-write request exceeding the preset time threshold can be queried, until the tail of the ordered queue.
[0099] If it is detected that the waiting time of the current read-write request does not exceed the preset time threshold, the next read-write request can be determined through the arbitration unit from the head to the tail of the ordered queue, and the next read-write request is taken as a new current read-write request. The step of detecting whether the waiting time of the current read-write request in the plurality of read-write requests exceeds the preset time threshold through the arbitration unit is returned to be executed, until the tail of the ordered queue.
[0100] Therefore, after all the read-write requests that exceed the timeout in the current target disk are dispatched in batches, the next disk is polled for dispatching processing. It is possible that all the read-write requests in the disk numbered n at the rear end may exceed the timeout, and then all the read-write requests that exceed the timeout in these disks will be directly dispatched in batches to the corresponding disks.
[0101] In one of the embodiments, the controller further includes an allocation unit, and the step of "dispatching the current read-write request to the target disk through the arbitration unit" in S502 includes:
[0102] The current read-write request is sent to the instruction acquisition unit through the arbitration unit.
[0103] The current read-write request is sent to the allocation unit through the instruction acquisition unit.
[0104] The current read-write request is dispatched to the target disk through the allocation unit.
[0105] In the embodiment of the present application, the controller can send the current read-write request to the instruction acquisition unit through the arbitration unit, so that the instruction acquisition unit can receive the current read-write request to be dispatched sent by the arbitration unit, and send the current read-write request to the allocation unit. Further, the allocation unit can receive the current read-write request to be dispatched sent by the instruction acquisition unit, and dispatch the current read-write request to the target disk.
[0106] In the embodiment, the controller can determine whether the waiting time of each read-write request in the ordered queue exceeds the preset time threshold through the cooperation of the arbitration unit, the instruction acquisition unit and the distribution unit, and can accurately dispatch the read-write request whose waiting time exceeds the preset time threshold to the target disk.
[0107] In one embodiment, an implementation for determining whether the read-write request is a read-write request of a mechanical hard disk is provided, that is, before S201, the method further includes:
[0108] In response to the read-write request, it is determined whether the read-write request is a read-write request of a mechanical hard disk.
[0109] If the read-write request is not a read-write request of a mechanical hard disk, the read-write request is dispatched to the disk corresponding to the read-write request.
[0110] If the read-write request is a read-write request of a mechanical hard disk, the address of the read-write request is obtained.
[0111] In the embodiment, the controller can receive at least one read-write request sent / delivered by the computer device or the central processing unit and parsed by hardware, and in response to the read-write request, it can be determined whether the read-write request is a read-write request of a mechanical hard disk. If the read-write request is not a read-write request of a mechanical hard disk, that is, the read-write request is a read-write request of an SSD or other non-HDD disk, the controller can dispatch the read-write request directly to the disk corresponding to the read-write request without sorting. If the read-write request is a read-write request of a mechanical hard disk, the controller can obtain the address of the read-write request, and then perform S201.
[0112] In the embodiment, in response to the read-write request, it can be determined whether the read-write request is a read-write request of a mechanical hard disk, so that for the read-write request of a non-mechanical hard disk (such as an SSD disk), the read-write request can be directly dispatched without sorting; for the read-write request of a mechanical hard disk, the address of the read-write request can be obtained, and the above sorting process can be performed. In this way, it can be ensured that only the read-write request of an HDD disk is sorted, that is, it can be ensured that the read-write performance of a non-mechanical hard disk is not affected.
[0113] In one embodiment, an implementation for determining whether to directly dispatch the read-write request is provided, that is, after obtaining the address of the read-write request, the method further includes:
[0114] In the case of obtaining the address of the read-write request, the end position of the last dispatched read-write request is obtained.
[0115] If an absolute value of a difference between the initial position of the read / write request and an end position of the last dispatched read / write request is greater than a preset difference threshold, or if the initial position of the read / write request is equal to the end position of the last dispatched read / write request, the read / write request is dispatched to the target disk.
[0116] In the embodiment, when the address of the read / write request is acquired, the controller can acquire the end position of the last dispatched read / write request. Thus, if the controller detects that an absolute value of a difference between the initial position (i.e., LBA) of the read / write request and the end position (i.e., LBA+IO request) of the last dispatched read / write request is greater than a preset difference threshold, or if the initial position (i.e., LBA) of the read / write request is equal to the end position (i.e., LBA+IO request) of the last dispatched read / write request, the controller can directly dispatch the read / write request to the target disk without sorting. The preset difference threshold can be 4 MB, and the embodiment is not limited in this regard.
[0117] In the embodiment, when the address of the read / write request is acquired, if an absolute value of a difference between the initial position of the read / write request and an end position of the last dispatched read / write request is greater than a preset difference threshold, or if the initial position of the read / write request is equal to the end position of the last dispatched read / write request, the controller can directly dispatch the read / write request to the target disk, which can save the sorting process and improve the efficiency of the disk.
[0118] In one exemplary embodiment, as shown in Figure 8 , a read / write request processing method is provided, which is applied to a controller in a computer device as an example and includes the following steps. Figure 1
[0119] S601, in response to a read / write request, determining whether the read / write request is a read / write request of a mechanical hard disk;
[0120] S602, if the read / write request is not a read / write request of a mechanical hard disk, dispatching the read / write request to a disk corresponding to the read / write request;
[0121] S603, if the read / write request is a read / write request of a mechanical hard disk, acquiring an address of the read / write request to be written into a target disk, and acquiring an end position of a last dispatched read / write request; the target disk is a mechanical hard disk, and the controller is deployed with queues corresponding to multiple disks;
[0122] In addition, it determines whether the absolute value of the difference between the initial position of the read / write request and the end position of the previously dispatched read / write request is greater than a preset difference threshold, or whether the initial position of the read / write request is equal to the end position of the previously dispatched read / write request; that is, it determines whether the absolute value of the difference between the LBA of the new IO and the length of the LBA+IO request of the previously dispatched IO is greater than a preset difference threshold (for IO with random LBA), or whether it is equal to the length of the LBA+IO of the previously dispatched IO in the ordered queue (for IO with sequential LBA).
[0123] S604, if the absolute value of the difference between the initial position of the read / write request and the end position of the last dispatched read / write request is greater than a preset difference threshold, or if the initial position of the read / write request is equal to the end position of the last dispatched read / write request, then the read / write request is dispatched to the target disk.
[0124] S605, if the absolute value of the difference between the initial position of the read / write request and the end position of the last dispatched read / write request is not greater than a preset difference threshold, or if the initial position of the read / write request is not equal to the end position of the last dispatched read / write request, then the binary search method is used to determine the target address of multiple target requests in the queue.
[0125] The address of the read / write request is compared with multiple target addresses to obtain the comparison result;
[0126] If the comparison result shows that the address of the read / write request is greater than the first target address among multiple target addresses, and the address of the read / write request is less than the second target address among multiple target addresses, then the position after the first target address is taken as the insertion position of the read / write request.
[0127] Insert read and write requests at the insertion positions to obtain an ordered queue;
[0128] S606, when the disk currently dispatched by the arbitration unit (ARB, Round Robin Arbiter) is the target disk, the arbitration unit notifies the instruction acquisition unit (Fech_orderQue) to obtain the ordered queue corresponding to the target disk from the queues corresponding to multiple disks;
[0129] S607, through the arbitration unit, receives instructions to obtain the ordered queue corresponding to the target disk sent by the unit;
[0130] The arbitration unit detects whether the waiting time of the current read / write request among multiple read / write requests exceeds a preset time threshold.
[0131] If the waiting time length of the current read-write request does not exceed the preset time length threshold, the arbitration unit is used to determine the next read-write request in the direction from the head to the tail of the ordered queue, and the next read-write request is taken as a new current read-write request, and the step of detecting whether the waiting time length of the current read-write request exceeds the preset time length threshold is returned to be executed.
[0132] If the waiting time length of the current read-write request exceeds the preset time length threshold, the arbitration unit is used to send the current read-write request to the instruction acquisition unit.
[0133] S608, the instruction acquisition unit is used to send the current read-write request to the allocation unit (Dispath).
[0134] S609, the allocation unit is used to dispatch the current read-write request to the target disk.
[0135] Wherein, ICT represents an initiator connection tag.
[0136] In the read-write request processing method, in response to a read-write request to be written into a target disk, the read-write request is inserted into a queue corresponding to the target disk according to the address of the read-write request, and an ordered queue corresponding to the target disk is obtained; the target disk is a mechanical hard disk, and a plurality of queues corresponding to different types of disks are deployed in the controller; and the read-write request is dispatched to the target disk according to the ordered queue corresponding to the target disk. Since the controller is specially designed independently of the central processing unit, the read-write request of the mechanical hard disk can be sorted and dispatched by the controller in a hardware acceleration mode, so that the continuity of the LBA of the plurality of read-write requests received by the mechanical hard disk can be improved, and the read-write performance of the mechanical hard disk can be improved; and the CPU processing performance can be improved without using the central processing unit to implement the read-write request processing process.
[0137] Based on the above embodiment, the embodiment of the application provides a method for sorting HDD IO requests according to the size of LBA by using hardware acceleration, which can realize HDD IO request sorting by using hardware acceleration, greatly reduce the software sorting overhead, and thus improve the performance upper limit of the entire IO request dispatch path. After software simulation test in a small IO request sequential read-write mixed scene, the method in the embodiment of the application can improve the IOPS (Input / Output Operations Per Second, number of input / output operations per second) by more than 20% compared with the sorting algorithm of the host driver HDD in the related art.
[0138] It should be understood that although the steps in the flowcharts involved in the above embodiments are shown in sequence according to the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of the steps is not strictly limited in sequence, and the steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts involved in the above embodiments can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of the steps or stages is not necessarily sequential, but can be alternately executed with at least some of the other steps or steps or stages in other steps. It can be understood that the steps in different embodiments can be freely combined as needed, and various non-contradictory schemes formed by the combination are within the scope of protection of the present application.
[0139] Based on the same inventive concept, the embodiments of the present application also provide a read-write request processing device for implementing the read-write request processing method described above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more read-write request processing device embodiments provided below can refer to the limitations of the read-write request processing method in the above text, and will not be repeated here.
[0140] In one exemplary embodiment, as shown in Figure 9 A read-write request processing device is provided, which is applied to a controller in a computer device, the controller is independently arranged with a central processing unit in the computer device, and is used for sorting and dispatching processing of read-write requests, and includes a sorting module 701 and a dispatching module 702, wherein:
[0141] The sorting module 701 is used for, in response to a read-write request to be written into a target disk, inserting the read-write request into a queue corresponding to the target disk according to an address of the read-write request, to obtain an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and the controller is arranged with queues corresponding to multiple kinds of disks.
[0142] The dispatching module 702 is used for dispatching the read-write request to the target disk according to the ordered queue corresponding to the target disk.
[0143] In one embodiment, the sorting module 701 includes:
[0144] The insertion position determination unit is used for determining an insertion position of the read-write request from the queue according to the address of the read-write request;
[0145] The insertion unit is used for inserting the read-write request into the insertion position to obtain the ordered queue.
[0146] In one of the embodiments, the insertion position determining unit is specifically configured to:
[0147] determining the target addresses of the plurality of target requests in the queue by using dichotomy;
[0148] comparing the address of the read-write request with the plurality of target addresses to obtain a comparison result;
[0149] if the comparison result is that the address of the read-write request is greater than a first target address in the plurality of target addresses and less than a second target address in the plurality of target addresses, then taking a next position of the first target address as the insertion position of the read-write request.
[0150] In one of the embodiments, the controller comprises an arbitration unit and an instruction obtaining unit, and the dispatching module 702 comprises:
[0151] an ordered queue obtaining unit configured to, in a case where the disk currently dispatched by the arbitration unit is the target disk, notify the instruction obtaining unit to obtain the ordered queue corresponding to the target disk from the queues corresponding to the plurality of disks through the arbitration unit;
[0152] a receiving unit configured to receive the ordered queue corresponding to the target disk sent by the instruction obtaining unit through the arbitration unit;
[0153] a dispatching unit configured to dispatch each read-write request in the ordered queue to the target disk according to the waiting time length of the plurality of read-write requests in the ordered queue through the arbitration unit.
[0154] In one of the embodiments, the dispatching unit comprises:
[0155] a detection subunit configured to detect whether the waiting time length of the current read-write request in the plurality of read-write requests exceeds a preset time threshold through the arbitration unit;
[0156] a dispatching subunit configured to, if the waiting time length of the current read-write request exceeds the preset time threshold, dispatch the current read-write request to the target disk through the arbitration unit;
[0157] a next read-write request determining subunit configured to, if the waiting time length of the current read-write request does not exceed the preset time threshold, determine a next read-write request in the direction from the head of the ordered queue to the tail of the ordered queue through the arbitration unit, take the next read-write request as a new current read-write request, and return to execute the step of detecting whether the waiting time length of the current read-write request in the plurality of read-write requests exceeds the preset time threshold through the arbitration unit.
[0158] In one of the embodiments, the controller further comprises an allocation unit, and the dispatching subunit is specifically configured to:
[0159] send the current read-write request to the instruction obtaining unit through the arbitration unit.
[0160] The instruction obtaining unit sends the current read-write request to the allocation unit;
[0161] The allocation unit dispatches the current read-write request to the target disk.
[0162] In one of the embodiments, the read-write request processing apparatus further includes:
[0163] The read-write request determining module is configured to determine, in response to the read-write request, whether the read-write request is a read-write request of a mechanical hard disk;
[0164] The first dispatching module is configured to dispatch the read-write request to the disk corresponding to the read-write request if the read-write request is not a read-write request of a mechanical hard disk;
[0165] The second dispatching module is configured to obtain the address of the read-write request if the read-write request is a read-write request of a mechanical hard disk.
[0166] In one of the embodiments, the read-write request processing apparatus further includes:
[0167] The end position obtaining module is configured to obtain the end position of the last dispatched read-write request if the address of the read-write request is obtained;
[0168] The third dispatching module is configured to dispatch the read-write request to the target disk if the absolute value of the difference between the initial position of the read-write request and the end position of the last dispatched read-write request is greater than a preset difference threshold, or if the initial position of the read-write request is equal to the end position of the last dispatched read-write request.
[0169] The modules in the read-write request processing apparatus can be implemented by software, hardware, or a combination thereof, in whole or in part. The modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to the modules.
[0170] In one exemplary embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor implementing any one of the method steps in the embodiments of the read-write request processing method in the foregoing embodiments when executing the computer program.
[0171] In one embodiment, a computer readable storage medium is provided, storing a computer program, and the computer program implements any one of the method steps in the embodiments of the read-write request processing method in the foregoing embodiments when executed by a processor.
[0172] In one embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements any of the method steps of the processing method of read and write requests in the foregoing embodiments.
[0173] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. Any reference to a memory, a database or other medium used in the embodiments provided in the present application can include at least one of a non-volatile memory and a volatile memory. The non-volatile memory can include a read-only memory (ROM), a magnetic tape, a floppy disk, a flash memory, an optical storage, a high-density embedded non-volatile memory, a resistive random access memory (ReRAM), a magnetoresistive random access memory (MRAM), a ferroelectric random access memory (FRAM), a phase change memory (PCM), a graphene memory, etc. The volatile memory can include a random access memory (RAM) or an external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as a static random access memory (SRAM) or a dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.
[0174] Any combination of the technical features of the above embodiments can be made. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.
[0175] The above embodiments only express several implementation ways of the present application, and the description is more specific and detailed, but it should not be understood as a limitation to the patent scope of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A method of processing read and write requests, characterized by, The application relates to a controller applied to a computer device, wherein the controller is arranged independently of a central processor in the computer device, and is used for sorting and dispatching read-write requests, and the method comprises the following steps: In response to a read-write request to be written into a target disk, the read-write request is inserted into a queue corresponding to the target disk according to the address of the read-write request, so as to obtain an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and the controller is arranged with queues corresponding to multiple disks; According to the ordered queue corresponding to the target disk, the read-write request is dispatched into the target disk.
2. The method of claim 1, wherein, The read-write request is inserted into the target disk according to the address of the read-write request, so as to obtain an ordered queue corresponding to the target disk, which comprises the following steps: The insertion position of the read-write request in the queue is determined according to the address of the read-write request; The read-write request is inserted into the insertion position, so as to obtain the ordered queue.
3. The method of claim 2, wherein, The insertion position of the read-write request in the queue is determined according to the address of the read-write request, which comprises the following steps: The binary method is used to determine the target addresses of multiple target requests in the queue; The address of the read-write request is compared with the multiple target addresses, so as to obtain a comparison result; If the comparison result is that the address of the read-write request is greater than a first target address in the multiple target addresses and the address of the read-write request is smaller than a second target address in the multiple target addresses, then the next position of the first target address is taken as the insertion position of the read-write request.
4. The method according to any one of claims 1 to 3, characterized in that, The controller comprises an arbitration unit and an instruction acquisition unit, and the read-write request is dispatched into the target disk according to the ordered queue corresponding to the target disk, which comprises the following steps: If the disk currently dispatched by the arbitration unit is the target disk, the instruction acquisition unit is informed by the arbitration unit to acquire the ordered queue corresponding to the target disk from the queues corresponding to the multiple disks; The ordered queue corresponding to the target disk is received by the arbitration unit from the instruction acquisition unit; According to the waiting time of multiple read-write requests in the ordered queue, each read-write request in the ordered queue is dispatched into the target disk by the arbitration unit.
5. The method of claim 4, wherein, According to the waiting time of multiple read-write requests in the ordered queue, each read-write request in the ordered queue is dispatched into the target disk by the arbitration unit, which comprises the following steps: Whether the waiting time of a current read-write request in the multiple read-write requests exceeds a preset time threshold is detected by the arbitration unit; If the waiting time of the current read-write request exceeds the preset time threshold, the current read-write request is dispatched into the target disk by the arbitration unit. If the waiting time of the current read-write request does not exceed the preset time threshold, the arbitration unit determines a next read-write request in the order of the ordered queue from the head to the tail of the queue, and returns to execute the step of detecting whether the waiting time of the current read-write request in the plurality of read-write requests exceeds the preset time threshold by the arbitration unit, with the next read-write request as a new current read-write request.
6. The method of claim 5, wherein, The controller further comprises an allocation unit, and the dispatching of the current read-write request to the target disk by the arbitration unit comprises: sending the current read-write request to the instruction acquisition unit by the arbitration unit; sending the current read-write request to the allocation unit by the instruction acquisition unit; dispatching the current read-write request to the target disk by the allocation unit.
7. The method according to any one of claims 1-3, characterized in that, The method further comprises: in response to a read-write request, determining whether the read-write request is a read-write request of a mechanical hard disk; if the read-write request is not a read-write request of a mechanical hard disk, dispatching the read-write request to a disk corresponding to the read-write request; if the read-write request is a read-write request of a mechanical hard disk, obtaining an address of the read-write request.
8. The method of claim 7, wherein, The method further comprises: in the case of obtaining the address of the read-write request, obtaining an end position of a last dispatched read-write request; if an absolute value of a difference between an initial position of the read-write request and the end position of the last dispatched read-write request is greater than a preset difference threshold, or if the initial position of the read-write request is equal to the end position of the last dispatched read-write request, dispatching the read-write request to the target disk.
9. An apparatus for processing read and write requests, characterized by A controller applied to a computer device, the controller and a central processing unit in the computer device are independently arranged, and the controller is used for sorting and dispatching processing of read-write requests, and the device comprises: a sorting module, configured to, in response to a read-write request to be written into a target disk, insert the read-write request into a queue corresponding to the target disk according to an address of the read-write request, to obtain an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and the controller is deployed with queues corresponding to a plurality of disks; a dispatching module, configured to dispatch the read-write request to the target disk according to the ordered queue corresponding to the target disk.
10. A computer device, comprising: The controller and the central processing unit are independently arranged, and the controller is used for sorting and dispatching processing of read-write requests; the controller is configured to, in response to a read-write request to be written into a target disk, insert the read-write request into a queue corresponding to the target disk according to an address of the read-write request, to obtain an ordered queue corresponding to the target disk; the target disk is a mechanical hard disk, and the controller is deployed with queues corresponding to a plurality of disks; the controller is further configured to dispatch the read-write request to the target disk according to the ordered queue corresponding to the target disk.
11. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by a processor to implement the steps of the method in any one of claims 1 to 8. The computer program is executed by a processor to implement the steps of the method in any one of claims 1 to 8.
12. A computer program product comprising a computer program, characterized in that, The computer program, which is executed by a processor, implements the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
IO request scheduling method and apparatus
CN107305473A
Information processing method and device and computer readable storage medium
CN117573023A
IO request processing method and device, equipment and medium
CN119088533A
Internal Data Transfer Management in a Hybrid Data Storage Device
US20170371554A1
Hybrid Data Storage Device with Partitioned Local Memory
US20180059955A1