Trim command processing method, system, terminal device and storage medium

CN115269452BActive Publication Date: 2026-10-30HEFEI ZHICUN MICROELECTRONICS CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210755318.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-29
Publication Date
2026-10-30
Estimated Expiration
2042-06-29

AI Technical Summary

Technical Problem

[0004]本发明的主要目的在于提供一种Trim命令处理方法、终端设备及计算机存储介质,旨在解决在主机平台给闪存设备连续发Trim命令时,对Trim命令的处理效率偏低的技术问题

Benefits of technology

[0032]本发明提出的Trim命令处理方法、系统、终端设备以及计算机存储介质,通过当接收到主机连续下发的各Trim命令时,记录各所述Trim命令各自的命令信息并向所述主机返回完成命令;在未接收到所述主机下发的操作命令的空闲状态下,根据各所述命令信息创建对应的Trim任务并执行,以针对各所述Trim命令进行处理。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115269452B_ABST
    Figure CN115269452B_ABST
Patent Text Reader

Abstract

The application discloses a Trim command processing method and system, terminal equipment and a storage medium. The Trim command processing method comprises the following steps: when receiving each Trim command continuously issued by a host, recording the command information of each Trim command and returning a completion command to the host; in an idle state without receiving an operation command issued by the host, creating a corresponding Trim task according to each command information and executing the Trim task, so as to process each Trim command. The application can greatly improve the processing efficiency of the continuously issued Trim command.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of memory technology, and in particular to a Trim command processing method, system, terminal device, and storage medium. Background Technology

[0002] In recent years, with the rapid development of flash memory technology, flash storage devices such as SSDs (Solid State Disks) are gradually replacing traditional storage devices due to their excellent performance, power consumption, and environmental adaptability. One of the characteristics of flash memory is that physical blocks need to be erased before new data can be written. To adapt to this characteristic, the host's file system specifically invented the Trim mechanism. That is, when the host no longer needs a part of the data in the flash storage device, the host issues a Trim command, and the flash storage device performs the corresponding Trim operation according to the Trim command.

[0003] However, when the host platform sends Trim commands to the flash storage device one after another, the flash storage device needs to process each received Trim command, and there may be repeated reading and writing of the logical address and physical address mapping table of the flash storage device, which leads to low processing efficiency of Trim commands. Summary of the Invention

[0004] The main objective of this invention is to provide a Trim command processing method, a terminal device, and a computer storage medium, aiming to solve the technical problem of low processing efficiency of Trim commands when the host platform continuously sends Trim commands to the flash memory device.

[0005] To achieve the above objectives, the present invention provides a Trim command processing method, which includes the following steps:

[0006] When receiving a series of Trim commands from the host, record the command information of each Trim command and return a completion command to the host;

[0007] In the idle state where no operation command is received from the host, a corresponding Trim task is created and executed according to the command information to process each Trim command.

[0008] Further, the command information includes: the Trim start address and the Trim length, and the step of creating and executing a corresponding Trim task based on each of the command information includes:

[0009] The target address range of each Trim command is determined based on the Trim start address and Trim length.

[0010] Each Trim command is created according to each target address range, and the Trim task is executed to perform a Trim operation on the target address range.

[0011] Further, after the step of determining the target address range of each Trim command based on the Trim start address and Trim length, the method includes:

[0012] Determine whether the target address ranges of each Trim command are consecutive or overlapping;

[0013] If the target address intervals are consecutive or overlap, the consecutive or overlapping target address intervals are merged to obtain a combined address interval;

[0014] Create a corresponding combined Trim task based on the combined address range, and execute the combined Trim task to perform a Trim operation on the combined address range.

[0015] Furthermore, the Trim command processing method also includes:

[0016] If an operation command is received from the host while the Trim task is being executed, the execution of the Trim task shall be aborted.

[0017] After executing the operation command, the Trim task is then executed.

[0018] Furthermore, the step of recording the command information of each Trim command and returning a completed command to the host when receiving consecutive Trim commands from the host includes:

[0019] Determine whether the number of Trim commands continuously issued by the host within a preset time period exceeds a preset number threshold;

