Queue management method of storage device, electronic device and storage medium
By sending batch operation instructions to storage devices, batch creation and deletion of storage device queues are realized, and the problems of heavy interaction burden, low link efficiency, long processing delay and reset timeout risks in the prior art are solved, which significantly improves configuration efficiency and response speed.
Patent Information
- Application Number
- CN202510237491.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-05-23
AI Technical Summary
In the prior art, the interaction burden between the host and the storage device is heavy, the link efficiency is low, the processing delay is long, and the reset timeout risk is high when configuring the storage device.
By sending batch operation instructions to the storage device, the storage address containing the batch operation type and queue parameters, the storage device triggers the storage device to batch obtain the queue parameters of multiple input and output queues from the specified address, and completes the creation or deletion of all input and output queues at one time.
It simplifies the interaction between the host and the storage device, significantly reduces the number of communications and data transmission redundancy, reduces the use of link bandwidth, shortens the time of the initialization or reset process, and improves configuration efficiency.
Smart Images

Figure CN120029428A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data transmission, and in particular to a queue management method for a storage device, an electronic device, and a storage medium. Background Art
[0002] When the host and storage device communicate, they communicate through command queues (SQ (Submission Queue) and CQ (Completion Queue). The host puts the command into the submission queue (SQ), the storage device reads the command from the SQ and executes it, and finally puts the result into the completion queue (CQ). According to the NVMe (Non-Volatile Memory Express) protocol, queues are divided into two categories: one is a control queue dedicated to managing the configuration operations of storage devices, and the other is an IO (input and output) queue used to read and write data in storage devices.
[0003] In the related art, when the host configures the storage device, the host needs to send control commands one by one through the control queue to create or delete the IO queue, and each control command can only create one IO queue (SQ queue or CQ queue), and the control command is stored in the control queue. When the number of IO queues to be configured is large, a large number of control commands need to be sent to complete this process, the interaction burden between the host and the storage device is large, and it takes a long time to process a large number of control instructions. If this process occurs during the reset process of the storage device, the storage device may be reset abnormally due to the long reset time, thereby affecting the use of the storage device. Summary of the invention
[0004] The present application provides a queue management method for a storage device, an electronic device and a storage medium, so as to at least solve the problems of heavy interaction burden, low link efficiency, long processing delay and reset timeout risk in the related art.
[0005] The present application provides a queue management method for a storage device, which is applied to a host. The queue management method for the storage device includes: when configuring the storage device, sending a batch operation instruction to the storage device; the batch operation instruction includes a batch operation type and a storage address of queue parameters, and the batch operation type includes batch deletion and batch creation; triggering the storage device to obtain queue parameters of multiple input and output queues from the storage address, and batch creation or batch deletion of the multiple input and output queues according to the batch operation type, and the input and output queues include an input and output submission queue and an input and output completion queue.
[0006] The present application also provides a queue management method for a storage device, which is applied to a storage device. The queue management method for a storage device includes: receiving a batch operation instruction; the batch operation instruction includes a batch operation type and a storage address of queue parameters, and the batch operation type includes batch deletion and batch creation; reading queue parameters of multiple input and output queues from the storage address; batch creating or batch deleting multiple input and output queues according to the batch operation type, and the input and output queues include an input and output submission queue and an input and output completion queue.
[0007] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned queue management methods for storage devices when executing the computer program.
[0008] The present application also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program is executed by a processor, the steps of any of the above-mentioned queue management methods for storage devices are implemented.
[0009] Through the present application, when configuring a storage device, the host only needs to send an instruction containing a batch operation type and a queue parameter storage address to trigger the storage device to batch obtain queue parameter information of multiple input and output queues from the specified address, and complete the creation or deletion of all input and output queues at one time; the present application simplifies multiple commands that originally needed to be issued one by one into a single interaction, greatly reducing the number of communications and data transmission redundancy between the host and the storage device, reducing the link bandwidth occupancy, and significantly shortening the initialization or reset process time. Especially in scenarios with a large number of queues, it effectively solves the problems of heavy interaction burden, low link efficiency, long processing delay and reset timeout risk in the prior art, and achieves the technical effect of simplifying the number of interactions and improving configuration efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1 A queue interaction architecture diagram of a host and a storage device provided in an embodiment of the present application;
[0012] Figure 2 A schematic architecture diagram of two queues of a host and a storage device provided in an embodiment of the present application;
[0013] Figure 3 An initialization flow chart of sequentially creating a single queue provided in an embodiment of the present application;
[0014] Figure 4 A reset flow chart of sequentially deleting a single queue provided in an embodiment of the present application;
[0015] Figure 5 A flowchart of a queue management method for a storage device provided in an embodiment of the present application;
[0016] Figure 6 A schematic diagram of a data structure for batch creation of IOCQ queues provided in an embodiment of the present application;
[0017] Figure 7 A schematic diagram of a data structure for batch creation of IOSQ queues provided in an embodiment of the present application;
[0018] Figure 8 A schematic diagram of a data structure for deleting IOCQ queues in batches provided in an embodiment of the present application;
[0019] Fig. 9 A schematic diagram of a data structure for deleting IOSQ queues in batches provided in an embodiment of the present application;
[0020] Fig.10 A flowchart of another queue management method for a storage device provided in an embodiment of the present application;
[0021] Fig.11 A flowchart for initializing batch creation of queues provided in an embodiment of the present application;
[0022] Fig.12 A reset flow chart of a batch deletion queue provided in an embodiment of the present application;
[0023] Fig.13 A schematic diagram of an electronic device provided in an embodiment of the present application;
[0024] Fig.14 A schematic diagram of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0026] It should be noted that, in the description of this application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0027] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0028] In conjunction with the specific application environment architecture or the specific hardware architecture on which the execution of the queue management method of the storage device depends, the specific application environment architecture or the specific hardware architecture is described herein.
[0029] The embodiment of the present application provides a queue management method for a storage device, and the method is described in detail in combination with the execution process of the queue management method for the storage device. Among them, the terms involved in the following embodiments are first explained. Specifically, the storage device may refer to a solid-state hard disk, a storage controller or a similar device based on the NVMe protocol, which is used to persist storage data and communicate with the host through a PCIe (Peripheral Component Interconnect Express) bus. The host refers to a computing device (such as a server) connected to the storage device, which is responsible for issuing instructions (such as read, write, and configuration commands) to the storage device and managing its operation. Batch operation instructions refer to an optimized command format defined in this application, which allows the creation or deletion of multiple queues to be completed through a single instruction interaction, replacing the method of issuing commands one by one in the NVMe protocol in the related art. The queue identity (ID) refers to the number that uniquely identifies the queue (such as SQ1, CQ2). The queue depth (Size) refers to the maximum number of instruction entries that the queue can accommodate. The interrupt configuration information indicates whether a hardware interrupt is triggered to notify the host after the specified queue operation is completed (which may not be limited to including the interrupt number and the interrupt enable bit). The binding relationship indicates the association between the submission queue (SQ) and the completion queue (CQ) (for example, SQ1 is bound to CQ1). The input / output submission queue is the queue where the host submits instructions (such as read / write requests) to the storage device, and the storage device reads and executes the instructions in sequence. The input / output completion queue is the queue where the storage device feeds back the results of instruction execution to the host. Each completion queue entry (CQE) contains the instruction status (success / failure) and related data. Direct memory access means that the storage device is allowed to bypass the host CPU and directly access the queue parameters in the host memory, reducing the CPU load and improving transmission efficiency. The control instruction submission queue is a dedicated SQ for the host to issue management commands (such as create / delete queues). The control instruction completion queue is a dedicated CQ for the storage device to return the results of management command execution.
[0030] Before describing this application, let’s first briefly introduce some basic principles. Communication between the host and the storage device based on the NVMe protocol needs to be completed through the input and output queues located in the host memory. The host needs to put the instructions executed by the storage device into the input queue (SQ queue), and then notify the storage device to read the instructions. The controller inside the storage device reads the instructions from the IO submission queue (SQ queue) of the host memory through the PCIe message, and executes the instructions inside the storage device. Finally, the executed instruction results are placed in the corresponding IO completion queue (CQ queue) through the PCIe message, and the host is notified of the instruction execution results to complete an IO interaction. For example, NVMe supports a maximum of 64K queues, and the input queue (SQ queue) and the completion queue (CQ queue) are one-to-one (such as Figure 1 as shown).
[0031] like Figure 2 As shown in the figure, the NVMe protocol defines two types of instructions, one is control instructions and the other is IO instructions. Control instructions are mainly used to configure storage devices, and IO instructions are mainly used to read and write data in the Flash media in storage devices. At the same time, the NVMe protocol also defines two types of queues, namely control queues and IO queues. Control instructions can only be submitted to control queues, and IO instructions can only be submitted to IO queues. The control queue only contains one set of input queues (SQ) and one set of completion queues (CQ), while the IO queue can contain multiple sets of input queues (SQ) and multiple sets of completion queues (CQ). When the host is initialized, the host needs to create an IO queue through control commands. Each control command can only create one input queue (SQ) or one completion queue (CQ). All instructions are sent from the host to the storage device through the PCIe link to perform corresponding operations. NVMe instructions interact based on the synchronization of requests and responses, and each request command corresponds to a response command. The request command is placed in the IO request queue (SQ) by the host, and the response command is placed in the IO completion queue (CQ) by the controller of the storage device. All instructions in the NVMe device are initiated by the host and the storage device responds to the request. The initialization of NVMe storage devices is also completed through the interaction of control instructions.
[0032] A more time-consuming initialization process such as Figure 3 As shown in the figure, (1) during initialization, the host sends a CC.EN=1 signal to the storage device to request that the device be initialized; (2) the storage device replies with a CSTS.RDY=1 signal, indicating that initialization can begin; (3) the host issues an SQE query command to query the device's capability parameters (the maximum number of IO queues that can be created); (4) the storage device replies with a CQE query command; (5) the host issues an SQE command to create an IOCQ queue; (6) the storage device responds to the IOCQ queue creation command and returns CQE; (7) the host issues an SQE command to create an IOSQ queue; (8) the storage device responds to the IOSQ queue creation command and returns CQE; (9) the host loops through steps 5-8 to create multiple IOSQ and IOCQ queues based on the number of IO queues supported by the device; (10) the host issues an SQE command to configure the storage device; (11) the storage device enables or disables the corresponding function based on the host's configuration and returns CQE.
[0033] If a storage device fails during use, it needs to be reset. The RESET process of the host and NVMe storage device also involves the deletion and creation of queues. A relatively time-consuming reset process is as follows: Figure 4As shown in the figure, (1) the host starts to deinitialize the storage device; (2) the host sends the SQE command to delete the IOCQ queue; (3) the storage device responds to the IOCQ queue deletion command and returns CQE; (4) the host sends the SQE command to delete the IOSQ queue; (5) the storage device responds to the IOSQ queue deletion command and returns CQE; (6) the host loops through steps 2-5 according to the number of IO queues that have been created, deleting multiple IOSQ and IOCQ queues; (7) the host sends a CC.EN=0 signal to the storage device, indicating that the host deinitializes the storage device; (8) the storage device replies with a CSTS.RDY=0 signal, indicating that the deinitialization is complete; (9) the subsequent steps are consistent with the initialization steps.
[0034] like Figure 5 As shown, the present application provides a queue management method for a storage device, which is applied to a host. The queue management method for the storage device includes:
[0035] S11: When configuring a storage device, a batch operation instruction is sent to the storage device; the batch operation instruction includes a batch operation type and a storage address of a queue parameter, and the batch operation type includes batch deletion and batch creation;
[0036] In the traditional NVMe protocol, the host needs to send commands one by one through the control queue (such as "create IOSQ" or "delete IOCQ"), and each command can only operate one queue. In scenarios with a large number of queues (such as supporting 64K queues), this one-by-one interaction method requires sending a large number of commands during initialization or reset (for example, a 64K queue requires 128K commands), which occupies the PCIe link bandwidth. Each command needs to transmit similar parameters (such as queue ID, size, etc.) separately, resulting in low link utilization.
[0037] To solve the above problems, this step proposes batch operation instructions, which embed the batch operation type (create / delete) and the storage address of queue parameters in a single instruction, rather than passing parameters one by one. Batch creation is used to instruct the storage device to read multiple queue parameters from the specified address and create all queues at one time. Batch deletion is used to instruct the storage device to batch delete all specified queues according to the queue ID list in the address. Among them, the batch operation type field uses 0 and 1 to represent a single operation or a batch operation, respectively. The host stores the queue parameters (such as queue ID, size, binding relationship) or the list of queue IDs to be deleted continuously at the preset address of the memory, and informs the device through the storage address field in the instruction.
[0038] By issuing a single instruction, S11 optimizes the traditional command-by-command interaction mode to batch processing, significantly reducing the number of interactions and redundant data transmission, and improving configuration efficiency.
[0039] S12: triggering the storage device to obtain queue parameters of multiple input and output queues from the storage address, and batch create or batch delete the multiple input and output queues according to the batch operation type, where the input and output queues include an input and output submission queue and an input and output completion queue.
[0040] This step is mainly based on the mechanism of batch operation instructions, triggering the storage device to read the queue parameters of multiple input and output queues from the storage address specified by the host, and perform corresponding operations on these queues according to the batch operation type (batch creation or batch deletion). Specifically, first, the host continuously stores the parameters of multiple queues in the preset memory address, such as queue ID, size, binding relationship, etc. The storage device learns these storage addresses through batch operation instructions and accesses the addresses to obtain a set of queue parameters. When the batch operation type is "batch creation", the storage device reads these parameters and creates multiple input and output queues (including input and output submission queues and input and output completion queues) at one time. When the batch operation type is "batch deletion", the storage device deletes multiple specified input and output queues according to the specified queue ID list.
[0041] This process is implemented by issuing a single instruction, avoiding the traditional one-by-one operation of commands, improving configuration efficiency, reducing the redundancy of command transmission and the occupancy of link bandwidth, thereby effectively reducing system overhead and improving link utilization while supporting a high number of queues.
[0042] In an exemplary embodiment, when configuring a storage device, before sending a batch operation instruction to the storage device, it also includes: predefining queue parameters of multiple input and output queues, and storing the queue parameters at a preset storage address of the host memory; the queue parameters include queue identity, queue depth, interrupt configuration information, and a binding relationship between an input and output submission queue and an input and output completion queue, and the binding relationship is used to indicate the association between the input and output submission queue and the input and output completion queue of the batch operation.
[0043] In this embodiment, in order to achieve high efficiency of batch operations when configuring the storage device, queue parameters of multiple input and output queues are first predefined, and these parameters are stored in a preset storage address of the host memory.
[0044] Specifically, queue parameters include several key elements, such as queue identity (used to uniquely identify each queue), queue depth (indicating the maximum number of requests that each queue can accommodate), interrupt configuration information (used to configure the conditions and methods for triggering interrupts to ensure real-time response of queue operations), and the binding relationship between input and output submission queues and input and output completion queues. The binding relationship is key, as it indicates which input and output submission queues are paired with which input and output completion queues, thereby ensuring the order of data operations and the correct transmission of data. The Submission Queue (SQ) is used to receive commands submitted by the host, while the Completion Queue (CQ) is used to store the execution results or feedback information of these commands by the storage device.
[0045] By predefining these parameters, the host can instruct the storage device to read these queue parameters from the specified storage address in a batch operation command, and perform batch creation or deletion operations based on the preset binding relationship. This method avoids the inefficient mode of command interaction one by one, allowing the storage device to automatically obtain and process the relevant information of multiple queues based on the batch operation instructions issued at one time, thereby improving the efficiency of storage device configuration, reducing redundant data transmission, and optimizing the overall system performance.
[0046] In an exemplary embodiment, the queue parameters also include priority information of multiple input and output submission queues; multiple input and output queues are batch created according to the batch operation type, including: determining the batch operation type as batch creation according to the batch operation type; parsing the priority information in the queue parameters, and creating multiple input and output queues in order from high to low priority.
[0047] In this embodiment, the queue parameters include not only basic information such as queue identity, queue depth and binding relationship, but also priority information of multiple input and output submission queues. These priority information specifies a priority level for each input and output submission queue, which is used to determine its relative importance and processing order when the queue is created.
[0048] Specifically, when the batch operation type is "batch creation", the host first parses the priority information in the queue parameters. Based on the priority information, the storage device will create multiple input and output queues in order from high to low. The core of this processing flow is priority sorting, which ensures that high-priority queues are created before low-priority queues, so that important or urgent tasks can be processed first in actual use, avoiding low-priority queues from occupying too many resources and affecting the execution of high-priority tasks.
[0049] In this way, when creating multiple queues, the storage device can not only efficiently batch process the queue initialization process, but also optimize resource allocation and scheduling according to the priority of the task, thereby improving the overall system performance and responsiveness. This process optimizes the batch creation operation not only in quantity, but also in quality, ensuring the system's efficient response and processing of tasks of different priorities.
[0050] According to the characteristics of these parameters, if the storage device supports multiple IO queues, the host can package the parameters of multiple IO queues together and send them to the storage device when creating or deleting IO queues. In this way, only one batch operation instruction is needed to create or delete multiple IO queues, which greatly improves the efficiency of creating or deleting queues and speeds up the device initialization or RESET process.
[0051] Specifically, the data structure for creating IOCQ queues in batches can be as follows Figure 6 As shown, size is the queue depth of the IOCQ queue, qid is the queue identity of the IOCQ queue, interrupt_vector is the interrupt number of the IOCQ queue, and interrupt_enable is the interrupt enable of the IOCQ queue.
[0052] Specifically, the data structure of batch creation of IOSQ queues is as follows Figure 7 As shown, size is the queue depth of the IOSQ queue, qid is the queue identifier of the IOSQ queue, cqid is the queue identifier of the IOCQ associated with the IOSQ queue, and priority is the priority information of the IOSQ queue.
[0053] Specifically, the data structure of batch deleting IOCQ queues is as follows Figure 8 As shown, size is the queue depth of the IOCQ queue to be deleted; the data structure of batch deleting IOSQ queues is as follows Fig. 9 As shown, qid is the queue identity of the IOSQ queue to be deleted.
[0054] In an exemplary embodiment, triggering a storage device to obtain queue parameters of multiple input and output queues from a storage address includes: triggering the storage device to obtain queue parameters of multiple input and output queues from the storage address by direct memory access.
[0055] In this embodiment, the process of triggering the storage device to obtain queue parameters of multiple input and output queues from the storage address adopts a direct memory access (DMA) method. This means that the storage device does not need to transmit data through the host's central processing unit (CPU), but directly reads data from the host's memory. DMA is an efficient data transmission method that can avoid data occupying too much CPU processing resources during the transmission process, thereby improving the efficiency of data processing.
[0056] Specifically, in this implementation, when the host issues a batch operation instruction, the storage device will access the specified memory address through DMA and directly obtain the queue parameters (such as queue ID, queue depth, priority, etc.) of multiple input and output queues stored in the memory. Compared with the traditional method of data transmission through the CPU, this method can greatly reduce the delay and system burden of data transmission, and improve the overall data liquidity and efficiency. Since DMA can directly transfer data between the storage device and the memory, the storage device can quickly and efficiently obtain the required queue parameters, and perform corresponding batch creation or batch deletion operations based on these parameters without waiting for CPU intervention, further improving the system's parallel processing capabilities and response speed.
[0057] In an exemplary embodiment, when configuring a storage device, sending batch operation instructions to the storage device includes: when configuring the storage device, sending batch operation instructions to the storage device through a control instruction submission queue; after batch creation or batch deletion of multiple input and output queues according to the batch operation type, it also includes: the storage device completes the queue through the control instruction to feedback the batch operation results.
[0058] In this embodiment, the implementation of the entire configuration process not only includes the issuance of batch operation instructions, but also involves a feedback mechanism after the batch operation is completed. When configuring the storage device, the batch operation instructions are first sent to the storage device through the control instruction submission queue. The control instruction submission queue (CSQ) is a channel for the host to interact with the storage device. The host sends batch operation instructions to the storage device through this queue. These instructions include the batch operation type (batch creation or batch deletion) and the specific operations that the storage device needs to perform.
[0059] After the batch operation command is issued, the storage device creates or deletes multiple input and output queues in batches according to the batch operation type. Specifically, the storage device creates a new queue or deletes a specified queue according to the queue parameters (such as queue ID, queue depth, etc.) provided by the host, and this process is implemented through batch operations, which greatly reduces the time and bandwidth consumption of traditional command-by-command interaction.
[0060] Once the batch operation is completed, the storage device needs to feedback the operation results to the host. During this process, the storage device feedbacks the results of the batch operation to the host through the Control Completion Queue (CCQ). The completion queue is a channel used by the storage device to report the operation status. It feeds back the success or failure of each operation, possible error information, etc. to the host. The host obtains feedback information from the completion queue to understand which queues have been successfully created or deleted, and which operations may have errors, so as to take corresponding follow-up actions.
[0061] This mechanism incorporates operation feedback into the batch operation process, allowing the host to promptly grasp the status of the storage device after the batch operation is completed, further enhancing the controllability and reliability of the system. At the same time, by controlling the feedback of the command completion queue, the communication between the host and the storage device becomes more efficient and clear, avoiding blind spots in operation and waste of resources.
[0062] In an exemplary embodiment, when configuring a storage device, before sending a batch operation instruction to the storage device, it also includes: when initializing the storage device, obtaining the maximum number of input and output queues supported by the storage device; predefining queue parameters of the maximum number of input and output queues, applying for a preset storage address from a host, and storing the queue parameters to the preset storage address; when configuring the storage device, sending a batch operation instruction to the storage device, including: when initializing the storage device, sending a batch creation instruction to the storage device, the batch operation type in the batch creation instruction is batch creation, and the storage address in the batch creation instruction points to the starting address of the preset storage address where the queue parameters of the input and output parameters to be created are located; triggering the storage device to obtain queue parameters of multiple input and output queues from the storage address, and batch creating or batch deleting multiple input and output queues according to the batch operation type, including: triggering the storage device to obtain queue parameters from the preset storage address by direct memory access, and batch creating the maximum number of input and output queues; after batch creating or batch deleting multiple input and output queues according to the batch operation type, it also includes: receiving the first completion queue entry returned by the storage device, and verifying the creation status of the input and output queue according to the first completion queue entry.
[0063] In this embodiment, operation steps in a storage device initialization scenario are specifically described.
[0064] Specifically, when initializing the storage device, the host needs to obtain the maximum number of input and output queues supported by the storage device. This information is usually obtained through the storage device's capability report or protocol specification, ensuring that the host can preset appropriate queue parameters based on the device's maximum supported capabilities. Next, the host will predefine the parameters of multiple input and output queues based on this maximum number. These parameters contain relevant information about the queues, such as queue ID, queue depth, priority, etc. The host applies for a preset storage address and stores these queue parameters in this preset storage address to ensure that the storage device can efficiently access these queue parameters in subsequent operations.
[0065] When configuring a storage device, the host will send a batch operation command to the storage device. Specifically, when the storage device is initialized, the host will send a batch creation command. The batch operation type of this command is "batch creation", and the storage address in the batch creation command will point to the starting position of the queue parameters in the previously preset storage address. This means that the host tells the storage device through this batch creation command to read the queue parameters of multiple input and output queues from the specified storage address and create queues according to these parameters.
[0066] The process of triggering the storage device to obtain queue parameters is implemented through direct memory access (DMA). Through DMA, the storage device can directly read the stored queue parameters from the preset storage address of the host without the intervention of the CPU, which can significantly improve the data transmission efficiency. After obtaining the queue parameters, the storage device batch creates input and output queues according to the batch operation type (i.e. batch creation), and can create up to the maximum number of queues supported by the storage device.
[0067] After the batch operation is completed, the host receives the first completion queue entry returned by the storage device through the control command completion queue. This first completion queue entry contains the result of the storage device executing the batch operation, including the creation status of each queue. The host verifies the creation status of the input and output queues based on these entries to ensure that all queues are successfully created as expected. If any queue creation fails, the host can take necessary remedial measures based on the feedback information, such as retrying creation or adjusting parameters.
[0068] In this way, the entire storage device configuration process can not only efficiently create queues in batches, but also verify the operation results through a feedback mechanism after the creation is completed, ensuring the stability and reliability of the system. At the same time, the use of DMA and batch operation instructions can greatly reduce the delay of command transmission and data processing, improving the overall performance of the system.
[0069] In an exemplary embodiment, when configuring a storage device, a batch operation instruction is sent to the storage device, including: when resetting the storage device, a batch deletion command is sent to the storage device, the batch operation type in the batch deletion instruction is batch deletion, and the storage address in the batch deletion instruction points to the starting address of the preset storage address where the queue parameters of the input and output queues to be deleted are located; triggering the storage device to obtain queue parameters of multiple input and output queues from the storage address, and batch creating or batch deleting multiple input and output queues according to the batch operation type, including: triggering the storage device to obtain queue identity identifiers from the preset storage address through direct memory access, and batch deleting the created input and output queues; after batch creating or batch deleting multiple input and output queues according to the batch operation type, it also includes: receiving a second completion queue entry returned by the storage device, and verifying the deletion status of the input and output queues according to the second completion queue entry; when the deletion status meets the preset conditions, re-entering the step of sending a batch creation instruction to the storage device when initializing the storage device.
[0070] In this embodiment, operation steps in the scenario of resetting the storage device are mainly described.
[0071] Specifically, when resetting the storage device, the host will send a batch delete command to the storage device. The batch operation type of this command is set to "batch delete", and the storage address in the delete command points to the starting position of the queue parameters of the input and output queues to be deleted stored in the preset storage address. The core of this operation is to let the storage device know which queues need to be deleted through the batch delete command, thereby avoiding the inefficiency of traditional one-by-one deletion operations.
[0072] Next, the storage device will obtain the queue parameters of multiple input and output queues from the specified storage address according to the type of batch delete operation. These queue parameters include key information such as queue identity. Through direct memory access (DMA), the storage device can efficiently read these parameters from the host memory without CPU intervention, thereby quickly obtaining relevant information about the queue to be deleted. Using the batch delete instruction, the storage device will batch delete the created input and output queues according to these queue parameters.
[0073] After the deletion operation is completed, the storage device returns a second completion queue entry through the control command completion queue, which contains the results of the batch deletion operation. The host can verify the deletion status of each queue by reading these completion queue entries. Based on the feedback information, the host can determine which queues have been successfully deleted and which queues have failed to be deleted.
[0074] When all queues to be deleted are successfully deleted and the deletion status meets the preset conditions (for example, the deletion operation is successful and the queues are completely released), the host will re-enter the stage of initializing the storage device. At this time, the host sends a batch creation command to the storage device. The batch creation command will batch create new input and output queues according to the previously predefined queue parameters, thereby restoring the normal working state of the device.
[0075] This process effectively integrates and optimizes the reset, queue deletion, and queue reconstruction of storage devices, reducing the operational complexity and bandwidth usage of queue management. During reset, the batch deletion operation ensures that all useless queues can be deleted quickly, while the batch creation operation can quickly restore the device's working capacity after the deletion is completed. By utilizing DMA and batch operation instructions, not only the speed of operation is improved, but also the use of system resources is optimized, especially in the scenarios of high-performance storage devices and large-scale queue management, which can greatly improve the efficiency and responsiveness of the system.
[0076] In an exemplary embodiment, during the operation of the storage device, the load conditions of each input and output queue are dynamically monitored, and the load conditions include queue depth and response time; based on the load conditions, the priority and depth of the queue are automatically adjusted; when necessary, the queue is automatically created or deleted according to the load conditions; when the queue remains idle for a long time during operation, the queue is automatically recycled, and a new queue is dynamically created according to the load conditions of the storage device to improve performance and avoid waste of resources.
[0077] In this embodiment, the storage device monitors the load of each input and output queue in real time, mainly monitoring the queue depth and response time to evaluate the workload of the queue. The queue depth refers to the number of pending requests in the queue, and the response time reflects the efficiency of the queue in processing requests. According to the monitored load conditions, the system can dynamically adjust the priority and depth of the queue to cope with changes in different workloads. For example, when the load of some queues is light, its priority can be lowered to release resources to queues with higher loads; or when the load is heavy, the queue depth can be increased to improve throughput.
[0078] If the system finds that some queues remain idle for a long time, it means that these queues are no longer needed by the workload of the storage device. The system will automatically recycle these idle queues to avoid wasting resources. In addition, based on load changes, the system can dynamically create new queues when necessary to handle higher loads, thereby ensuring that the storage device can operate efficiently under various workloads. This dynamic adjustment and resource management method not only optimizes the performance of the storage device, but also improves resource utilization.
[0079] like Fig.10As shown, the present application also adopts a queue management method for a storage device, which is applied to a storage device. The queue management method for a storage device includes:
[0080] S21: receiving a batch operation instruction; the batch operation instruction includes a batch operation type and a storage address of a queue parameter, and the batch operation type includes batch deletion and batch creation;
[0081] S21: Read queue parameters of multiple input and output queues from the storage address;
[0082] S21: Batch create or batch delete multiple input and output queues according to the batch operation type, where the input and output queues include an input and output submission queue and an input and output completion queue.
[0083] The description of the features in the embodiment corresponding to the queue management method of the storage device can refer to the relevant description of the above embodiment, which will not be repeated here.
[0084] The initialization process in this application is as follows Fig.11 As shown in the figure, (1) the host obtains the number N of IO queues supported by the device during initialization; (2) the host creates an IOCQ / IOSQ queue, applies for a section of memory to store N IOCQ_create_data / IOSQ_create_data structures, and fills the contents therein. The address of this section of memory is filled into the field specified by SQE, and the TYPE of SQE is specified as a batch creation operation, and SQE is sent to the storage device; (3) after receiving the SQE, the storage device checks that the TYPE field is for batch creation of IOCQ queues, and moves N IOCQ_create_data / IOSQ_create_data structures from the host memory to the device through DMA, creates the queue, and then replies to the host CQE.
[0085] The reset process in this application is as follows Fig.12 As shown in the figure, (1) the host deletes the IOCQ / IOSQ queue and applies for a memory section to store N IOCQ_delete_data / IOSQ_delete_data structures. The content is filled in and the address of this memory section is filled into the field specified by SQE. The TYPE of SQE is specified as batch deletion queue and SQE is sent to the storage device; (2) After receiving SQE, the storage device checks that the TYPE field is for batch creation of IOCQ queues, and moves N IOCQ_delete_data / IOSQ_delete_data structures from the host memory to the device through DMA to delete the queue and then reply to the host CQE.
[0086] It can be seen that the queue management method for storage devices provided in this embodiment improves the efficiency of NVMe storage devices in creating and deleting IO queues, reduces redundant information of NVMe storage devices in initialization and RESET control paths, improves link utilization, accelerates the initialization and RESET process of multi-queue NVMe storage devices, improves the response speed of the device, and simplifies the interaction process between the host and the storage device.
[0087] like Fig.13 An embodiment of the present application further provides an electronic device, including a memory 61 and a processor 62, wherein the memory 61 stores a computer program, and the processor 62 is configured to run the computer program to execute the steps in any of the above-mentioned queue management method embodiments of the storage device.
[0088] For the description of the features in the embodiments corresponding to the electronic device, reference can be made to the relevant description of the embodiments corresponding to the queue management method of the storage device, which will not be described one by one here.
[0089] like Fig.14 An embodiment of the present application further provides a computer-readable storage medium 71, in which a computer program 72 is stored, wherein the computer program 72 is configured to execute the steps of any of the above-mentioned queue management method embodiments of the storage device when running.
[0090] In an exemplary embodiment, the computer-readable storage medium 71 may include, but is not limited to, various media that can store the computer program 72, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0091] The description of the features in the embodiment corresponding to the computer-readable storage medium 71 can be found in the relevant description of the embodiment corresponding to the queue management method of the storage device, which will not be repeated here.
[0092] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any of the above-mentioned queue management method embodiments of the storage device are implemented.
[0093] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned queue management method embodiments of the storage device are implemented.
[0094] For the description of the features in the embodiments corresponding to the computer program product, reference may be made to the relevant description of the embodiments corresponding to the queue management method of the storage device, which will not be described in detail here.
[0095] Professionals may 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 the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians 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.
[0096] The above is a detailed introduction to a queue management method for a storage device, an electronic device, and a storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A queue management method for a storage device, characterized in that: Applied to a host, the queue management method of the storage device includes: When configuring a storage device, a batch operation instruction is sent to the storage device; the batch operation instruction includes a batch operation type and a storage address of a queue parameter, and the batch operation type includes batch deletion and batch creation; The storage device is triggered to obtain queue parameters of multiple input and output queues from the storage address, and to batch create or batch delete the multiple input and output queues according to the batch operation type, wherein the input and output queues include an input and output submission queue and an input and output completion queue.
2. The queue management method of a storage device according to claim 1, characterized in that: When configuring a storage device, before sending a batch operation instruction to the storage device, the method further includes: Predefine queue parameters of a plurality of input and output queues, and store the queue parameters in a preset storage address of a host memory; The queue parameters include queue identity, queue depth, interrupt configuration information, and a binding relationship between an input / output submission queue and an input / output completion queue, wherein the binding relationship is used to indicate the association between the input / output submission queue and the input / output completion queue of a batch operation.
3. The queue management method of a storage device according to claim 1, characterized in that: The queue parameters also include priority information of multiple input and output submission queues; Creating a plurality of the input and output queues in batches according to the batch operation type includes: Determining, according to the batch operation type, that the batch operation type is batch creation; The priority information in the queue parameters is parsed, and a plurality of the input and output queues are created in sequence according to the order of priority from high to low.
4. The queue management method of a storage device according to claim 1, characterized in that: Triggering the storage device to obtain queue parameters of multiple input and output queues from the storage address includes: The storage device is triggered to obtain queue parameters of multiple input and output queues from the storage address in a direct memory access manner.
5. The queue management method of a storage device according to claim 1, characterized in that: When configuring a storage device, sending a batch operation instruction to the storage device includes: When configuring a storage device, sending batch operation instructions to the storage device through a control instruction submission queue; After batch creation or batch deletion of the plurality of input and output queues according to the batch operation type, the method further includes: The storage device feeds back batch operation results via a control instruction completion queue.
6. The queue management method for a storage device according to any one of claims 1 to 5, characterized in that: When configuring a storage device, before sending a batch operation instruction to the storage device, the method further includes: When initializing the storage device, obtaining the maximum number of input and output queues supported by the storage device; predefining queue parameters of the maximum number of input and output queues, applying for a preset storage address from the host, and storing the queue parameters in the preset storage address; When configuring a storage device, sending a batch operation instruction to the storage device includes: When initializing a storage device, a batch creation instruction is sent to the storage device, the batch operation type in the batch creation instruction is batch creation, and the storage address in the batch creation instruction points to the starting address of the preset storage address where the queue parameters of the input and output parameters to be created are located; Triggering the storage device to obtain queue parameters of multiple input and output queues from the storage address, and batch creating or batch deleting the multiple input and output queues according to the batch operation type, includes: Triggering the storage device to obtain queue parameters from the preset storage address by direct memory access, and batch create a maximum number of the input and output queues; After batch creation or batch deletion of the plurality of input and output queues according to the batch operation type, the method further includes: A first completion queue entry returned by the storage device is received, and a creation state of the input / output queue is verified according to the first completion queue entry.
7. The queue management method of a storage device according to claim 6, characterized in that: When configuring a storage device, sending a batch operation instruction to the storage device includes: When resetting the storage device, a batch deletion command is sent to the storage device, the batch operation type in the batch deletion command is batch deletion, and the storage address in the batch deletion command points to the starting address of the preset storage address where the queue parameters of the input and output queues to be deleted are located; Triggering the storage device to obtain queue parameters of multiple input and output queues from the storage address, and batch creating or batch deleting the multiple input and output queues according to the batch operation type, includes: Triggering the storage device to obtain a queue identity from the preset storage address by direct memory access, and batch delete the created input and output queues; After batch creation or batch deletion of the plurality of input and output queues according to the batch operation type, the method further includes: receiving a second completion queue entry returned by the storage device, and verifying the deletion status of the input and output queue according to the second completion queue entry; When the deletion state meets the preset condition, when re-entering the step of initializing the storage device, a batch creation instruction is sent to the storage device.
8. A queue management method for a storage device, characterized in that: Applied to a storage device, the queue management method of the storage device includes: Receive a batch operation instruction; the batch operation instruction includes a batch operation type and a storage address of a queue parameter, and the batch operation type includes batch deletion and batch creation; Reading queue parameters of a plurality of input and output queues from the storage address; The plurality of input / output queues are batch created or batch deleted according to the batch operation type, wherein the input / output queues include an input / output submission queue and an input / output completion queue.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the queue management method for a storage device as claimed in any one of claims 1 to 8 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the queue management method for a storage device according to any one of claims 1 to 8.
Citation Information
Cited By
Communication method and device, storage medium and electronic equipment
CN121441978A
Data interaction method, electronic equipment and computer readable storage medium
CN122064603A
Control method of storage device and electronic device
CN122614297A
Control method of storage device and electronic device
CN122614297B