Method and device for processing host command by solid state disk, solid state disk and firmware thereof

By adopting multi-threading and queue asynchronous processing methods in solid-state drives, the problem of SSD's lack of ability to handle multi-type host commands is solved, and efficient and accurate command execution is achieved.

CN119847424APending Publication Date: 2025-04-18ANHUI KEDA QINGTIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411778555.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

The current SSD's host command processing method has low processing capabilities for multiple types of host commands, which are prone to errors in command execution or low efficiency.

Method used

By introducing multi-threaded processing mechanisms and queue asynchronous processing in the solid-state drive, host commands are allocated by the main queue and slave queues, and tasks are detected and executed through thread polling, ensuring that different types of host commands are processed by the corresponding threads.

Benefits of technology

It realizes efficient processing of multi-type host commands, improves execution accuracy and efficiency, and solves the problem of insufficient SSD's ability to handle multi-type host commands.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847424A_ABST
    Figure CN119847424A_ABST
Patent Text Reader

Abstract

The invention relates to a method and device for processing a host command by a solid state disk, the solid state disk and firmware of the solid state disk, and the method comprises the following steps: acquiring the host command sent by a host end, and placing the host command in a main queue; polling and detecting whether each thread in the target thread pool is called or not, and determining the currently called thread; executing a corresponding thread task through the currently called thread; wherein the threads are bound with different thread processing functions, and thread tasks corresponding to the thread processing functions are a command allocation task and a plurality of command execution tasks; the command allocation task comprises the following steps: allocating different types of host commands in the main queue to different slave queues; the plurality of command execution tasks correspond to the plurality of slave queues, and each command execution task comprises the step of executing the host command in the corresponding slave queue. When the method is adopted, the solid state disk can process different types of host commands in order, and the method has the advantages of being high in execution accuracy and execution efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data storage, and in particular to a method and device for a solid-state hard disk to process a host command, a solid-state hard disk and its firmware. Background Art

[0002] In the evaluation criteria of SSD (solid state drive), there is an IOPS indicator for judging its performance. Its main description is the ability of SSD to process input and output per second. From a technical perspective, it is the read and write capability of SSD. The SSD read and write process mainly includes: the PC sends commands, and the SSD receives and processes the commands. Among them, these commands include many types.

[0003] The host command processing mechanism of the current SSD firmware mainly stores all types of host commands in the same queue, and then calls a thread to process the host commands in the queue. Since different types of host commands correspond to different thread processing functions, when there are many types of host commands in the queue, it is easy to have command execution errors or low command execution efficiency. Therefore, the current SSD host command processing method has a low processing capability for multiple types of host commands. Summary of the invention

[0004] The present invention provides a method for a solid state drive to process host commands, so as to solve the problem that the current method for processing host commands of SSDs has low processing capability for multiple types of host commands.

[0005] In a first aspect, the present invention provides a method for a solid state drive to process a host command, comprising:

[0006] Get the host command sent by the host end, and place the host command in the main queue;

[0007] Poll to detect whether each thread in the target thread pool is called and determine the currently called thread;

[0008] Execute the corresponding thread task through the currently called thread;

[0009] Each of the threads is bound to a different thread processing function, and the thread tasks corresponding to each of the thread processing functions are a command allocation task and a plurality of command execution tasks;

[0010] The command distribution task includes: distributing different types of host commands to different slave queues;

[0011] The plurality of command execution tasks correspond to the plurality of slave queues, and each of the command execution tasks includes: executing a host command in a corresponding slave queue.

[0012] In a second aspect, the present invention provides a host command processing device for SSD firmware, including:

[0013] A command acquisition module is used to acquire the host command sent by the host end and place the host command in the main queue;

[0014] The thread detection module is used to poll and detect whether each thread in the target thread pool is called and determine the currently called thread;

[0015] A task execution module, used for executing the corresponding thread task through the currently called thread;

[0016] Each of the threads is bound to a different thread processing function, and the thread tasks corresponding to each of the thread processing functions are a command allocation task and a plurality of command execution tasks;

[0017] The command distribution task includes: distributing different types of host commands in the master queue to different slave queues;

[0018] The plurality of command execution tasks correspond to the plurality of slave queues, and each of the command execution tasks includes: executing a host command in a corresponding slave queue.

[0019] In a third aspect, a solid-state hard disk firmware is provided in the present invention, including the method for a solid-state hard disk to process a host command described in the first aspect.

