SSD garbage collection method and device with RAID redundancy and medium
By selecting a single NAND flash physical block for data copying and RAID block reassembly in a RAID redundant SSD, the write amplification problem is solved, improving the performance and lifespan of the SSD.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 成都芯忆联信息技术有限公司
- Filing Date
- 2026-01-22
- Publication Date
- 2026-04-21
AI Technical Summary
In existing SSDs employing RAID redundancy, write amplification occurs during garbage collection due to data imbalance within RAID blocks, impacting performance and lifespan.
By selecting individual NAND flash physical blocks that meet preset conditions during the garbage collection process, copying data and updating mapping relationships, recombining RAID blocks, and recalculating parity data, write amplification is reduced.
It reduces write amplification, decreases wear on the NAND flash memory medium, extends the lifespan of the SSD, and improves performance.
Smart Images

Figure CN121900700A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of waste recycling technology, and in particular to a method, device and medium for SSD waste recycling with RAID redundancy. Background Technology
[0002] Solid-state drives (SSDs) use NAND flash memory as their storage medium. Their write characteristics require data to be erased before being written, and in-situ updates are not possible. Therefore, SSDs typically have a flash translation layer (FTL) to maintain a dynamic mapping between host logical addresses and flash physical addresses. When the host repeatedly writes to the same logical address, the FTL writes the new data to a new physical page, invalidating the data in the original page. These invalidated pages must undergo garbage collection (GC) to be reused. This process involves moving the remaining valid data in the block to another location before erasing the entire block. This additional data movement causes write amplification, which in turn affects SSD performance and lifespan.
[0003] Furthermore, to improve data reliability, especially in enterprise-grade SSDs using high-density flash memory, RAID (Redundant Array of Independent Disks) redundancy protection mechanisms are often introduced. This mechanism combines data pages and parity pages distributed across multiple flash memory cells into RAID stripes, and then aggregates several stripes into a RAID block. Under this architecture, to ensure the integrity and recoverability of the parity information and the corresponding data, a fixed binding relationship is formed between the physical flash memory blocks within a RAID block. Traditional garbage collection strategies are forced to use the entire RAID block as the smallest unit of collection. However, in practical applications, the distribution of effective data among the physical blocks within a RAID block is often extremely uneven. When collecting data on a block-by-block basis, even if some physical blocks have very little effective data, all effective data in all physical blocks within that RAID block needs to be moved, resulting in a large number of unnecessary write operations. This significantly increases write amplification and reduces garbage collection efficiency. Summary of the Invention
[0004] This invention provides a method, device, and medium for SSD garbage collection with RAID redundancy. The technical problem it aims to solve is: how to provide an effective solution that can achieve finer-grained garbage collection while maintaining RAID data protection capabilities, so as to reduce write amplification and improve the performance and lifespan of solid-state drives.
[0005] In a first aspect, embodiments of the present invention provide an SSD garbage collection method with RAID redundancy, wherein the solid-state drive employs a RAID redundancy mechanism to protect data, and multiple NAND flash memory physical blocks form a RAID block; the method includes: During the garbage collection process, a target NAND flash physical block that meets the preset recycling conditions is selected from all NAND flash physical blocks of the solid-state drive; the valid data in the target NAND flash physical block is copied to a new physical location, and the mapping relationship between logical address and physical address is updated; The first mapping table is used to query the first RAID block to which the target NAND flash physical block belongs, wherein the first mapping table is used to record the mapping from NAND flash physical block identifier to RAID block identifier; According to the preset second mapping table, query all NAND flash physical block identifiers that constitute the first RAID block. The second mapping table is used to record the mapping from RAID block identifiers to the set of NAND flash physical block identifiers. The remaining NAND flash physical blocks that constitute the first RAID block, excluding the target NAND flash physical block, are combined into a second RAID block; Recalculate and store the parity data for the second RAID block; Update the first mapping table and the second mapping table to reflect the composition information of the second RAID block; Erase the target NAND flash physical block.
[0006] Optionally, in the garbage collection process, selecting target NAND flash memory blocks from all NAND flash memory blocks of the solid-state drive that meet preset recycling conditions includes: Count the number of valid data pages contained in each NAND flash physical block of a solid-state drive; Based on the statistical results, all NAND flash physical blocks are sorted in ascending order of the number of valid data pages; From the sorted sequence, one or more NAND flash physical blocks are selected as the target NAND flash physical blocks in order of increasing number of valid data pages.
[0007] Optionally, combining the remaining NAND flash physical blocks that constitute the first RAID block, excluding the target NAND flash physical block, into a second RAID block includes: Obtain at least one free NAND flash physical block from the free NAND flash physical block resource pool of the solid-state drive; The remaining NAND flash physical blocks are associated with the at least one free NAND flash physical block to form the second RAID block.
[0008] Optionally, the step of querying the first RAID block to which the target NAND flash physical block belongs according to a preset first mapping table includes: The identifier of the target NAND flash physical block is used as the query key value to search in the first mapping table. The first mapping table stores multiple key-value pairs. The key in each key-value pair is an identifier of a NAND flash physical block, and the corresponding value is the identifier of the RAID block to which the NAND flash physical block currently belongs. Obtain the RAID block identifier corresponding to the key-value pair that matches the query key-value pair, and use it as the identifier of the first RAID block.
[0009] Optionally, the step of querying all NAND flash physical block identifiers constituting the first RAID block according to a preset second mapping table includes: Using the identifier of the first RAID block as the query key, a search is performed in the second mapping table. The second mapping table stores multiple key-value pairs. The key in each key-value pair is a RAID block identifier, and the corresponding value is a list. The list records the identifiers of all NAND flash physical blocks that constitute the RAID block in order. Obtain the list of key-value pairs that match the query key-value pair, which will serve as the set of NAND flash physical block identifiers constituting the first RAID block.
[0010] Optionally, the step of recalculating and storing the parity data for the second RAID block includes: Read data from all physical pages within the second RAID block used for storing user data; Perform a bitwise XOR operation on all the read user data to generate a verification data page; The verification data page is written into a physical page, which serves as the verification page for the second RAID block.
[0011] Optionally, the RAID redundancy mechanism is the RAID 5 mechanism.
[0012] Optionally, the method further includes: maintaining the first mapping table and the second mapping table during non-garbage collection operations, the maintenance including: in response to bad block management operations or wear leveling operations performed by the solid-state drive, when a NAND flash physical block is replaced or data is migrated, identifying the affected RAID block; updating the set of NAND flash physical block identifiers corresponding to the affected RAID block in the second mapping table; and synchronously updating the mapping entries in the first mapping table associated with the replaced or migrated NAND flash physical block.
[0013] Secondly, 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] Thirdly, 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, device, and medium for SSD garbage collection with RAID redundancy. The method includes: during garbage collection, selecting a target NAND flash memory physical block from all NAND flash memory physical blocks of the solid-state drive (SSD) whose effective data volume meets preset collection conditions; copying the effective data in the target NAND flash memory physical block to a new physical location and updating the mapping relationship between logical addresses and physical addresses; querying the first RAID block to which the target NAND flash memory physical block belongs according to a preset first mapping table, wherein the first mapping table records the mapping from NAND flash memory physical block identifiers to RAID block identifiers; querying all NAND flash memory physical block identifiers constituting the first RAID block according to a preset second mapping table, wherein the second mapping table records the mapping from RAID block identifiers to a set of NAND flash memory physical block identifiers; combining the remaining NAND flash memory physical blocks constituting the first RAID block (excluding the target NAND flash memory physical block) into a second RAID block; recalculating and storing the parity data for the second RAID block; updating the first and second mapping tables to reflect the composition information of the second RAID block; and erasing the target NAND flash memory physical block. By introducing and maintaining a mapping structure that records the dynamic relationship between physical blocks and logical protection groups, garbage collection is performed using individual NAND flash physical blocks as the smallest unit of operation, replacing the traditional method of collecting entire RAID blocks. Furthermore, this design allows the storage controller to prioritize and collect physical blocks with the least amount of valid data, significantly reducing the amount of valid data that needs to be moved in each collection operation. This reduction in valid data migration directly reduces additional write operations caused by garbage collection, i.e., lowering the write amplification factor. Furthermore, the reduced write amplification factor not only reduces write wear on the NAND flash media, helping to extend the lifespan of the solid-state drive (SSD), but also allows more resources to be used to handle host I / O requests, thus improving the overall performance of the SSD, as the bandwidth and time consumed by the collection process itself are reduced. Finally, in achieving fine-grained collection, this method maintains the data recovery capability of the RAID redundancy protection mechanism by dynamically reorganizing the remaining physical blocks and recalculating the parity data, ensuring that data reliability is not affected. 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 method with RAID redundancy provided in 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 garbage collection method for SSDs with RAID redundancy. The solid-state drive uses a RAID redundancy mechanism to protect data, wherein multiple NAND flash memory physical blocks form a RAID block. The method includes the following steps: S1, During the garbage collection process, select a target NAND flash physical block from all NAND flash physical blocks of the solid-state drive whose effective data volume meets the preset collection conditions; copy the effective data in the target NAND flash physical block to a new physical location, and update the mapping relationship between logical address and physical address.
[0024] In practice, during garbage collection, the SSD controller traverses all NAND flash memory physical blocks, evaluating the number of valid data pages within each block. Based on preset collection conditions, such as setting a threshold for the number of valid pages, or directly searching for the block with the fewest valid pages, the controller selects the target NAND flash memory physical block. Once selected, the controller reads and writes the data from all the physical pages marked as valid within that target NAND flash memory physical block into newly allocated, erased physical pages. After data copying is complete, the controller updates the logical address to physical address mapping table, i.e., the FTL table or L2P table, pointing the relevant logical addresses to the addresses of these newly written physical pages.
[0025] In some preferred embodiments, the step of selecting target NAND flash memory physical blocks that meet preset recycling conditions from all NAND flash memory physical blocks of the solid-state drive during the garbage collection process includes: counting the number of valid data pages contained in each NAND flash memory physical block of the solid-state drive; sorting all NAND flash memory physical blocks in ascending order of the number of valid data pages based on the statistical results; and selecting one or more NAND flash memory physical blocks as the target NAND flash memory physical blocks from the sorted sequence in ascending order of the number of valid data pages.
[0026] In practice, the step of counting the number of valid data pages within each NAND flash memory physical block can be achieved by traversing the metadata area of the solid-state drive or maintaining a dedicated block status table. The controller maintains a counter for each NAND flash memory physical block, updating this counter whenever a page within that block becomes invalid due to a host overwrite, or is selected as a target for garbage collection and has valid data evicted during this embodiment. During garbage collection selection, the controller reads these counter values for all NAND flash memory physical blocks.
[0027] When sorting based on statistical results, the controller loads the identifiers of all NAND flash physical blocks and their corresponding effective page count values into memory. In memory, using a sorting algorithm, such as quicksort or heapsort, all physical block identifiers are arranged into an ordered sequence according to the key indicator of the effective page count, with the sequence order from the fewest to the most effective page counts.
[0028] When selecting from the sorted sequence, the controller sets a selection strategy. This strategy can be to consistently select the single physical block at the very front of the sequence, or to dynamically determine the selection of multiple consecutive physical blocks from the front based on the current garbage collection pressure or the level of the free block pool. The identifiers of the selected one or more NAND flash physical blocks are then identified as the target NAND flash physical blocks, for which subsequent data migration and block erasure operations will be performed.
[0029] This embodiment uses the number of valid data pages as the core indicator for sorting and selection, and prioritizes the physical blocks with the fewest number, thereby systematically minimizing the amount of valid data migration that must be triggered for each garbage collection operation.
[0030] S2, query the first RAID block to which the target NAND flash physical block belongs according to the preset first mapping table, wherein the first mapping table is used to record the mapping from NAND flash physical block identifier to RAID block identifier.
[0031] In practice, the controller queries the first mapping table. This first mapping table, typically existing in memory as a table or hash table, records the correspondence between each NAND flash physical block identifier and a RAID block identifier. The controller uses the identifier of the target NAND flash physical block as an index or key to search the first mapping table and retrieve the identifier of the first RAID block to which the physical block currently belongs.
[0032] For example, in some preferred embodiments, the step of querying the first RAID block to which the target NAND flash physical block belongs according to a preset first mapping table includes: using the identifier of the target NAND flash physical block as the query key value, searching in the first mapping table, wherein the first mapping table stores multiple key-value pairs, where the key in each key-value pair is a NAND flash physical block identifier, and the corresponding value is the RAID block identifier to which the NAND flash physical block currently belongs; obtaining the RAID block identifier corresponding to the key-value pair that matches the query key value, and using it as the identifier of the first RAID block.
[0033] In practice, during the step of retrieving data from the first mapping table using the identifier of the target NAND flash physical block as the query key, the controller takes the target block's identifier, such as a globally unique numeric number or address encoding, as input. The first mapping table may be stored as a hash table; in this case, the controller calculates the bucket address corresponding to the key value using a hash function and searches for an exact matching key-value pair in the linked list of that bucket. If it is represented as an ordered array or a B-tree, the retrieval can be performed using algorithms such as binary search.
[0034] Furthermore, each key-value pair stored in the first mapping table has a well-defined structure. The key is the NAND flash physical block identifier, typically an integer. The value is the RAID block identifier to which the physical block currently belongs, which can also be an integer or a string. This mapping table covers all NAND flash physical blocks in the solid-state drive that are in use (i.e., not idle).
[0035] Furthermore, the step of obtaining the RAID block identifier corresponding to the matching key-value pair refers to the controller reading the value stored in that entry, i.e., the RAID block identifier, after successfully retrieving an entry whose key matches the query key-value pair. This identifier is the unique identifier of the first RAID block to which the target physical block logically belongs before the garbage collection operation, and subsequent processes will perform related operations based on this identifier.
[0036] This embodiment provides a precise and efficient addressing mechanism for achieving dynamic decoupling between physical blocks and RAID blocks by specifying the structure and query method of the first mapping table. It establishes a reverse query path, enabling the controller to quickly locate the logical protection group where any physical block to be reclaimed is located.
[0037] S3, query all NAND flash physical block identifiers that constitute the first RAID block according to the preset second mapping table. The second mapping table is used to record the mapping from RAID block identifiers to the set of NAND flash physical block identifiers.
[0038] In practice, the controller queries the second mapping table. The second mapping table records the correspondence between each RAID block identifier and a list of NAND flash physical block identifiers, which defines all the member physical blocks constituting the RAID block. The controller uses the newly obtained first RAID block identifier as an index to search the second mapping table and retrieve the list of identifiers for all NAND flash physical blocks constituting the first RAID block.
[0039] In some preferred embodiments, the step of querying all NAND flash memory physical block identifiers constituting the first RAID block according to a preset second mapping table includes: using the identifier of the first RAID block as the query key value, searching in the second mapping table, wherein the second mapping table stores multiple key-value pairs, where the key in each key-value pair is a RAID block identifier and the corresponding value is a list, the list recording in order the identifiers of all NAND flash memory physical blocks constituting the RAID block; obtaining the list corresponding to the key-value pairs matching the query key value, as the set of NAND flash memory physical block identifiers constituting the first RAID block.
[0040] In practice, the controller uses the obtained first RAID block identifier as the key to access the second mapping table. The second mapping table can also use data structures such as hash tables and B-trees to achieve efficient lookups.
[0041] Furthermore, the structure of each key-value pair in the second mapping table is as follows: the key is the RAID block identifier; the value is a list data structure. This list, such as an array or linked list, sequentially records the identifiers of all NAND flash physical blocks currently constituting this RAID block. The order of the list may correspond to the order of data distribution within the RAID stripes.
[0042] Furthermore, the step of obtaining the list corresponding to the matching key-value pairs refers to the controller reading the list stored in that entry after retrieving the corresponding entry. This list contains the complete set of physical members constituting the first RAID block at the time the garbage collection operation is initiated. By parsing this list, the controller can clearly determine which physical blocks, besides the target reclaimed block, belong to the original RAID group. This information is necessary input for performing subsequent physical block reassembly operations.
[0043] This embodiment provides a positive, grouped view for dynamic member management of RAID blocks by specifying the structure and query method of the second mapping table, enabling the controller to efficiently obtain the complete physical composition of any RAID protection group.
[0044] S4, combine the remaining NAND flash physical blocks that constitute the first RAID block, excluding the target NAND flash physical block, into a second RAID block.
[0045] In practice, the controller identifies the remaining NAND flash physical blocks, excluding the target block, based on the list obtained from the second mapping table. These physical blocks are then used as the basis for recombination into a logical second RAID block. This recombination process is completed at the logical level, meaning that these physical blocks are marked as belonging to the same new RAID group.
[0046] In some preferred embodiments, combining the remaining NAND flash physical blocks that constitute the first RAID block, excluding the target NAND flash physical block, into a second RAID block includes: obtaining at least one free NAND flash physical block from the free NAND flash physical block resource pool of the solid-state drive; associating the remaining NAND flash physical blocks with the at least one free NAND flash physical block to jointly constitute the second RAID block.
[0047] In practice, the solid-state drive controller maintains a list of all physical blocks that are in an erased state and not mapped to any RAID block, i.e., a free block resource pool. When a second RAID block needs to be combined, the controller selects the identifiers of one or more free blocks from the head of this resource pool or according to a specific policy.
[0048] Furthermore, the controller creates a new data structure, such as a list or bitmap, containing the identifiers of the remaining physical blocks from the original first RAID block, as well as the identifiers of newly acquired free physical blocks. This data structure logically represents the physical composition of the newly formed second RAID block. This association does not immediately change the data on the physical blocks, but rather lays the foundation for subsequent recalculation of parity data and updates to the mapping table.
[0049] This embodiment addresses the issue of insufficient member count in existing RAID blocks due to member block reclamation by introducing idle NAND flash physical blocks into the combination of new RAID blocks, ensuring the integrity and maintainability of the RAID redundancy structure. By instantly replenishing idle physical blocks, a new RAID group with full protection capabilities can be quickly reconstructed, allowing the RAID protection mechanism to seamlessly adapt to reclamation operations on a physical block basis. This guarantees the continuity of data redundancy protection and avoids the risk of data protection level degradation or temporary failure due to reclamation operations.
[0050] S5, recalculate the parity data for the second RAID block and store it.
[0051] In practice, the controller calculates new parity data for the second RAID block of this new combination. It reads the contents of all physical pages storing user data within the second RAID block, and generates new parity information according to the RAID algorithm, such as performing an XOR operation on the data. The generated parity data is written to a dedicated physical page, which serves as the parity page for the second RAID block.
[0052] In some preferred embodiments, the step of recalculating and storing the parity data for the second RAID block includes: reading data from all physical pages used for storing user data within the second RAID block; performing a bitwise XOR operation on all the read user data to generate a parity data page; and writing the parity data page into a physical page, which serves as the parity page for the second RAID block.
[0053] In practice, the step of reading data from all physical pages within the second RAID block used for storing user data requires the controller to traverse all member NAND flash memory physical blocks according to the logical definition of the second RAID block. Further, for each physical block, the controller identifies the physical pages storing user data, excluding any metadata pages or previously stored parity pages. The controller then reads data sequentially or in parallel from the flash memory chips containing these user data pages into its internal buffer or memory.
[0054] Furthermore, the step of performing a bitwise XOR operation on all the read user data is typically executed in the controller's processor or dedicated hardware acceleration circuitry. The operation can be performed sequentially: first, XOR the data from the first two pages to obtain an intermediate result, then XOR this intermediate result with the data from the next page, and so on, iterating until all user data pages are involved in the operation. Alternatively, a tree-structured or other parallel computing method can be used to improve speed. The final generated data block, with a length equal to a physical page, is the newly calculated checksum data page.
[0055] Furthermore, the step of writing the parity data page to a physical page involves the controller allocating a dedicated physical page for storing the parity data to the new RAID block. This page is typically located on a member physical block, and its specific location may be determined by the RAID striping algorithm. The controller then programs the generated parity data page into this designated physical page via the flash interface protocol, completing the storage of the parity information.
[0056] This embodiment describes the recalculation and storage process of verification data in detail, ensuring the real-time reconstruction of data redundancy protection capabilities after dynamic RAID reconfiguration. When the logical RAID group structure changes, its corresponding physical verification information is updated synchronously, thus enabling the new RAID group to have complete data error recovery capabilities. When the original RAID blocks are dismantled due to the reclamation of some physical blocks, and the remaining physical blocks are combined with newly added free blocks to form a new second RAID block, the original verification data, based on the old membership relationships and data layout, is no longer applicable to the new combination. By recalculating the verification value based on the current actual members and the latest user data on them, a completely new and correct redundancy relationship can be established for the new group. This process ensures that even if a single member physical block in the new group fails, the lost information can still be recovered using the data of other members and the newly calculated verification data.
[0057] S6, update the first mapping table and the second mapping table to reflect the composition information of the second RAID block.
[0058] In practice, after writing the verification data, the controller must update the first and second mapping tables to maintain consistency. In the second mapping table, a new entry is created with the new second RAID block identifier as the key and a list of all NAND flash physical block identifiers constituting the second RAID block as the value. Simultaneously, in the first mapping table, the mapping entries for these member physical blocks are updated, modifying their associated RAID block identifiers to the new second RAID block identifier. The existing first RAID block identifier and its associated mapping entries can be marked as invalid or deleted.
[0059] S7, erase the target NAND flash physical block.
[0060] In practice, after ensuring that all valid data has been migrated out and the mapping relationship has been updated, the controller sends an erase command to the chip where the target NAND flash physical block is located, resetting all storage cells in the physical block to a writable state and completing the recycling.
[0061] This embodiment dynamically manages the composition relationship between NAND flash physical blocks and RAID blocks by introducing and maintaining a first mapping table and a second mapping table. This allows garbage collection to be performed on a single NAND flash physical block as the smallest unit of operation, rather than the entire RAID block as in traditional methods. Furthermore, this mechanism allows the SSD controller to prioritize the physical blocks with the least amount of valid data for recycling. Since the amount of valid data to be moved in each recycling operation is limited to the selected few physical blocks, rather than all the valid data in the original RAID block, the amount of additional data written due to garbage collection is significantly reduced. This reduction in additional writes directly translates to a decrease in write amplification. A lower write amplification means less actual wear and tear on the NAND flash media under the same host write load, which helps extend the lifespan of the SSD. Furthermore, the bandwidth and time resources consumed by the garbage collection process itself are also reduced, allowing more storage channel bandwidth and controller resources to be used to handle host I / O requests, thereby improving the overall performance of the SSD. Furthermore, while achieving fine-grained recycling, this method fully maintains the data recovery capability of the RAID redundancy protection mechanism by recombining the remaining physical blocks and calculating new verification data, ensuring that the reliability required for enterprise-level storage is not compromised by the optimization of the recycling strategy.
[0062] In some preferred embodiments, the RAID redundancy mechanism is the RAID 5 mechanism, but this invention is not specifically limited to this.
[0063] In practice, each RAID block is logically divided into multiple stripes. Each stripe is a basic unit for data distribution and parity calculation. Within a stripe, user data is divided into several data blocks, each typically aligned to the size of a physical page, such as 4KB. These data blocks are stored separately on different NAND flash memory physical blocks contained within the RAID block, with each physical block carrying one data block or parity block for that stripe.
[0064] Each stripe contains a parity data page, which is generated by XORing the data from all user data pages within that stripe. The parity data page is cyclically distributed across different NAND flash physical blocks in different stripes. This is a typical feature of RAID 5, designed to avoid storing parity information concentrated in a single physical block, which could become a performance bottleneck or a single point of failure. For example, in a RAID group with N physical blocks, the parity information for the i-th stripe might be stored on the (i mod N)-th physical block.
[0065] When managing data and performing read / write operations, the solid-state drive controller needs to determine the specific physical location of the user data page and its corresponding checksum page based on this striping rule, and calculate or update the checksum information in real time when writing data.
[0066] In some preferred embodiments, the method further includes: maintaining the first mapping table and the second mapping table during non-garbage collection operations, the maintenance including: in response to bad block management operations or wear leveling operations performed by the solid-state drive, when a NAND flash physical block is replaced or data is migrated, identifying the affected RAID block; updating the set of NAND flash physical block identifiers corresponding to the affected RAID block in the second mapping table; and synchronously updating the mapping entries in the first mapping table associated with the replaced or migrated NAND flash physical block.
[0067] In practice, during non-garbage collection operations, the first and second mapping tables are maintained. This requires the SSD controller firmware to synchronously maintain the mapping information while executing business processes. When performing bad block management operations, if the controller detects that a NAND flash physical block is unreliable or has failed, it will trigger a bad block replacement process. At this time, the controller needs to determine which RAID block the bad block currently belongs to, which is done by querying the first mapping table. After identifying the affected RAID block, the controller allocates a good block from the free pool to replace the bad block and copies the valid data from the bad block (obtained by querying the FTL, etc.) to the new block.
[0068] Furthermore, when updating the set of NAND flash physical block identifiers corresponding to the affected RAID block in the second mapping table, the controller finds the entry for the RAID block in the second mapping table and replaces the bad block identifier in its list with the newly assigned good block identifier.
[0069] Furthermore, when synchronously updating the mapping entries in the first mapping table associated with the replaced or migrated NAND flash physical blocks, for replaced bad blocks, the controller marks their entries as invalid or deletes them in the first mapping table. For newly replaced good blocks, the controller adds a new entry to the first mapping table, with the good block identifier as the key and the RAID block identifier as the value. The mapping table update logic for data migration caused by wear leveling operations is similar: first, the RAID block to which the source block belongs is determined; after migrating the data to the target block, the RAID block member list is updated in the second mapping table, and the mapping relationship between the source block and the target block is updated in the first mapping table.
[0070] This embodiment extends the mapping table maintenance mechanism to all data lifecycle management operations, ensuring metadata consistency across the entire storage system. This makes the first and second mapping tables authoritative sources reflecting the real-time relationship between the physical structure of the SSD and its logical protection groups. Whether it's garbage collection, bad block replacement, or wear leveling, any operation that changes the logical ownership of physical blocks or the RAID block membership structure will atomically update these two mapping tables. This global consistency maintenance is crucial, preventing mapping state inconsistencies or obsolescence caused by asynchronous management operations.
[0071] 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.
[0072] 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.
[0073] 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 perform an SSD garbage collection method with RAID redundancy.
[0074] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.
[0075] The internal memory 504 provides an environment for the operation 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 perform an SSD garbage collection method with RAID redundancy.
[0076] 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.
[0077] The processor 502 is used to run a computer program 5032 stored in the memory to perform the following steps: During the garbage collection process, a target NAND flash physical block that meets the preset recycling conditions is selected from all NAND flash physical blocks of the solid-state drive; the valid data in the target NAND flash physical block is copied to a new physical location, and the mapping relationship between logical address and physical address is updated; The first mapping table is used to query the first RAID block to which the target NAND flash physical block belongs, wherein the first mapping table is used to record the mapping from NAND flash physical block identifier to RAID block identifier; According to the preset second mapping table, query all NAND flash physical block identifiers that constitute the first RAID block. The second mapping table is used to record the mapping from RAID block identifiers to the set of NAND flash physical block identifiers. The remaining NAND flash physical blocks that constitute the first RAID block, excluding the target NAND flash physical block, are combined into a second RAID block; Recalculate and store the parity data for the second RAID block; Update the first mapping table and the second mapping table to reflect the composition information of the second RAID block; Erase the target NAND flash physical block.
[0078] Optionally, in the garbage collection process, selecting target NAND flash memory blocks from all NAND flash memory blocks of the solid-state drive that meet preset recycling conditions includes: Count the number of valid data pages contained in each NAND flash physical block of a solid-state drive; Based on the statistical results, all NAND flash physical blocks are sorted in ascending order of the number of valid data pages; From the sorted sequence, one or more NAND flash physical blocks are selected as the target NAND flash physical blocks in order of increasing number of valid data pages.
[0079] Optionally, combining the remaining NAND flash physical blocks that constitute the first RAID block, excluding the target NAND flash physical block, into a second RAID block includes: Obtain at least one free NAND flash physical block from the free NAND flash physical block resource pool of the solid-state drive; The remaining NAND flash physical blocks are associated with the at least one free NAND flash physical block to form the second RAID block.
[0080] Optionally, the step of querying the first RAID block to which the target NAND flash physical block belongs according to a preset first mapping table includes: The identifier of the target NAND flash physical block is used as the query key value to search in the first mapping table. The first mapping table stores multiple key-value pairs. The key in each key-value pair is an identifier of a NAND flash physical block, and the corresponding value is the identifier of the RAID block to which the NAND flash physical block currently belongs. Obtain the RAID block identifier corresponding to the key-value pair that matches the query key-value pair, and use it as the identifier of the first RAID block.
[0081] Optionally, the step of querying all NAND flash physical block identifiers constituting the first RAID block according to a preset second mapping table includes: Using the identifier of the first RAID block as the query key, a search is performed in the second mapping table. The second mapping table stores multiple key-value pairs. The key in each key-value pair is a RAID block identifier, and the corresponding value is a list. The list records the identifiers of all NAND flash physical blocks that constitute the RAID block in order. Obtain the list of key-value pairs that match the query key-value pair, which will serve as the set of NAND flash physical block identifiers constituting the first RAID block.
[0082] Optionally, the step of recalculating and storing the parity data for the second RAID block includes: Read data from all physical pages within the second RAID block used for storing user data; Perform a bitwise XOR operation on all the read user data to generate a verification data page; The verification data page is written into a physical page, which serves as the verification page for the second RAID block.
[0083] Optionally, the RAID redundancy mechanism is the RAID 5 mechanism.
[0084] Optionally, the method further includes: maintaining the first mapping table and the second mapping table during non-garbage collection operations, the maintenance including: in response to bad block management operations or wear leveling operations performed by the solid-state drive, when a NAND flash physical block is replaced or data is migrated, identifying the affected RAID block; updating the set of NAND flash physical block identifiers corresponding to the affected RAID block in the second mapping table; and synchronously updating the mapping entries in the first mapping table associated with the replaced or migrated NAND flash physical block.
[0085] 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.
[0086] 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.
[0087] 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: During the garbage collection process, a target NAND flash physical block that meets the preset recycling conditions is selected from all NAND flash physical blocks of the solid-state drive; the valid data in the target NAND flash physical block is copied to a new physical location, and the mapping relationship between logical address and physical address is updated; The first mapping table is used to query the first RAID block to which the target NAND flash physical block belongs, wherein the first mapping table is used to record the mapping from NAND flash physical block identifier to RAID block identifier; According to the preset second mapping table, query all NAND flash physical block identifiers that constitute the first RAID block. The second mapping table is used to record the mapping from RAID block identifiers to the set of NAND flash physical block identifiers. The remaining NAND flash physical blocks that constitute the first RAID block, excluding the target NAND flash physical block, are combined into a second RAID block; Recalculate and store the parity data for the second RAID block; Update the first mapping table and the second mapping table to reflect the composition information of the second RAID block; Erase the target NAND flash physical block.
[0088] Optionally, in the garbage collection process, selecting target NAND flash memory blocks from all NAND flash memory blocks of the solid-state drive that meet preset recycling conditions includes: Count the number of valid data pages contained in each NAND flash physical block of a solid-state drive; Based on the statistical results, all NAND flash physical blocks are sorted in ascending order of the number of valid data pages; From the sorted sequence, one or more NAND flash physical blocks are selected as the target NAND flash physical blocks in order of increasing number of valid data pages.
[0089] Optionally, combining the remaining NAND flash physical blocks that constitute the first RAID block, excluding the target NAND flash physical block, into a second RAID block includes: Obtain at least one free NAND flash physical block from the free NAND flash physical block resource pool of the solid-state drive; The remaining NAND flash physical blocks are associated with the at least one free NAND flash physical block to form the second RAID block.
[0090] Optionally, the step of querying the first RAID block to which the target NAND flash physical block belongs according to a preset first mapping table includes: The identifier of the target NAND flash physical block is used as the query key value to search in the first mapping table. The first mapping table stores multiple key-value pairs. The key in each key-value pair is an identifier of a NAND flash physical block, and the corresponding value is the identifier of the RAID block to which the NAND flash physical block currently belongs. Obtain the RAID block identifier corresponding to the key-value pair that matches the query key-value pair, and use it as the identifier of the first RAID block.
[0091] Optionally, the step of querying all NAND flash physical block identifiers constituting the first RAID block according to a preset second mapping table includes: Using the identifier of the first RAID block as the query key, a search is performed in the second mapping table. The second mapping table stores multiple key-value pairs. The key in each key-value pair is a RAID block identifier, and the corresponding value is a list. The list records the identifiers of all NAND flash physical blocks that constitute the RAID block in order. Obtain the list of key-value pairs that match the query key-value pair, which will serve as the set of NAND flash physical block identifiers constituting the first RAID block.
[0092] Optionally, the step of recalculating and storing the parity data for the second RAID block includes: Read data from all physical pages within the second RAID block used for storing user data; Perform a bitwise XOR operation on all the read user data to generate a verification data page; The verification data page is written into a physical page, which serves as the verification page for the second RAID block.
[0093] Optionally, the RAID redundancy mechanism is the RAID 5 mechanism.
[0094] Optionally, the method further includes: maintaining the first mapping table and the second mapping table during non-garbage collection operations, the maintenance including: in response to bad block management operations or wear leveling operations performed by the solid-state drive, when a NAND flash physical block is replaced or data is migrated, identifying the affected RAID block; updating the set of NAND flash physical block identifiers corresponding to the affected RAID block in the second mapping table; and synchronously updating the mapping entries in the first mapping table associated with the replaced or migrated NAND flash physical block.
[0095] 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.
[0096] 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.
[0097] 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.
[0098] 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.
[0099] 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.
[0100] 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.
[0101] 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.
[0102] 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 garbage collection of SSDs with RAID redundancy, characterized in that, The solid-state drive employs a RAID redundancy mechanism to protect data, wherein multiple NAND flash memory physical blocks form a RAID block, and the method includes: During the garbage collection process, a target NAND flash physical block that meets the preset recycling conditions is selected from all NAND flash physical blocks of the solid-state drive; the valid data in the target NAND flash physical block is copied to a new physical location, and the mapping relationship between logical address and physical address is updated; The first mapping table is used to query the first RAID block to which the target NAND flash physical block belongs, wherein the first mapping table is used to record the mapping from NAND flash physical block identifier to RAID block identifier; According to the preset second mapping table, query all NAND flash physical block identifiers that constitute the first RAID block. The second mapping table is used to record the mapping from RAID block identifiers to the set of NAND flash physical block identifiers. The remaining NAND flash physical blocks that constitute the first RAID block, excluding the target NAND flash physical block, are combined into a second RAID block; Recalculate and store the parity data for the second RAID block; Update the first mapping table and the second mapping table to reflect the composition information of the second RAID block; Erase the target NAND flash physical block.
2. The SSD garbage collection method with RAID redundancy according to claim 1, characterized in that, The step of selecting target NAND flash memory blocks that meet preset recycling conditions from all NAND flash memory blocks of the solid-state drive during the garbage collection process includes: Count the number of valid data pages contained in each NAND flash physical block of a solid-state drive; Based on the statistical results, all NAND flash physical blocks are sorted in ascending order of the number of valid data pages; From the sorted sequence, one or more NAND flash physical blocks are selected as the target NAND flash physical blocks in order of increasing number of valid data pages.
3. The SSD garbage collection method with RAID redundancy according to claim 1, characterized in that, The step of combining the remaining NAND flash memory physical blocks, excluding the target NAND flash memory physical block, that constitute the first RAID block into a second RAID block includes: Obtain at least one free NAND flash physical block from the free NAND flash physical block resource pool of the solid-state drive; The remaining NAND flash physical blocks are associated with the at least one free NAND flash physical block to form the second RAID block.
4. The SSD garbage collection method with RAID redundancy according to claim 1, characterized in that, The step of querying the first RAID block to which the target NAND flash physical block belongs according to a preset first mapping table includes: The identifier of the target NAND flash physical block is used as the query key value to search in the first mapping table. The first mapping table stores multiple key-value pairs. The key in each key-value pair is an identifier of a NAND flash physical block, and the corresponding value is the identifier of the RAID block to which the NAND flash physical block currently belongs. Obtain the RAID block identifier corresponding to the key-value pair that matches the query key-value pair, and use it as the identifier of the first RAID block.
5. The SSD garbage collection method with RAID redundancy according to claim 1, characterized in that, The step of querying all NAND flash physical block identifiers constituting the first RAID block according to a preset second mapping table includes: Using the identifier of the first RAID block as the query key, a search is performed in the second mapping table. The second mapping table stores multiple key-value pairs. The key in each key-value pair is a RAID block identifier, and the corresponding value is a list. The list records the identifiers of all NAND flash physical blocks that constitute the RAID block in order. Obtain the list of key-value pairs that match the query key-value pair, and use it as the set of NAND flash physical block identifiers that constitute the first RAID block.
6. The SSD garbage collection method with RAID redundancy according to claim 1, characterized in that, The step of recalculating and storing the parity data for the second RAID block includes: Read data from all physical pages within the second RAID block used for storing user data; Perform a bitwise XOR operation on all the read user data to generate a verification data page; The verification data page is written into a physical page, which serves as the verification page for the second RAID block.
7. The SSD garbage collection method with RAID redundancy according to claim 1, characterized in that, The RAID redundancy mechanism is RAID 5.
8. The SSD garbage collection method with RAID redundancy according to claim 1, characterized in that, The method further includes maintaining the first mapping table and the second mapping table during non-garbage collection operations, wherein the maintenance includes: in response to bad block management operations or wear leveling operations performed by the solid-state drive, when a NAND flash physical block is replaced or data is migrated, identifying the affected RAID block; updating the set of NAND flash physical block identifiers corresponding to the affected RAID block in the second mapping table; and synchronously updating the mapping entries in the first mapping table associated with the replaced or migrated NAND flash physical block.
9. A computer device, characterized in that, The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method as described in any one of claims 1-8.
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-8.
Citation Information
Cited By
A method for reorganizing storage resources in a flash memory device, a flash memory device, and a storage medium.
CN122131989A