Garbage recycling method for solid state disk and solid state disk
By selecting storage strategies and arbitration mechanisms based on programming modes to recover start page information during the garbage collection process of solid-state drives (SSDs), the problem of data loss in QLC storage media under frequent abnormal power outages is solved, thereby improving the robustness of SSDs and the effective utilization of storage space.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-04-07
AI Technical Summary
In the event of frequent abnormal power outages, the existing garbage collection progress recovery mechanism of solid-state drives (SSDs) cannot effectively handle unstable data in high-density storage media such as QLC, leading to problems such as data loss and insufficient storage space.
By selecting to store the start page information in a snapshot or metadata based on the programming mode of the target physical block during the garbage collection process, and arbitrating when the solid-state drive is powered on to determine the valid start page information, garbage collection is ensured to continue from the most accurate position.
This improves the robustness and reliability of solid-state drives in harsh power environments, avoids redundant work and data loss, and ensures effective release of storage space.
Smart Images

Figure CN121807731A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of memory, and more particularly to a garbage collection method of a solid state disk and a solid state disk. BACKGROUND
[0002] A solid state disk (SSD) is a storage device based on flash memory technology, which manages and releases occupied physical blocks through a garbage collection (GC) mechanism. The garbage collection process mainly includes three steps: first, confirming the location of valid data on the source physical block, then reading the valid data, and finally writing it to the target physical block, repeating this process until all valid data in the source physical block is moved, and then the source physical block can be erased and reused.
[0003] In actual application, garbage collection may encounter abnormal power-off situations. If the garbage collection operation for a certain physical block has not been completed when abnormal power-off occurs, the garbage collection for this physical block needs to be restarted from the starting page of the physical block the next time the power is turned on. This repeated effort leads to a decrease in garbage collection efficiency. In some scenarios where abnormal power-off occurs frequently, this inefficiency may cause garbage collection to fail to release enough available storage space in time, ultimately causing all storage blocks in the SSD to be exhausted, the device to enter a write-protected state, and normal use to be affected.
[0004] In the prior art, to solve the problem of resuming the garbage collection progress after abnormal power-off, the starting page information indicating the garbage collection progress is saved in a snapshot (Check Point) and written to the storage medium regularly. When abnormal power-off occurs, the system continues to perform garbage collection operations from the breakpoint according to the starting page information stored in the latest snapshot before power-off the next time the power is turned on.
[0005] However, with the development of flash memory technology, high-density storage media such as quarter level cell (QLC) have emerged. QLC has a special property: data written to QLC needs to go through a twice-programming (rough programming and accurate programming) and data verification process to ensure its reliability. When abnormal power-off occurs, those data on the QLC physical block that are being programmed and have not completed twice-programming and data verification before power-off will be discarded as unstable data the next time the power is turned on due to this property of QLC. If the garbage collection progress recovery still only relies on the starting page information recorded in the snapshot, it may lead to some valid data on the source physical block actually being discarded but not identified, resulting in data missing during the garbage collection process. An example is given. Figure 1In the garbage collection process, when an abnormal power-off occurs, the starting page information is the source physical block A and page y. After power-on, the garbage collection continues from page y to physical block A. However, because the data of page a of the target physical block B corresponding to page y-1 of the source physical block A is discarded due to instability, the garbage collection fails to move the data of page y-1. Once the data moving fails, the source physical block cannot be correctly released even if the garbage collection operation is completed, which also causes the problem of reduced available storage space. SUMMARY
[0006] Therefore, the embodiments of the present disclosure provide a garbage collection method of a solid state disk and a solid state disk to solve the above problems.
[0007] According to a first aspect, the embodiments of the present disclosure provide a garbage collection method of a solid state disk, the solid state disk comprising a controller and a storage medium coupled to the controller, the storage medium being composed of multiple layers of storage units, the garbage collection method being performed by the controller and comprising the following steps:
[0008] In the garbage collection process, the starting page information indicating the garbage collection progress is stored in a snapshot or metadata according to different programming modes of the target physical block, the programming modes comprising a single-bit programming mode corresponding to the snapshot and a multi-bit programming mode corresponding to the metadata;
[0009] When the solid state disk is powered on, the starting page information is recovered from the snapshot and the metadata respectively, and the recovered starting page information is arbitrated to determine valid starting page information; and
[0010] The garbage collection is continued according to the starting page information determined by the arbitration.
[0011] In some embodiments, in the garbage collection process, when the valid data proportion of the source physical block is less than or equal to a set threshold, the single-bit programming mode is selected to write the valid data in the source physical block to the target physical block; when the valid data proportion of the source physical block is greater than the set threshold, the multi-bit programming mode is selected to write the valid data in the source physical block to the target physical block.
[0012] In some embodiments, the arbitration of the recovered starting page information to determine the valid starting page information comprises:
[0013] When the starting page information from only one source in the snapshot and the metadata is valid, the starting page information from the source is the valid starting page information;
[0014] When the starting page information from two sources in the snapshot and the metadata is valid, if both indicate the same physical block, the starting page information with the larger page number is the valid starting page information.
[0015] When the start page information of the two sources in the snapshot and the metadata are both valid, if they indicate different physical blocks, the start page information of the two sources are both valid start page information.
[0016] In some embodiments, the method further comprises: if the start page information of the two sources in the snapshot and the metadata indicates different physical blocks, preferentially continuing the garbage collection operation of the physical block indicated by the snapshot.
[0017] In some embodiments, the method further comprises: converting the start page information into a block number and a page number according to a preset mapping rule.
[0018] In some embodiments, the start page information is a 32-bit unsigned number, the high 16 bits of which represent the block number and the low 16 bits of which represent the page number.
[0019] In some embodiments, the multi-layer storage unit requires secondary programming to complete data writing.
[0020] In some embodiments, the multi-layer storage unit is QLC.
[0021] According to a second aspect, the embodiments of the present disclosure provide a controller of a solid state disk, wherein the controller is coupled with a storage medium composed of flash memory particles, and the controller or the storage medium stores a computer instruction, and the computer instruction is executed by a processing unit in the controller to implement the garbage collection method described in any of the above.
[0022] According to a third aspect, the embodiments of the present disclosure provide a solid state disk, which comprises the above controller and a storage medium composed of flash memory particles.
[0023] Compared with the prior art, the present application has the following advantages: in the garbage collection process, different storage strategies are used to store the start page information according to the programming mode of the target physical block, after the power of the solid state disk is turned on or off, the start page information is recovered according to a plurality of storage strategies, and the valid start page information is determined through arbitration to continue the garbage collection, so as to ensure that the garbage collection can continue to be executed from the most accurate and effective position after frequent abnormal power on and off, avoid repeated work and data missing, and improve the robustness and reliability of the solid state disk in a harsh power supply environment. BRIEF DESCRIPTION OF DRAWINGS
[0024] Figure 1 is a schematic diagram of the snapshot record start page information of the garbage collection process;
[0025] Figure 2 is a schematic block diagram of a computer system to which the embodiments of the present disclosure are applied;
[0026] Figure 3 is a flowchart of a garbage collection method provided by an embodiment of the present disclosure;
[0027] Figure 4 is used to illustrate snapshots and metadata in various power-off and power-on scenarios in garbage collection;
[0028] Figure 5 is a flowchart of arbitration of start page information from two sources after power-off and power-on in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0029] The present application is described in detail below based on embodiments, but the present application is not limited to only these embodiments. In the following detailed description of the present application, some specific details are described in detail. The present application can also be fully understood without the description of these details by those skilled in the art. In order to avoid confusion of the essence of the present application, well-known methods, processes, and flows are not described in detail. In addition, the drawings are not necessarily drawn to scale.
[0030] The flowcharts and block diagrams in the drawings illustrate the possible system, method, and device of the embodiments of the present application, and the blocks in the flowcharts and block diagrams can represent a module, a program segment, or only a piece of code, which are executable instructions for implementing the specified logical functions. It should also be noted that the executable instructions for implementing the specified logical functions can be recombined to generate new modules and program segments. Therefore, the blocks and the block sequence in the drawings are only used to better illustrate the processes and steps of the embodiments, and should not be regarded as a limitation on the present application itself.
[0031] Figure 2 is a schematic block diagram of a computer system to which an embodiment of the present disclosure is applied. The computer system 200 includes a host 110, a controller 120, and a storage medium 130. The controller 120 and the storage medium 130 constitute various types of storage devices, such as solid state disks.
[0032] The host interface 121 of the controller 120 is connected to the host 110. The host interface 121 is, for example, a SATA, M.2, mSATA, or PCI-E interface. The processor 123 is connected to the host interface 121, the cache controller 124, and the storage media interface 125. The cache chip of the controller 120 includes an SRAM chip 122 located inside the controller and a DRAM chip 126 located outside the controller. The processor 123 can execute the core software layer for memory control, namely the FTL (Flash Translation Layer). The FTL enables the operating system and file system of the host 110 to access the storage medium 130 as if it were accessing the host memory. Specifically, the FTL maintains the mapping relationship data between logical addresses and physical addresses. When a read or write command is received from the host 110, the processor 123 executes the corresponding software program in the FTL. The software program maps the logical address in the read or write request to the physical address of the storage medium 130 according to the mapping relationship data between the logical address and physical address of the cache chip. Then, it performs data access operations on the corresponding storage unit of the storage medium 130 through the storage medium interface 125 connected to the storage medium 130.
[0033] In a host write operation, the controller 120 receives a write command from the host 110, controls the FTL to map the logical address in the command to a physical address, which represents the location in the storage medium 130. Then, the data to be written is organized into data in physical pages as the basic unit, and written to the storage medium 130 one by one, updating the mapping table. In a host read operation, the controller 120 controls the FTL to map the logical address in the command to a physical address, and reads data from the corresponding location in physical pages as the unit.
[0034] Storage medium 130 may be composed of flash memory chips. Storage medium interface 125 of controller 120 connects to multiple flash memory chips via multiple channels (CH0 and CH1). Each flash memory chip is divided into multiple physical planes in the column direction and multiple physical blocks in the row direction, with each physical block further divided into multiple physical pages. The basic unit for reading and writing to a flash memory chip is a physical page, and the basic unit for erasing data from a flash memory chip is a physical block. Each physical page consists of storage cells, which can be multi-level storage cells, such as three-level storage cells (TLC), four-level storage cells (QLC), or single-level storage cells (SLC).
[0035] Both multi-level and single-level memory cells can use a single-bit programming mode for data writing, meaning only one bit is written to each multi-level or single-level memory cell. Multi-level memory cells can also use a multi-bit programming mode, meaning data is written to all levels of the multi-level memory cell. For multi-level memory cells, using a single-bit mode results in a relatively faster data write speed, but at the same time reduces storage density. It should be noted that not all multi-level memory cells use a double-programming mode for data writing; for example, in TLC and QLC, only QLC uses a double-programming mode.
[0036] To address the issue of data instability in garbage collection methods mentioned in the background art after abnormal power outages, this disclosure proposes a garbage collection method that solves the problem by improving the storage strategy and recovery mechanism for garbage collection progress information. Figure 3 This is a flowchart of the waste recycling method, including the following steps.
[0037] In step S301, the starting page information representing the garbage collection progress is stored in a snapshot or metadata, depending on the different programming modes of the target physical block.
[0038] In step S302, when the solid-state drive is powered on, the start page information is recovered from the snapshot and metadata of the storage medium, respectively, and the recovered start page information is arbitrated to determine the valid start page information.
[0039] In step S303, garbage collection continues based on the starting page information determined by arbitration.
[0040] In this embodiment, during garbage collection, the programming mode of the target physical block is first determined. If the target physical block is programmed in a single-bit mode, the programming process is relatively simple, and the data is considered stable by the controller after being provided to the storage medium. Therefore, the starting page information representing the garbage collection progress is saved in a snapshot. If the target physical block is programmed in a multi-bit mode, considering that abnormal power outages may cause data loss on the target physical block, to ensure the reliability of the garbage collection progress, the starting page information is written to the storage medium as metadata along with the user data. Since the metadata and user data have undergone the same programming mode (e.g., the metadata and user data in the QLC undergo secondary programming and data verification), they are considered stable. After power-on, the starting page information is recovered from two independent sources: one is from the latest snapshot, and the other is from the metadata already written to the storage medium. Then, the valid starting page information is determined by comparing the two to continue garbage collection. Here, snapshots and metadata represent two storage strategies: snapshots are periodically refreshed to the storage medium, while metadata is written to the storage medium in real time along with user data.
[0041] In some embodiments, the starting page information includes the block number and page number of the source physical block (e.g., ...). Figure 1 As shown, the block number and page number are organized according to agreed rules. For example, the high 16 bits are the block number and the low 16 bits are the page number.
[0042] In some embodiments, for a source physical block undergoing garbage collection, if its proportion of valid data is less than or equal to a set threshold, a single-bit programming mode is used to move its valid data to the target physical block. When the proportion of valid data in the source physical block is greater than the set threshold, a multi-bit programming mode is used to move its valid data to the target physical block. Subsequently, when convenient, the valid data of the target physical block is moved to other physical blocks using the multi-bit programming mode. The purpose of this processing method is to release available physical blocks as early as possible to avoid the SSD failing to function properly due to insufficient storage space.
[0043] Figure 4 This is used to illustrate snapshots and metadata in various power-off and power-on scenarios during waste recycling.
[0044] As shown in the figure, scenario 1 indicates that no garbage collection was performed before the power failure. Therefore, the start page information of both sources after power-on should be equal to the preset invalid value (e.g., all 0s or all Fs). Alternatively, if the start page information of both sources is checked after power-on and is found to be the preset invalid value (e.g., all 0s or all Fs), then it can be determined that no garbage collection was performed before the power failure.
[0045] In scenarios 2 and 3, if the starting page information from only one source is a valid value (verified through value validation, block / page range validation, block type validation, etc.), then the starting page information from that source is valid starting page information.
[0046] In scenarios 4 and 5, where information from both sources is valid, a further comparison is made. If they point to the same source physical block (with the same block number), the one with the larger page number is selected because a larger page number indicates a later GC progress. If they point to different source physical blocks, the starting page information recovered from the snapshot is used first, and garbage collection continues from that position. This is because the starting page information in the snapshot is usually associated with a single-bit programming mode, which can release the source data block faster. Prioritizing it is beneficial to the overall space reclamation efficiency.
[0047] Figure 5 A flowchart illustrating the arbitration of start page information from two sources after power-on according to an embodiment of this disclosure is provided. As shown in the figure, the start page information is first acquired and verified through two paths: one path includes steps S501 to S504, which acquires the start page information from the snapshot, converts the start page information into a block number and a page number according to a preset mapping relationship, and determines whether the block number and page number are normal and whether the physical block type is GC type, provided that the start page information is not invalid; the other path includes steps S505 to S508, which acquires the start page information from the metadata, converts the start page information into a block number and a page number according to a preset mapping relationship, and determines whether the block number and page number are normal and whether the physical block type is GC type, provided that the start page information is not invalid. Type C; Step S509 determines whether the information in the snapshot and metadata are both invalid values. If yes, it means that garbage collection was not performed before the power failure and there is no need to resume garbage collection after power-on. If no, steps S511 and S513 determine that only one of the information in the snapshot and metadata is valid, and steps S512 and S514 use the valid information to continue garbage collection accordingly. Step S515 determines whether the information in the snapshot and metadata is the same physical block. If yes, step S516 uses the starting page information with the larger page number to continue garbage collection. If no, step S517 prioritizes the starting page information in the snapshot to continue garbage collection.
[0048] In summary, the embodiments of this disclosure provide two storage strategies for storing start page information representing the progress of garbage collection, ensuring that garbage collection can continue from the most accurate and efficient position after frequent abnormal power outages and power-ups, avoiding duplicate work and data loss. This solution is particularly suitable for storage media that require secondary programming (e.g., QLC).
[0049] Accordingly, embodiments of this disclosure also provide, for example... Figure 2The solid-state drive controller and solid-state drive shown have readable computer instructions stored in the cache unit of the controller or the storage medium of the solid-state drive. When these instructions are executed by the processor, they can implement the garbage collection method provided in the above embodiments.
[0050] Accordingly, embodiments of this disclosure also provide a computer-readable storage medium for storing readable computer instructions of a software program constructed based on the garbage collection method provided in embodiments of this disclosure.
[0051] As used herein, the term "module" may refer to, be part of, or include the following: application-specific integrated circuits (ASICs), electronic circuits, processors (shared, dedicated, or grouped) and / or memories (shared, dedicated, or grouped) that execute one or more software or firmware programs, combinational logic circuits, and / or other suitable components that provide the described functionality.
[0052] Those skilled in the art will understand that the various modules or units of the data processing system according to the present invention can be implemented by hardware, firmware, or software. Software includes, for example, coded programs written in various programming languages such as JAVA, C / C++ / C#, and SQL. Although the steps and their order are given in the methods and method diagrams of embodiments of the present invention, the executable instructions that implement the specified logical functions of the steps can be recombined to generate new steps. The order of the steps should not be limited to the order shown in the methods and method diagrams, and can be adjusted at any time according to functional needs. For example, some steps can be executed in parallel or in reverse order.
[0053] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. For those skilled in the art, the present invention can be modified and varied in various ways. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of protection of the present invention.
Claims
1. A garbage collection method for a solid-state drive (SSD), the SSD comprising a controller and a storage medium coupled to the controller, the storage medium comprising multiple layers of storage cells, the garbage collection method being executed by the controller, comprising the following steps: During the garbage collection process, the starting page information representing the garbage collection progress is stored in a snapshot or metadata according to the different programming modes of the target physical block. The programming modes include a single-bit programming mode corresponding to the snapshot and a multi-bit programming mode corresponding to the metadata. When the solid-state drive is powered on, the start page information is recovered from the snapshot and the metadata respectively, and the recovered start page information is arbitrated to determine the valid start page information; as well as Waste collection will continue based on the starting page information determined by the arbitration.
2. The waste recycling method according to claim 1, wherein, During the garbage collection process, when the proportion of valid data in the source physical block is less than or equal to a set threshold, the single-bit programming mode is selected to write the valid data in the source physical block to the target physical block; when the proportion of valid data in the source physical block is greater than the set threshold, the multi-bit programming mode is selected to write the valid data in the source physical block to the target physical block.
3. The waste recycling method according to claim 1, wherein, The arbitration of the recovered start page information to determine valid start page information includes: When only one source of the snapshot and the metadata has valid start page information, then the start page information of that source is valid start page information; When both the snapshot and the metadata contain valid starting page information from two sources, if they both indicate the same physical block, the starting page information with the larger page number is the valid starting page information. When both the snapshot and the metadata contain valid start page information from two sources, if they indicate different physical blocks, then the start page information from both sources is valid start page information.
4. The waste recycling method according to claim 3 further includes: If the starting page information from the two sources in the snapshot and the metadata indicates different physical blocks, then the garbage collection operation of the physical block indicated by the snapshot shall continue first.
5. The waste recycling method according to claim 1 further includes: The starting page information is converted into block number and page number according to the preset mapping rules.
6. The waste recycling method according to claim 5, wherein, The start page information is a 32-bit unsigned number, with the high 16 bits representing the block number and the low 16 bits representing the page number.
7. The waste recycling method according to any one of claims 1 to 6, wherein, The multi-layer storage unit requires secondary programming to complete data writing.
8. The waste recycling method according to any one of claims 1 to 6, wherein, The multi-layer storage unit is a QLC.
9. A controller for a solid-state drive, wherein, The controller is coupled to a storage medium composed of flash memory chips, and the controller or the storage medium stores computer instructions that, when executed by a processing unit in the controller, implement the garbage collection method as described in any one of claims 1 to 7.
10. A solid-state drive, wherein, It includes the controller as described in claim 9 and the storage medium composed of the flash memory chips.