[0020] If the number of Trim commands exceeds a preset threshold, the command information of each Trim command is recorded and a completion command is returned to the host.

[0021] Furthermore, after the step of determining whether the number of Trim commands continuously issued by the host within a preset time period exceeds a preset threshold, the method further includes:

[0022] If the number of Trim commands does not exceed the preset number threshold, then a corresponding real-time Trim task is created based on the Trim command, and the real-time Trim task is executed.

[0023] Furthermore, after the step of recording the command information of each Trim command and returning a completed command to the host when each Trim command is received consecutively from the host, the method further includes:

[0024] The command information is stored in a preset non-volatile memory;

[0025] The step of creating and executing corresponding Trim tasks based on the command information includes:

[0026] Read each command information from the preset non-volatile memory, and create and execute the corresponding Trim task based on each command information.

[0027] Furthermore, to achieve the above objectives, the present invention also provides a Trim command processing system, the Trim command processing system comprising:

[0028] The command recording module is used to record the command information of each Trim command when it receives Trim commands issued consecutively by the host, and return a completion command to the host.

[0029] The Trim task module is used to create and execute corresponding Trim tasks based on the command information when the host is not receiving operation commands, so as to process each Trim command.

[0030] In addition, to achieve the above objectives, the present invention also provides a terminal device, the terminal device comprising: a memory, a processor, and a Trim command handler stored in the memory and executable on the processor, wherein when the Trim command handler is executed by the processor, it implements the steps of the Trim command processing method as described above.

[0031] In addition, to achieve the above objectives, the present invention also provides a computer storage medium storing a computer program, which, when executed by a processor, implements the steps of the Trim command processing method described above.

[0032] The Trim command processing method, system, terminal device, and computer storage medium proposed in this invention process each Trim command by recording its command information and returning a completion command to the host when receiving consecutive Trim commands from the host; and by creating and executing corresponding Trim tasks based on the command information when not receiving any operation commands from the host in an idle state, in order to process each Trim command.

[0033] This invention, upon receiving a series of Trim commands from a host, does not execute each command sequentially. Instead, it records the command information of each Trim command and returns a completion command to the host, notifying the host that the Trim command has been completed. This eliminates the need for the host to wait for the terminal device to complete each Trim command sequentially. Then, in an idle state where no operation commands are received from the host, a corresponding Trim task is created and executed based on the command information to process each Trim command, thereby completing the series of Trim commands issued by the host. This invention avoids processing each Trim command issued by the host sequentially and repeatedly reading the logical address to physical address mapping table. Furthermore, by having the terminal device execute the Trim task in an idle state where no operation commands are received from the host, it effectively utilizes the interval between host command issuance to complete the series of Trim commands. Therefore, this invention significantly improves the processing efficiency of consecutively issued Trim commands.

[0034] Furthermore, this invention also determines whether the target address ranges of each Trim command are consecutive or overlapping; if the target address ranges are consecutive or overlapping, the consecutive or overlapping target address ranges are merged to obtain a combined address range; a corresponding combined Trim task is created based on the combined address range, and the combined Trim task is executed to perform the Trim operation on the combined address range. By integrating Trim commands with consecutive or overlapping target address ranges into the same Trim task, this invention can further reduce the execution time of each Trim command, thereby improving the processing efficiency of Trim commands continuously issued by the host. Attached Figure Description

[0035] Figure 1 This is a schematic diagram of the structure of the terminal device in the hardware operating environment involved in the embodiments of the present invention;

[0036] Figure 2 This is a flowchart illustrating an embodiment of a Trim command processing method according to the present invention;

[0037] Figure 3 This is a schematic diagram of the structural relationship of a Trim command processing system according to the present invention.

[0038] The objectives, features, and advantages of this invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0039] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0040] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0041] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0042] like Figure 1 As shown, Figure 1 This is a schematic diagram of the structure of the terminal device in the hardware operating environment involved in the embodiments of the present invention.