[0020] In a fourth aspect, the present invention provides a solid state drive comprising a processor and flash memory particles, wherein the processor is used to execute the method for the solid state drive to process host commands described in the first aspect to read and write data in the flash memory particles.

[0021] Compared with the related art, the present invention provides a method for processing host commands by a solid-state hard disk with multi-threading and queue asynchronous processing (based on thread polling). Different types of host commands are executed by different threads, and are executed asynchronously in an orderly manner. The execution processes of various host commands do not interfere with each other. When this method is adopted, the solid-state hard disk can process different types of host commands in an orderly manner, and has the advantages of high execution accuracy and high execution efficiency, which solves the problem that the current SSD host command processing method has low processing ability for multiple types of host commands.

[0022] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 is a flow chart of a method for a solid state drive to process a host command provided in an embodiment of the present invention;

[0024] Figure 2 This is a flow chart of the method for a solid state drive to process a host command in the present invention;

[0025] Figure 3 is a schematic diagram of the basic structure of queues and data in some embodiments of the present invention;

[0026] Figure 4 is a schematic diagram of the process of queue creation and execution in some embodiments of the present invention;

[0027] Figure 5 It is a flowchart of thread creation and calling in some embodiments of the present invention. DETAILED DESCRIPTION

[0028] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0029] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0030] In an embodiment of the present invention, a method for a solid state drive to process a host command (cmd) is provided. Figure 1 is a flow chart of a method for a solid state drive to process a host command provided in an embodiment of the present invention. Figure 1 As shown, the process includes step S110, step S120 and step S130.

[0031] Step S110, obtaining the host command sent by the host end, and placing the host command in the main queue.

[0032] Step S120, polling to detect whether each thread in the target thread pool is called, and determining the currently called thread. Each thread is called through the time slice scheduling algorithm of the operating system.

[0033] Step S130, executing the corresponding thread task through the currently called thread.

[0034] Each thread is bound to a different thread processing function, and the thread tasks corresponding to each thread processing function are command allocation tasks and multiple command execution tasks. When a thread is called, the thread will enter its corresponding thread processing function to execute the corresponding thread task.

[0035] The command allocation task includes: allocating different types of host commands in the main queue to different slave queues. The types of host commands include: read commands, write commands, synchronization commands, and unknown commands. Different types of host commands are placed in different slave queues. Exemplarily, the read command is allocated to the first slave queue, the write command is allocated to the second slave queue, the synchronization command is allocated to the third slave queue, and the unknown command is divided into the fourth slave queue. In some embodiments, the command allocation task also includes: allocating different type tags to different types of host commands.

[0036] The plurality of command execution tasks correspond to the plurality of slave queues, and each command execution task includes: executing a host command in the corresponding slave queue.

[0037] The thread processing function needs to be designed according to the specific event that the specific thread wants to process. In the present invention, because there are main main queues and various slave queues that need to be processed, different thread processing functions are designed for each different queue. For example, when a thread enters the thread processing function of the main queue, the thread will distribute the host commands in the main queue to different slave queues according to the type. When a thread enters the thread processing function of the first slave queue, the read command in the first slave queue will be executed to read the relevant data in the flash memory particles. When a thread enters the thread processing function of the second slave queue, the write command in the second slave queue will be executed to write the relevant data into the flash memory particles.

[0038] In the above technical scheme, the main process is to construct a main queue and a slave queue. First, the host commands sent by the host are placed in the main queue. When the thread corresponding to the main queue is called, the thread will classify the host commands and assign them to different slave queues, and each slave queue will be placed with the same type of host commands. When a thread of a slave queue is called, the thread will execute the host command in the slave queue. Among them, different queues correspond to different thread processing functions, that is, each queue is called in the corresponding thread processing function. Different threads are bound to different thread processing functions. Then, when a thread is called, the thread will enter the thread processing function bound to itself to perform the corresponding task. Furthermore, each thread is called through the time slice scheduling algorithm of the operating system, and a polling strategy is used to detect whether each thread is called. After detecting the called thread, the thread is allowed to enter the corresponding thread processing function to process the corresponding thread task.

[0039] For example, Figure 2An example of the method flow for processing host commands for solid-state drives. First, various cmds (commands) are sent by the host side, and there is a receiving queue host_FIFO (main queue, a queue for receiving various cmds from the host side) in the SSD firmware. This queue mainly stores the cmd commands sent from the host side. Next, the host_FIFO queue is processed by a thread, and different commands on the host_FIFO queue are divided according to the command tag and saved in different sub-queues cmd_queue (from the queue, queue 1, queue 2 and queue 3). For different sub-queues, there will be corresponding processing threads, which will process the corresponding commands and return the information after command processing according to the particularity of some commands.

