IO command processing method and device
By monitoring the IO response time of the hard disk and dynamically adjusting the IO command frequency, the problem of slow disk when the hard disk SMART status is normal is solved, which extends the hard disk life and reduces operating costs, and effectively manages the slow disk.
Patent Information
- Application Number
- CN202310847963.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-11
- Publication Date
- 2025-01-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art is difficult to effectively solve the problem of longer response time of hard disk IO (slow disk), especially when the hard disk SMART state is normal, frequent replacement of hard disks leads to waste of resources and increased operating costs.
By monitoring the IO response time of the hard disk, dynamically adjusting the transmission frequency of the IO commands, reducing the probability of the hard disk slow disk, including determining the IO response time on the hard disk side, adjusting the NCQ dispatch interval, executing the number of IO commands in parallel, and sending IO within a unit time Number of commands to reduce IO queue depth and extend hard disk life.
It effectively reduces the probability of slow disks appearing, extends the service life of hard disks, reduces the operating costs caused by slow disk replacement, and ensures the stability of upper-level services and the read and write performance of computing devices.
Smart Images

Figure CN119311199A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for processing IO commands. Background Art
[0002] The storage system in a computer generally includes one or more hard disks. As these hard disks are used for a longer period of time, various types of anomalies or failures may occur. One type of anomaly is the longer input / output (IO) response time of the hard disk, which is commonly referred to as a "slow disk". The average response time of a slow disk to IO commands generally exceeds the design range of the hard disk. Therefore, a slow disk will become the shortcoming of the storage system, slowing down the IO response time of the entire system. The existence of a slow disk will have an impact on upper-level businesses, such as causing untimely processing of business data. The general solution is to monitor the IO response time of each hard disk in real time, identify the slow disks in the storage system, and replace them to ensure the IO response time of the storage system.
[0003] However, there are many reasons for slow disk. One is that the hard disk itself has hardware failure, such as abnormal self-monitoring analysis and reporting technology (SMART) status of the hard disk, which causes slow disk phenomenon. Another is that the SMART status of the hard disk is normal, but the slow disk phenomenon is caused by other reasons. If the slow disk is caused by the second reason, it will cause a waste of hard disk resources if it is replaced. Summary of the invention
[0004] The embodiment of the present application provides a method for processing IO commands, which dynamically adjusts the IO sending frequency to the hard disk according to the IO response time of the hard disk side, reduces the probability of a slow hard disk, and ensures the stability of upper-level business operation.
[0005] In a first aspect, the present application provides a method for processing IO commands, including determining the IO response time of the IO command on the hard disk side; based on the IO response time, determining the sending parameters for sending the IO command to the target hard disk, the sending parameters are used to adjust the frequency of sending the IO command to the target hard disk, and the target hard disk is a hard disk used to respond to the IO command.
[0006] The IO command processing method provided in the present application dynamically adjusts the frequency of IO issuance according to the response time of IO commands on the disk side, so as to reduce the IO queue depth on the disk side, increase the IO response time margin on the hard disk side, reduce the probability of slow disk occurrence, thereby extending the service life of the hard disk and reducing the operating costs caused by replacing slow disks.
[0007] In a possible implementation, a specific implementation of determining the sending parameter of the IO command to the target hard disk based on the IO response time is: when the IO response time is less than a preset threshold, the sending parameter is determined to be the first sending parameter; when the IO response time is greater than or equal to the preset threshold, the sending parameter is determined to be the second sending parameter; wherein the frequency of sending the IO command to the target hard disk with the first sending parameter is greater than the frequency of sending the IO command to the target hard disk with the second sending parameter.
[0008] Whether the hard disk is a slow disk is determined by whether the IO response time on the disk side is greater than or equal to the preset threshold. If the hard disk reaches the slow disk judgment threshold, the sending parameters are adjusted to reduce the frequency of sending IO commands to the hard disk to reduce the IO queue depth on the disk side, giving the hard disk more repeated response time margin and eliminating the slow disk phenomenon. If the hard disk does not reach the slow disk judgment threshold, IO commands are still sent to the hard disk at the default sending frequency to ensure the read and write performance of the computing device.
[0009] Optionally, the sending parameters mentioned above include one or more of a sending interval of a native command queuing (NCQ), a number of IO commands executed in parallel, and a number of IO commands sent per unit time.
[0010] Exemplarily, when the target hard disk is detected as slow IO, the hard disk driver reduces the interval for issuing NCQ IO. Optionally, the interval uses the kernel's standard interface function usleep_range to control the order of issuing IO commands; reduces the number of IO commands executed in parallel (that is, reduces the IO concurrency within the disk, for example, by reducing NCQ queue_depth to reduce the IO concurrency within the disk); reduces the number of IO commands sent within a unit, for example, the system kernel (OS kernel) adjusts blkio.throttle to reduce the number of read / output operations per second (IOPS) of the hard disk.
[0011] In another possible implementation, the IO command processing method provided by the present application further includes: determining that the IO response time is greater than or equal to a preset threshold; parsing the IO command to determine the target hard disk corresponding to the IO command; and marking the target hard disk as a risky disk. In other words, marking a hard disk that meets the slow IO standard as a risky hard disk.
[0012] In another possible implementation, the IO command processing method provided by the present application further includes: determining that the number of times the target hard disk is marked as a risk disk is greater than or equal to a preset number of times; and determining the target hard disk as a slow disk. In other words, after the risk disk has been processed by adjusting the IO sending frequency several times, the hard disk that still has the slow IO phenomenon is determined as a slow disk. At this time, the hard disk is likely to have an internal failure, so the risk disk is marked as a slow disk. In order not to affect the read and write performance of the storage system, it is recommended to replace the hard disk.
[0013] In another possible implementation, a specific implementation of determining the IO response time of the IO command on the hard disk side is: obtaining a first moment and a second moment, the first moment indicating the moment when the hard disk controller receives the IO command, and the second moment indicating the moment when the IO command is executed; based on the first moment and the second moment, determining the IO response time of the IO command on the hard disk side.
[0014] For example, after the host (HOST) sends an IO command, timestamp t is added to several key states of IO (also called key time points). For example, timestamp t1 is added when the IO command is sent to the hard disk controller, and timestamp t4 is added when the IO is completed (that is, after the hard disk returns the IO, it means that the IO is completed and the task is done). t4-t1 is the IO response time of the IO command on the hard disk side.
[0015] In another example, several key states of IO also include IO timeout time point t2 (t2=t1+timeout duration) and driver release IO time point t3.
[0016] It should be noted that the timeout period refers to the time when the hard disk side takes longer than the set time to complete the IO command.
[0017] In one example, the IO command processing method provided in the present application is applicable to any storage system that may have slow IO, and the storage system includes a hard disk and a hard disk controller. The hard disk controller can be any hard disk controller, and the hard disk can be any hard disk compatible with the hard disk controller. For example, the hard disk controller can be a serial small computer system interface (serial attached SCSI, SAS) controller, a SAS hard disk, or a SAS controller, a serial advanced technology attachment (serial advanced technology attachment, SATA) hard disk. The hard disk can be a hard disk of any storage medium, such as a mechanical hard disk (hard disk drive, HDD), a solid-state drive (solid-state drive, SSD), and a hybrid hard drive (hybrid hard drive, HHD), etc.
[0018] In the second aspect, the present application also provides an IO command processing device including at least a first determination module and a parameter adjustment module, wherein the first determination module is used to determine the IO response time of the IO command on the hard disk side; the parameter adjustment module is used to determine the sending parameters of the IO command to the target hard disk based on the IO response time, and the sending parameters are used to adjust the frequency of sending IO commands to the target hard disk, and the target hard disk is a hard disk used to respond to IO commands.
[0019] In one possible implementation, the parameter adjustment module is specifically used to determine that the sending parameter is a first sending parameter when the IO response time is less than a preset threshold; when the IO response time is greater than or equal to the preset threshold, determine that the sending parameter is a second sending parameter; wherein the frequency of sending IO commands to the target hard disk with the first sending parameter is greater than the frequency of sending IO commands to the target hard disk with the second sending parameter.
[0020] In another possible implementation, the sending parameter includes one or more of the sending interval of the native command queue, the number of IO commands executed in parallel, and the number of IO commands sent per unit time.
[0021] In another possible implementation, the IO command processing device provided in the present application also includes a second determination module, a parsing module and a marking module, wherein the second determination module is used to determine that the IO response time is greater than or equal to a preset threshold; the parsing module is used to parse the IO command and determine the target hard disk corresponding to the IO command; and the marking module is used to mark the target hard disk as a risky disk.
[0022] In another possible implementation, the IO command processing device provided in the present application also includes a third determination module, which is used to determine that the number of times the target hard disk is marked as a risk disk is greater than or equal to a preset number; and determine the target hard disk as a slow disk.
[0023] In another possible implementation, the first determination module is specifically used to: obtain a first moment and a second moment, the first moment indicating the moment when the hard disk controller receives the IO command, and the second moment indicating the moment when the IO command is executed; based on the first moment and the second moment, determine the IO response time of the IO command on the hard disk side.
[0024] In another possible implementation, the target hard disk is a SATA mechanical hard disk, and the hard disk controller of the target hard disk is a SAS controller.
[0025] In a third aspect, an embodiment of the present application provides a computing device, comprising a memory and a processor, wherein the memory stores instructions, and when the instructions are executed by the processor, the method described in the first aspect or any possible implementation of the first aspect is implemented.
[0026] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method described in the first aspect or any possible implementation of the first aspect is implemented.
[0027] In a fifth aspect, an embodiment of the present application further provides a computer program or a computer program product, which includes instructions that, when executed, cause a computer to execute the method described in the first aspect or any possible implementation of the first aspect.
[0028] In a sixth aspect, an embodiment of the present application further provides a chip, comprising at least one processor and a communication interface, wherein the processor is used to execute the method described in the first aspect or any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 This is a schematic diagram of a complete IO trace captured on the disk side;
[0030] Figure 2 A schematic flow chart of a method for processing IO commands in a system architecture where an ARM platform SAS controller is connected to a SATA disk is shown;
[0031] Figure 3 A flowchart of a method for processing an IO command provided in an embodiment of the present application;
[0032] Figure 4 A schematic diagram of a method for adding timestamps to several key states of IO after sending IO (command) to software is shown;
[0033] Figure 5 A schematic diagram of an implementation flow of an IO command processing method provided in an embodiment of the present application;
[0034] Figure 6 A schematic diagram of the structure of an IO command processing device provided in an embodiment of the present application;
[0035] Figure 7 A schematic diagram of the structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] The term "and / or" in this article is a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The symbol " / " in this article indicates that the associated objects are in an or relationship, for example, A / B means A or B.
[0037] The terms "first" and "second" in the specification and claims herein are used to distinguish different objects rather than to describe a specific order of the objects. For example, a first response message and a second response message are used to distinguish different response messages rather than to describe a specific order of the response messages.
[0038] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0039] In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more than two. For example, multiple processing units refer to two or more processing units, etc.; multiple elements refer to two or more elements, etc.
[0040] The technical solution of the present application is further described in detail below through the accompanying drawings and embodiments.
[0041] The IO command processing method provided in the embodiment of the present application can be used in any storage system, which includes a hard disk controller and a hard disk. The hard disk controller can be any hard disk controller, such as a SAS controller and a SATA controller, and the hard disk can be any hard disk compatible with the hard disk controller. For example, when the hard disk controller is a SAS controller, the hard disk can be a SAS hard disk or a SATA controller. The hard disk controller is a SATA controller, and the hard disk is a SATA hard disk.
[0042] The following takes a hard disk controller that is a SAS controller and a SAS controller that is connected to a SATA hard disk as an example to introduce the IO command processing method provided in the embodiment of the present application.
[0043] Since the introduction of the SAS interface, it has been increasingly used in the server and storage fields because it is backward compatible with SATA and has great advantages over SATA in performance and speed. The main CPU or key chips are also increasingly integrating SAS storage or expansion interfaces. In HDD hard disks, the proportion of SAS interfaces has gradually increased, but the cost is more expensive. In most storage applications, SATA HDD disks with higher cost performance are preferred as terminal storage media. SATA HDD still occupies half of the storage market. Because the main control is mainly SAS interface (controllers include but are not limited to CPU direct output or RAID), it is very common to connect SAS controllers to SATA HDDs.
[0044] After a SATA HDD has been online for a period of time, its performance will gradually deteriorate and its IO response will gradually slow down, but the SMART status is normal. This is simply manifested as a slow disk phenomenon. Combined with the analysis of a large number of slow disk samples, the typical cause is that the host side or the business side sends IO frequency too fast, and the IO queue in the slow disk is deep, resulting in a slow DMA setup frame response, such as Figure 1 As shown in the figure, a complete IO trace captured on the disk side shows that a single IO takes a total of 6.6s, almost all of which is consumed in the DMA setup frame.
[0045] If the above slow disks are not processed, they will generally be replaced directly, which will greatly increase the operating costs. There is an urgent need for a solution to solve or avoid slow disks, extend the service life of SATA HDDs, and reduce costs for enterprise operations.
[0046] In the related art, there is generally no flow control design for the frequency of sending IO commands. For example, Figure 2 The present invention shows a schematic flow chart of a method for processing IO commands in a system architecture of an ARM platform SAS controller connected to a SATA disk, including a service IO issuing process and a disk internal IO scheduling process. Figure 2 As shown in the figure, after the kernel sends the IO of the command sequence to the SAS controller, it uses libata's NCQ technology to send it to the delivery queue (DQ) buffer. The DQ buffer can be understood as the cache of the command queue in a SAS controller on an ARM platform, which is used as an overall scheduling to adapt to the higher rate of SAS reading and writing. The maximum number of entries per DQ is 4096, and the maximum number of DQs is 16. When the write pointer is greater than the read pointer, it means that there is a new IO. The SAS controller chip will read from the DQ queue and send the IO to the disk. When the write pointer = the read pointer, it means that all command IOs have been completed.
[0047] In the related technologies, there is no flow control design in the IO scheduling design, NCQ concurrent IO, and sending IO from the chip side to the disk. For normal SATA HDD disks, the disk can process IO in time, which can improve the overall IO read and write performance, and the advantages are obvious. However, for sub-healthy disks and HDDs with a tendency to slow down, the IO response in the disk becomes slow, and the input has no flow control design, which will lead to a deeper IO queue in the disk and more obvious slow disk characteristics, which will affect the upper-layer business and shorten the life cycle of the hard disk.
[0048] In view of the technical problems existing in the background technology and related technologies, the embodiment of the present application provides a method for processing IO commands, which dynamically adjusts the frequency of issuing IO commands according to the response time of the IO commands on the hard disk side, solves the slow disk problem of the hard disk, increases the service life of the hard disk, and reduces the operating costs of the enterprise.
[0049] Figure 3 The present invention provides a flowchart of a method for processing IO commands. The method can be implemented by a processor of a computing device or by a hard disk controller (such as a SAS controller) of a storage system, thereby reducing the probability of slow disks in the storage system and avoiding the cost of frequently replacing slow disks. Figure 3 As shown, the IO command processing method provided in the present application at least includes step S301 to step S302.
[0050] In step S301, the IO response time of the IO command on the hard disk side is determined.
[0051] The IO response time of each IO command issued by the host side / business layer on the hard disk side is monitored in real time, and the IO response time greater than or equal to the preset threshold (for example, 30s) is determined as slow IO. The hard disk corresponding to slow IO is a "slow disk". In other words, the purpose of this step is to detect and find out the "slow disk" in the popular sense in the storage system, and then process the IO of the "slow disk" to eliminate the slow disk phenomenon of the hard disk.
[0052] There are many methods to determine the IO response time of an IO command on the hard disk side. For example, by adding timestamps t to several key states in the IO command processing process, and then determining the IO response time of the IO command on the hard disk side according to the timestamps of several key IO states.
[0053] Exemplarily, the key status of IO includes the status of IO command sent to SAS controller and IO completion status. When detecting that IO command is sent to SAS controller, timestamp t1 is added to the IO (t1 is the time point when IO command is sent to SAS controller), and when detecting that IO is completed, timestamp t4 is added to the IO. That is to say, timestamp t1 indicates the time point when IO command is sent to SAS controller, timestamp t4 indicates the time point when IO is completed on hard disk side, and then IO response time of the hard disk side of the IO command can be obtained according to t4-t1.
[0054] It can be understood that the meaning of IO completion is that the hard disk completes the processing of the IO command and returns the IO processing result to the host, and it will go to task done, indicating that the IO is completed. For example, the host sends a read command to the hard disk side, the read command is added to the IO queue, the hard disk side responds to the read command, executes the read operation and returns the data to be read to the host, the IO is completed, the taskdone operation is executed, and the read command in the IO queue is executed.
[0055] In some other examples, the key status of IO may include more, such as IO timeout status, SAS drive release IO status, IO timeout detection, adding timestamp t2 (t2=t1+set timeout duration) to the IO, and when the SAS drive releases IO, adding timestamp t3 of the time point to the IO. More IO information can be obtained based on timestamps t1, t2, t3 and t4, and corresponding operations can be processed based on the IO information. For example, if the IO command has timestamp t1 and timestamp t4, it can be known that the IO is completed within the timeout. If the IO command has timestamp t1, timestamp t2 and timestamp t4, it can be known that the IO is completed after the timeout. If the IO command has timestamp t1, timestamp t2 and timestamp t3, it means that the IO is not completed, and the IO resources will be released in the repair process.
[0056] In step S302, based on the IO response time, a sending parameter for sending an IO command to the target hard disk is determined.
[0057] After obtaining the IO response time of each IO command, the sending parameters for sending the IO command to the target hard disk can be determined according to the IO response time, and the frequency of sending the IO command to the target hard disk can be adjusted by the sending parameters.
[0058] The target hard disk mentioned here is the hard disk corresponding to the IO command, that is, the hard disk used to respond to the IO command. For example, if the IO command is a write operation command, the write operation command will carry the hard disk ID (i.e. hard disk identification) of the hard disk used to perform the write operation. The hard disk ID is obtained by parsing the IO command, and the hard disk identified by the hard disk ID is the target hard disk of the IO command.
[0059] Through the IO response time of each IO command, the slow IO in the IO command can be detected. For example, the IO whose IO response time is greater than or equal to the preset threshold is marked as slow IO, and then the hard disk corresponding to the slow IO is obtained by parsing the IO command, and then the sending parameters of the IO command sent to the hard disk are adjusted, thereby reducing the frequency of sending IO commands to the hard disk, thereby reducing the IO queue depth in the disk, increasing the IO response time margin of the hard disk, and eliminating the slow IO phenomenon of the hard disk.
[0060] The sending parameters of the IO command sent to the target hard disk may include one or more of the number of IO commands executed in parallel, the number of IO commands sent in a unit, and the time interval for sending the IO command to the hard disk. For example, when the IO response time of the IO command is greater than or equal to a preset threshold, it is determined that the IO command has a slow IO phenomenon, and the IO command is parsed to obtain the target hard disk corresponding to the IO command. For the target hard disk, the number of IO commands executed in parallel can be reduced, and / or the number of IO commands sent in a unit can be reduced, and / or the time interval for sending IO commands to the hard disk can be increased, thereby reducing the frequency of sending IO commands to the target hard disk and eliminating the slow IO phenomenon of the target hard disk.
[0061] In another example, for a hard disk with NCQ function, the sending parameters of the IO command sent to the target hard disk may include one or more of the interval of NCQ IO sending, NCQ queue_depth and blkio.throttle. For example, for a hard disk detected to have slow IO, the hard disk driver can reduce the interval of NCQ IO sending, and optionally, the interval time uses the kernel standard interface function usleep_range to control the order of IO command sending; and / or, reduce NCQqueue_depth to reduce the IO concurrency in the disk, for example, the value of NCQ queue_depth is 32, indicating that the concurrency in the disk is 32 before, and the hard disk can process up to 32 IOs at the same time. If the disk is identified to have slow IO now, the value of NCQqueue_depth is adjusted to 8, indicating that the concurrency in the disk is 8, and the hard disk can process up to 8 IOs at the same time; and / or, the system kernel (OS kernel) adjusts blkio.throttle to lower the IOPS of the hard disk; by adjusting the sending parameters, the frequency of sending IO commands to the target hard disk is reduced, and the slow IO phenomenon of the target hard disk is eliminated.
[0062] The IO command processing method provided in the present application can dynamically adjust the frequency of IO issuance according to the response time of the IO command on the disk side, so as to reduce the IO queue depth on the disk side, increase the IO response time margin on the hard disk side, reduce the probability of slow disk occurrence, and thus extend the service life of the hard disk and reduce the cost overhead caused by replacing the slow disk.
[0063] In another example, the IO command processing method provided by the present application further includes: determining that the IO response time is greater than or equal to a preset threshold; parsing the IO command to determine the target hard disk corresponding to the IO command; and marking the target hard disk as a risky disk. In other words, marking a hard disk that meets the slow IO standard as a risky hard disk.
[0064] In another possible implementation, the IO command processing method provided by the present application further includes determining that the number of times the target hard disk is marked as a risk disk is greater than or equal to a preset number of times; determining the target hard disk as a slow disk. For example, if the number of times the target hard disk is marked as a risk disk is greater than or equal to 4 times, the target hard disk is determined to be a slow disk. In other words, after the risk disk has been processed by adjusting the IO sending frequency several times, the hard disk that still has the slow IO phenomenon is determined to be a slow disk. At this time, the hard disk is most likely to have an internal failure, so the risk disk is determined to be a slow disk.
[0065] In another example, in order not to affect the read and write performance of the storage system, the hard disk determined to be a slow disk is processed. For example, it is recommended to replace the hard disk. Exemplarily, a message "Hard disk ID, a slow disk problem has occurred, it is recommended to replace the hard disk" is sent to the user, or "Hard disk ID, a slow disk problem has occurred, it is recommended to replace the hard disk" is displayed on the interactive interface of the computing device to remind the user to replace the hard disk determined to be a slow disk to ensure the IO performance of the computing device.
[0066] The following is an introduction to the specific implementation of the IO command processing method provided in the embodiment of the present application through a specific example.
[0067] Figure 4 The figure shows a schematic diagram of a method for adding timestamps to several key states of IO after sending IO (command) to the software. Figure 4 The software shown sends IO, and the timestamps added by IO include timestamp t0, timestamp t1, timestamp t2, timestamp t3 and timestamp t4, wherein timestamp t0 indicates the time point when the kernel generates IO request, timestamp t1 indicates the time point when IO is sent to the SAS controller, timestamp t2 indicates the time point when IO times out, timestamp t3 indicates the time point when the SAS driver releases IO, and timestamp t4 indicates the time point when IO is completed and the task done operation is executed. It is judged by t4-t1 whether IO is slow IO, and the standard size of t4-t1 is customized according to the actual business needs. When slow IO is detected, the IO sending frequency is adjusted. After the IO response returns to normal, it is restored to the default parameters. In addition, if the slow IO of a specific disk is detected to exceed a certain number N (the number N is customized according to the actual business needs, and the embodiment of this application is not limited), it is marked as a slow disk and it is recommended to replace it.
[0068] Figure 5 The following is a schematic diagram of an implementation flow of a method for processing an IO command provided in an embodiment of the present application. Figure 5 As shown, a method for processing an IO command provided in an embodiment of the present application specifically includes the following steps in actual implementation:
[0069] S501, the software sends IO, and the kernel monitors IO in real time, paying attention to timestamps t4 and t1;
[0070] S502, enter judgment condition 1, whether t4-t1>N is established (i.e., whether the slow IO condition is established);
[0071] S503, if the judgment condition 1 is Yes, parse the IO address to determine which disk the IO address belongs to, mark the disk as a risky disk, and increase the number of slow IO times by 1;
[0072] S504. If the judgment condition 1 is No, parse the IO address to determine whether the hard disk corresponding to the IO address is a risk disk. If it is not a risk disk, do not do anything to the hard disk. If it is a risk disk, restore the sending parameters corresponding to the hard disk to the default parameters.
[0073] S505, enter judgment condition 2, whether the number of slow IO times of risk disk>N is established;
[0074] S506, if the judgment condition 2 is Yes, then mark it as a slow disk and recommend replacement;
[0075] S507. If the judgment condition 2 is NO, then for this risk disk, the IO sending frequency is reduced. There are three optional operations. According to the actual business situation, one or more of the three optional operations can be customized to adjust the IO sending frequency.
[0076] S508, SAS driver reduces NCQ IO interval, it is recommended to use usleep_range; ②SAS driver reduces NCQqueue_depth; ③OS kernel adjusts blkio.throttle to reduce read and write IOPS;
[0077] S509, enter judgment condition 3, when the IO is not slow IO, judge whether it is a risk disk;
[0078] S510. If the judgment condition 3 is Yes, it means that the risk disk has returned to normal, and the default parameters of the IO sending frequency are restored;
[0079] S511, if the judgment condition 3 is NO, no processing is performed;
[0080] S512, cyclically detect IO in real time.
[0081] By providing a method for processing IO commands in an embodiment of the present application, the frequency of IO issuance can be dynamically adjusted according to the disk-side response time of IO, thereby reducing the slow IO phenomenon, improving IO robustness, and ensuring the smooth operation of upper-layer services.
[0082] Based on the same concept as the above-mentioned embodiment of the method for processing IO commands, the embodiment of the present application also provides an IO command processing device 600, which is deployed on a computing device, and the computing device can be any computing device with a processor and a storage system, and is used to reduce the probability of a "slow disk" appearing in the hard disk in the storage system. The IO command processing device 600 includes a method for implementing Figure 3-5 The units or modules of each step in the IO command processing method shown.
[0083] Figure 6 A schematic diagram of the structure of an IO command processing device provided in an embodiment of the present application. Figure 6 As shown, the processing device 600 of an IO command includes at least a first determination module 601 and a parameter adjustment module 602, wherein the first determination module 601 is used to determine the IO response time of the IO command on the hard disk side; the parameter adjustment module 602 is used to determine the sending parameters of the IO command to the target hard disk based on the IO response time, and the sending parameters are used to adjust the frequency of sending the IO command to the target hard disk, and the target hard disk is a hard disk used to respond to the IO command.
[0084] In a possible implementation, the parameter adjustment module 602 is specifically used to determine that the sending parameter is a first sending parameter when the IO response time is less than a preset threshold; when the IO response time is greater than or equal to the preset threshold, determine that the sending parameter is a second sending parameter; wherein the frequency of sending IO commands to the target hard disk with the first sending parameter is greater than the frequency of sending IO commands to the target hard disk with the second sending parameter.
[0085] In another possible implementation, the sending parameter includes one or more of the sending interval of the native command queue, the number of IO commands executed in parallel, and the number of IO commands sent per unit time.
[0086] In another possible implementation, the IO command processing device 600 provided in the present application also includes a second determination module 603, a parsing module 604 and a marking module 605, wherein the second determination module 603 is used to determine that the IO response time is greater than or equal to a preset threshold; the parsing module 604 is used to parse the IO command and determine the target hard disk corresponding to the IO command; the marking module 605 is used to mark the target hard disk as a risky disk.
[0087] In another possible implementation, the IO command processing device 600 provided in the present application also includes a third determination module 606, which is used to determine that the number of times the target hard disk is marked as a risk disk is greater than or equal to a preset number; and determine the target hard disk as a slow disk.
[0088] In another possible implementation, the first determination module 601 is specifically used to: obtain a first moment and a second moment, the first moment indicating the moment when the hard disk controller receives the IO command, and the second moment indicating the moment when the IO command is executed; based on the first moment and the second moment, determine the IO response time of the IO command on the hard disk side.
[0089] In another possible implementation, the target hard disk is a SATA mechanical hard disk, and the hard disk controller of the target hard disk is a SAS controller.
[0090] The IO command processing device 600 according to the embodiment of the present application may correspond to the method described in the embodiment of the present application, and the above and other operations and / or functions of each module in the IO command processing device 600 are respectively to implement Figure 3-5 For the sake of brevity, the corresponding processes of each method in are not repeated here.
[0091] The present application also provides a computing device, including at least one processor, a memory and a communication interface, wherein the processor is used to execute Figure 3-5 The method described.
[0092] Figure 7 A schematic diagram of the structure of a computing device provided in an embodiment of the present application.
[0093] like Figure 7 As shown, the computing device 700 includes at least one processor 701, a memory 702 and a communication interface 703. The processor 701, the memory 702 and the communication interface 703 are communicatively connected, and the communication connection can be realized by a wired manner (such as a bus) or by a wireless manner. The communication interface 703 is used to receive data sent by other devices; the memory 702 stores computer instructions, and the processor 701 executes the computer instructions to execute the IO command processing method in the aforementioned method embodiment, so as to realize the IO response time of the IO command on the hard disk side, and dynamically adjust the IO sending frequency, thereby reducing the probability of "slow disk" appearing in the storage system and reducing the cost overhead caused by replacing the hard disk.
[0094] It should be understood that in the embodiment of the present application, the processor 701 may be a central processing unit CPU, and the processor 701 may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0095] The memory 702 may include a read-only memory and a random access memory, and provides instructions and data to the processor 701. The memory 702 may also include a nonvolatile random access memory.
[0096] The memory 702 may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. Among them, the nonvolatile memory may be a read-only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0097] It should be understood that the computing device 700 according to the embodiment of the present application can execute the implementation of the embodiment of the present application. Figure 3-5 The method shown, the detailed description of the implementation of this method can be found above, for the sake of brevity, it will not be repeated here.
[0098] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer instructions are executed by a processor, the above-mentioned method is implemented.
[0099] An embodiment of the present application provides a chip, which includes at least one processor and an interface, wherein the at least one processor determines program instructions or data through the interface; the at least one processor is used to execute the program instructions to implement the method mentioned above.
[0100] An embodiment of the present application provides a computer program or a computer program product, wherein the computer program or the computer program product comprises instructions, and when the instructions are executed, the computer is caused to execute the above-mentioned method.
[0101] Those of ordinary skill in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those of ordinary skill in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0102] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented by hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0103] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only the specific implementation method of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A method for processing an IO command, characterized in that: include: Determine the IO response time of IO commands on the hard disk side; Based on the IO response time, a sending parameter for sending an IO command to a target hard disk is determined, wherein the sending parameter is used to adjust a frequency of sending the IO command to the target hard disk, and the target hard disk is a hard disk used to respond to the IO command.
2. The method according to claim 1, characterized in that The determining, based on the IO response time, a sending parameter for sending an IO command to a target hard disk includes: When the IO response time is less than a preset threshold, determining the sending parameter to be a first sending parameter; When the IO response time is greater than or equal to the preset threshold, determining the sending parameter to be a second sending parameter; The frequency of sending IO commands to the target hard disk with the first sending parameter is greater than the frequency of sending IO commands to the target hard disk with the second sending parameter.
3. The method according to claim 2, characterized in that The sending parameters include one or more of the sending interval of the native command queue, the number of IO commands executed in parallel, and the number of IO commands sent per unit time.
4. The method according to claim 2 or 3, characterized in that: Also includes: Determine that the IO response time is greater than or equal to the preset threshold; Parsing the IO command to determine a target hard disk corresponding to the IO command; The target hard disk is marked as a risky disk.
5. The method according to claim 4, characterized in that Also includes: Determine that the number of times the target hard disk is marked as a risk disk is greater than or equal to a preset number; The target hard disk is determined to be a slow disk.
6. The method according to any one of claims 1 to 5, characterized in that: Determining the IO response time of the IO command on the hard disk side includes: Acquire a first time and a second time, wherein the first time indicates a time when the hard disk controller receives the IO command, and the second time indicates a time when the IO command is executed; Based on the first time and the second time, an IO response time of the IO command on the hard disk side is determined.
7. The method according to any one of claims 1 to 6, characterized in that: The target hard disk is a SATA mechanical hard disk, and the hard disk controller of the target hard disk is a SAS controller.
8. An IO command processing device, characterized in that: include: A first determination module, used to determine an IO response time of an IO command on a hard disk side; The parameter adjustment module is used to determine the sending parameters of the IO command to the target hard disk based on the IO response time, and the sending parameters are used to adjust the frequency of sending the IO command to the target hard disk, and the target hard disk is a hard disk used to respond to the IO command.
9. The device according to claim 8, characterized in that The parameter adjustment module is specifically used for: When the IO response time is less than a preset threshold, determining the sending parameter to be a first sending parameter; When the IO response time is greater than or equal to the preset threshold, determining the sending parameter to be a second sending parameter; The frequency of sending IO commands to the target hard disk with the first sending parameter is greater than the frequency of sending IO commands to the target hard disk with the second sending parameter.
10. The device according to claim 9, characterized in that The sending parameters include one or more of the sending interval of the native command queue, the number of IO commands executed in parallel, and the number of IO commands sent per unit time.
11. The device according to claim 9 or 10, characterized in that Also includes: A second determination module, configured to determine whether the IO response time is greater than or equal to the preset threshold; A parsing module, used for parsing the IO command and determining a target hard disk corresponding to the IO command; The marking module is used to mark the target hard disk as a risky disk.
12. The device according to claim 11, characterized in that Also includes: A third determination module is used to determine whether the number of times the target hard disk is marked as a risk disk is greater than or equal to a preset number; The target hard disk is determined to be a slow disk.
13. The device according to any one of claims 8 to 12, characterized in that: The first determining module is specifically used for: Acquire a first time and a second time, wherein the first time indicates a time when the hard disk controller receives the IO command, and the second time indicates a time when the IO command is executed; Based on the first time and the second time, an IO response time of the IO command on the hard disk side is determined.
14. The device according to any one of claims 8 to 13, characterized in that: The target hard disk is a SATA mechanical hard disk, and the hard disk controller of the target hard disk is a SAS controller.
15. A computing device comprising a memory and a processor, characterized in that: Instructions are stored in the memory, and when the instructions are executed by the processor, the method according to any one of claims 1 to 7 is implemented.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Slow disk detection method and device
CN103810062A
Prediction and processing of slow disks
CN111813585A
Slow disk detection method, device and equipment and storage medium
CN112416639A