[0043] The terminal device in this embodiment of the invention can be a device that executes the Trim command processing method provided by the present invention for a memory that uses flash memory chips as the storage medium. Specifically, the terminal device can be a mobile terminal, a data storage control terminal, a PC (Personal Computer), or a portable computer.

[0044] like Figure 1 As shown, the terminal device may include: a processor 1001, such as a CPU (Central Processing Unit), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed random access memory (RAM) or stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.

[0045] Those skilled in the art will understand that Figure 1 The device structure shown does not constitute a limitation on the terminal device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0046] like Figure 1 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a Trim command handler. The operating system is a program that manages and controls the hardware and software resources of the sample terminal device, and supports the operation of the Trim command handler and other software or programs.

[0047] exist Figure 1 In the terminal device shown, the user interface 1003 is mainly used for data communication with various terminals; the network interface 1004 is mainly used for connecting to the backend server and communicating with the backend server; and the processor 1001 can be used to call the Trim command processing program stored in the memory 1005 and perform the following operations:

[0048] When receiving a series of Trim commands from the host, record the command information of each Trim command and return a completion command to the host;

[0049] In the idle state where no operation command is received from the host, a corresponding Trim task is created and executed according to the command information to process each Trim command.

[0050] Furthermore, the processor 1001 can call the Trim command handler stored in the memory 1005 and also perform the following operations:

[0051] The target address range of each Trim command is determined based on the Trim start address and Trim length.

[0052] Create a corresponding combined Trim task based on the combined address range, and execute the combined Trim task to perform a Trim operation on the combined address range.

[0053] Furthermore, the processor 1001 can call the Trim command handler stored in the memory 1005 and also perform the following operations:

[0054] Determine whether the target address ranges of each Trim command are consecutive or overlapping;

[0055] If the target address intervals are consecutive or overlap, the consecutive or overlapping target address intervals are merged to obtain a combined address interval;

[0056] Create a corresponding combined Trim task based on the combined address range, and execute the combined Trim task to perform a Trim operation on the combined address range.

[0057] Furthermore, the processor 1001 can call the Trim command handler stored in the memory 1005 and also perform the following operations:

[0058] If an operation command is received from the host while the Trim task is being executed, the execution of the Trim task shall be aborted.

[0059] After executing the operation command, the Trim task is then executed.

[0060] Furthermore, the processor 1001 can call the Trim command handler stored in the memory 1005 and also perform the following operations:

[0061] Determine whether the number of Trim commands continuously issued by the host within a preset time period exceeds a preset number threshold;

[0062] If the number of Trim commands exceeds a preset threshold, the command information of each Trim command is recorded and a completion command is returned to the host.

[0063] Furthermore, the processor 1001 can call the Trim command handler stored in the memory 1005 and also perform the following operations:

[0064] If the number of Trim commands does not exceed the preset number threshold, then a corresponding real-time Trim task is created based on the Trim command, and the real-time Trim task is executed.

[0065] Furthermore, the processor 1001 can call the Trim command handler stored in the memory 1005 and also perform the following operations:

[0066] The command information is stored in a preset non-volatile memory;

[0067] Read each command information from the preset non-volatile memory, and create and execute the corresponding Trim task based on each command information.

[0068] Based on the above structure, various embodiments of the Trim command processing method of the present invention are proposed.

[0069] It should be noted that in this embodiment, due to the rapid development of flash memory technology in recent years, flash memory storage devices such as SSDs (Solid State Disks) are gradually replacing traditional storage devices due to their excellent performance, power consumption, and environmental adaptability. One characteristic of flash memory is that physical blocks need to be erased before new data can be written. To adapt to this characteristic, the host's file system specifically invented the Trim mechanism. When the host no longer needs a part of the data in the flash memory storage device, the host issues a Trim command, and the flash memory storage device performs the corresponding Trim operation according to the Trim command.

[0070] However, when the host platform sends Trim commands to the flash storage device one after another, the flash storage device needs to process each received Trim command, and there may be repeated reading and writing of the logical address and physical address mapping table of the flash storage device, which leads to low processing efficiency of Trim commands.