[0040] Therefore, the present invention provides a method for processing host commands by a solid-state hard disk with multi-threading and queue asynchronous processing (based on thread polling). Different types of host commands are executed by different threads, and are executed asynchronously in an orderly manner. The execution processes of various host commands do not interfere with each other. When this method is adopted, the solid-state hard disk can process different types of host commands in an orderly manner, and has the advantages of high execution accuracy and high execution efficiency, which solves the problem that the current SSD host command processing method has low processing ability for multiple types of host commands.

[0041] In order to implement the above method for the solid state drive to process host commands, some preparation work needs to be done, such as creating a queue and designing a thread processing function, and binding the thread processing function and the thread. The following is an explanation of the design process of the above method for the solid state drive to process host commands.

[0042] Step 1: Define the basic structure of the queue and data, such as Figure 3 As shown in part a of , an array is used to define a queue, and the head and tail pointers are defined to point to the array. The queue is empty, full, etc., based on the calculation of the head and tail pointers. Figure 3 As shown in b, each command entry in the queue is also defined. Its main purpose is to set different tag flags according to different commands sent from the host to distinguish different command types.

[0043] Specifically, an array is used to represent a queue. Two pointers are mainly defined: the head pointer and the tail pointer, and the size of the array MAX is set. During initialization, head == tail is used to indicate that the queue is empty, head is incremented to indicate entry, tail is decremented to indicate exit, (head+1)%MAX==tail is used to indicate that the queue is full, and (tail+1)%MAX==head is used to indicate that the queue is empty during use.

[0044] Step 2: Since the host will send different command types, combined with the basic definition of queues and their entries in the first step, different queue data organization structures are defined according to different command types, such as Figure 4 The queue pool creation step in , this queue pool contains queue organization structures of various command types, and these queue data structures serve as the basic data for defining thread processing functions. Figure 4 Take the thread processing function of the main queue as an example to explain whether it is called. First, define the data structure of the queue, including the main queue and each slave queue, and then create a queue pool. Each queue is called in the corresponding thread processing function. Determine whether the thread processing function of the main queue is called by the system. If so, assign the cmd in the main queue to the corresponding slave queue, otherwise wait.

[0045] Step 3: Define thread processing functions and thread pools according to the different command types sent from the host, such as Figure 5 As shown in the flow chart, firstly, according to the different command types and functions of these commands on the host side, the thread processing functions corresponding to these command functions are designed (the thread processing functions are defined). According to the characteristics of the real-time operating system, corresponding threads are created for the thread processing functions corresponding to each command type (thread pools are created and thread processing functions are bound). In this way, under the action of the operating system, different commands will be processed independently in each thread. The next step is whether the thread is called by the system. If the thread is called by the system, the execution starting point of the program will jump to the corresponding thread processing function, and the corresponding thread processing function will be executed to process the corresponding host-side command. If the thread is not called in time, it will keep waiting for the system call to be called.

[0046] Step 4: In step 2, the data structures of various commands sent from the host are organized. In step 3, the thread processing function will need these data structures, use these data structures to process the host commands, and then determine whether these thread processing functions are executed in the system call. If the data structure of the queue corresponding to a command is used and the corresponding thread processing function is called, the corresponding command will be executed. If the thread is not called in time, wait.

[0047] Step 5: The first four steps are the basic module definition and processing flow of the present invention, which include queue data structures corresponding to different commands, processing methods for each type of command, etc. Next, the overall architecture processing flow of the present invention is mainly introduced. First, a main thread is defined, which is dedicated to allocating commands on the host side, regardless of the command type. Similarly, relevant data structures and thread processing functions will be defined for this main thread, and the system will poll to detect whether the main thread is called. If so, the main thread processes the cmd on the host side and assigns it to the corresponding slave queue according to the type of cmd. If not, then according to the system's polling mechanism, it is detected whether the child thread is scheduled. If the child thread is called, the child thread will execute the corresponding cmd in the slave queue. The system will then detect whether the main thread and each child thread are called in turn according to the polling mechanism.

[0048] In summary, in the present invention, threads are called in real time according to the time slice scheduling algorithm of the operating system to implement asynchronous operations, wherein the thread is a basic scheduling unit. In the present invention, because there are main host_FIFO queues and various command cmd_queue sub-queues that need to be processed, different thread processing functions are implemented for each different queue. The next step is to create a thread pool and bind the thread processing function to the threads in the thread pool to form threads with specific processing functions. The judgment is made based on whether the thread is called by the system; if the thread is called by the system, the corresponding thread processing function is run, and if it is executed within the time slice, the execution of the function is terminated; if the thread is not called, it waits for the next call by the system. In addition, the present invention has the following technical effects:

