A trim management method, storage device and storage system
By breaking down the Trim command into multiple command segments and issuing them according to rules, the problem of slow Trim command processing speed is solved, resulting in faster Trim operations and higher storage device performance.
Patent Information
- Application Number
- CN202211711105.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2042-12-29
AI Technical Summary
In existing technologies, the Trim command is slow to process, resulting in long I/O blocking times, which affects the stability and performance of storage devices.
The Trim command is processed into multiple Trim command segments, and an operation completion message is sent upon completion, allowing the host to write. At the same time, Trim command segments are issued according to preset rules until the operation of all command segments is completed.
It improves the speed of Trim operations, reduces IO blocking time, and enhances the write performance and stability of storage devices.
Smart Images

Figure CN116185286B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage, in particular to a Trim management method, a storage device and a storage system. BACKGROUND
[0002] Trim command, also called Disable Delete Notify, can enable the operating system to notify the range of invalid data in the storage device (such as solid state drive SSD), so that the storage device can skip the invalid data instead of moving it when performing garbage collection (GC), saving the time of not rewriting invalid data, reducing the number of erase cycles on the flash memory, and achieving higher performance during writing.
[0003] When the host device issues a Trim command, the storage device needs to suspend the write operation (IO) being performed. If the length of the Trim command is long, the feedback time of the completion of the trim operation will be long, which will cause the blocking time of the IO to be very long, which is not conducive to the stability of the IO. In order to solve the above problem, the current solution is to use the set bit table (BITMAP) scheme, which caches the Trim command to quickly feedback the completion of the Trim operation, but this way does not actually modify the logical address to physical address mapping table (L2P table), which has the problem of obvious lag in the actual completion time of the Trim operation, and the processing speed is slow. SUMMARY
[0004] In view of the above technical problems, the present application provides a Trim management method, a storage device and a storage system, which processes the Trim command into multiple Trim command segments, and feeds back the completion of the trim operation after processing is completed, allowing the host to write, which is faster in feedback speed, and Trim command segments can be issued after allowing the host to write, which shortens the time of Trim operation and speeds up the processing.
[0005] To solve the above technical problems, the present application provides a Trim management method applied to a storage device, comprising the following steps:
[0006] When receiving the Trim command of the host, suspend the host write;
[0007] Processing the Trim command into multiple Trim command segments;
[0008] Returning a signal of the completion of the Trim command to the host to allow the host to write;
[0009] Issuing the multiple Trim command segments according to a preset rule until the Trim operation of the multiple Trim command segments is completed.
[0010] Optionally, the method further comprises:
[0011] In the process of processing the Trim command into a plurality of Trim command segments, the Trim operation of at least a part of the processed Trim command segments is synchronously performed;
[0012] Returning a signal of completion of the Trim command execution to the host, comprising:
[0013] After completing the processing of the Trim command into a plurality of Trim command segments and the Trim operation of at least a part of the Trim command segments, returning a signal of completion of the Trim command execution to the host.
[0014] Optionally, the preset rule comprises at least one of the following:
[0015] When the IO is running at full speed, the Trim command segment is paused from being issued;
[0016] When there is no IO, the Trim command segment is issued at full speed;
[0017] When the IO is in a non-full-speed state, the Trim command segment is issued according to a time point of the IO.
[0018] According to the list of to-be-GC data recorded in the Trim command segment, a Trim command segment to be preferentially processed is selected for issuance.
[0019] Optionally, the Trim command segment records key information of the Trim operation of the Trim command segment, the Trim command segment comprises a head and an information block, the head stores an address of the information block, and the information block stores the key information of the Trim operation of the Trim command segment.
[0020] Optionally, the Trim command segment records key information of the Trim operation of the Trim command segment, and the key information of the Trim operation of the Trim command segment comprises a Trim state, a set table, a list of to-be-written data, and a list of to-be-GC data.
[0021] Optionally, after the signal of completion of the Trim command execution is returned to the host to allow the host to write, the method further comprises:
[0022] When a host write command is received, it is judged whether a logical block in the host write data hits a Trim command segment that needs to be processed by Trim operation;
[0023] If the Trim command segment that needs to be processed by Trim operation is not hit, the host write data is written;
[0024] If the hit current Trim command segment is currently performing a Trim operation, the first target logical block is locked and recorded in the to-be-written data list of the current Trim command segment;
[0025] If the hit Trim command segment is not currently performing a Trim operation, the hit logical block is continuously written, and the set table of the Trim command segment corresponding to the hit logical block is modified.
[0026] Optionally, the Trim operation process of the Trim command segment comprises:
[0027] The target Trim command segment performing a Trim operation is selected;
[0028] The mapping table of logical address to physical address is modified according to the set table of the target Trim command segment;
[0029] It is judged whether the to-be-written data list of the target Trim command segment is empty;
[0030] If the to-be-written data list is not empty, the logical block in the to-be-written data list is unlocked, and the write-in storage medium is flushed.
[0031] Optionally, after the signal that the Trim command is executed is returned to the host to allow the host to write, the method further comprises:
[0032] When the GC command is received, it is judged whether the logical block of the GC data hits a Trim command segment needing to perform a Trim operation;
[0033] If the hit, the second target logical block is locked, and the second target logical block is recorded in the to-be-GC data list of the corresponding Trim command segment.
[0034] Optionally, the Trim operation process of the Trim command segment comprises:
[0035] After the to-be-written data list of the target Trim command segment is processed, it is judged whether the to-be-GC data list of the target Trim command segment is empty;
[0036] If the to-be-GC data list is not empty, the logical block in the to-be-GC data list is unlocked, and it is judged whether the unlocked logical block is valid data;
[0037] If the valid data, the write-in storage medium is flushed;
[0038] If the invalid data, the cleaning is performed.
[0039] The application further provides a storage device including a storage medium and a controller, wherein the storage medium stores a management program, and the management program, when executed by the controller, implements the steps of the Trim management method according to any one of the above.
[0040] The application further provides a storage system including a host and a storage device, wherein the storage device is configured to implement the Trim management method according to any one of the above.
[0041] The Trim management method, the storage device and the storage system according to the application, the method is applied to the storage device, and the method includes: when receiving a Trim command from the host, suspending the host from writing; processing the Trim command into multiple Trim command segments; returning a signal indicating that the Trim command is executed to the host, so as to allow the host to write; and issuing the multiple Trim command segments according to a preset rule until the Trim operation of the multiple Trim command segments is completed. The storage system includes the host and the storage device. According to the application, the Trim command is processed into multiple Trim command segments, and then the completion of the Trim operation is fed back, so that the host is allowed to write, the feedback speed is faster, and the Trim command segment is issued after the host is allowed to write, the time of the Trim operation is advanced, and the processing speed is faster. BRIEF DESCRIPTION OF DRAWINGS
[0042] Figure 1 is a flowchart of a Trim management method according to an embodiment;
[0043] Figure 2 is a flowchart of a host write operation according to an embodiment;
[0044] Figure 3 is a flowchart of a Trim operation according to an embodiment;
[0045] Figure 4 is a flowchart of a GC operation according to an embodiment;
[0046] Figure 5 is a schematic diagram of a storage device according to an embodiment;
[0047] Figure 6 is a schematic diagram of a storage system according to an embodiment. DETAILED DESCRIPTION
[0048] In order to make the application more comprehensively understood, the application will be described more fully below with reference to the accompanying drawings. The preferred embodiments of the application are shown in the drawings. However, the application can be realized in many different forms and is not limited to the embodiments described herein. On the contrary, these embodiments are provided so that the disclosure of the application can be more thoroughly and completely understood.
[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items. In this application, the use of "each" includes one and more than one.
[0050] Figure 1 is a flowchart of a Trim management method according to an embodiment. As shown in Figure 1 , a Trim management method applied to a storage device includes the following steps:
[0051] S1, when receiving a Trim command from a host, suspending the host write;
[0052] S2, processing the Trim command into multiple Trim command segments;
[0053] S3, returning a signal of Trim command execution completion to the host to allow the host to write;
[0054] S4, issuing the multiple Trim command segments according to a preset rule until the Trim operation of the multiple Trim command segments is completed.
[0055] After the application processes the Trim command into multiple Trim command segments, the Trim operation completion can be fed back to allow the host to write, the feedback speed is faster, and the IO blocking is as small as possible. After allowing the host to write, the Trim command segment can be issued, and the small Trim command segment processing is more flexible, which can realize the time advance of the Trim operation, that is, compared with the whole block BITMAP, the logical address to physical address mapping table (L2P table) can be modified earlier, and the processing speed is faster.
[0056] Optionally, the Trim command segment records key information of the Trim operation of the Trim command segment, and the Trim command segment includes a header and an information block. The header stores the address of the information block, and the corresponding information block is pointed to after reading the header to obtain information. The information block stores the key information of the Trim operation of the Trim command segment. In this way, the longer Trim command is managed in small blocks. The header part can be automatically managed by hardware, and since only the header is managed, the required space is very small. The key information uses the space of the memory (DDR), which can be managed by software, thereby reducing the occupation of the DDR bandwidth.
[0057] Optionally, the key information of the Trim command segment performing the Trim operation includes a Trim state, a set table, a to-be-written data list, and a to-be-GC data list. The Trim state is used to identify whether the Trim operation of the Trim command segment is completed. The set table is used to record the command content of the Trim command segment. The to-be-written data list is used to record the logical blocks locked in the host write data. The logical blocks in the to-be-written data list are written into the storage medium after the Trim operation of the corresponding Trim command segment. The to-be-GC data list is used to record the logical blocks locked in the GC data. The logical blocks in the to-be-GC data list are written into the storage medium or deleted after the Trim operation of the corresponding Trim command segment.
[0058] Optionally, in the process of processing the Trim command into a plurality of Trim command segments in step S1, the Trim operation of at least part of the processed Trim command segments can be performed synchronously, the time of the Trim operation of part of the Trim command segments can be advanced, and the speed of the Trim operation can be improved. After the Trim command is processed into a plurality of Trim command segments and the Trim operation of at least part of the Trim command segments is completed, a signal that the Trim command execution is completed is returned to the host. Then, the host can start to normally perform data writing.
[0059] Optionally, in S4, the preset rule includes at least one of the following:
[0060] When the IO is running at full speed, the Trim command segment is paused;
[0061] When no IO is performed, the Trim command segment is issued at full speed;
[0062] When the IO is in a non-full-speed state, the Trim command segment is issued according to the time point of the IO;
[0063] According to the to-be-GC data list recorded in the Trim command segment, a Trim command segment that is preferentially processed is selected for issuance.
[0064] The Trim command segment can be evenly distributed with the IO state by the above rule, and the Trim command segment can be completely distributed as soon as possible without affecting or less affecting the IO, so that the final Trim operation is completed. The Trim command segment can be distributed according to the time point of the IO, that is, a preset number of Trim command segments can be distributed after a preset number of data writes are performed, and the distribution of the Trim command segment is performed in this way. Since the length of the Trim command segment is very small, the jamming of the IO is not obvious. In addition, when the Trim command segment is selected, the Trim command segment to be processed preferentially is selected according to the to-be-GC data list recorded in the Trim command segment, and the Trim command segment is distributed. Specifically, the Trim command segment with the longest to-be-GC data list can be selected and distributed preferentially, and when the Trim command segment with the longest to-be-GC data list is greater than one, the Trim command segments can be selected and distributed in order. In this way, the to-be-GC data can be processed as soon as possible, and the write performance of the storage device is improved.
[0065] Optionally, please refer to Figure 2 In the S3 step, the signal that the Trim command is executed is returned to the host to allow the host to write, and the following steps can also be included:
[0066] When the host write command is received, it is judged whether the logical block in the host write data hits the Trim command segment that needs to be trimmed.
[0067] If the Trim command segment that needs to be trimmed is not hit, the host write data is written;
[0068] If the current Trim command segment that is currently being trimmed is hit, the first target logical block is locked, and the first target logical block is recorded in the to-be-written data list of the current Trim command segment;
[0069] If the Trim command segment that is not currently being trimmed is hit, the logical block is continuously written, and the set table of the Trim command segment corresponding to the hit logical block is modified.
[0070] The Trim command segment that needs to be trimmed refers to the Trim command segment with an unfinished Trim state, including the current Trim command segment that is currently being trimmed and the Trim command segment that is not currently being trimmed.
[0071] If the logical block in the host write data does not hit the Trim command segment that needs to be trimmed, the logical block in the host write data can be normally flushed and written. If the logical block in the host write data hits the current Trim command segment that is currently being trimmed, the first target logical block in the host write data that hits is locked, and the first target logical block is recorded in the to-be-written data list of the current Trim command segment. Since the data has entered the SSD host at this time, there is no influence on the external IO, and there is also no influence on the progress of the current Trim command segment. Since the length of the current Trim command segment is very small, the locked logical block will be released soon, and then the logical block data can be taken from the to-be-written data list to continue flushing and writing into the storage medium. If the logical block in the host write data hits the Trim command segment that is not currently being trimmed, the logical block that hits is continuously written, and the set table of the Trim command segment corresponding to the logical block that hits is modified. For example, in the process of flushing and writing, the set table of the corresponding Trim command segment is synchronously modified. In this way, the set table of the Trim command segment is updated, and the Trim operation of the Trim command segment is more accurate. In actual implementation, the set table can be modified by hardware to realize processing acceleration.
[0072] Optionally, please refer to Figure 3 , the Trim operation process of the Trim command segment, comprising:
[0073] selecting a target Trim command segment for Trim operation;
[0074] modifying the mapping table of the logical address to the physical address according to the set table of the target Trim command segment;
[0075] determining whether the to-be-written data list of the target Trim command segment is empty;
[0076] if the to-be-written data list is not empty, unlocking the logical block in the to-be-written data list, and flushing and writing into the storage medium.
[0077] In the selection of the target Trim command segment for the Trim operation, the Trim command segment with the longest list of data to be GCed can be selected for preferential processing and issuance. When there are multiple Trim command segments with the longest list of data to be GCed, the Trim command segments can be sequentially selected for issuance. In this way, the data to be GCed can be processed as soon as possible, and the write performance of the storage device can be improved. After the target Trim command segment is determined, the mapping table of the logical address to the physical address is modified according to the set table of the target Trim command segment. Compared with the whole set table, the mapping table of the logical address to the physical address can be modified earlier, the processing can be accelerated, and the Trim command can be actually completed earlier.
[0078] After the mapping table of the logical address to the physical address is modified according to the set table of the target Trim command segment, it is determined whether the list of data to be written in the target Trim command segment is empty. If the list of data to be written is not empty, the logical blocks in the list of data to be written are unlocked, and the data is written into the storage medium. If the list of data to be written is empty, the list of data to be GCed is processed.
[0079] Optionally, please refer to Figure 4 In addition to the signal returned to the host in the S3 step to indicate that the Trim command is executed, the following steps can also be included to allow the host to write.
[0080] When the GC command is received, it is determined whether the logical block of the GC data hits the Trim command segment that needs to be trimmed.
[0081] If the hit occurs, the second target logical block is locked, and the second target logical block is recorded in the list of data to be GCed corresponding to the Trim command segment.
[0082] In the selection of the target Trim command segment for the Trim operation, the Trim command segment with the longest list of data to be GCed can be selected for preferential processing and issuance. When there are multiple Trim command segments with the longest list of data to be GCed, the Trim command segments can be sequentially selected for issuance. In this way, the data to be GCed can be processed as soon as possible, and the write performance of the storage device can be improved. After the target Trim command segment is determined, the mapping table of the logical address to the physical address is modified according to the set table of the target Trim command segment. Compared with the whole set table, the mapping table of the logical address to the physical address can be modified earlier, the processing can be accelerated, and the Trim command can be actually completed earlier.
[0083] Optionally, please continue to refer to Figure 3 The Trim operation process of the Trim command segment also includes:
[0084] After the list of data to be written in the target Trim command segment is processed, it is determined whether the list of data to be GCed in the target Trim command segment is empty.
[0085] If the list of data to be GCed is not empty, the logical blocks in the list of data to be GCed are unlocked, and it is determined whether the unlocked logical blocks are valid data.
[0086] If the data is valid, the data is written to the storage medium;
[0087] If the data is invalid, the data is cleared.
[0088] If the data is valid, the data is written to the storage medium; if the data is invalid, the data is cleared. Thus, the data correctness can be ensured, and the write amplification caused by the GC can be reduced.
[0089] If the list of data to be GC is empty or the processing of the list of data to be GC is completed, the Trim state is set to completed, and the resources of the target Trim command segment are released, including the head and key information such as the list of data to be written, the list of data to be GC, and the set table.
[0090] In the above manner, the DDR is not queried at all times during the host writing and the GC, and the reading and writing of the DDR space are reduced. Since the Trim command segment is continuously issued in small blocks, the Trim command is eventually consumed, and at this time, the software is informed that there is no Trim command, and the software processing L2P is simpler and purer. In addition, during the abnormal power-off, only the key information of the Trim command segment needs to be saved and written to the storage medium. Since the header part in the hardware is small, and the set table is managed by the software and can be dynamically applied, the consumption of the DDR resources is also very small, and the data written to the storage medium is also very small. Therefore, the power can be used more to protect the host writing data, and the recovery after the power-off is also faster, and the data to be recovered is less.
[0091] The Trim management method provided in the application suspends the host writing when the Trim command of the host is received, processes the Trim command into a plurality of Trim command segments, returns a signal of completion of the Trim command execution to the host to allow the host writing, and issues the plurality of Trim command segments according to a preset rule until the Trim operation of the plurality of Trim command segments is completed. After the Trim command is processed into a plurality of Trim command segments, the Trim completion can be fed back, the host writing is allowed, the feedback speed is faster, the Trim command segment can be issued after the host writing is allowed, the Trim operation time is advanced, and the processing speed is faster.
[0092] Figure 5 is a schematic diagram of a storage device according to an embodiment. As shown in Figure 5 The application further provides a storage device including a storage medium 10 and a controller 20, wherein the storage medium 10 stores a management program, and the management program is executed by the controller 20 to implement the steps of the Trim management method according to the above embodiments.
[0093] Figure 6 is a schematic diagram of a storage system according to an embodiment. As shown, the present application also provides a storage system comprising a host 30 and a storage device 40, the storage device 40 being configured to perform the Trim management method as described in the above embodiments. Figure 6
[0094] The storage device and the storage system of the present application, when receiving the Trim command from the host, suspend the host writing; process the Trim command into multiple Trim command segments; return a signal of completion of the Trim command execution to the host to allow the host to write; and issue the multiple Trim command segments according to a preset rule until the Trim operation of the multiple Trim command segments is completed. The storage system comprises the host and the storage device. After the Trim command is processed into multiple Trim command segments, the present application can feed back the completion of the Trim and allow the host to write, which is faster in speed. After allowing the host to write, the Trim command segments can be issued, the time of the Trim operation is advanced, and the processing speed is faster.
[0095] The above-described embodiments only express several implementation manners of the present application, which are described in detail, but should not be understood as the limitation of the patent scope of the present application. It should be noted that, for those skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the patent protection scope of the present application should be subject to the appended claims.
Claims
1. A Trim management method applied to storage devices, characterized in that, Includes the following steps: When a Trim command is received from the host, pause host writes; The Trim command is processed into multiple Trim command segments. Each Trim command segment records key information about the Trim operation performed by the Trim command segment. The key information about the Trim operation performed by the Trim command segment includes Trim status, a set table, a list of data to be written, and a list of data to be GC. The list of data to be written records logical blocks in the host-written data that are locked due to hitting the current Trim command segment that is currently performing a Trim operation. The logical blocks in the list of data to be written are flushed to the storage medium after the corresponding Trim command segment performs a Trim operation. The list of data to be GC records logical blocks in the GC data that are locked due to hitting the Trim command segment that needs to perform a Trim operation. The logical blocks in the list of data to be GC are flushed to the storage medium or deleted after the corresponding Trim command segment performs a Trim operation. The system sends a signal indicating that the Trim command has been executed to the host, allowing the host to write. The multiple Trim command segments are issued according to preset rules until the Trim operation of the multiple Trim command segments is completed.
2. The method according to claim 1, characterized in that, The method further includes: During the process of processing the Trim command into multiple Trim command segments, the Trim operation of at least a portion of the processed Trim command segments is performed simultaneously. Returning a signal to the host indicating that the Trim command has been executed successfully includes: After processing the Trim command into multiple Trim command segments and completing the Trim operation of at least some of the Trim command segments, a signal indicating that the Trim command execution is complete is returned to the host.
3. The method according to claim 1, characterized in that, The preset rules include at least one of the following: When IO is running at full speed, pause the issuance of Trim command segments; When no I / O is in progress, the Trim command segment is issued at full speed. When IO is not at full speed, issue the Trim command segment according to the IO time point; Based on the list of data to be GC recorded in the Trim command segment, select the Trim command segment to be processed first and issue it.
4. The method according to claim 1, characterized in that, The Trim command segment includes a queue head and an information block. The queue head stores the address of the information block, and the information block stores key information for the Trim command segment to perform the Trim operation.
5. The method according to claim 1, characterized in that, After returning a signal indicating completion of the Trim command to the host to allow the host to write, the method further includes: When a host write command is received, it is determined whether the logical block in the host write data matches the Trim command segment that needs to be Trimed. If the Trim command segment that requires a Trim operation is not hit, then the data to be written to the host is written. If the current Trim command segment that is currently performing a Trim operation is hit, the first target logic block that was hit is locked, and the first target logic block is recorded in the list of data to be written in the current Trim command segment. If a Trim command segment that is not currently performing a Trim operation is hit, the logic block that was hit is written to, and the set table of the Trim command segment corresponding to the hit logic block is modified.
6. The method according to claim 5, characterized in that, The Trim operation process of the Trim command segment includes: Select the target Trim command segment to perform the Trim operation; Modify the mapping table from logical address to physical address according to the set table of the target Trim command segment; Determine whether the list of data to be written for the target Trim command segment is empty; If the list of data to be written is not empty, then the logical blocks in the list of data to be written are unlocked and written down to the storage medium.
7. The method according to claim 6, characterized in that, After returning a signal indicating completion of the Trim command to the host to allow the host to write, the method further includes: When a GC command is received, it is determined whether the logical block of GC data hits the Trim command segment that needs to be Trimed. If a match is found, the second target logic block is locked, and the second target logic block is recorded in the GC list of the corresponding Trim command segment.
8. The method according to claim 7, characterized in that, The Trim operation process of the Trim command segment includes: After processing the list of data to be written in the target Trim command segment, it is determined whether the list of data to be GC in the target Trim command segment is empty; If the list of data to be GC is not empty, then unlock the logical blocks in the list of data to be GC and determine whether the unlocked logical blocks are valid data; If the data is valid, it will be flushed and written to the storage medium. If the data is invalid, it will be cleared.
9. A storage device, characterized in that, The system includes a storage medium and a controller, wherein the storage medium stores a management program that, when executed by the controller, implements the steps of the Trim management method as described in any one of claims 1 to 8.
10. A storage system, characterized in that, It includes a host and a storage device, the storage device being used to execute the Trim management method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Trim command implementation method and device based on solid state disk and computer device
CN110568998A