[0071] To address the aforementioned problems, this application provides a Trim command processing method. When receiving a series of Trim commands consecutively issued by the host, instead of executing each command one by one, the method records the command information of each Trim command and returns a completion command to the host, notifying the host that the Trim command has been completed. This eliminates the need for the host to spend a considerable amount of time waiting for the terminal device to complete each of the consecutively issued Trim commands. Then, in an idle state where no operation commands are received from the host, a corresponding Trim task is created based on the command information and executed to process each Trim command, thereby completing the consecutively issued Trim commands from the host. This invention avoids processing each consecutively issued Trim command from the host and repeatedly reading the mapping table between logical and physical addresses. Furthermore, by having the terminal device execute the Trim task in an idle state where no operation commands are received from the host, the method effectively utilizes the interval between the host's operation commands to complete the consecutively issued Trim commands. Therefore, this invention can significantly improve the processing efficiency of consecutively issued Trim commands.

[0072] Furthermore, this invention also determines whether the target address ranges of each Trim command are consecutive or overlapping; if the target address ranges are consecutive or overlapping, the consecutive or overlapping target address ranges are merged to obtain a combined address range; a corresponding combined Trim task is created based on the combined address range, and the combined Trim task is executed to perform the Trim operation on the combined address range. By integrating Trim commands with consecutive or overlapping target address ranges into the same Trim task, this invention can further reduce the execution time of each Trim command, thereby improving the processing efficiency of Trim commands continuously issued by the host.

[0073] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the Trim command processing method of the present invention.

[0074] This invention provides an embodiment of a Trim command processing method, which is applied to the aforementioned terminal device. It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0075] In this embodiment, the Trim command processing method of the present invention includes:

[0076] Step S100: When receiving each Trim command issued consecutively by the host, record the command information of each Trim command and return a completion command to the host;

[0077] The host is a device used to issue operation commands to the terminal device, and can be a mobile terminal, PC, portable computer, or other similar devices. The Trim command is a command used by the host's operating system to notify the terminal device that a specified logical address is no longer in use. When the host no longer needs a portion of data previously written to the terminal device, it issues a Trim command corresponding to that portion of data. The Trim command can include information such as the Trim start address and Trim length, so that the terminal device can execute the Trim command.

[0078] Upon receiving Trim commands from the host, the terminal device can determine whether the host has issued multiple Trim commands consecutively by analyzing the number, frequency, and time interval of the issued Trim commands. When receiving consecutive Trim commands from the host, the terminal device enters continuous Trim mode. In continuous Trim mode, the terminal device records the command information for each Trim command, including but not limited to the Trim start address and Trim length. While recording the command information, a completion command can be returned to the host. The completion command indicates that the Trim command has been completed. When the host receives the completion command, it can determine that the terminal device has completed issuing the Trim commands. This eliminates the need for the host to spend a considerable amount of time waiting for the terminal device to complete each consecutively issued Trim command.

[0079] Further, step S100 includes the following steps:

[0080] Step S110: Determine whether the number of Trim commands continuously issued by the host within a preset time period exceeds a preset number threshold.

[0081] Step S111: If the number of Trim commands exceeds a preset threshold, record the command information of each Trim command and return a completion command to the host.

[0082] Specifically, the preset duration is a pre-set monitoring duration used to determine whether the host continuously issues Trim commands, such as 2 seconds, 3 seconds, 5 seconds, etc. The preset quantity threshold is a pre-set threshold for the number of Trim commands continuously issued by the host, such as 5, 8, 10, etc. By determining whether the number of Trim commands continuously issued by the host within the preset duration exceeds the preset quantity threshold, if the number of Trim commands issued by the host within the preset duration exceeds the preset quantity threshold, it indicates that the continuous issuance of Trim commands by the host may make it difficult for the terminal device to complete the continuous issuance of multiple Trim commands in a timely and rapid manner. In this case, the command information of each Trim command can be recorded and a completion command can be returned to the host to quickly respond to the host's Trim commands and improve the processing efficiency of continuous Trim commands.

[0083] Furthermore, the following steps are included before step S110:

[0084] Step S112: If the number of Trim commands does not exceed the preset number threshold, then a corresponding real-time Trim task is created according to the Trim command, and the real-time Trim task is executed.

[0085] If the number of Trim commands issued by the host does not exceed a preset threshold within a preset time period, it indicates that the host is not issuing multiple Trim commands consecutively. The terminal device can then complete the issued Trim commands promptly and quickly. In this case, there is no need to record the command information of the Trim commands; instead, a corresponding real-time Trim task can be created and executed directly based on the Trim command. Therefore, when the host is not issuing multiple Trim commands consecutively, no unnecessary processes are required, ensuring the processing efficiency of non-consecutive Trim commands.

[0086] Step S200: In the idle state where no operation command is received from the host, a corresponding Trim task is created and executed according to each command information to process each Trim command.

[0087] In an idle state where no operation command has been received from the host, a corresponding Trim task can be created and executed based on previously recorded command information. The idle state can be the state of the terminal device when no operation command has been received from the host. The command information may include the Trim start address and Trim length, thereby determining the target address range for each Trim command based on the Trim start address and Trim length. Then, a corresponding combined Trim task is created based on the combined address range, and the combined Trim task is executed to perform the Trim operation on the combined address range. It is understood that the Trim operation involves setting the mapping information corresponding to the target address range in the logical address to no mapping (Nomap). In this embodiment, by executing the Trim task in an idle state where no operation command has been received from the host, the interval between the host issuing operation commands is effectively utilized to complete each Trim command continuously issued by the host. Therefore, this invention can significantly improve the processing efficiency for continuously issued Trim commands.

[0088] Furthermore, the command information includes the Trim start address and the Trim length, and step S200 includes the following steps:

[0089] Step S210: Determine the target address range of each Trim command based on the Trim start address and Trim length;

[0090] Step S220: Create a corresponding combined Trim task based on the combined address range, and execute the combined Trim task to perform a Trim operation on the combined address range.

[0091] Specifically, the Trim start address is the starting point of the logical address from which the Trim command expects to perform the Trim operation. The Trim length is the length of the Trim operation expected by the Trim command, starting from the Trim start address. Therefore, based on the Trim start address and Trim length, the target address range for each Trim command to perform the Trim operation is determined. A corresponding combined Trim task is created based on the combined address range, and the combined Trim task is executed to perform the Trim operation on the combined address range, setting the mapping information corresponding to the target address range in the logical address to physical address mapping table of the terminal device to no mapping (Nomap). It can be understood that after the mapping information corresponding to the target address range is set to no mapping (Nomap), the data stored in the physical block corresponding to the target address range can be erased, freeing up the storage space of the physical block.

[0092] Furthermore, after step S210, the following steps are included:

[0093] Step S230: Determine whether the target address ranges of each Trim command are consecutive or overlapping;

[0094] Step S231: If the target address intervals are consecutive or overlapping, then the consecutive or overlapping target address intervals are merged to obtain a combined address interval.

[0095] Step S232: Create a corresponding combined Trim task based on the combined address range, and execute the combined Trim task to perform a Trim operation on the combined address range.

[0096] In practical use, the target address ranges of the various Trim commands may be consecutive or overlapping. This can be addressed by determining whether the target address ranges of the various Trim commands are consecutive or overlapping. If they are, the consecutive or overlapping target address ranges in each Trim command are merged to obtain a combined address range. Then, a corresponding combined Trim task is created based on the combined address range, and the combined Trim task is executed to perform the Trim operation on the combined address range. This reduces the number of Trim operations, thereby improving the processing efficiency of the Trim commands.

[0097] Furthermore, the Trim command processing method also includes the following steps:

[0098] Step S221: If an operation command is received from the host while the Trim task is being executed, the execution of the Trim task is stopped.

[0099] Step S222: After executing the operation command, the Trim task is executed subsequently.

