SSD garbage collection acceleration method and device based on data distribution, equipment and medium
By distinguishing between sequential and random data and maintaining a logical address table, efficient garbage collection is achieved in mixed data flow scenarios, solving the problems of low efficiency and complexity in traditional solutions, and improving the write performance and resource utilization of solid-state drives.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUZHOU UNIONMEMORY INFORMATION SYST LTD
- Filing Date
- 2026-01-30
- Publication Date
- 2026-04-21
AI Technical Summary
Existing technologies suffer from inefficient garbage collection when processing mixed data streams, leading to performance delays and potentially accelerating cache resource exhaustion. Meanwhile, traditional data splitting schemes increase the complexity of write points and require additional reserved space.
By distinguishing between sequential and random data, maintaining a logical address table for random data, and performing precise data migration under specific conditions, full block scanning is avoided, a single host write point is maintained, and management complexity and resource consumption are reduced.
It improves garbage collection speed, enhances user write performance of SSDs, simplifies firmware logic, and reduces latency and resource consumption.
Smart Images

Figure CN121900702A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of waste recycling technology, and in particular to a method, apparatus, equipment and medium for accelerating SSD waste recycling based on data diversion. Background Technology
[0002] In solid-state drives (SSDs), garbage collection is crucial for maintaining write performance. In applications such as circular recording, which require repeated overwriting of a limited logical address space, the data stream written by the host typically contains a large amount of sequential data and a small amount of scattered random data. Traditional solutions, when handling such mixed data streams, usually write all data indiscriminately to the same physical block. When sequential data is overwritten by new data, these small amounts of random data remain in the original physical block, preventing it from being directly reclaimed as a free block. To reclaim this physical block, the entire block's physical pages must be traversed and scanned to identify and move all remaining valid data. This process is inefficient, causing performance latency and potentially accelerating cache resource exhaustion.
[0003] Furthermore, another improvement scheme employs data splitting technology, which writes the identified random data into separate storage blocks, making it easier to reclaim physical blocks containing sequential data. However, this scheme requires maintaining multiple active host write pointers simultaneously at the flash translation layer. This not only increases the complexity of the write data path and power-down recovery logic, but also causes garbage collection to be triggered earlier due to the additional reserved space occupied, thus offsetting some of the performance gains. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and medium for accelerating SSD garbage collection based on data splitting. The technical problem it aims to solve is: how to provide a garbage collection acceleration method that can efficiently reclaim physical blocks in a mixed data stream scenario of cyclic overwrite, while avoiding the introduction of multi-write point complexity and additional overhead.
[0005] In a first aspect, embodiments of the present invention provide a method for accelerating SSD garbage collection based on data splitting, comprising: When writing data to the host, sequential data and random data are distinguished based on the order of the data stream and the continuity of the logical address. Maintain a logical address table for random data in the physical blocks of the solid-state drive; Write the sequential data and the random data into the same current physical block, and record the logical address corresponding to the random data written into the current physical block into the target random data logical address table corresponding to the current physical block; When the current physical block is full, if there is a record in the target random data logical address table corresponding to the current physical block, and the effective data count of the current physical block is less than or equal to the number of logical addresses recorded in the target random data logical address table, then all logical addresses recorded in the target random data logical address table are traversed, and the current mapping relationship of each logical address in the target random data logical address table is queried one by one. The number of logical addresses that still point to the current physical block in each of the current mapping relationships is counted. If the counted number of logical addresses is equal to the valid data count of the current physical block, then only the data corresponding to the counted logical addresses is moved. After the data migration is completed, the current physical block will be reclaimed as an idle block.
[0006] Optionally, it also includes: Set a capacity threshold for the random data logical address table; During the process of recording logical addresses, if the number of logical addresses recorded in the random data logical address table corresponding to the physical block reaches the set capacity threshold, then the recording of new logical addresses into the random data logical address table corresponding to the physical block will stop.
[0007] Optionally, after stopping the recording of new logical addresses to the random data logical address table corresponding to the physical block, the method further includes: Delete or clear the random data logical address table corresponding to the physical block.
[0008] Optionally, the step of traversing all logical addresses recorded in the target random data logical address table and querying the current mapping relationship of each logical address in the target random data logical address table one by one is performed only when the current physical block is not the target physical block that the host is currently writing to.
[0009] Optionally, distinguishing between sequential data and random data based on the sequentiality of the data stream and the continuity of logical addresses includes: If the logical addresses accessed by the host write command are consecutive and sequentially connected to the end logical address of the previous command, then the corresponding data will be identified as sequential data. Otherwise, the corresponding data will be identified as random data.
[0010] Optionally, it also includes: During the host write command processing, if the data splitting function is not enabled, or if the write command is identified as sequential data, the data is directly written to the target physical block without updating the random data logical address table corresponding to any physical block.
[0011] Optionally, after reclaiming the current physical block as a free block, the method further includes: Clear the random data logical address table corresponding to the current physical block.
[0012] Secondly, embodiments of the present invention also provide an SSD garbage collection acceleration device based on data diversion, which includes a unit for performing the above-described method.
[0013] Thirdly, embodiments of the present invention also provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0014] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the above-described method.
[0015] This invention provides a method, apparatus, device, and medium for accelerating SSD garbage collection based on data diversion. The method includes: when writing data to the host, distinguishing between sequential data and random data based on the sequentiality of the data stream and the continuity of logical addresses; maintaining a random data logical address table for physical blocks in the solid-state drive; writing the sequential data and the random data to the same current physical block, and recording the logical address corresponding to the random data written to the current physical block in the target random data logical address table corresponding to the current physical block; when the current physical block is full, if there are records in the target random data logical address table corresponding to the current physical block, and the effective data count of the current physical block is less than or equal to the number of logical addresses recorded in the target random data logical address table, then traversing all logical addresses recorded in the target random data logical address table, and querying the current mapping relationship of each logical address in the target random data logical address table one by one; counting the number of logical addresses that still point to the current physical block in each current mapping relationship; if the counted number of logical addresses is equal to the effective data count of the current physical block, then only moving the data corresponding to the counted logical addresses; after completing the data movement, reclaiming the current physical block as a free block. This invention distinguishes between sequential and random data streams and records the logical addresses of random data. This allows for precise judgment after a data block is full, combining valid data counts and address mapping information. When conditions are met, only a small amount of recorded random data needs to be moved to complete the garbage collection, avoiding the performance overhead of traversing the entire physical block to reclaim residual data in traditional solutions. Furthermore, this method maintains a single host write point, overcoming the shortcomings of traditional split-feed schemes, such as complex firmware logic, difficult power-off recovery, and increased reserved space usage caused by maintaining multiple parallel write points. Therefore, in typical application scenarios, this significantly accelerates garbage collection, improves cache utilization, and ultimately enhances the user write performance of solid-state drives. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A flowchart illustrating an SSD garbage collection acceleration method based on data splitting, provided for an embodiment of the present invention; Figure 2 This is a schematic block diagram of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0020] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0021] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0022] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."
[0023] Please see Figure 1 This invention provides a method for accelerating SSD garbage collection based on data splitting, which includes the following steps: S1 distinguishes between sequential data and random data based on the order of the data stream and the continuity of the logical address when writing data to the host.
[0024] In practice, when the host sends a write command to the solid-state drive, the firmware or controller determines the type of data stream by parsing the command sequence. Specifically, it analyzes the logical address range of the current write command. If its starting address is consecutive to the ending address of the previous command, and the address range itself is continuously increasing, then the data carried by this command is determined to be sequential data; otherwise, if the addresses are not consecutive or jump, it is determined to be random data. This is the basic logic for distinguishing between sequential and random data.
[0025] For example, in some preferred embodiments, the step of distinguishing between sequential data and random data based on the sequentiality of the data stream and the continuity of logical addresses includes: if the logical addresses accessed by the host write command are continuous and sequentially connected with the end logical address of the previous command, then the corresponding data is identified as sequential data; otherwise, the corresponding data is identified as random data.
[0026] In practice, a context variable is maintained to record the end logical address of the most recently processed write command.
[0027] When a new host write command is received, the system extracts the logical address range declared in the command, including the starting logical address and the logical address length. First, it determines whether the address range itself is continuous, that is, starting from the starting address and increasing in logical sectors or pages, and whether the length it covers is consistent with the command declaration. Second, it compares the starting logical address of the command with the ending logical address of the previous command recorded in the context variable.
[0028] If two conditions are met simultaneously: first, the logical address range of the new command is contiguous; second, the starting logical address of the new command is equal to the ending logical address of the previous command plus one, meaning the two are sequentially connected in the logical address space, then the system will recognize the data carried by this write command as sequential data. This simulates typical large-scale sequential write behavior.
[0029] Furthermore, if any of the above conditions are not met—for example, if the logical address of the new command is not contiguous, or if its starting address does not connect with the ending address of the previous command, resulting in a jump or overlap—then the system will identify the data carried by this write command as random data. This identification is performed at the command level; all data within a write command is uniformly identified as the same type.
[0030] S2 maintains a logical address table for random data for physical blocks in the solid-state drive.
[0031] In practice, a data structure called a random data logical address table is maintained for each physical block within the solid-state drive (SSD). This random data logical address table can be implemented using data structures such as arrays, linked lists, or bitmaps, and is stored in the controller's dynamic random access memory (DRAM). It can also be partially persistently stored in the metadata area of the flash memory; this invention does not specifically limit the specific storage method. Each table is used to associate and record the logical addresses of all random data subsequently written to its corresponding physical block. Specifically, this random data logical address table can be implemented using data structures such as arrays, linked lists, or bitmaps, and is usually preferentially stored in the controller's DRAM to ensure access speed. For power-down recovery considerations, its metadata or complete content can also be periodically backed up to a specific metadata area of the flash memory. The capacity threshold can be set based on available memory resources, the total number of pages in the physical block (e.g., set to 10%-20% of the number of physical block pages), or empirical values, with the aim of preventing a few physical blocks from consuming too many management resources.
[0032] In some preferred embodiments, the method further includes: setting a capacity threshold for the random data logical address table; and during the recording of logical addresses, if the number of logical addresses recorded in the random data logical address table corresponding to the physical block reaches the set capacity threshold, then stopping the recording of new logical addresses into the random data logical address table corresponding to the physical block.
[0033] In specific implementation, this embodiment further enhances capacity management of the random data logical address table by setting a capacity threshold for the random data logical address table. This capacity threshold can be preset based on available memory resources, the size of physical blocks, or empirical values; for example, it can be set to a fixed value or a proportion of the total number of pages in the physical block. This invention does not specifically limit this. During the recording of logical addresses, the number of logical address entries recorded in the random data logical address table corresponding to each physical block is monitored in real time.
[0034] Before or after adding a new logical address record to the random data logical address table of a physical block, the system checks the current number of records in the table. If the check finds that the number of logical addresses recorded in the table has reached or exceeded a preset capacity threshold, the system triggers a management action: immediately stopping the addition of any new logical address records to this specific random data logical address table. This means that for this physical block that has reached the threshold, subsequent write operations identified as random data will no longer record its logical address in the table. This mechanism ensures that the size of each random data logical address table is controllable, preventing the table from becoming excessively bloated due to writing large amounts of random data, thus avoiding excessive consumption of management resources.
[0035] In some preferred embodiments, after stopping the recording of new logical addresses to the random data logical address table corresponding to the physical block, the method further includes: deleting or clearing the random data logical address table corresponding to the physical block.
[0036] In practice, when the system determines that the random data logical address table corresponding to a physical block has reached its capacity threshold and executes a stop recording operation, it deletes or clears the random data logical address table corresponding to that physical block. Deletion can completely release the table's data structure from the memory management pool, reclaiming the memory space it occupies. Clearing can retain the table's data structure framework but remove all logical address record entries stored within it, restoring the table to an empty state. Whether deleted or cleared, the purpose is to ensure that the physical block is no longer associated with a valid random data logical address table containing historical records. Afterward, the physical block is logically equivalent to a physical block that has never had such a table created, and the system will no longer perform any fast reclamation judgment logic based on this table. This cleanup action supplements and improves the stop recording logic.
[0037] In this embodiment of the invention, after stopping the recording of new addresses into a random data logical address table, the existing records in the table can no longer reflect the complete random data write history of the physical block. Continuing to retain the table is no longer meaningful for management; on the contrary, the residual old records may be incorrectly referenced in subsequent operations. By promptly deleting or clearing tables that have reached a threshold, the system can immediately reclaim these management resources, including memory space and the indirect overhead required to process these entries. This prevents the rigid occupation of management resources and ensures that available resources can efficiently serve other active physical blocks that have not yet reached their thresholds.
[0038] S3, write the sequential data and the random data into the same current physical block, and record the logical address corresponding to the random data written into the current physical block into the target random data logical address table corresponding to the current physical block.
[0039] In practice, data writing operations are performed. Both sequential data and identified random data are written to the same currently active physical block allocated by the flash memory translation layer, i.e., the current physical block. Simultaneously with writing random data, all logical addresses of the random data involved in this write command are added to the end of the target random data logical address table associated with the current physical block.
[0040] S4, when the current physical block is full, if there is a record in the target random data logical address table corresponding to the current physical block, and the effective data count of the current physical block is less than or equal to the number of logical addresses recorded in the target random data logical address table, then traverse all logical addresses recorded in the target random data logical address table and query the current mapping relationship of each logical address in the target random data logical address table one by one.
[0041] In practice, the process enters the recycling triggering and judgment phase. When it's detected that all available pages in the current physical block are filled, the current physical block is considered to have finished writing. The system first reads the valid data count of the current physical block. This count, typically maintained by the flash translation layer, represents the number of valid pages in the block whose logical address mappings have not yet been updated. Simultaneously, it checks whether the current physical block is associated with a non-empty target random data logical address table. If both conditions are met, and the valid data count is less than or equal to the total number of logical addresses recorded in the target random data logical address table, then the next mapping relationship check is performed.
[0042] It should be noted that if the number of valid data in the current physical block is greater than the number of logical addresses recorded in its corresponding random data logical address table, it indicates that the valid data in the block is not limited to the recorded random data. In this case, the traditional full block scan reclamation method should be adopted, and the subsequent steps described in this method will not be applicable.
[0043] In some preferred embodiments, the step of traversing all logical addresses recorded in the target random data logical address table and querying the current mapping relationship of each logical address in the target random data logical address table one by one is performed only when the current physical block is not the target physical block that the host is currently writing to.
[0044] In practice, within the flash translation layer of the solid-state drive (SSD), the system constantly maintains an identifier to indicate the target physical block that the host is currently writing to, i.e., the current write block. When it is necessary to determine whether a physical block (denoted as block X) meets the fast reclamation criteria, the system first checks the identity of block X. Specifically, it compares the physical block number of block X with the physical block number of the current write block recorded by the system.
[0045] If the physical block number of block X is the same as the physical block number of the currently written block, then block X is determined to be the target physical block that the host is currently writing to. In this case, the system will skip the subsequent steps of traversing and querying mapping relationships, statistical comparisons, and fast relocation. That is, for the currently written block, the fast reclamation judgment process based on the random data logical address table is not executed. Conversely, only when the physical block number of block X is different from the physical block number of the currently written block, i.e., block X is not the currently written block, will the system continue to execute subsequent operations such as traversing its associated random data logical address table and querying the current mapping relationship of logical addresses.
[0046] This embodiment ensures the correctness and stability of the data writing process, preventing garbage collection logic from interfering with ongoing active write operations. The validity of the data within the physical block currently being written by the host, as well as the mapping relationships in the flash memory translation layer, are dynamically changing. If a historical record-based mapping traversal and judgment is performed on this block at this moment, inconsistent intermediate states may be read. For example, the logical addresses of some recently written random data may not yet be correctly updated in the mapping table, or the valid data count may not reflect the latest situation in real time. This inconsistency may lead to incorrect judgments, causing unnecessary or erroneous data migration, and in severe cases, potentially damaging user data. By limiting fast garbage collection judgments to non-currently written blocks, it ensures that the block state information (such as valid data counts and logical address mappings) upon which the judgment is based is relatively static and stable, thereby improving the accuracy and reliability of the fast garbage collection mechanism's decisions. This fundamentally avoids the risk of conflict with foreground write operations and enhances the system's robustness.
[0047] S5, count the number of logical addresses that still point to the current physical block in each of the current mapping relationships. If the counted number of logical addresses is equal to the valid data count of the current physical block, then only the data corresponding to the counted logical addresses is moved.
[0048] In practice, a mapping consistency verification is performed. The system iterates through each logical address recorded in the random data logical address table, and sequentially queries the logical-to-physical address mapping table in the flash translation layer to obtain the physical block address that each logical address is currently actually mapped to. The number of logical addresses whose current mapping relationships still point to the current physical block (i.e., the physical block currently to be reclaimed) is counted.
[0049] Perform a fast data migration. If the number of logical addresses obtained in the previous step is exactly equal to the number of valid data in this physical block, it means that all the remaining valid data in this physical block are exactly the data corresponding to those logical addresses in the random data logical address table that still point to this block. At this time, the system does not need to scan the entire physical block, but only needs to initiate a data migration operation to read the data pages corresponding to the logical addresses obtained above and write them into the new free physical block.
[0050] S6. After the data migration is completed, the current physical block is reclaimed as an idle block.
[0051] In practice, physical block reclamation is performed. After the aforementioned targeted data relocation operation is completed, no valid data remains in the original physical block. The system then updates the block status information, marks the physical block as a free block, and adds it to the free block pool, thus completing the garbage collection process. The resources occupied by the random data logical address table associated with this physical block can also be released.
[0052] This invention achieves efficient garbage collection in specific write scenarios by distinguishing data stream types and recording random data logical addresses for physical blocks, reducing data movement during garbage collection and improving collection speed. Specifically, in application scenarios where sequential overwriting is dominant, such as circular recording, and interspersed with a small amount of random writing, when sequential data is overwritten by new data, the remaining valid data in the original physical block is usually only a few random data. Through a pre-established random data logical address table, the system can quickly locate these potentially remaining data when collection is triggered. By comparing the count of valid data with the number of logical addresses in the table that still point to the same block, the range of data that needs to be moved can be accurately identified when conditions are met, thereby avoiding a time-consuming full scan of the entire physical block. This significantly reduces the overhead of garbage collection operations and shortens collection latency. At the same time, since sequential data and random data are still written to the same physical block, this method avoids the problems of firmware logic complexity, power failure recovery difficulty, and extra space occupation caused by maintaining multiple parallel host write points, thus improving performance while maintaining the simplicity of the system architecture.
[0053] In some preferred embodiments, after the current physical block is reclaimed as a free block, the method further includes: clearing the random data logical address table corresponding to the current physical block.
[0054] In practice, after the system completes the data migration of the current physical block (whether via a fast recycling path or a traditional recycling path) and successfully marks the physical block as a free block, it checks whether the recently recycled physical block (i.e., the current physical block) is still associated with a random data logical address table. Since the block has been recycled, all data within it is invalid, and its associated random data logical address table has also lost its meaning. Therefore, the system performs a cleanup operation: clearing the random data logical address table corresponding to the current physical block.
[0055] The clearing operation can be implemented by finding the random data logical address table data structure corresponding to the physical block ID, deleting all logical address record entries stored within it, and resetting the record count counter to zero. After completing this step, the physical block is logically restored to a "clean" idle state, decoupled from all historical management information from its time as a data block, and prepared to be allocated as a write block next time.
[0056] In some preferred embodiments, the method further includes: during the host write command processing, if the data splitting function is not enabled, or if the write command is identified as sequential data, the data is directly written to the target physical block without updating the random data logical address table corresponding to any physical block.
[0057] In practice, upon receiving a host write command, the system first performs a conditional check. This check involves two aspects: First, it checks whether global or session-level data routing is enabled. This function can be controlled via firmware configuration parameters and may be disabled in certain operating modes or for specific logical address spaces. Second, it determines whether the current write command is identified as sequential data.
[0058] If either of the above two conditions is met—that is, the data splitting function is not enabled, or the current write command is identified as sequential data—the system will execute a simplified write path. In this path, the system directly writes the data carried by the current command to the target physical block allocated by the flash translation layer (which could be the current write block or a newly allocated block). Crucially, in this simplified path, the system does not perform any update operations related to the random data logical address table. Specifically, it does not check whether the target physical block has an associated random data logical address table, nor does it attempt to record the logical address of the current command into any table. Once the write operation is complete, a success status is returned, and the process ends.
[0059] This embodiment enhances the flexibility and compatibility of the garbage collection acceleration method and optimizes processing efficiency by default. By providing a write bypass that does not rely on a random data logical address table, the system can complete data writing with minimal overhead in scenarios where data splitting acceleration is not needed or suitable. For example, when the data splitting function is explicitly disabled by the administrator, the entire system degenerates into traditional write mode, avoiding unnecessary table maintenance overhead. Furthermore, for writes of data explicitly identified as sequential, since they leave virtually no residue after being overwritten (they will be completely overwritten by subsequent sequential data), maintaining logical address records for them is not beneficial and wastes resources. Skipping table update operations for such data can significantly reduce write operations to memory or metadata areas, reduce CPU processing load, and improve the response speed of write commands.
[0060] In some preferred embodiments, the method further includes: if the physical block is not associated with a valid random data logical address table, or if the valid data count of the physical block is greater than the number of logical addresses recorded in the random data logical address table associated with the physical block, then for the physical block, the steps of judging the relationship between the valid data count and the number of logical addresses, traversing and querying the mapping relationship, and moving data based on the comparison results are not performed.
[0061] In practice, before attempting to initiate the fast recycling judgment process as described in steps S1-S6 for a physical block (called the target block), the system first performs two pre-checks.
[0062] The first check is to determine whether the target block is associated with a valid random data logical address table. Validity means that there exists a table data structure associated with the physical block ID, and that table is accessible. If the target block is not associated with any table, or if the associated table has been cleared or marked as invalid, then this condition is not met.
[0063] The second check is performed after the first check passes. The system reads the valid data count of the target block and the total number of logical addresses recorded in its associated random data logical address table. These two values are compared. If the valid data count is greater than the number of logical addresses recorded in the table, the condition is deemed not met.
[0064] If either of the above two checks results in "not satisfied"—that is, the target block is not associated with a valid random data logical address table, or its valid data count is greater than the number of logical addresses recorded in the table—then the system will not continue executing the subsequent series of core steps related to fast reclamation for this target block. These skipped steps specifically include: determining whether the valid data count is less than or equal to the number of logical addresses; traversing the random data logical address table and querying the current mapping relationship of each logical address; counting the number of addresses mapped to this block; and deciding whether to move the data based on whether the count equals the valid data count. The system will then employ other reclamation strategies for this target block, such as the traditional full-block scan reclamation method.
[0065] This embodiment provides a secure and efficient filtering mechanism that ensures fast reclamation logic is activated only in scenarios with a high probability of success, thereby improving the overall system's processing efficiency and reliability. When a physical block is not associated with a random data logical address table, it indicates that the block may not have recorded random data during the write process, or the records may have been cleared, lacking the information basis for fast reclamation, and forcibly executing subsequent steps is ineffective. When the valid data count of a physical block is greater than the number of logical addresses recorded in the table, it indicates that the remaining valid data in the block may not be limited to the random data recorded in the table, but may also contain other unrecorded data. In this case, even if fast reclamation judgment is performed, the result is almost impossible to meet the precise matching condition of "statistical count equals valid count," and it will ultimately fall into the traditional reclamation path, but the previous table traversal and mapping query consume additional resources. Through these two pre-checks, the system can identify physical blocks that are clearly unsuitable for fast reclamation in advance and directly skip related computationally intensive operations, avoiding unnecessary performance overhead.
[0066] Corresponding to the above-described SSD garbage collection acceleration method based on data diversion, the present invention also provides an SSD garbage collection acceleration device based on data diversion. This data diversion-based SSD garbage collection acceleration device includes a unit for executing the aforementioned data diversion-based SSD garbage collection acceleration method, and can be configured in a terminal or server. Specifically, the data diversion-based SSD garbage collection acceleration device includes: The differentiation unit is used to distinguish between sequential data and random data based on the order of the data stream and the continuity of the logical address when writing data to the host. The maintenance unit is used to maintain a random data logical address table for physical blocks in the solid-state drive; The first writing unit is used to write the sequential data and the random data into the same current physical block, and record the logical address corresponding to the random data written into the current physical block into the target random data logical address table corresponding to the current physical block; The query unit is used to, when the current physical block is full, if there is a record in the target random data logical address table corresponding to the current physical block, and the effective data count of the current physical block is less than or equal to the number of logical addresses recorded in the target random data logical address table, then traverse all logical addresses recorded in the target random data logical address table and query the current mapping relationship of each logical address in the target random data logical address table one by one. The statistics unit is used to count the number of logical addresses that still point to the current physical block in each of the current mapping relationships. If the counted number of logical addresses is equal to the valid data count of the current physical block, then only the data corresponding to the counted logical addresses is moved. The recycling unit is used to reclaim the current physical block as an idle block after the data migration is completed.
[0067] Optionally, it also includes a configuration unit for: Set a capacity threshold for the random data logical address table; During the process of recording logical addresses, if the number of logical addresses recorded in the random data logical address table corresponding to the physical block reaches the set capacity threshold, then the recording of new logical addresses into the random data logical address table corresponding to the physical block will stop.
[0068] Optionally, a deletion unit is also included for: Delete or clear the random data logical address table corresponding to the physical block.
[0069] Optionally, the step of traversing all logical addresses recorded in the target random data logical address table and querying the current mapping relationship of each logical address in the target random data logical address table one by one is performed only when the current physical block is not the target physical block that the host is currently writing to.
[0070] Optionally, distinguishing between sequential data and random data based on the sequentiality of the data stream and the continuity of logical addresses includes: If the logical addresses accessed by the host write command are consecutive and sequentially connected to the end logical address of the previous command, then the corresponding data will be identified as sequential data. Otherwise, the corresponding data will be identified as random data.
[0071] Optionally, a second write unit is also included, for: During the host write command processing, if the data splitting function is not enabled, or if the write command is identified as sequential data, the data is directly written to the target physical block without updating the random data logical address table corresponding to any physical block.
[0072] Optionally, it also includes a clearing unit for: Clear the random data logical address table corresponding to the current physical block.
[0073] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned SSD garbage collection acceleration device based on data diversion and each unit can be referred to the corresponding description in the foregoing method embodiments. For the sake of convenience and brevity, it will not be repeated here.
[0074] The aforementioned SSD garbage collection acceleration device based on data offloading can be implemented as a computer program, which can, for example... Figure 2 It runs on the computer device shown.
[0075] Please see Figure 2 , Figure 2 This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 500 can be a terminal or a server, wherein the server can be a standalone server or a server cluster composed of multiple servers.
[0076] The computer device 500 includes a processor 502, a memory, and a network interface 505 connected via a system bus 501. The memory may include a non-volatile storage medium 503 and internal memory 504.
[0077] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, it causes the processor 502 to execute an SSD garbage collection acceleration method based on data offloading.
[0078] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.
[0079] The internal memory 504 provides an environment for the execution of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute an SSD garbage collection acceleration method based on data diversion.
[0080] The network interface 505 is used for network communication with other devices. Those skilled in the art will understand that the above structure is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 500 to which the present application is applied. A specific computer device 500 may include more or fewer components than shown in the figures, or combine certain components, or have different component arrangements.
[0081] The processor 502 is used to run a computer program 5032 stored in the memory to perform the following steps: When writing data to the host, sequential data and random data are distinguished based on the order of the data stream and the continuity of the logical address. Maintain a logical address table for random data in the physical blocks of the solid-state drive; Write the sequential data and the random data into the same current physical block, and record the logical address corresponding to the random data written into the current physical block into the target random data logical address table corresponding to the current physical block; When the current physical block is full, if there is a record in the target random data logical address table corresponding to the current physical block, and the effective data count of the current physical block is less than or equal to the number of logical addresses recorded in the target random data logical address table, then all logical addresses recorded in the target random data logical address table are traversed, and the current mapping relationship of each logical address in the target random data logical address table is queried one by one. The number of logical addresses that still point to the current physical block in each of the current mapping relationships is counted. If the counted number of logical addresses is equal to the valid data count of the current physical block, then only the data corresponding to the counted logical addresses is moved. After the data migration is completed, the current physical block will be reclaimed as an idle block.
[0082] Optionally, it also includes: Set a capacity threshold for the random data logical address table; During the process of recording logical addresses, if the number of logical addresses recorded in the random data logical address table corresponding to the physical block reaches the set capacity threshold, then the recording of new logical addresses into the random data logical address table corresponding to the physical block will stop.
[0083] Optionally, after stopping the recording of new logical addresses to the random data logical address table corresponding to the physical block, the method further includes: Delete or clear the random data logical address table corresponding to the physical block.
[0084] Optionally, the step of traversing all logical addresses recorded in the target random data logical address table and querying the current mapping relationship of each logical address in the target random data logical address table one by one is performed only when the current physical block is not the target physical block that the host is currently writing to.
[0085] Optionally, distinguishing between sequential data and random data based on the sequentiality of the data stream and the continuity of logical addresses includes: If the logical addresses accessed by the host write command are consecutive and sequentially connected to the end logical address of the previous command, then the corresponding data will be identified as sequential data. Otherwise, the corresponding data will be identified as random data.
[0086] Optionally, it also includes: During the host write command processing, if the data splitting function is not enabled, or if the write command is identified as sequential data, the data is directly written to the target physical block without updating the random data logical address table corresponding to any physical block.
[0087] Optionally, after reclaiming the current physical block as a free block, the method further includes: Clear the random data logical address table corresponding to the current physical block.
[0088] It should be understood that in the embodiments of this application, the processor 502 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0089] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program may be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0090] Therefore, the present invention also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program. When executed by a processor, the computer program causes the processor to perform the following steps: When writing data to the host, sequential data and random data are distinguished based on the order of the data stream and the continuity of the logical address. Maintain a logical address table for random data in the physical blocks of the solid-state drive; Write the sequential data and the random data into the same current physical block, and record the logical address corresponding to the random data written into the current physical block into the target random data logical address table corresponding to the current physical block; When the current physical block is full, if there is a record in the target random data logical address table corresponding to the current physical block, and the effective data count of the current physical block is less than or equal to the number of logical addresses recorded in the target random data logical address table, then all logical addresses recorded in the target random data logical address table are traversed, and the current mapping relationship of each logical address in the target random data logical address table is queried one by one. The number of logical addresses that still point to the current physical block in each of the current mapping relationships is counted. If the counted number of logical addresses is equal to the valid data count of the current physical block, then only the data corresponding to the counted logical addresses is moved. After the data migration is completed, the current physical block will be reclaimed as an idle block.
[0091] Optionally, it also includes: Set a capacity threshold for the random data logical address table; During the process of recording logical addresses, if the number of logical addresses recorded in the random data logical address table corresponding to the physical block reaches the set capacity threshold, then the recording of new logical addresses into the random data logical address table corresponding to the physical block will stop.
[0092] Optionally, after stopping the recording of new logical addresses to the random data logical address table corresponding to the physical block, the method further includes: Delete or clear the random data logical address table corresponding to the physical block.
[0093] Optionally, the step of traversing all logical addresses recorded in the target random data logical address table and querying the current mapping relationship of each logical address in the target random data logical address table one by one is performed only when the current physical block is not the target physical block that the host is currently writing to.
[0094] Optionally, distinguishing between sequential data and random data based on the sequentiality of the data stream and the continuity of logical addresses includes: If the logical addresses accessed by the host write command are consecutive and sequentially connected to the end logical address of the previous command, then the corresponding data will be identified as sequential data. Otherwise, the corresponding data will be identified as random data.
[0095] Optionally, it also includes: During the host write command processing, if the data splitting function is not enabled, or if the write command is identified as sequential data, the data is directly written to the target physical block without updating the random data logical address table corresponding to any physical block.
[0096] Optionally, after reclaiming the current physical block as a free block, the method further includes: Clear the random data logical address table corresponding to the current physical block.
[0097] The storage medium is a physical, non-transient storage medium, such as a USB flash drive, external hard drive, read-only memory (ROM), magnetic disk, or optical disk, or any other physical storage medium capable of storing program code. The computer-readable storage medium can be non-volatile or volatile.
[0098] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0099] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0100] The steps in the method of this invention can be adjusted, merged, or reduced in order according to actual needs. The units in the device of this invention can be merged, divided, or reduced according to actual needs. Furthermore, the functional units in the various embodiments of this invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0101] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0102] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0103] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Since these modifications and variations fall within the scope of the claims and their equivalents, this invention also intends to include these modifications and variations.
[0104] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for accelerating SSD garbage collection based on data diversion, characterized in that, include: When writing data to the host, sequential data and random data are distinguished based on the order of the data stream and the continuity of the logical address. Maintain a logical address table for random data in the physical blocks of the solid-state drive; Write the sequential data and the random data into the same current physical block, and record the logical address corresponding to the random data written into the current physical block into the target random data logical address table corresponding to the current physical block; When the current physical block is full, if there is a record in the target random data logical address table corresponding to the current physical block, and the effective data count of the current physical block is less than or equal to the number of logical addresses recorded in the target random data logical address table, then all logical addresses recorded in the target random data logical address table are traversed, and the current mapping relationship of each logical address in the target random data logical address table is queried one by one. The number of logical addresses that still point to the current physical block in each of the current mapping relationships is counted. If the counted number of logical addresses is equal to the valid data count of the current physical block, then only the data corresponding to the counted logical addresses is moved. After the data migration is completed, the current physical block will be reclaimed as an idle block.
2. The SSD garbage collection acceleration method based on data diversion according to claim 1, characterized in that, Also includes: Set a capacity threshold for the random data logical address table; During the process of recording logical addresses, if the number of logical addresses recorded in the random data logical address table corresponding to the physical block reaches the set capacity threshold, then the recording of new logical addresses into the random data logical address table corresponding to the physical block will stop.
3. The SSD garbage collection acceleration method based on data diversion according to claim 2, characterized in that, After stopping the recording of new logical addresses to the random data logical address table corresponding to the physical block, the method further includes: Delete or clear the random data logical address table corresponding to the physical block.
4. The SSD garbage collection acceleration method based on data diversion according to claim 1, characterized in that, The step of traversing all logical addresses recorded in the target random data logical address table and querying the current mapping relationship of each logical address in the target random data logical address table is performed only when the current physical block is not the target physical block that the host is currently writing to.
5. The SSD garbage collection acceleration method based on data diversion according to claim 1, characterized in that, The method of distinguishing between sequential data and random data based on the sequentiality of the data stream and the continuity of logical addresses includes: If the logical addresses accessed by the host write command are consecutive and sequentially connected to the end logical address of the previous command, then the corresponding data will be identified as sequential data. Otherwise, the corresponding data will be identified as random data.
6. The SSD garbage collection acceleration method based on data diversion according to claim 1, characterized in that, Also includes: During the host write command processing, if the data splitting function is not enabled, or if the write command is identified as sequential data, the data is directly written to the target physical block without updating the random data logical address table corresponding to any physical block.
7. The SSD garbage collection acceleration method based on data splitting according to claim 1, characterized in that, After reclaiming the current physical block as a free block, the process also includes: Clear the random data logical address table corresponding to the current physical block.
8. A data-based SSD garbage collection acceleration device, characterized in that, Includes a unit for performing the method as described in any one of claims 1-7.
9. A computer device, characterized in that, The computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, can implement the method as described in any one of claims 1-7.