Solid-state hard drive garbage recovery method and device, electronic device and storage medium
By evaluating the effective data distribution uniformity and physical block-level parameters of logical units in solid-state drives, and optimizing the garbage collection strategy, the write amplification problem caused by forced migration of super blocks is solved, and the garbage collection efficiency and storage resource utilization are improved.
Patent Information
- Application Number
- CN202510828526.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-19
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2045-06-19
AI Technical Summary
In the prior art, the write amplification problem caused by forced migration of super blocks in solid-state drive garbage collection leads to the unreleased read performance advantages, and the user writes data to the garbage collection operation form a fixed proportion of write amplification, further aggravating the system burden.
By obtaining the valid data parameters of multiple logical units in the storage system, evaluating the distribution uniformity of effective data in the logical unit, filtering out the target logical units that need to be garbage collected, and determining the data migration method based on physical block-level parameters, reducing redundant operations, and optimizing resource utilization.
It improves the efficiency of garbage collection, reduces unnecessary erasing operations, improves the utilization rate of storage resources, avoids write amplification, and prioritizes the use of NAND life for user writing.
Smart Images

Figure CN120353724B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of storage technology, and in particular to a method and device for solid-state hard drive garbage recovery, an electronic device, and a storage medium. Background Art
[0002] With the widespread adoption of enterprise-class solid-state drives (SSDs) in data centers and high-performance computing, optimizing their performance and lifespan has become a key technical challenge. Currently, SSD garbage collection generally uses the superblock-level valid data frame count (VDFC) as a screening and evaluation criterion. Garbage collection (GC) is a computer system mechanism that automatically reclaims space occupied by invalid data, with the core goal of freeing up storage resources for reuse. With the advancement of NAND flash memory technology, the capacity of individual physical blocks has increased significantly, leading to a significant increase in the total capacity of superblocks. This makes it difficult to achieve high VDFC selection accuracy, directly limiting further improvements in garbage collection efficiency. The superblock-based recycling mechanism forces the migration of all valid data, leading to excessive write amplification when some physical blocks have an extremely high percentage of valid data. While NAND backend read performance is significantly higher than write performance, traditional solutions require a strict correspondence between garbage collection read and write operations, preventing the read performance advantage from being realized. Furthermore, the write amplification generated by user writes and garbage collection operations creates a fixed ratio, further increasing system burden. Summary of the Invention
[0003] The present disclosure provides a solid-state drive garbage collection method and apparatus, electronic device, and storage medium, with the primary purpose of resolving the write amplification problem caused by the coarse-grained operation of forced migration of superblocks during garbage collection in related technologies.
[0004] According to a first aspect of the present disclosure, a method for garbage collection of a solid-state drive is provided, comprising:
[0005] Acquire first valid data parameters of a plurality of logical units in a storage system and second valid data parameters of physical blocks included in each logical unit;
[0006] Based on the first valid data parameter and the second valid data parameter, evaluating the distribution uniformity of valid data in the plurality of logical units, and based on the distribution uniformity evaluation result, selecting at least one target logical unit that needs to be garbage collected;
[0007] Based on the second valid data parameter, determining a data migration method for valid data stored in a target physical block in each target logical unit and performing data migration;
[0008] After the valid data is migrated, whether the target physical block needs resource recycling is determined based on the data migration mode of the valid data stored in the target physical block, and resource recycling is performed on the target physical block that needs resource recycling.
[0009] Optionally, the distribution uniformity of valid data in multiple logical units is evaluated based on multi-level evaluation parameters, including:
[0010] Calculating a data distribution deviation of each physical block based on the second valid data parameter and the corresponding first valid data parameter of each physical block;
[0011] The data distribution deviations of the physical blocks in multiple logical units are aggregated to generate deviation characteristic parameters that characterize the uniformity of the effective data distribution of the logical unit.
[0012] Optionally, based on the distribution uniformity evaluation result, screening at least one target logical unit requiring garbage collection includes:
[0013] Calculating the recycling priorities of multiple logical units respectively according to the deviation characteristic parameters;
[0014] Based on the collection priority, at least one target logical unit that needs to be garbage collected is selected.
[0015] Optionally, before determining a data migration mode for valid data stored in a target physical block in each target logical unit based on the second valid data parameter and performing data migration, the solid state drive garbage collection method further includes:
[0016] A migration threshold for performing data migration on valid data is calculated based on first valid data parameters of the plurality of logical units.
[0017] Optionally, calculating a migration threshold for performing data migration on valid data based on first valid data parameters of the plurality of logical units includes:
[0018] calculating a global average valid data parameter using first valid data parameters of the plurality of logic units;
[0019] A migration threshold is calculated and generated according to a global average valid data parameter, the number of physical blocks in the target logical unit, and a first constant.
[0020] Optional data migration methods include: mapping migration and physical migration.
[0021] Optionally, determining a data migration method for valid data stored in a target physical block in each target logical unit based on the second valid data parameter and performing data migration includes:
[0022] Comparing the second valid data parameter with the migration threshold to determine a data migration method for valid data stored in the migration target physical block;
[0023] According to the data migration method, the valid data stored in the target physical block is migrated to the first logical unit or the second logical unit.
[0024] Optionally, comparing the second valid data parameter with the migration threshold to determine a data migration method for valid data stored in the migration target physical block includes:
[0025] If the second valid data parameter of the target physical block exceeds the migration threshold, determining that the data migration mode of the valid data stored in the target physical block is mapping migration;
[0026] If the second valid data parameter of the target physical block is less than or equal to the migration threshold, it is determined that the data migration mode of the valid data stored in the target physical block is physical migration.
[0027] Optionally, migrating valid data stored in the target physical block to the first logical unit or the second logical unit according to the data migration method includes:
[0028] If the data migration mode is mapping migration, the mapping relationship between the target physical block and the target logical unit is released, and the target physical block is mapped to the first logical unit;
[0029] If the data migration mode is physical migration, the valid data stored in the target physical block is read, and the valid data is written into the physical block of the second logical unit.
[0030] Optionally, before determining a data migration mode for valid data stored in a target physical block in each target logical unit based on the second valid data parameter and performing data migration, the solid state drive garbage collection method further includes:
[0031] A first logical unit and a second logical unit are created based on a free logical unit and an empty physical block.
[0032] Optionally, creating the first logical unit and the second logical unit based on the free logical unit and the empty physical block includes:
[0033] Selecting an idle logical unit from an idle resource pool and selecting an idle physical block from an idle physical block pool to generate a first logical unit;
[0034] An idle logical unit is selected from the idle resource pool and multiple idle physical blocks are selected from the idle physical block pool to generate a second logical unit.
[0035] Optionally, selecting an idle logical unit from an idle resource pool and selecting an idle physical block from an idle physical block pool to generate a first logical unit includes:
[0036] Configure a selected idle logical unit as a check block;
[0037] A mapping relationship between the check block and the idle logical unit is established to generate a first logical unit.
[0038] Optionally, selecting an idle logical unit from an idle resource pool and selecting multiple idle physical blocks from an idle physical block pool to generate a second logical unit includes:
[0039] Selecting one of a plurality of idle physical blocks to be configured as a check block, wherein the plurality of idle physical blocks come from different wafer dies;
[0040] A mapping relationship is established between the check block and the remaining free physical blocks and the free logical unit to generate a second logical unit.
[0041] Optionally, before reclaiming resources on a target physical block requiring resource reclamation, the solid-state drive garbage collection method further includes:
[0042] Release the mapping relationship between at least one target logical unit and each target physical block;
[0043] The target logical unit whose mapping relationship is released is recycled as an idle logical unit into the idle resource pool.
[0044] Optionally, judging whether the target physical block needs resource recovery based on a data migration mode of valid data stored in the target physical block includes:
[0045] If the data migration mode is mapping migration, it is determined that the target physical block does not need to be recycled;
[0046] If the data migration mode is physical migration, it is determined that the target physical block needs to be reclaimed.
[0047] Optionally, perform resource recycling on the target physical block that requires resource recycling, including:
[0048] Erasing data on target physical blocks that require resource recovery;
[0049] The physical blocks after data erasure are recycled as free physical blocks into the free physical block pool.
[0050] According to a second aspect of the present disclosure, a device for solid-state hard disk garbage collection is provided, comprising:
[0051] An acquiring unit, configured to acquire first valid data parameters of a plurality of logical units in a storage system and second valid data parameters of physical blocks included in each logical unit;
[0052] a screening unit, configured to evaluate the distribution uniformity of valid data in the plurality of logical units based on the first valid data parameter and the second valid data parameter, and screen at least one target logical unit requiring garbage collection based on the distribution uniformity evaluation result;
[0053] a determining unit, configured to determine, based on the second valid data parameter, a data migration mode for valid data stored in a target physical block in each target logical unit and perform data migration;
[0054] The recycling unit is used to determine whether the target physical block needs resource recycling according to the data migration mode of the valid data stored in the target physical block after the valid data is migrated, and to recycle the target physical block that needs resource recycling.
[0055] Optionally, the screening unit includes:
[0056] A first calculation module is configured to calculate a data distribution deviation of each physical block based on the second valid data parameter and the corresponding first valid data parameter of each physical block;
[0057] The first generating module is configured to aggregate the data distribution deviations of the physical blocks in the plurality of logical units to generate a deviation characteristic parameter representing the uniformity of the effective data distribution of the logical unit.
[0058] Optionally, the screening unit includes:
[0059] A second calculation module is used to calculate the recycling priorities of the multiple logical units according to the deviation characteristic parameters;
[0060] The screening module is used to screen at least one target logical unit that needs to be garbage collected based on the collection priority.
[0061] Optionally, the solid state drive garbage collection device further includes:
[0062] The calculation unit is used to calculate a migration threshold for data migration of valid data based on the first valid data parameters of multiple logical units before determining the data migration method of valid data stored in the target physical block in each target logical unit based on the second valid data parameter and performing data migration.
[0063] Optionally, the computing unit includes:
[0064] a third calculation module, configured to calculate a global average valid data parameter using the first valid data parameters of the plurality of logic units;
[0065] The fourth calculation module is used to calculate and generate a migration threshold according to the global average valid data parameter, the number of physical blocks in the target logical unit, and the first constant.
[0066] Optional data migration methods include: mapping migration and physical migration.
[0067] Optionally, the determining unit includes:
[0068] A first determining module is configured to compare the second valid data parameter with the migration threshold value to determine a data migration mode for valid data stored in the migration target physical block;
[0069] The migration module is used to migrate the valid data stored in the target physical block to the first logical unit or the second logical unit according to the data migration method.
[0070] Optionally, the first determining module is further configured to:
[0071] If the second valid data parameter of the target physical block exceeds the migration threshold, determining that the data migration mode of the valid data stored in the target physical block is mapping migration;
[0072] If the second valid data parameter of the target physical block is less than or equal to the migration threshold, it is determined that the data migration mode of the valid data stored in the target physical block is physical migration.
[0073] Optionally, the migration module is also used to:
[0074] If the data migration mode is mapping migration, the mapping relationship between the target physical block and the target logical unit is released, and the target physical block is mapped to the first logical unit;
[0075] If the data migration mode is physical migration, the valid data stored in the target physical block is read, and the valid data is written into the physical block of the second logical unit.
[0076] Optionally, the solid state drive garbage collection device further includes:
[0077] The creation unit is used to create the first logical unit and the second logical unit based on the idle logical unit and the empty physical block before determining the data migration method of the valid data stored in the target physical block in each target logical unit based on the second valid data parameter and performing data migration.
[0078] Optionally, create a unit including:
[0079] A second generating module is configured to select an idle logical unit from an idle resource pool and an idle physical block from an idle physical block pool to generate a first logical unit;
[0080] The third generating module is configured to select an idle logical unit from the idle resource pool and select multiple idle physical blocks from the idle physical block pool to generate a second logical unit.
[0081] Optionally, the second generation module is further configured to:
[0082] Configure a selected idle logical unit as a check block;
[0083] A mapping relationship between the check block and the idle logical unit is established to generate a first logical unit.
[0084] Optionally, the third generation module is further configured to:
[0085] Selecting one of a plurality of idle physical blocks to be configured as a check block, wherein the plurality of idle physical blocks come from different wafer dies;
[0086] A mapping relationship is established between the check block and the remaining free physical blocks and the free logical unit to generate a second logical unit.
[0087] Optionally, the solid state drive garbage collection device further includes:
[0088] The release unit is used to release the mapping relationship between at least one target logical unit and each target physical block before recycling the target physical block that needs resource recycling; and recycle the target logical unit whose mapping relationship is released as an idle logical unit into the idle resource pool.
[0089] Optionally, the recovery unit also includes:
[0090] A second determining module is configured to determine that the target physical block does not need to be reclaimed if the data migration mode is mapping migration;
[0091] The third determining module is configured to determine whether resource recovery is required for the target physical block if the data migration mode is physical migration.
[0092] Optionally, the recovery unit also includes:
[0093] The erase module is used to erase data on the target physical block that needs resource recovery;
[0094] The recycling module is used to recycle the physical blocks that have been processed by data erasure as free physical blocks into the free physical block pool.
[0095] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0096] at least one processor; and
[0097] a memory communicatively connected to the at least one processor; wherein,
[0098] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the solid-state hard disk garbage collection method described in the first aspect.
[0099] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the solid-state hard disk garbage collection method described in the first aspect.
[0100] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the solid-state hard disk garbage collection method as described in the first aspect.
[0101] The present disclosure provides a method and device for solid-state hard drive garbage collection, an electronic device, and a storage medium, relating to the field of storage technology. Compared with related technologies, the present disclosure can accurately locate logical units and physical blocks with uneven distribution of valid data through detailed evaluation of physical block-level parameters. It can prioritize triggering units with more urgent recycling needs, avoiding efficiency bottlenecks caused by "one-size-fits-all" recycling. Screening target logical units based on the distribution uniformity evaluation results can improve screening accuracy and improve garbage collection efficiency. By identifying logical units with "valid data concentrated in some physical blocks", invalid recycling of units with a lot of valid data but large internal physical block differences can be avoided, reducing redundant operations. The amount of NAND writes to high-valid data blocks can be reduced to avoid write amplification caused by "writing all valid data to a new block". Unnecessary erase operations are reduced, and NAND life is prioritized for user writes rather than redundant writes generated by garbage collection. Combined with dynamic mapping, the recovered logical units can be reallocated as free blocks, improving storage resource utilization.
[0102] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0103] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.
[0104] Figure 1 A flowchart of a solid-state drive garbage collection method provided by an embodiment of the present disclosure;
[0105] Figure 2 A flowchart of another solid-state drive garbage collection method provided by an embodiment of the present disclosure;
[0106] Figure 3 A schematic diagram of a data migration process provided by an embodiment of the present disclosure;
[0107] Figure 4 A schematic structural diagram of a solid-state hard disk garbage collection device provided by an embodiment of the present disclosure;
[0108] Figure 5 A schematic structural diagram of another solid-state drive garbage collection device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0109] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0110] The following describes the solid-state drive garbage collection method and apparatus, electronic device, and storage medium according to embodiments of the present disclosure with reference to the accompanying drawings.
[0111] Figure 1 A flowchart of a solid-state drive garbage collection method provided by an embodiment of the present disclosure.
[0112] like Figure 1 As shown, the method comprises the following steps:
[0113] Step 101: Acquire first valid data parameters of multiple logical units in a storage system and second valid data parameters of physical blocks included in each logical unit.
[0114] In an embodiment of the present disclosure, in a storage system based on NAND flash memory, data storage and management follow a hierarchical structure of physical blocks and physical pages: a physical block is the smallest unit for erasing data, while a physical page is the smallest unit for writing and reading data. Data cannot be deleted directly at the physical page level, and space must be released by erasing the entire physical block. A logical unit, as an upper-level unit of data organization (such as a superblock in an SSD), is composed of multiple physical blocks to form a RAID stripe (such as RAID 5) to achieve data protection. In a storage system, a logical unit, as a basic unit for data organization and management (such as a superblock in an SSD), contains several physical blocks (such as a block in NAND flash). A hierarchical association mapping relationship between logical units and physical blocks is established through the main control chip or firmware layer of the storage system. When performing garbage collection, it is also necessary to ensure the normal storage of valid data. Therefore, when performing garbage collection, the following two types of parameters need to be collected: First valid data parameter: a statistical parameter that characterizes the overall valid data volume of the logical unit (such as superblock-level VDFC, that is, the total number of valid data). It is generated by traversing the address mapping table of all physical blocks in the logical unit and counting the number of data frames marked as "valid". Second valid data parameter: a detailed parameter that characterizes the valid data volume of each physical block in the logical unit. It is generated by parsing the RAID stripe structure of the logical unit (such as RAID 5) and independently counting the number of valid data frames according to the physical block dimension. The first valid data parameter and the second valid data parameter can be the valid data volume or indicators such as the data density of the valid data. The present disclosure does not limit the specific parameter form.
[0115] In the related art, only valid data parameters (superblock VDFC) are collected at the logical unit level, resulting in a coarse evaluation granularity that makes it impossible to identify differences in the distribution of valid data in physical blocks within the logical unit. The disclosed embodiment, through a hierarchical parameter collection mechanism, expands the evaluation dimension from the logical unit level to the physical block level, solving the problem of "overall evaluation masking local differences" in the related art and providing a data foundation for refined garbage collection strategies. By introducing physical block-level parameters (second valid data parameters), the degree of discreteness of valid data within a logical unit can be quantified, avoiding the situation where the "high invalid data ratio" of a local physical block is ignored due to the overall balance of valid data in the logical unit.
[0116] Step 102 : Based on the first valid data parameter and the second valid data parameter, evaluate the distribution uniformity of valid data in multiple logical units, and based on the distribution uniformity evaluation result, select at least one target logical unit that needs to be garbage collected.
[0117] In the disclosed embodiments, the distribution uniformity of valid data within a logical unit is quantitatively characterized by the degree of dispersion of its physical block-level valid data parameters. This module uses statistical analysis methods (such as variance calculation and extreme value comparison) based on these multi-level evaluation parameters (i.e., the first valid data parameter at the logical unit level and the second valid data parameter at the physical block level) to assess the distribution uniformity of valid data within each logical unit across physical blocks. The specific process is as follows:
[0118] The effective data distribution characteristics of a logical unit are directly related to the space utilization efficiency of its internal physical blocks. Based on the underlying "physical block erase, physical page write" mechanism of NAND flash memory, this approach quantitatively evaluates the distribution of effective data within a logical unit in the physical block dimension by analyzing multi-level evaluation parameters (i.e., the first effective data parameter at the logical unit level and the second effective data parameter at the physical block level). Specifically, for each logical unit, the set of physical blocks it contains is traversed. Based on the second effective data parameter (such as the number of effective data frames at the physical block level, VDFC_B), information such as the effective data volume, percentage, and address mapping of each physical block is extracted. A two-dimensional "effective data-physical address" distribution model for the physical blocks is established to characterize the spatial dispersion of data storage within the logical unit.
[0119] When conducting a quantitative analysis of distribution uniformity, statistical measures such as standard deviation and coefficient of variation can be used to quantify the differences in effective data volume between physical blocks, but are not limited to these. By setting an effective data volume threshold (such as a percentage of the global average effective data volume), a classification is established between "high-percentage effective data blocks" and "low-percentage effective data blocks," and the numerical or spatial proportions of these two types of physical blocks within the logical unit are calculated. This ultimately generates a distribution uniformity index for the logical unit, which is negatively correlated with the difference in effective data volume between physical blocks; that is, the greater the difference, the worse the uniformity.
[0120] By combining the first valid data parameter at the logical unit level (such as the total valid data volume (VDFC) of the logical unit) with the distribution uniformity indicator, a composite screening condition is constructed based on the distribution uniformity indicator. Logical units that meet the conditions are included in the target set and enter the subsequent garbage collection process. The selected target logical units can be prioritized to ensure orderly processing of the target logical units and optimize the resource scheduling efficiency of garbage collection.
[0121] By analyzing the distribution of valid data at the physical block level, this technology accurately identifies physical blocks with low valid data percentages within a logical unit, avoiding redundant erases of blocks with high valid data and reducing the number of physical erase cycles (PEs) consumed by the NAND flash memory. Based on the distribution uniformity assessment results, differentiated processing is applied to logical units. Compared to the "one-size-fits-all" recycling of logical units in related technologies, this technology reduces the amount of valid data migration.
[0122] Step 103 : Based on the second valid data parameter, determine a data migration method for valid data stored in the target physical block in each target logical unit and perform data migration.
[0123] In an embodiment of the present disclosure, the storage system, based on its own storage conditions, needs to perform garbage collection on stored invalid data to reclaim storage resources. Therefore, a garbage collection instruction is generated for the selected target logical unit to perform garbage collection. For the target physical block within the target logical unit, a data migration strategy is dynamically selected based on the second valid data parameter at the physical block level (e.g., the number of valid data frames) and the physical characteristics of the NAND flash memory (e.g., the erase and write limit, read and write performance differences). By analyzing the second valid data parameter of each physical block in the target logical unit, data migration can be performed using, but not limited to, the following data characteristics, such as the percentage of valid data and the amount of valid data frames. Based on the above characteristics, the target physical blocks are divided into two categories and the migration methods are matched accordingly: For blocks with high valid data (e.g., the percentage of valid data is greater than a threshold T), a data remapping strategy is adopted. By updating the mapping relationship between the logical unit and the physical block (e.g., dynamic RAID striping reorganization), the logical address of the physical block is mapped to the new storage location, and only the RAID checksum data is updated and written, avoiding full data migration. Low-validity data blocks (e.g., the percentage of valid data is lower than the threshold T): Using the traditional garbage collection strategy, valid data in the physical block is read and written to a new physical block. After the data migration is completed, the original physical block is erased. The remapping strategy is used to reduce the number of erase and write times (PE times) of high-validity data blocks, prioritizing the limited NAND life resources to user data writes rather than redundant operations generated by garbage collection. The remapping strategy utilizes the characteristic of NAND flash memory that "read speed is higher than write speed" to simplify the traditional solution of "read + full write" to "read + verify write", significantly reducing the time consumption of single-block migration; the two types of strategies are executed in parallel, supporting the storage system to dynamically schedule migration tasks according to the load, improving the concurrent processing capabilities of garbage collection.
[0124] Step 104 : After the valid data is migrated, it is determined whether the target physical block needs resource recycling based on the data migration mode of the valid data stored in the target physical block, and the target physical block that needs resource recycling is recycled.
[0125] In an embodiment of the present disclosure, after completing the migration operation of valid data in the target logical unit, the module performs differentiated resource recovery at the logical unit level and the physical block level to release invalid storage space and maintain the availability of the storage system. Based on the first valid data parameter of the logical unit level after migration (such as the overall valid data volume), combined with the changes in the mapping relationship of its internal physical blocks, it is determined whether the logical unit has entered a recyclable state. Typical conditions for the recyclable state include but are not limited to: all physical blocks in the target logical unit have completed data migration or remapping; the RAID stripe corresponding to the target logical unit has achieved data protection switching through verification data reconstruction. Based on the second valid data parameter of the physical block level in the data migration phase, the target physical blocks that need to perform resource recovery are screened out; for physical blocks migrated using the traditional garbage collection strategy, if the valid data volume after migration is zero, they are marked as "erasable"; for the original physical blocks involved in the remapping strategy, if the logical address decoupling has been achieved through verification data update, data erasure is not performed.
[0126] The present disclosure provides a method for garbage collection of solid-state drives. Compared with related technologies, the present disclosure can accurately locate logical units and physical blocks with uneven distribution of valid data through detailed evaluation of physical block-level parameters. It can give priority to triggering units with more urgent recycling needs, avoiding efficiency bottlenecks caused by "one-size-fits-all" recycling. Screening target logical units based on the distribution uniformity evaluation results can improve screening accuracy and improve garbage collection efficiency. By identifying logical units with "valid data concentrated in some physical blocks", invalid recycling of units with a lot of valid data but large differences in internal physical blocks can be avoided, reducing redundant operations. Reduce the amount of NAND writes to high-valid data blocks, and avoid write amplification caused by "writing all valid data to new blocks". Reduce unnecessary erase operations, and give priority to using NAND life for user writes rather than redundant writes generated by garbage collection. Combined with dynamic mapping, the recovered logical units can be reallocated as free blocks to improve storage resource utilization.
[0127] To clearly illustrate the embodiments of the present disclosure, this embodiment provides a flowchart of another method for garbage collection of a solid-state drive.
[0128] like Figure 2 As shown, the method comprises the following steps:
[0129] Step 201: Acquire first valid data parameters of multiple logical units in a storage system and second valid data parameters of physical blocks included in each logical unit.
[0130] Specifically, in step 201, in a NAND flash-based storage system, a logical unit (LU) serves as the basic unit of data organization. The distribution of valid data within its internal physical blocks directly impacts garbage collection efficiency and NAND lifespan. The first valid data parameter (at the LU level) represents the total valid data frame count for the LU, referred to as VDFC at the superblock level. The second valid data parameter (at the physical block level) represents the valid data distribution for each physical block within the LU, referred to as VDFC_B (valid data count per block). In a RAID stripe structure based on LUs (superblocks are dynamically composed of blocks from each die), the number of valid data frames is counted independently for each physical block (for example, VDFC8_B2 represents the number of valid data frames for the second physical block in superblock 8). This parameter is updated in real time during user I / O operations (such as data writes and updates): When data is written to a new physical block, VDFC_B increments by 1, while VDFC_B decrements by 1 for the old physical block. During data migration by garbage collection, VDFC_B decrements by 1 for the source physical block and increments by 1 for the destination physical block.
[0131] The mapping between logical units and physical blocks is no longer fixed but is updated through garbage collection. For example, when a physical block is identified as "low VDFC_B" and needs to be reclaimed, it is unmapped from the original logical unit and reallocated to the free block pool. In remapping scenarios, a new logical unit (such as superblock B) is dynamically bound to the physical block with higher VDFC_B, updating the RAID parity mapping.
[0132] Step 202 : Calculate the data distribution deviation of each physical block based on the second valid data parameter and the corresponding first valid data parameter of each physical block.
[0133] Specifically, in step 202, the data distribution deviation of the physical block is used to quantify the difference between the number of valid data frames of each physical block within the logical unit and the number of valid data frames of the logical unit as a whole. This calculation is based on the linkage analysis of the logical unit-level VDFC (the first valid data parameter) and the physical block-level VDFC_B (the second valid data parameter). When calculating the data distribution deviation, assuming that logical unit n contains N physical blocks, the data distribution deviation D(n,i) of the i-th physical block is defined as: D(n,i)=VDFC(n)_B(i)⋅N / VDFC(n)−1
[0134] Where VDFC(n) is the total number of valid data frames in logical unit n (the first valid data parameter); VDFC(n)_B(i) is the number of valid data frames in the i-th physical block within logical unit n (the second valid data parameter); and N is the total number of physical blocks within logical unit n. This formula reflects the degree of deviation between the number of valid data frames in a single physical block and the number of valid data frames in the physical blocks within the logical unit. When VDFC(n)_B(i) equals the number of valid data frames, D(n,i) = 0; greater deviations indicate higher D(n,i) values.
[0135] Step 203 : Aggregate the data distribution deviations of the physical blocks in the multiple logical units to generate a deviation characteristic parameter that characterizes the uniformity of the effective data distribution of the logical unit.
[0136] Specifically, in step 203, the data distribution deviation is summed and squared to obtain Aggregating the data distribution deviation can amplify the degree of data deviation. In order to make the aggregated parameters better represent the uniformity of effective data distribution, the deviation characteristic parameters representing the uniformity of effective data distribution of the logical unit are obtained by performing data operations on the aggregated parameters: .
[0137] Step 204 : Calculate the recycling priorities of the plurality of logic units respectively according to the deviation characteristic parameters.
[0138] Specifically, in step 204, the recycling priority of the logical unit is calculated by coupling its deviation characteristic parameter with the logical unit level valid data parameter. The recycling priority calculation formula is:
[0139] Where N represents the N physical blocks in superblock n, and the constant ; VDFC(n) is the total number of valid data frames in logical unit n (the first valid data parameter); VDFC(n) _B(i) is the number of valid data frames in the i-th physical block in logical unit n (the second valid data parameter). The above recycling priority formula is that the selected superblock is based on VDFC(n), and there are multiple physical blocks with smaller VDFC(n)_B(i) in the selected source block. (a) When VDFC(n)_B(i) is very even, then Closer to the distribution of existing solutions; (b) When the difference in VDFC(n)_B(i) is large, then It will be larger than (a) and have a higher priority.
[0140] Step 205: Based on the recycling priority, screen at least one target logical unit that needs to be garbage collected.
[0141] Specifically, in step 205, after the logical unit's reclamation priority is calculated and generated, the priority value is used to dynamically screen target logical units, prioritizing and triggering reclamation of superblocks (logical units). For example, a global priority threshold can be set, and logical units with a priority greater than the global threshold are included in the target candidate set. Such units contain significant "low-validity data blocks," and reclamation can effectively free up inactive space. The logical units in the candidate set are sorted in descending order to form a priority queue. The following strategy is used for screening: When the number of free physical blocks is detected to be below the watermark, logical units are selected from the head of the queue until the space reclamation requirement is met. The number of target logical units processed simultaneously is limited to avoid a sudden drop in storage performance due to large-scale reclamation.
[0142] Step 206 : Calculate a migration threshold for performing data migration on valid data based on the first valid data parameters of the plurality of logical units.
[0143] As a specific implementation method of this embodiment, "calculating the migration threshold for data migration of valid data based on the first valid data parameters of multiple logical units" can be implemented in the following manner, but is not limited to: using the first valid data parameters of multiple logical units to calculate the global average valid data parameter; calculating and generating the migration threshold based on the global average valid data parameter, the number of physical blocks in the target logical unit, and the first constant.
[0144] Specifically, in step 206, the global average valid data parameter (gloabl_avgVDFC) is the arithmetic mean of the first valid data parameter (VDFC) of all logical units in the storage system. The storage system's firmware periodically scans all logical units (e.g., every 10ms) and updates gloabl_avgVDFC in real time. When a logical unit's status changes (such as creation, deletion, or recycling), an incremental update of avgVDFC is triggered to ensure that the statistical results reflect the current system load. Based on the global average valid data parameter gloabl_avgVDFC, the number of physical blocks N in the target logical unit, and a first constant T, a migration threshold is generated: (gloabl_avgVDFC / N)*T.
[0145] Step 207: Create a first logical unit and a second logical unit based on the free logical units and the empty physical blocks.
[0146] As a specific implementation method of this embodiment, "creating a first logical unit and a second logical unit based on an idle logical unit and an empty physical block" can be implemented in the following manner, but is not limited to: selecting an idle logical unit from an idle resource pool and selecting an idle physical block from an idle physical block pool to generate a first logical unit; selecting an idle logical unit from an idle resource pool and selecting multiple idle physical blocks from an idle physical block pool to generate a second logical unit.
[0147] As a more specific implementation method, "selecting an idle logical unit from the idle resource pool and selecting an idle physical block from the idle physical block pool to generate a first logical unit" can be implemented in, but not limited to, the following methods: configuring the selected idle logical unit as a check block; establishing a mapping relationship between the check block and the idle logical unit to generate the first logical unit.
[0148] As a more specific implementation method, "selecting an idle logical unit from the idle resource pool and selecting multiple idle physical blocks from the idle physical block pool to generate a second logical unit" can be implemented in the following ways, but not limited to: selecting one physical block from the multiple idle physical blocks to be configured as a check block, and the multiple idle physical blocks come from different wafer dies; establishing a mapping relationship between the check block and the remaining idle physical blocks and the idle logical unit to generate a second logical unit.
[0149] Specifically, in step 207, the first logical unit (remapping superblock) is used to carry the remapping operation of the high-validity data block, requiring only a single parity block to support RAID parity updates. An unallocated logical unit (marked as "free") is selected from the free logical unit pool. A physical block is selected from the free physical block pool (blocks released after erasure) as the RAID parity block. The selected physical block is configured as a parity block, and its RAID parity function (such as the XOR calculation logic of RAID5) is initialized. A one-to-one mapping relationship is established between the logical unit and the parity block, forming the first logical unit (i.e., the remapping superblock). At this point, the logical unit only contains the parity block and has no associated data blocks.
[0150] The second logical unit (traditional recovery superblock) is used to carry out traditional recovery operations on low-validity data blocks and requires a full RAID stripe to support data migration. An unallocated logical unit is selected from the free logical unit pool. N physical blocks (N ≥ 2, corresponding to the number of data blocks in RAID 5) are selected from the free physical block pool. These physical blocks must come from different NAND dies (different blocks on each die) to leverage inter-die command concurrency (operations can be performed simultaneously on different dies). One of the N physical blocks is selected as a parity block, and the remaining N-1 blocks are selected as data blocks. A stripe is created using the RAID 5 structure (N-1 data blocks + 1 parity block). A mapping is established between the logical unit and the N physical blocks to form the second logical unit (the traditional recovery target unit). All physical blocks are initialized to an empty state.
[0151] Step 208 : Compare the second valid data parameter with the migration threshold to determine a data migration method for the valid data stored in the migration target physical block.
[0152] Step 209: Migrate the valid data stored in the target physical block to the first logical unit or the second logical unit according to the data migration method.
[0153] Specifically, in steps 208 to 209, Figure 3 As shown, based on the migration threshold calculated in step 206, the data migration method for the valid data stored in the target physical block is compared and determined. If the number of valid data frames in the target physical block is greater than the migration threshold, the target physical block is determined to be a high-validity data block (high percentage of valid data) and the remapping migration method is triggered. This corresponds to the data migration method shown on the left side of the figure. If the number of valid data frames in the target physical block is less than or equal to the migration threshold, the target physical block is determined to be a high-low-validity data block (low percentage of valid data) and the physical migration method is triggered. This corresponds to the data migration method shown on the right side of the figure.
[0154] Step 210 : After the valid data is migrated, it is determined whether the target physical block needs resource recycling based on the data migration mode of the valid data stored in the target physical block, and the target physical block that needs resource recycling is recycled.
[0155] As a specific implementation of this embodiment, before resource recycling is performed on the target physical block requiring resource recycling, in order to better realize resource recycling and utilization, resource recycling processing can be performed on the target logical unit, which can be implemented in but not limited to the following ways: releasing the mapping relationship between at least one target logical unit and each target physical block; and recycling the target logical unit whose mapping relationship has been released as an idle logical unit into the idle resource pool.
[0156] As a specific implementation method of this embodiment, "resource recovery for target physical blocks that require resource recovery" can be implemented in the following ways, but not limited to: erasing data on target physical blocks that require resource recovery; and recycling the physical blocks that have been subjected to data erasure as free physical blocks into the free physical block pool.
[0157] As a specific implementation method of this embodiment, "determining whether the target physical block needs resource recovery based on the data migration method of the valid data stored in the target physical block" includes: if the data migration method is mapping migration, determining that the target physical block does not need resource recovery; if the data migration method is physical migration, determining that the target physical block needs resource recovery.
[0158] Specifically, in step 210, after completing the migration of valid data, the storage system performs layered reclamation on the target logical units and physical blocks.
[0159] Target logical unit reclamation involves unmapping the logical unit (e.g., superblock A), which has completed data migration. The logical-to-physical address mapping table is traversed, all physical block mapping entries are deleted, and the RAID stripe association between the logical unit and the physical blocks is severed (all block mappings are removed). If the logical unit uses a RAID 5 structure, the XOR parity between the parity block and the data block is simultaneously cleared. Reclamation in the free resource pool marks the unmapped logical unit as "free" and places it in the free logical unit pool (superblock A is placed in the free superblock pool) for reuse by subsequent remapping or traditional reclamation tasks.
[0160] Target physical block reclamation involves determining whether a physical block needs to be reclaimed, based on the data migration method and the following rules. Mapping migration (remapping): If a physical block is migrated using remapping (i.e., VDFC_B > migration threshold), its valid data remains in the original physical block, with only the logical address mapped to a new logical unit (e.g., superblock B). The original physical block is marked as "retained" and does not need to be erased.
[0161] Physical Migration (Traditional Reclamation): If a physical block is migrated using traditional reclamation (i.e., VDFC_B ≤ the migration threshold), its valid data is migrated to a new physical block (such as superblock C). The original physical block becomes a "zero valid data block" and is marked as "erasable" (corresponding to step 7 of the document, "Write valid data to superblock C and then erase the original block"). For physical blocks identified as "erasable," a block erase command (BlockErase) is sent to the NAND controller to clear the stored charge and reset the status register, restoring the block to its factory-set writable state (the minimum NAND erase unit is a block). After erasure, the physical block is marked as "free" and placed in the free physical block pool, ready for subsequent data writing or RAID stripe creation.
[0162] It should be noted that the embodiments of the present disclosure may include multiple steps. For the convenience of description, these steps are numbered, but these numbers do not limit the execution time slots or execution order between the steps; these steps can be implemented in any order, and the embodiments of the present disclosure do not limit this.
[0163] Corresponding to the above-mentioned solid-state drive garbage collection method, the present disclosure also provides a solid-state drive garbage collection device. Since the device embodiment of the present disclosure corresponds to the above-mentioned method embodiment, any details not disclosed in the device embodiment can be referred to the above-mentioned method embodiment and will not be repeated in this disclosure.
[0164] Figure 4 A schematic diagram of a solid state drive garbage collection device provided by an embodiment of the present disclosure is shown in FIG. Figure 4 As shown, including:
[0165] An acquiring unit 31 is configured to acquire first valid data parameters of a plurality of logical units in a storage system and second valid data parameters of a physical block included in each logical unit;
[0166] a screening unit 32 configured to evaluate the distribution uniformity of valid data in the plurality of logical units based on the first valid data parameter and the second valid data parameter, and screen at least one target logical unit requiring garbage collection based on the distribution uniformity evaluation result;
[0167] A determining unit 33 is configured to determine a data migration mode for valid data stored in a target physical block in each target logical unit based on the second valid data parameter and perform data migration;
[0168] The recycling unit 34 is configured to determine whether the target physical block needs resource recycling according to the data migration mode of the valid data stored in the target physical block after the valid data is migrated, and to recycle the target physical block that needs resource recycling.
[0169] The present disclosure provides a device for garbage collection of solid-state hard disks. Compared with related technologies, the present disclosure can accurately locate logical units and physical blocks with uneven distribution of valid data through detailed evaluation of physical block-level parameters. It can give priority to triggering units with more urgent recycling needs, avoiding efficiency bottlenecks caused by "one-size-fits-all" recycling. Screening target logical units based on the distribution uniformity evaluation results can improve screening accuracy and improve garbage collection efficiency. By identifying logical units with "valid data concentrated in some physical blocks", invalid recycling of units with a lot of valid data but large differences in internal physical blocks can be avoided, reducing redundant operations. Reduce the amount of NAND writes to high-valid data blocks, and avoid write amplification caused by "writing all valid data to new blocks". Reduce unnecessary erase operations, and give priority to using NAND life for user writes rather than redundant writes generated by garbage collection. Combined with dynamic mapping, the recovered logical units can be reallocated as free blocks to improve storage resource utilization.
[0170] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the screening unit 32 includes:
[0171] A first calculation module 321 is configured to calculate a data distribution deviation of each physical block based on the second valid data parameter and the corresponding first valid data parameter of each physical block;
[0172] The first generating module 322 is configured to aggregate the data distribution deviations of the physical blocks in the multiple logical units to generate a deviation characteristic parameter representing the uniformity of the effective data distribution of the logical unit.
[0173] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the screening unit 32 includes:
[0174] A second calculation module 323 is used to calculate the recycling priorities of the plurality of logical units according to the deviation characteristic parameters;
[0175] The screening module 324 is configured to screen at least one target logical unit that needs to be garbage collected based on the collection priority.
[0176] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the solid state drive garbage collection device also includes:
[0177] The calculation unit 35 is used to calculate the migration threshold for data migration of valid data based on the first valid data parameters of multiple logical units before determining the data migration method of the valid data stored in the target physical block in each target logical unit based on the second valid data parameter and performing data migration.
[0178] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the calculation unit 35 includes:
[0179] A third calculation module 351 is configured to calculate a global average valid data parameter using the first valid data parameters of the plurality of logic units;
[0180] The fourth calculation module 352 is configured to calculate and generate a migration threshold according to the global average valid data parameter, the number of physical blocks in the target logical unit, and the first constant.
[0181] Furthermore, in a possible implementation of this embodiment, data migration methods include: mapping migration and physical migration.
[0182] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the determining unit 33 includes:
[0183] A first determining module 331 is configured to compare the second valid data parameter with the migration threshold to determine a data migration method for valid data stored in the migration target physical block;
[0184] The migration module 332 is configured to migrate the valid data stored in the target physical block to the first logical unit or the second logical unit according to the data migration method.
[0185] Furthermore, in a possible implementation of this embodiment, the first determining module 331 is further configured to:
[0186] If the second valid data parameter of the target physical block exceeds the migration threshold, determining that the data migration mode of the valid data stored in the target physical block is mapping migration;
[0187] If the second valid data parameter of the target physical block is less than or equal to the migration threshold, it is determined that the data migration mode of the valid data stored in the target physical block is physical migration.
[0188] Furthermore, in a possible implementation of this embodiment, the migration module 332 is further configured to:
[0189] If the data migration mode is mapping migration, the mapping relationship between the target physical block and the target logical unit is released, and the target physical block is mapped to the first logical unit;
[0190] If the data migration mode is physical migration, the valid data stored in the target physical block is read, and the valid data is written into the physical block of the second logical unit.
[0191] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the solid state drive garbage collection device also includes:
[0192] The creation unit 36 is used to create the first logical unit and the second logical unit based on the free logical unit and the empty physical block before determining the data migration method of the valid data stored in the target physical block in each target logical unit based on the second valid data parameter and performing data migration.
[0193] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the creation unit 36 includes:
[0194] The second generating module 361 is configured to select an idle logical unit from the idle resource pool and an idle physical block from the idle physical block pool to generate a first logical unit;
[0195] The third generating module 362 is configured to select an idle logical unit from the idle resource pool and select multiple idle physical blocks from the idle physical block pool to generate a second logical unit.
[0196] Furthermore, in a possible implementation of this embodiment, the second generating module 361 is further configured to:
[0197] Configure a selected idle logical unit as a check block;
[0198] A mapping relationship between the check block and the idle logical unit is established to generate a first logical unit.
[0199] Furthermore, in a possible implementation of this embodiment, the third generating module 362 is further configured to:
[0200] Selecting one of a plurality of idle physical blocks to be configured as a check block, wherein the plurality of idle physical blocks come from different wafer dies;
[0201] A mapping relationship is established between the check block and the remaining free physical blocks and the free logical unit to generate a second logical unit.
[0202] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the solid state drive garbage collection device also includes:
[0203] The release unit 37 is used to release the mapping relationship between at least one target logical unit and each target physical block before recycling the target physical block that needs resource recycling; and recycle the target logical unit whose mapping relationship is released as an idle logical unit into the idle resource pool.
[0204] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the recovery unit 34 also includes:
[0205] The second determining module 341 is configured to determine that the target physical block does not need to be reclaimed if the data migration mode is mapping migration;
[0206] The third determining module 342 is configured to determine whether the target physical block needs to be reclaimed if the data migration mode is physical migration.
[0207] Furthermore, in a possible implementation of this embodiment, as Figure 5 As shown, the recovery unit 34 also includes:
[0208] An erasing module 343 is used to erase data on a target physical block that requires resource recovery;
[0209] The recycling module 344 is configured to recycle the physical blocks that have undergone data erasure processing as free physical blocks into a free physical block pool.
[0210] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and the principles are the same, which is not limited in this embodiment.
[0211] For the description of the features in the embodiments corresponding to the apparatus for solid-state hard disk garbage collection, reference may be made to the relevant description of the embodiments corresponding to the method for solid-state hard disk garbage collection, which will not be repeated here.
[0212] An embodiment of the present application further provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps of any of the above-mentioned solid-state drive garbage collection method embodiments.
[0213] An embodiment of the present application further provides a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps of any of the above-mentioned solid-state drive garbage collection method embodiments when running.
[0214] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0215] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned solid-state hard drive garbage collection method embodiments are implemented.
[0216] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of any of the above-mentioned solid-state hard drive garbage collection method embodiments.
[0217] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0218] The above is a detailed introduction to a solid-state hard disk garbage recovery method and device, electronic device and storage medium provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A method for garbage collection of a solid state drive, characterized in that: include: Acquire first valid data parameters of a plurality of logical units in a storage system and second valid data parameters of physical blocks included in each logical unit; Based on the first valid data parameter and the second valid data parameter, evaluating the distribution uniformity of valid data in the multiple logical units, including: calculating the data distribution deviation of each physical block based on the second valid data parameter and the corresponding first valid data parameter of each physical block; aggregating the data distribution deviations of the physical blocks in the multiple logical units to generate a deviation characteristic parameter representing the distribution uniformity of valid data in the logical unit; and selecting at least one target logical unit that requires garbage collection based on the distribution uniformity evaluation result; Based on the second valid data parameter, determining a data migration method for valid data stored in a target physical block in each target logical unit and performing data migration; After the valid data is migrated, whether the target physical block needs resource recycling is determined based on the data migration mode of the valid data stored in the target physical block, and resource recycling is performed on the target physical block that needs resource recycling.
2. The solid state drive garbage collection method according to claim 1, wherein: The step of screening at least one target logical unit requiring garbage collection based on the distribution uniformity evaluation result includes: Calculating the recycling priorities of the plurality of logical units respectively according to the deviation characteristic parameters; Based on the recycling priority, the at least one target logical unit requiring garbage collection is screened.
3. The solid state drive garbage collection method according to claim 1, wherein: Before determining a data migration mode for valid data stored in a target physical block in each target logical unit based on the second valid data parameter and performing data migration, the method further includes: A migration threshold for performing data migration on valid data is calculated based on the first valid data parameters of the plurality of logical units.
4. The solid state drive garbage collection method according to claim 3, wherein: The calculating, based on the first valid data parameters of the plurality of logical units, a migration threshold for performing data migration on valid data includes: calculating a global average valid data parameter using the first valid data parameters of the plurality of logic units; The migration threshold is calculated and generated according to the global average valid data parameter, the number of physical blocks in the target logical unit, and a first constant.
5. The solid state drive garbage collection method according to claim 1, wherein: The data migration methods include: mapping migration and physical migration.
6. The solid state drive garbage collection method according to claim 5, characterized in that: The determining, based on the second valid data parameter, a data migration method of valid data stored in a target physical block in each target logical unit and performing data migration includes: Comparing the second valid data parameter with a migration threshold to determine a data migration method for migrating the valid data stored in the target physical block; According to the data migration method, the valid data stored in the target physical block is migrated to the first logical unit or the second logical unit.
7. The solid state drive garbage collection method according to claim 6, wherein: The comparing the second valid data parameter with the migration threshold to determine a data migration method for migrating the valid data stored in the target physical block includes: If the second valid data parameter of the target physical block exceeds the migration threshold, determining that the data migration mode of the valid data stored in the target physical block is mapping migration; If the second valid data parameter of the target physical block is less than or equal to the migration threshold, it is determined that the data migration mode of the valid data stored in the target physical block is physical migration.
8. The solid state drive garbage collection method according to claim 7, wherein: Migrating the valid data stored in the target physical block to the first logical unit or the second logical unit according to the data migration method includes: If the data migration mode is mapping migration, the mapping relationship between the target physical block and the target logical unit is released, and the target physical block is mapped to the first logical unit; If the data migration mode is physical migration, the valid data stored in the target physical block is read, and the valid data is written into the physical block of the second logical unit.
9. The solid state drive garbage collection method according to claim 1, wherein: Before determining a data migration mode for valid data stored in a target physical block in each target logical unit based on the second valid data parameter and performing data migration, the method further includes: A first logical unit and a second logical unit are created based on a free logical unit and an empty physical block.
10. The solid state drive garbage collection method according to claim 9, characterized in that: The step of creating the first logical unit and the second logical unit based on the free logical unit and the empty physical block includes: Selecting an idle logical unit from an idle resource pool and selecting an idle physical block from an idle physical block pool to generate the first logical unit; An idle logical unit is selected from the idle resource pool and multiple idle physical blocks are selected from the idle physical block pool to generate the second logical unit.
11. The solid state drive garbage collection method according to claim 10, characterized in that: The step of selecting an idle logical unit from an idle resource pool and selecting an idle physical block from an idle physical block pool to generate the first logical unit includes: configuring the selected one idle logical unit as a check block; A mapping relationship between the check block and the idle logical unit is established to generate the first logical unit.
12. The solid state drive garbage collection method according to claim 10, wherein: The step of selecting an idle logical unit from the idle resource pool and selecting multiple idle physical blocks from the idle physical block pool to generate the second logical unit includes: Selecting one of the plurality of idle physical blocks to be configured as a check block, wherein the plurality of idle physical blocks come from different wafer dies; A mapping relationship is established between the check block and the remaining free physical blocks and the free logical unit to generate the second logical unit.
13. The solid state drive garbage collection method according to claim 1, wherein: Before performing resource recycling on the target physical block requiring resource recycling, the method further includes: Release the mapping relationship between the at least one target logical unit and each target physical block; The target logical unit whose mapping relationship is released is recycled as an idle logical unit into the idle resource pool.
14. The solid state drive garbage collection method according to claim 1, wherein: The determining whether the target physical block needs resource recovery based on the data migration mode of the valid data stored in the target physical block includes: If the data migration mode is mapping migration, determining that the target physical block does not need to be reclaimed; If the data migration mode is physical migration, it is determined that the target physical block needs to be reclaimed.
15. The solid state drive garbage collection method according to claim 14, wherein: The resource recycling of the target physical block requiring resource recycling includes: Erasing data on target physical blocks that require resource recovery; The physical blocks after data erasure are recycled as free physical blocks into the free physical block pool.
16. A solid state hard disk garbage collection device, characterized in that: include: An acquiring unit, configured to acquire first valid data parameters of a plurality of logical units in a storage system and second valid data parameters of physical blocks included in each logical unit; a screening unit configured to evaluate the distribution uniformity of valid data in the plurality of logical units based on the first valid data parameter and the second valid data parameter, including: calculating a data distribution deviation of each physical block based on the second valid data parameter and the corresponding first valid data parameter of each physical block; aggregating the data distribution deviations of the physical blocks in the plurality of logical units to generate a deviation characteristic parameter representing the distribution uniformity of valid data in the logical unit; and screening at least one target logical unit requiring garbage collection based on the distribution uniformity evaluation result; a determining unit, configured to determine, based on the second valid data parameter, a data migration mode for valid data stored in a target physical block in each target logical unit and perform data migration; The recycling unit is used to determine whether the target physical block needs resource recycling according to the data migration mode of the valid data stored in the target physical block after the valid data is migrated, and to recycle the target physical block that needs resource recycling.
17. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the solid state drive garbage collection method according to any one of claims 1 to 15.
18. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the solid-state drive garbage collection method according to any one of claims 1 to 15.
19. A computer program product, characterized in that The invention comprises a computer program, which implements the solid state drive garbage collection method according to any one of claims 1 to 15 when executed by a processor.
Citation Information
Patent Citations
Method and device for selecting garbage collection block
CN106339324A
Intelligent garbage collection method and device compatible with NVMe solid state disk
CN112463057A