[0100] Specifically, the operation command is a command used to operate the terminal device, such as a read command, a write command, or a Trim command. When executing the Trim task, if an operation command is received from the host, the execution of the Trim task is suspended, thereby ensuring a timely response to operation commands issued by the host. After executing the operation command, the Trim task continues to be executed to complete all created Trim tasks. In this embodiment, by monitoring whether the host issues operation commands during the execution of the Trim task, the execution of the Trim task is suspended upon receiving an operation command from the host, ensuring a timely response to the operation commands issued by the host and avoiding interference with the normal operation of the host.

[0101] Furthermore, after step S100, the method further includes the following steps:

[0102] Step S120: Store the command information in a preset non-volatile memory.

[0103] The step of creating and executing corresponding Trim tasks based on the command information includes:

[0104] Step S240: Read each of the command information from the preset non-volatile memory, and create and execute the corresponding Trim task according to each of the command information.

[0105] Specifically, the preset non-volatile memory can be flash memory. By storing the command information in the preset non-volatile memory, each command information can be read from the preset non-volatile memory, and a corresponding Trim task can be created and executed based on each command information. This ensures that the command information is not lost when the terminal device is suddenly and unexpectedly shut down due to power failure or other emergencies, thus guaranteeing the security of the command information.

[0106] In addition, please refer to Figure 3 This invention also proposes a Trim command processing system, which includes:

[0107] The command recording module 10 is used to record the command information of each Trim command when it receives Trim commands issued continuously by the host and return a completion command to the host.

[0108] Trim task module 20 is used to create and execute corresponding Trim tasks based on the command information when the host is not receiving operation commands, so as to process each Trim command.

[0109] Furthermore, the Trim task module 20 is also used for

[0110] The target address range of each Trim command is determined based on the Trim start address and Trim length.

[0111] Each Trim command is created according to each target address range, and the Trim task is executed to perform a Trim operation on the target address range.

[0112] Furthermore, the Trim task module 20 is also used for

[0113] Determine whether the target address ranges of each Trim command are consecutive or overlapping;

[0114] If the target address intervals are consecutive or overlap, the consecutive or overlapping target address intervals are merged to obtain a combined address interval;

[0115] Create a corresponding combined Trim task based on the combined address range, and execute the combined Trim task to perform a Trim operation on the combined address range.

[0116] Furthermore, the Trim command processing system also includes: an abort module 30, used for...

[0117] If an operation command is received from the host while the Trim task is being executed, the execution of the Trim task shall be aborted.

[0118] After executing the operation command, the Trim task is then executed.

[0119] Furthermore, the Trim command processing system also includes: a judgment module 40, used for...

[0120] Determine whether the number of Trim commands continuously issued by the host within a preset time period exceeds a preset number threshold;

[0121] If the number of Trim commands exceeds a preset threshold, the command information of each Trim command is recorded and a completion command is returned to the host.

[0122] Furthermore, the judgment module 40 is also used for

[0123] If the number of Trim commands does not exceed the preset number threshold, then a corresponding real-time Trim task is created based on the Trim command, and the real-time Trim task is executed.

[0124] Furthermore, the Trim command processing system also includes: a storage module 50, used for...

[0125] The command information is stored in a preset non-volatile memory;

[0126] Furthermore, the Trim task module 20 is also used for

[0127] Read each command information from the preset non-volatile memory, and create and execute the corresponding Trim task based on each command information.

[0128] Furthermore, this invention also proposes a computer storage medium for use in a computer. The computer storage medium can be a non-volatile computer-readable storage medium, which stores a Trim command processing program. When the Trim command processing program is executed by the processor, it implements the steps of the Trim command processing method as described above.

[0129] The steps implemented when the Trim command handler running on the processor is executed can be referred to in various embodiments of the Trim command processing method of the present invention, and will not be repeated here.