[0049] 1. Use multi-threading technology to implement asynchronous processing of host-side commands and improve the system's ability to process different types of data.

[0050] 2. Utilize the thread scheduling mechanism and queue storage mechanism of the operating system to process commands from different host terminals and improve the scalability of the firmware.

[0051] In an embodiment of the present invention, a host command processing device for SSD firmware is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. The terms "module", "unit", "subunit", etc. used below may be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0052] The host command processing device of the SSD firmware includes:

[0053] The command acquisition module is used to obtain the host command sent by the host and place the host command in the main queue.

[0054] The thread detection module is used to poll and detect whether each thread in the target thread pool is called and determine the currently called thread.

[0055] The task execution module is used to execute the corresponding thread task through the currently called thread.

[0056] Each thread is bound to a different thread processing function, and the thread tasks corresponding to each thread processing function are a command allocation task and a plurality of command execution tasks.

[0057] The command distribution task includes: distributing different types of host commands to different slave queues.

[0058] The plurality of command execution tasks correspond to the plurality of slave queues, and each command execution task includes: executing a host command in the corresponding slave queue.

[0059] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0060] In an embodiment of the present invention, a solid state drive firmware is also provided, including the method for a solid state drive to process a host command provided by the present invention.

[0061] In an embodiment of the present invention, a solid state drive is further provided, including a processor and flash memory particles, wherein the processor is used to execute the method for processing host commands by a solid state drive provided by the present invention to read and write data in the flash memory particles.

[0062] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.

[0063] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.

Claims

1. A method for a solid state drive to process a host command, characterized in that: include: Get the host command sent by the host end, and place the host command in the main queue; Poll to detect whether each thread in the target thread pool is called and determine the currently called thread; Execute the corresponding thread task through the currently called thread; Each of the threads is bound to a different thread processing function, and the thread tasks corresponding to each of the thread processing functions are a command allocation task and a plurality of command execution tasks; The command distribution task includes: distributing different types of host commands in the master queue to different slave queues; The plurality of command execution tasks correspond to the plurality of slave queues, and each of the command execution tasks includes: executing a host command in a corresponding slave queue.

2. The method for processing host commands by a solid state drive according to claim 1, characterized in that: The types of host commands include: read command, write command, synchronization command, and unknown command.

3. The method for processing host commands by a solid state drive according to claim 1, characterized in that: The command allocation task also includes: allocating different type tags to different types of host commands.

4. The method for processing host commands by a solid state drive according to claim 1, characterized in that: The master queue and the slave queue are represented by arrays.

5. The method for processing host commands by a solid state drive according to claim 1, characterized in that: A head pointer head, a tail pointer tail and an array size MAX are defined in the array; When the queue is initialized, head == tail is used to indicate that the queue is empty; Use head to add itself to indicate that the host command is queued; Use tail to decrement to indicate that the host command is out of the queue; Use (head+1)%MAX==tail to indicate that the queue is full; Using (tail+1)%MAX==head indicates that the queue is empty during use.

6. The method for processing host commands by a solid state drive according to claim 1, characterized in that: Each of the threads is called through the time slice scheduling algorithm of the operating system.

7. The method for processing host commands by a solid state drive according to claim 1, characterized in that: Each of the queues is called in a corresponding thread processing function.

8. A host command processing device for SSD firmware, characterized in that: include: A command acquisition module is used to acquire the host command sent by the host end and place the host command in the main queue; The thread detection module is used to poll and detect whether each thread in the target thread pool is called and determine the currently called thread; A task execution module, used for executing the corresponding thread task through the currently called thread; Each of the threads is bound to a different thread processing function, and the thread tasks corresponding to each of the thread processing functions are a command allocation task and a plurality of command execution tasks; The command distribution task includes: distributing different types of host commands to different slave queues; The plurality of command execution tasks correspond to the plurality of slave queues, and each of the command execution tasks includes: executing a host command in a corresponding slave queue.

9. A solid state drive firmware, characterized in that: A method for a solid state drive to process a host command comprising any one of claims 1-7.

10. A solid state hard disk, comprising a processor and flash memory particles, characterized in that: The processor is used to execute the method for processing host commands by a solid-state hard disk according to any one of claims 1 to 7 to read and write data in the flash memory particles.