[0130] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0131] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0132] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a computer storage medium (such as Flash memory, ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a controller in a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to control the data read and write operations of the storage medium to execute the methods described in the various embodiments of the present invention.

[0133] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A method for processing the Trim command, characterized in that, The Trim command processing method includes the following steps: When receiving a series of Trim commands from the host, record the command information of each Trim command and return a completion command to the host; In the idle state where no operation command is received from the host, a corresponding Trim task is created and executed according to each command information to process each Trim command; The step of recording the command information of each Trim command and returning a completed command to the host when receiving consecutive Trim commands from the host includes: Determine whether the number of Trim commands continuously issued by the host within a preset time period exceeds a preset number threshold; If the number of Trim commands exceeds a preset threshold, the command information of each Trim command is recorded and a completion command is returned to the host. The command information includes: the Trim start address and the Trim length. The step of creating and executing a corresponding Trim task based on the command information includes: The target address range of each Trim command is determined based on the Trim start address and Trim length. Based on each of the target address ranges, a Trim task corresponding to each Trim command is created, and the Trim task is executed to perform a Trim operation on the target address range, wherein the Trim operation is to set the mapping information corresponding to the target address range in the logical address to physical address mapping table to no mapping; After the step of determining the target address range of each Trim command based on the Trim start address and Trim length, the method includes: Determine whether the target address ranges of each Trim command are consecutive or overlapping; If the target address intervals are consecutive or overlap, the consecutive or overlapping target address intervals are merged to obtain a combined address interval; Create a corresponding combined Trim task based on the combined address range, and execute the combined Trim task to perform a Trim operation on the combined address range.

2. The Trim command processing method as described in claim 1, characterized in that, The Trim command processing method also includes: If an operation command is received from the host while the Trim task is being executed, the execution of the Trim task shall be aborted. After executing the operation command, the Trim task is then executed.

3. The Trim command processing method as described in claim 1, characterized in that, After the step of determining whether the number of Trim commands continuously issued by the host within a preset time period exceeds a preset number threshold, the method further includes: If the number of Trim commands does not exceed the preset number threshold, then a corresponding real-time Trim task is created based on the Trim command, and the real-time Trim task is executed.

4. The Trim command processing method as described in any one of claims 1 to 3, characterized in that, After the step of recording the command information of each Trim command and returning a completed command to the host when receiving consecutive Trim commands from the host, the method further includes: The command information is stored in a preset non-volatile memory; The step of creating and executing corresponding Trim tasks based on the command information includes: Read each command information from the preset non-volatile memory, and create and execute the corresponding Trim task based on each command information.

5. A Trim command processing system, characterized in that, The Trim command processing system includes: The command recording module is used to record the command information of each Trim command when it receives Trim commands issued consecutively by the host, and return a completion command to the host. The Trim task module is used to create and execute corresponding Trim tasks based on the command information when the host is not receiving operation commands, so as to process each Trim command. The command recording module is also used to determine whether the number of Trim commands continuously issued by the host within a preset time period exceeds a preset number threshold; if the number of Trim commands exceeds the preset number threshold, the module records the command information of each Trim command and returns a completion command to the host. The command information includes: the Trim start address and the Trim length. The Trim task module is further configured to: determine the target address range of each Trim command based on the Trim start address and Trim length; create a Trim task corresponding to each Trim command based on each target address range, and execute the Trim task to perform a Trim operation on the target address range, wherein the Trim operation involves setting the mapping information corresponding to the target address range in the logical address to physical address mapping table to no mapping; determine whether the target address ranges of each Trim command are continuous or overlapping; if the target address ranges are continuous or overlapping, merge the continuous or overlapping target address ranges to obtain a combined address range; create a corresponding combined Trim task based on the combined address range, and execute the combined Trim task to perform a Trim operation on the combined address range.

6. A terminal device, characterized in that, The terminal device includes: a memory, a processor, and a Trim command handler stored in the memory and executable on the processor. When the Trim command handler is executed by the processor, it implements the steps of the Trim command processing method as described in any one of claims 1 to 4.

7. A computer storage medium, characterized in that, The computer storage medium stores a computer program, which, when executed by a processor, implements the steps of the Trim command processing method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method of quickly responding to trim command, SSD (Solid State Disk) controller and system

    CN103019971A

  • Solid state disk data TRIM method and device, electronic equipment and storage medium

    CN112631953A

  • Trim management in solid state drives

    US20180074708A1

  • Enhanced trim command support for solid state drives

    US20200081830A1