Method of garbage collection operation and related memory controller and storage system
By segmenting and adjusting the intensity and time period of the garbage collection operation, the response time instability and performance degradation during flash memory garbage collection is solved, ensuring the stability of write performance and the effectiveness of block release.
Patent Information
- Application Number
- CN202410416637.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-05-09
- Filing Date
- 2024-04-08
- Publication Date
- 2024-11-12
AI Technical Summary
During the garbage collection operation of flash memory, the host write/read operation response time is unstable, resulting in a degradation of write/read performance and may cause a command timeout or block failure to be released.
By dividing the garbage collection operation into multiple partial operations, and adjusting the intensity and time period of partial garbage collection according to different factors such as GC type, write type, data entropy, residual capacity and number of spare blocks, partial GC operations alternately performing partial GC operations. and host write commands to balance GC tasks and host command tasks.
It realizes stable write performance in the flash memory from blank to full state, avoids the problems of command timeout and insufficient block release, and ensures the constant of the number of spare blocks.
Smart Images

Figure CN118939178A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a flash memory, and more particularly to a method for managing garbage collection operations in the flash memory based on source block types, and a related memory controller and storage system. Background Art
[0002] Due to the characteristics of flash memory, flash-based storage devices do not support overwrite operations. When new data needs to replace old data stored in flash memory, the new data is written to a new location, and the old data at the old location becomes invalid. Therefore, as old data is repeatedly overwritten, the amount of invalid data will increase. To ensure sufficient storage space for new data, flash memory devices rely on garbage collection (GC) operations to free up space occupied by invalid data.
[0003] The GC operation selects one or more source blocks from the flash memory and copies only the valid pages (i.e., pages with valid data) in the source blocks to the target blocks. After all valid pages in the selected one or more source blocks are copied to the target block, the selected one or more source blocks can be erased, thereby becoming one or more spare blocks that can be written with new data. Since the GC operation is an internal behavior of the flash memory device, its controller needs to process the GC operation and host commands simultaneously. This means that once the GC operation begins, write / read access operations based on host commands will be restricted, resulting in unstable response time to host commands and even reduced write / read performance of the flash memory device. In view of the above situation, it is necessary to propose a mechanism for managing GC operations of flash memory devices. Summary of the Invention
[0004] One of the purposes of the present invention is to provide a mechanism for managing garbage collection operations. An embodiment of the present invention alternately executes partial GC operations (cut out from a complete GC operation) and host write commands, while appropriately adjusting the intensity of the GC operations to prevent host write command timeouts. In other words, the present invention aims to more effectively balance GC tasks and host command tasks, and properly manage GC operations to avoid command timeouts. The present invention determines the intensity of GC operations based on different factors such as GC type (e.g., S2S, S2T, T2T, wear-leveling), write type (writing data to SLC blocks or TLC blocks), data entropy, remaining capacity, and the number of spare blocks. This helps the flash memory maintain stable write performance from blank to full. The present invention can ensure that even in the event of sudden power-off events, a relatively constant number of spare blocks is maintained. In addition, the present invention can prevent host write command timeouts caused by excessive GC intensity, and avoid situations where blocks cannot be released due to insufficient GC intensity.
[0005] An embodiment of the present invention provides a method for managing garbage collection operations on a flash memory, the method comprising: dividing a garbage collection operation into multiple partial garbage collection operations; determining a preset time period for a partial garbage collection operation for each partial garbage collection operation; determining a partial garbage collection intensity based on at least a basic adjustment factor and a magnification factor; determining the basic adjustment factor based on a type of one or more source blocks corresponding to the garbage collection operation; determining the magnification factor based on a percentage of invalid pages in the one or more source blocks corresponding to the garbage collection operation; and performing the partial garbage collection operations based on the partial garbage collection intensity and the preset time period for the partial garbage collection operation.
[0006] An embodiment of the present invention provides a memory controller for controlling a flash memory and managing garbage collection operations on the flash memory. The memory controller includes a storage unit and a processing unit. The storage unit is configured to store information and program code. The processing unit is configured to use the program code to: divide a garbage collection operation into multiple partial garbage collection operations; determine a preset time period for each partial garbage collection operation; determine a partial garbage collection intensity based on at least a basic adjustment factor and an amplification factor; determine the basic adjustment factor based on the type of one or more source blocks corresponding to the garbage collection operation; determine the amplification factor based on the percentage of invalid pages in the one or more source blocks corresponding to the garbage collection operation; and execute the partial garbage collection operations based on the partial garbage collection intensity and the preset time period for the partial garbage collection operation.
[0007] An embodiment of the present invention provides a storage system comprising: a flash memory and a memory controller. The memory controller is used to control the flash memory and manage garbage collection operations on the flash memory. The memory controller is used to: divide a garbage collection operation into multiple partial garbage collection operations; determine a preset time period for a partial garbage collection operation for each partial garbage collection operation; determine a partial garbage collection intensity based on at least a basic adjustment factor and an amplification factor; determine the basic adjustment factor based on the type of one or more source blocks corresponding to the garbage collection operation; determine the amplification factor based on the percentage of invalid pages in the one or more source blocks corresponding to the garbage collection operation; and perform the partial garbage collection operations based on the partial garbage collection intensity and the preset time period for the partial garbage collection operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 A diagram illustrating the architecture of an electronic device and a storage system according to an embodiment of the present invention is shown.
[0009] Figure 2 FIG. 1 illustrates an embodiment of the present invention performing a T2T garbage collection operation when the valid page ratio of a source block is low.
[0010] Figure 3 FIG. 1 illustrates an embodiment of the present invention performing a T2T garbage collection operation when the source block has a high valid page ratio.
[0011] Figure 4 FIG. 4 illustrates the arrangement of different types of garbage collection operations in a hybrid mode according to an embodiment of the present invention.
[0012] Figure 5 FIG. 1 illustrates the numerical range of the amplification factor and partial garbage collection operation time periods corresponding to different types of garbage collection operations in one embodiment of the present invention.
[0013] Figure 6 FIG. 4 illustrates the numerical range of the amplification factor and the partial garbage collection operation time periods corresponding to different types of garbage collection operations according to another embodiment of the present invention.
[0014] Figure 7 A flowchart of a method for managing garbage collection operations according to an embodiment of the present invention is shown.
[0015]
Explanation of symbols
[0016] 10 Electronic devices
[0017] 50 host device
[0018] 52 processors
[0019] 54 RAM
[0020] 100 Storage System
[0021] 110 Memory Controller
[0022] 112 microprocessors
[0023] 112C Program Code
[0024] 112M ROM
[0025] 113 Internal Memory
[0026] 114 Control Logic Circuit
[0027] 118 transmission interface circuit
[0028] 120 NV memory
[0029] 122_1 to 122_N NV memory elements
[0030] Steps S210 to S260 DETAILED DESCRIPTION
[0031] In the following text, many specific details are described to provide the reader with a thorough understanding of the embodiments of the present invention. However, those skilled in the art will understand how to implement the present invention without one or more specific details, or using other methods, components, materials, etc. In other cases, well-known structures, materials, or operations are not shown or described in detail to avoid obscuring the core concepts of the present invention.
[0032] References in this specification to "one embodiment" mean that the specific features, structures, or characteristics described in that embodiment may be included in at least one embodiment of the present invention. Therefore, the phrase "in one embodiment" appearing throughout this specification does not necessarily refer to the same embodiment. Furthermore, the aforementioned specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0033] Figure 1The figure is a schematic diagram of the architecture of an electronic device 10 according to an embodiment of the present invention. The electronic device 10 includes a host device 50 and a storage system 100. The host device 50 may include: at least one processor 52; and a random access memory (RAM) 54 for storing information and data required by the processor 52. Examples of the host device 50 include, but are not limited to: a smartphone, a tablet computer, a wearable device, a personal computer (e.g., a desktop computer or a notebook computer), an image generating device (e.g., a digital camera or video camera), a game console, a car navigation system, a printer, a scanner, or a server system. Examples of the storage system 100 include, but are not limited to: a portable memory device (e.g., a memory card compliant with the SD / MMC, CF, MS, XD, or UFS specifications), a solid-state drive (SSD), and various embedded storage devices (e.g., an embedded storage device compliant with the UFS or EMMC specifications).
[0034] In various embodiments of the present invention, the storage system 100 may include a controller (e.g., memory controller 110) and may further include a non-volatile (NV) memory 120. The NV memory 120 is used to store information. The NV memory 120 may include one or more NV memory elements, such as NV memory elements 122_1 to 122_N. In one embodiment, the NV memory 120 may be a flash memory, and the NV memory elements 122_1 to 122_N may be a plurality of flash memory chips or a plurality of flash memory dies, respectively, but the present invention is not limited thereto. In addition, the NV memory 120 may include memory cells having a two-dimensional structure, or may include memory cells having a three-dimensional structure.
[0035] like Figure 1As shown, the memory controller 110 may include: a processing circuit (e.g., a microprocessor 112), a storage element (e.g., read-only memory (ROM)) 112M, internal memory 113, control logic circuit 114, and transmission interface circuit 118. At least some of these components may be interconnected via a bus. The internal memory 113 may be implemented as random-access memory (RAM). For example, the internal memory 113 may be implemented as one or more RAMs, including static RAM (SRAM) and / or dynamic RAM (DRAM). The internal memory 113 may be used to provide internal storage space for the memory controller 110, such as for temporarily storing information (e.g., parameters, variables, commands, data, addresses, and / or mapping tables). In some embodiments, the internal memory 113 may not be a physical memory within the memory controller 110. The memory controller 110 may request the host device 50 to use a portion of the RAM 54 as the internal memory 113, which is the so-called host memory buffer (HMB) technology. By utilizing HMB technology, the memory controller 110 can utilize the RAM 54 of the host device 50 to compensate for the lack of internal memory, thereby improving the read and write performance of the storage system 100. Furthermore, in this embodiment, the ROM 112M is used to store program code 112C, and the microprocessor 112 is used to execute program code 112C, thereby controlling access to the NV memory 120. Alternatively, the program code 112C may be stored in the NV memory 120.
[0036] In addition, the memory controller 110 can execute the writing of user data according to the host command from the host device 50, and can also simultaneously execute the writing of valid data read out by garbage collection and / or wear leveling operations. The control logic circuit 114 can also be used to control the NV memory 120 and includes an error correction code (ECC) circuit (not shown) to perform data protection and / or error correction, but the present invention is not limited to this. The transmission interface circuit 118 may comply with a specific communication standard (for example: Serial Advanced Technology Attachment (SATA) standard, Universal Serial Bus (USB) standard, Peripheral Component Interconnect Express (PCIE) standard, embedded Multi Media Card (eMMC) standard, or Universal Flash Storage (UFS) standard) and communicate with the host device 50 according to the above-mentioned specific communication standard.
[0037] Generally speaking, the host device 50 can indirectly access the storage system 100 by transmitting host read / write commands and corresponding logical addresses to the memory controller 110. The memory controller 110 receives the host commands and logical addresses and translates the host commands into memory operation commands to further control the NV memory 120 using the memory operation commands to perform read, write, or erase operations on memory cells or data pages with physical addresses in the NV memory 120. The physical addresses correspond to the logical addresses. When the memory controller 110 performs an erase operation on any one of the multiple NV memory elements 122_1 to 122_N NV memory elements 122_k, at least one block of the NV memory element 122_k may be erased. In addition, each block of the NV memory element 122_k may include multiple pages, and access operations may be performed on one or more pages (e.g., read or write).
[0038] In one embodiment, each of the NV memory elements 122_1 to 122_N can be an NV memory chip (or die). Each NV memory die 122_1 to 122_N has a control circuit for executing the memory operation command issued by the memory controller 110. In addition, each of the NV memory dies 122_1 to 122_N can include multiple planes. Each plane can include multiple memory cell blocks and related row and column control circuits. The memory cells in each plane can be arranged in a two-dimensional or three-dimensional memory structure. According to the multi-plane operation command, multiple operations (such as reading, programming, and erasing) can be performed in parallel (i.e., simultaneously) on the memory blocks in different planes. That is, the multi-plane operation command allows multiple processing operations to be performed simultaneously on different planes.
[0039] The following sections discuss several different types of GC operations. An "S2S" GC operation involves moving data from valid pages of one or more single-level cell (SLC) blocks to blank pages of another SLC block. An "S2M" GC operation involves moving data from valid pages of one or more SLC blocks to blank pages of a multi-level cell (MLC) block. An "S2T" GC operation involves moving data from valid pages of one or more SLC blocks to blank pages of a triple-level cell (TLC) block. An "S2Q" GC operation involves moving data from valid pages of one or more SLC blocks to blank pages of a quad-level cell (QLC) block. An "M2M" GC operation involves moving data from valid pages of one or more MLC blocks to blank pages of an MLC block. A "T2T" GC operation involves moving data from valid pages of a TLC block to blank pages of a TLC block. The "Q2Q" GC operation moves data on a valid page of a QLC block to a blank page of a QLC block.
[0040] In one embodiment, the memory controller 110 will perform multiple partial GC operations in a short period of time instead of completing a full GC operation in a long period of time. In other words, a GC operation will be divided into multiple partial GC operations. The memory controller 110 will alternately perform normal access operations based on host commands and multiple partial GC operations. Performing partial GC operations may limit the time the memory controller 110 performs normal access operations. On the other hand, the GC operation essentially releases blocks occupied by invalid data. Therefore, the memory controller 110 will determine and adjust the intensity of the partial GC operation (equivalent to the GC intensity), which indicates the ratio between the length of time the partial GC operation currently needs to be executed (i.e., the time period) and the length of time the partial GC operation is preset to be executed.
[0041] Specifically, the preset time period ptGcT for a partial GC operation can be determined by the following formula: ptGcT = (LastGcT) / (ptGcTimes). "LastGcT" refers to the time period required to complete the last full GC operation. "ptGcTimes" refers to the number of partial GC operations required to complete a spare block (spareblock) or a target block associated with a GC operation in response to a host command. Generally speaking, if the memory controller 110 determines that a GC operation is required, it will perform a partial GC operation after completing writing a data chunk in response to the host command. Therefore, the value of "ptGcTimes" can be obtained by the following formula: ptGcTimes = (total number of pages in the spare block) / (number of pages per data chunk). Furthermore, the preset partial GC time "ptGcT" refers to the possible time period required to complete a single partial GC operation. In some embodiments, "ptGcTimes" refers to the number of partial GC operations performed by the memory controller 110 to move valid pages from one or more source blocks to a target block. Therefore, "ptGcTimes" can also be obtained by the following formula: ptGcTimes = (total number of valid pages in the source block) / (number of pages per data block).
[0042] In various embodiments of the present invention, the memory controller 110 determines the intensity of a partial GC operation based on various factors. First, the memory controller 110 determines the intensity of a partial GC operation based on a basic adjustment factor. This basic adjustment factor is dependent on the source block type and the target block type. Specifically, a source block is a block from which a partial GC operation removes valid data (e.g., reading data from a valid page of the source block), while a target block is a block into which a partial GC operation removes valid data (e.g., writing valid data to a blank page of the target block).
[0043] In one embodiment, the memory controller 110 performs a garbage collection (GC) operation (including several partial GC operations) to move valid data from an SLC block to a TLC block (i.e., an S2T GC operation). Typically, due to storage cell density, one S2T GC operation (including several S2T partial GC operations) frees three SLC blocks (i.e., the source blocks of the S2T GC operation) and consumes one spare TLC block (i.e., the target block of the S2T GC operation). This means that the total number of spare blocks in the NV memory 120 is replenished by two. Therefore, the intensity of the partial GC operation corresponding to this S2T GC operation must be sufficient to complete an S2T GC operation after every two spare blocks are completely filled or closed. Block closure means that the block can no longer be used to store additional data. Therefore, the basic adjustment factor of the S2T GC operation is set to 2, resulting in an intensity of the partial GC operation of 1 / 2 (i.e., the inverse of the basic adjustment factor). This also means that the partial GC operation time period "ptGcTS2T" corresponding to the S2T GC operation can be 1 / 2 times the preset time period "ptGcT" of the partial GC operation. S2T =(1 / 2)*ptGcT. In a preferred embodiment, an amplification factor "Amp" (to be explained later) can also be added to the partial GC operation time period ptGcP corresponding to the S2T GC operation. S2T Therefore, the partial GC operation time period corresponding to the S2T GC operation can be determined by the following formula: ptGcP S2T =(1 / 2)*(Amp)*ptGcT.
[0044] In one embodiment, the memory controller 110 performs a GC operation (including several partial GC operations) to move valid data from one or more TLC blocks to one TLC block (ie, a T2T GC operation). Figure 2The situation shown. Assuming that the valid page percentages of the TLC source blocks blk1, blk2, and blk3 are less than 50%, then at this time a T2T GC operation (including multiple T2T partial GC operations) will release two TLC blocks blk1 and blk2, and consume one spare TLC block (i.e., the target block of the T2T GC operation). This means that the total number of spare blocks in the NV memory 120 will be replenished by 1. The intensity of the partial GC operation corresponding to this T2T GC operation must be sufficient to ensure that: after each spare block is completely filled or closed, an S2T GC operation is completed. Among them, block closing means that the block can no longer be used to store additional data. Therefore, the basic adjustment factor of the T2T GC operation will be set to 1, which makes the intensity of the partial GC operation 1 (i.e., the inverse of the basic adjustment factor). This also means that the partial GC operation time period ptGcT corresponding to the T2T GC operation T2T The preset time period ptGcT for partial GC operation will be the same as ptGcT T2T =ptGcT.
[0045] On the other hand, if the valid page percentage of the TLC source block is high (for example, more than 50%), multiple T2T GC operations are required to free the TLC block. Figure 3The figure illustrates how two TLC source blocks are freed by performing multiple T2T GC operations. In the first T2T GC operation, the source blocks are blk0 and blk1, both of which have a valid page percentage of 80%. After the first T2T GC operation, one spare TLC block is consumed to store the data of the valid pages of source blocks blk0 and blk1, and source block blk0 is completely freed. Simultaneously, the valid page percentage of source block blk1 is reduced to 60%. This leaves the total number of spare blocks in NV memory 120 unchanged. In the second T2T GC operation, the valid page percentage of source block blk1 is 60%, and the valid page percentage of source block blk2 is 80%. After the second T2T GC operation, one spare TLC block is consumed to store the data of the valid pages of source blocks blk1 and blk2, and source block blk1 is completely freed. Simultaneously, the valid page percentage of source block blk2 is reduced to 40%. Thus, the total number of spare blocks in the NV memory 120 remains unchanged. During the third T2T GC operation, the valid page percentage of source block blk2 is 40%, and the valid page percentage of source block blk3 is 80%. After the third T2T GC operation, one spare TLC block is consumed to store the data of the valid pages of source blocks blk2 and blk3, and source block blk2 is completely released. Simultaneously, the valid page percentage of source block Blk3 decreases to 20%. Therefore, the total number of spare blocks in the NV memory 120 remains unchanged. During the fourth T2T GC operation, the valid page percentage of source block blk3 is 20%, and the valid page percentage of source block blk4 is 80%. After the fourth T2T GC operation, one spare TLC block is consumed to store the data of the valid pages of source blocks blk3 and blk4, and source blocks blk3 and blk4 are completely released. Thus, the total number of spare blocks in the NV memory 120 is increased by one.
[0046] From the above, we can see that in some cases, 4 or 5 (if the valid page percentage of the source block exceeds 80%) T2T GC operations are required to obtain (replenish) a new spare TLC block. Therefore, the intensity of the partial GC operation corresponding to the T2T GC operation must be set to ensure that 4 or 5 T2T GC operations are completed each time a spare block is completely filled or closed. In view of this, in the case of a high valid page percentage, the intensity of the partial GC operation corresponding to the T2T GC operation will be 5, which means that the partial GC operation time period ptGcT corresponding to the T2T GC operation T2T It will be 5 times the preset time period ptGcT of the partial GC operation, that is, ptGcP T2T=5*ptGcT. Therefore, in the case of high valid page percentage and low valid page percentage, the partial GC operation time period ptGcT corresponding to the T2T GC operation is T2T It can be expressed as: ptGcT T2T =(Amp)*(ptGcT), where "Amp" is the amplification factor mentioned above.
[0047] In one embodiment, the amplification factor Amp is determined by rounding the value of (TlcVpc / rlsVpc), where "TlcVpc" is the total number of pages (or valid pages) contained in a source block (TLC block or other type of block). "rlsVpc" is the total number of valid pages that can be freed by the current GC operation, excluding the total number of valid pages in the source block remaining (incomplete) from the previous GC operation. This value can be obtained using the following formula: rlsVpc = (TlcVpc*rlsBlkCnt-trueSrcVpc) / rlsBlkCnt.
[0048] Please note that the remaining (unfinished) source blocks in the previous GC operation refer to the source blocks whose valid data has been moved to the target blocks in the previous GC operation. Figure 3 In the second T2T GC operation mentioned in the preceding text, the source block blk1 is the remaining (unfinished) source block from the previous GC operation (i.e., the first T2T GC operation). In addition, the value of "rlsBlkCnt" represents the total number of source blocks in the current GC operation, excluding the remaining (unfinished) source blocks from the previous GC operation. In other words, the value of "rlsBlkCnt" is the result of subtracting the total number of source blocks remaining in the previous GC operation, "residueBlkCnt", from the total number of source blocks in the current GC operation, "srcBlkCnt", i.e., rlsBlkCnt = srcBlkCnt - residualBlkCnt. Figure 3 For example, in the second T2T GC operation, srcBlkCnt is 2 (ie, blk1 and blk2), residualBlkCnt is 1 (because blk1 is the remaining source block from the first T2T operation), and rlsBlkCnt is 1 (ie, blk2).
[0049] In addition, the value of "trueSrcVpc" represents the total number of valid pages of the source block in the current GC operation, and excludes the valid pages of the source block remaining (incomplete) from the previous GC operation. In other words, the value of "trueSrcVpc" is the result of subtracting the total number of valid pages of the source block remaining in the previous GC operation "residueVpc" from the total number of valid pages of the source block in the current GC operation "srcVpc", that is, trueSrcVpc = srcVpc - residualVpc. Figure 3 For example, in the second T2T GC operation, “residueVpc” corresponds to the number of valid pages in blk1 (because blk1 is the remaining source block from the first T2T GC operation), and “trueSrcVpc” corresponds to the number of valid pages in blk2.
[0050] Furthermore, the amplification factor Amp can also be determined based on the invalid page percentage of each source block in the current GC operation, excluding the invalid page percentage of the remaining (incomplete) source blocks from the previous GC operation. For example, in a GC operation, the source blocks include blk0, blk1, and blk2. The invalid page percentage of source block blk0 is IA, the invalid page percentage of source block blk1 is IB, and the invalid page percentage of source block blk2 is IC, and source block blk0 is the remaining source block from the previous GC operation. Therefore, the amplification factor Amp can be determined based on the inverse of the average of the invalid page percentages of source blocks blk1 and blk2, i.e., Amp = 1 / ((IB + IC) / 2).
[0051] In one embodiment, a GC operation may be associated with multiple different types of data movement, which is a mixed mode GC operation. The mixed mode GC operation may involve an S2T GC operation and a T2T GC operation. When host data is only written to SLC blocks (as cache blocks) and the remaining capacity of the NV memory 120 is relatively low, a mixed mode GC operation may be involved. In this case, the data in the NV memory 120 will be distributed between the TLC blocks (written by the GC operation) and the SLC blocks (written by the host data). Taking this into account, when the number of closed SLC blocks reaches a predetermined critical value requiring the initiation of a GC operation, an S2T GC operation will be performed, and when the number of closed TLC blocks reaches another predetermined critical value for initiating a GC operation, a T2T GC operation will be performed, resulting in a mixed mode GC operation. Under the mixed mode GC operation, in order to maintain the number of spare blocks in the NV memory 120, the following can be used: Figure 4 GC operations are performed in the order shown.
[0052] Please refer to Figure 4 Assuming the data entropy (which is essentially the same as the amplification factor) corresponding to a TLC (source) block is 8, the memory controller 110 will complete 8 T2T GC operations and one S2T GC operation after filling three cache blocks based on host commands, thereby freeing three blocks (i.e., one TLC block and two SLC blocks). In this way, the NV memory 120 can replenish three spare blocks, which can balance the consumption of the three cache blocks mentioned above. Simply put, in order to maintain the number of spare blocks in the NV memory 120, it is necessary to complete the release of three blocks within the time it takes for the memory controller 110 to fill three cache blocks. Therefore, it is only necessary to increase the intensity of the partial GC operation corresponding to the T2T GC operation by 3 times, that is, (8+1) / 3=3. In this case, the 8 T2T GC operations are distributed within the time period when the memory controller 110 fills the first two cache blocks and the time period when the memory controller 110 fills the first two-thirds of the third cache block. In addition, the last 1 / 3 of the time period when the memory controller 110 fills the third cache block is reserved for the S2T GC operation. Since the intensity of the partial GC operation corresponding to the S2T GC operation is designed to be completed once every two blocks are filled (based on host commands), the intensity of the partial GC operation corresponding to the S2T GC operation in the hybrid mode must be increased to 6 times the original value. In other words, the partial GC operation time period ptGcT corresponding to the S2T GC operation in the hybrid mode is MIX_S2T Will be hosted by: ptGcT MIX_S2T =ptGcT*((Amp+1)*(1 / 2)*(1 / 3)*2), and the T2TGC operation in the hybrid mode corresponds to the partial GC operation time period ptGcT MIX_T2T Will be hosted by: ptGcT MIX_T2T =ptGcT*((Amp+1)*1 / 3).
[0053] In one embodiment, wear-leveling and read-disturbance situations require data to be moved between blocks of the NV memory 120 through garbage collection (GC) operations. When the memory controller 110 decides to perform a wear-leveling operation or address a read-disturb situation, the memory controller 110 increases the minimum value of the amplification factor, Amp, to 4. This adjustment increases the intensity of some GC operations, performing additional GC operations to address wear-leveling operations and read-disturb situations. As a result, the intensity of some GC operations is increased by at least a factor of four. For S2T GC operations, the amplification factor is 4; for T2T GC operations, the amplification factor is greater than or equal to 4 and less than or equal to 32 (i.e., 4 ≤ Amp ≤ 32).
[0054] In one embodiment, assuming the number of spare blocks in the NV memory 12 is very low (i.e., below a predetermined level), the memory controller 110 increases the predetermined time period ptGcT for partial GC operations using a low spare block state adjustment factor. The factor is preferably: (1+(LOS / 2)). That is, in the low spare block state, the partial GC operation time period is amplified by: (1+(LOS / 2))*(ptGcT). The value of "LOS" can be determined based on a predetermined spare block number threshold SPRTHD and the number of spare blocks SPRN in the NV memory 120. The value of "LOS" can be determined by: LOS=(SPRTHD–SPRN). The low spare block state adjustment factor is particularly helpful when the number of spare blocks in the NV memory 120 is low and sudden power off recovery (SPOR) testing is performed continuously. This is because the rebuild process after SPOR consumes a large amount of spare blocks in the NV memory 120 , so a low spare block status adjustment factor is used when necessary to increase the intensity of the partial GC operation.
[0055] Figure 5 A table is shown that shows the range of amplification factors in one embodiment of the present invention and how to determine the partial GC operation time period (ptGcT') corresponding to different types of GC operations. If the GC operation is of S2T type (i.e., the source block is an SLC block and the target block is a TLC block), the amplification factor Amp is usually 1 under normal circumstances, but can be increased to 4 in the case of wear leveling (WL) or read disturbance (RD). In addition, the partial GC operation time period ptGCT corresponding to the S2T type is S2T It can be determined according to the following formula: ptGcT S2T =ptGcT*(Amp / 2)*(1+(LOS / 2)). Among them, (1+(LOS / 2)) is only included in the calculation in the low spare block state. If the GC operation is of T2T type (the source block is a TLC block and the target block is a TLC block), the amplification factor Amp is usually greater than or equal to 1 and less than or equal to 32 under normal circumstances. In the case of wear leveling or read disturbance, the amplification factor Amp can be increased to greater than or equal to 4 and less than or equal to 32. In addition, the partial GC operation time period corresponding to the T2T type is ptGCT T2T It can be determined according to the following formula: ptGcT T2T =ptGcT*(Amp)*(1+(LOS / 2)). In addition, (1+(LOS / 2)) is only included in the calculation in the low spare block state.
[0056] In hybrid mode, the memory controller 110 performs N T2T GC operations and one S2T GC operation. Therefore, under normal circumstances, the amplification factor Amp is greater than or equal to 2 and less than or equal to 32. In the case of wear leveling or read disturbance, the amplification factor Amp increases and becomes greater than or equal to 11 and less than or equal to 32. In addition, the partial GC operation time period ptGCT corresponding to the S2T type in hybrid mode is MIX_S2T (corresponding to the partial GC operation of S2T) can be determined according to the following formula: ptGCT MIX_S2T =ptGcT*((Amp+1) / 3)*(1+(LOS / 2)), where (1+(LOS / 2)) is only included in the calculation in the low spare block state. In addition, the ptGCT of the partial GC operation period corresponding to the T2T type in the hybrid mode MIX_T2T (corresponding to the partial GC operation of T2T) can be determined according to the following formula: ptGCT MIX_T2T =ptGcT*((Amp+1) / 3)*(1+(LOS / 2)), where (1+(LOS / 2)) is only taken into account in the low spare block state.
[0057] Figure 6 A table is shown that shows the range of amplification factors in one embodiment of the present invention and how to determine the partial GC operation time period (ptGcT') corresponding to different types of GC operations. If the GC operation is of the S2X type (the source block is an SLC block and the target block is an SLC block, MLC block, TLC block, or QLC block), the amplification factor Amp is usually 1 under normal circumstances, but can be increased to A in the case of wear leveling or read disturbance. high In addition, the GC operation time period corresponding to the S2X type is ptGCT S2X It can be determined according to the following formula: ptGcT S2X =ptGcT*(Amp / EGBC S2X) *(1+k*LOS). Where k is greater than 0, and (1+(LOS / 2)) is only included in the calculation in the low spare block state. S2X The value of " corresponds to the number of spare blocks that are expected to be replenished / added after the S2X GC operation is completed. For example, EGBC S2S is 1 (i.e., the minimum value) because an S2S GC operation can free up one SLC block and consume one spare SLC block. S2M Is 1, because the S2MGC operation can free up two SLC blocks and consume one spare MLC block. S2TIt is 2, because the S2T GC operation can free up three SLC blocks and consume one spare TLC block. S2Q It is 3 because the S2Q GC operation can free up four SLC blocks and consume one spare QLC block.
[0058] If the GC operation is of type X2X (i.e., the source block and the target block are of the same type), in general, the amplification factor Amp is greater than or equal to 1 and less than or equal to A MAX , but in the case of wear leveling or read disturb, the amplification factor will increase to be greater than or equal to A high and less than or equal to A MAX In addition, the GC operation time period corresponding to the X2X type is ptGCT X2X It can be determined according to the following formula: ptGcT X2X =ptGcT*(Amp / EGBC X2X )*(1+k*LOS), where k is greater than 0, and (1+(LOS / 2)) is only included in the calculation in the low spare block state. X2X The value of " corresponds to the number of spare blocks that can be supplemented / added after the X2X GC operation is completed. Generally speaking, multiple X2X GC operations are required to supplement / add one spare block. For example, Figure 3 As shown in Figure 1, 4 or 5 T2T GC operations are required to add / acquire a spare TLC block. X2X Will be set to 1 (minimum value).
[0059] In hybrid mode, the memory controller 110 will perform N X2X GC operations and 1 S2X GC operation. Therefore, under normal circumstances, the amplification factor Amp will be greater than or equal to (EGBC mix -1) and less than or equal to A MAX In the case of wear leveling or read disturb, the amplification factor increases and becomes greater than or equal to (EGBC mix *A high -1) and less than or equal to A MAX In addition, the GC operation time period ptGCT mix It can be determined according to the following formula: ptGcT mix =ptGcT*((Amp+1) / (EGBC miX ))*(1+k*LOS), where k is greater than 0, and (1+k*LOS) is included in the calculation only in the low spare block state. mixThe value of " corresponds to the number of spare blocks that can be supplemented / added after N X2X GC operations and 1 S2X GC operation are completed. It can be determined by the following formula: mix =EGBC X2X +EGBC S2X .
[0060] Figure 7 A flow chart of a method for managing garbage collection operations according to an embodiment of the present invention is shown. As shown in the figure, the flow chart includes the following steps:
[0061] Step S210: Split a garbage collection operation into multiple partial GC operations;
[0062] Step S220: determining a preset time period for each partial GC operation;
[0063] Step S230: determining a portion of GC intensity according to at least one basic adjustment factor and an amplification factor;
[0064] Step S240: determining the basic adjustment factor according to the type of one or more source blocks corresponding to the garbage collection operation;
[0065] Step S250: determining the amplification factor according to the invalid page percentage in the one or more source blocks corresponding to the garbage collection operation; and
[0066] Step S260: performing the partial garbage collection operations according to the partial garbage collection intensity and the preset time period of the partial garbage collection operations.
[0067] Since the principles and details of the above steps have been explained in detail through the above embodiments, they will not be repeated here. It is worth noting that the above process can be further improved by adding other additional steps or making appropriate modifications and adjustments to improve the flexibility and efficiency of GC processing. In addition, all the operations mentioned in the above embodiments can be replaced by Figure 1 The memory controller 110 shown is implemented.
[0068] The embodiments of the present invention may be specifically implemented as an apparatus, a method or a computer program product. Accordingly, the embodiments of the present invention may take the form of an entity implemented entirely by hardware, an entity implemented entirely by software (including firmware, resident software, microcode, etc.), or an entity combining software and hardware aspects, which may be collectively referred to as a "module" or "system". In addition, the embodiments of the present invention may take the form of a computer program product embodied in any tangible expression medium, and the medium has a computer-usable program code embodied in the medium. In terms of hardware, the present invention may be implemented by applying any of the following technologies or related combinations: separate operating logic of logic gates capable of executing logic functions based on data signals, and an application specific integrated circuit (ASIC), a programmable gate array (PGA) or a field programmable gate array (FPGA) with appropriate combinational logic.
[0069] The flowcharts and block diagrams illustrate the architecture, functionality, and operation of the systems, methods, and computer program products of various possible implementations of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, segment, or portion of program code, including one or more executable instructions, to implement a specific logic function. It should also be noted that each block in the block diagram and / or flowchart, as well as combinations of blocks in the block diagram and / or flowchart, can be implemented by a special-purpose hardware-based system, or a combination of special hardware and computer program instructions. These computer program instructions can be stored in a readable computer medium to instruct a computer or other programmable data processing device to operate in a specific manner so that the instructions stored in the readable computer medium generate functions / operations specified in the blocks or combinations of blocks in the flowchart and / or block diagram.
[0070] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A method for managing garbage collection operations on a flash memory, comprising: Splitting a garbage collection operation into multiple partial garbage collection operations; Determining a preset time period for a portion of the garbage collection operation for each partial garbage collection operation; Determining a portion of the garbage collection intensity based on at least one base adjustment factor and an amplification factor; determining the basic adjustment factor according to a type of one or more source blocks corresponding to the garbage collection operation; determining the amplification factor based on a percentage of invalid pages in the one or more source blocks corresponding to the garbage collection operation; as well as The partial garbage collection operations are performed according to the partial garbage collection intensity and the preset time period of the partial garbage collection operation.
2. The method according to claim 1, characterized in that The steps to determine the amplification factor include: When determining the amplification factor, a source block whose valid page data has been partially moved to a target block in a previous garbage collection operation is excluded; Calculating an average value of percentages of invalid pages in one or more source blocks whose valid pages data were not partially moved to the target block in the last garbage collection operation; as well as The amplification factor is determined according to a reciprocal of an average value of percentages of invalid pages in the one or more source blocks whose valid pages data are not partially moved to the target block in the last garbage collection operation.
3. The method according to claim 1, characterized in that The steps to determine the amplification factor include: When determining the amplification factor in the case of performing a wear-leveling operation or handling a read-disturbance, a lower bound for setting the amplification factor is increased.
4. The method according to claim 1, characterized in that The steps to determine the basic adjustment factor include: The basic adjustment factor is determined according to an expected number of spare blocks that are expected to be obtained after the garbage collection operation is completed.
5. The method according to claim 4, characterized in that The steps to determine the basic adjustment factor include: If the one or more source blocks corresponding to the garbage collection operation and the one or more target blocks corresponding to the garbage collection operation are of the same type, setting the basic adjustment factor to 1; as well as If the one or more source blocks corresponding to the garbage collection operation and the one or more target blocks corresponding to the garbage collection operation are of different types, the basic adjustment factor is set to the reciprocal of an expected number of spare blocks expected to be obtained after the garbage collection operation is completed.
6. The method according to claim 1, characterized in that Also includes: If a number of spare blocks in the flash memory is less than a low spare block threshold, determining a low spare block status adjustment factor as (1+k*LOS), where k is greater than zero and LOS is the difference between the number of spare blocks in the flash memory and the low spare block threshold; as well as The partial garbage collection intensity is determined according to the basic adjustment factor, the amplification factor and the low spare block status adjustment factor.
7. The method according to claim 1, characterized in that Also includes: Splitting a first garbage collection operation into a plurality of first partial garbage collection operations, and splitting a second garbage collection operation into a plurality of second partial garbage collection operations, wherein the first garbage collection operation and the second garbage collection operation are of different types; Determining a first portion of garbage collection intensity and a second portion of garbage collection intensity according to at least one mixed mode basic adjustment factor and a mixed mode amplification factor; as well as The first part of garbage collection operations are performed according to the first part of garbage collection intensity and the preset time period of the part of garbage collection operations, and the second part of garbage collection operations are performed according to the second part of garbage collection intensity and the preset time period of the part of garbage collection operations.
8. The method according to claim 7, characterized in that Also includes: The hybrid mode basic adjustment factor is determined according to the sum of an expected number of spare blocks expected to be obtained after completing the first garbage collection operation a predetermined number of times and an expected number of spare blocks expected to be obtained after completing the second garbage collection operation once.
9. The method according to claim 7, characterized in that Also includes: A lower bound of the hybrid mode amplification factor is set based on the sum of an expected number of spare blocks expected to be obtained after completing the first garbage collection operation a predetermined number of times and an expected number of spare blocks expected to be obtained after completing the second garbage collection operation once.
10. A memory controller for controlling a flash memory and managing garbage collection operations on the flash memory in a flash memory, comprising: a storage unit for storing information and program codes; as well as A processing unit, configured to use the program code to: Splitting a garbage collection operation into multiple partial garbage collection operations; Determining a preset time period for a portion of the garbage collection operation for each partial garbage collection operation; Determining a portion of the garbage collection intensity based on at least one base adjustment factor and an amplification factor; determining the basic adjustment factor according to a type of one or more source blocks corresponding to the garbage collection operation; determining the amplification factor based on a percentage of invalid pages in the one or more source blocks corresponding to the garbage collection operation; as well as The partial garbage collection operations are performed according to the partial garbage collection intensity and the preset time period of the partial garbage collection operation.
11. The memory controller according to claim 10, wherein: The processing unit is used to perform: When determining the amplification factor, a source block whose valid page data has been partially moved to a target block in a previous garbage collection operation is excluded; Calculating an average value of percentages of invalid pages in one or more source blocks whose valid pages data were not partially moved to the target block in the last garbage collection operation; as well as The amplification factor is determined according to a reciprocal of an average value of percentages of invalid pages in the one or more source blocks whose valid pages data are not partially moved to the target block in the last garbage collection operation.
12. The memory controller according to claim 10, wherein: The processing unit is used to perform: When determining the amplification factor in the case of performing a wear-leveling operation or handling a read-disturbance, a lower bound for setting the amplification factor is increased.
13. The memory controller according to claim 10, wherein: The processing unit is used to perform: The basic adjustment factor is determined according to an expected number of spare blocks that are expected to be obtained after the garbage collection operation is completed.
14. The memory controller according to claim 13, wherein: The processing unit is used to perform: If the one or more source blocks corresponding to the garbage collection operation and the one or more target blocks corresponding to the garbage collection operation are of the same type, setting the basic adjustment factor to 1; as well as If the one or more source blocks corresponding to the garbage collection operation and the one or more target blocks corresponding to the garbage collection operation are of different types, the basic adjustment factor is set to the reciprocal of an expected number of spare blocks expected to be obtained after the garbage collection operation is completed.
15. The memory controller according to claim 10, wherein: The processing unit is used to perform: If a number of spare blocks in the flash memory is less than a low spare block threshold, determining a low spare block status adjustment factor as (1+k*LOS), where k is greater than zero and LOS is the difference between the number of spare blocks in the flash memory and the low spare block threshold; as well as The partial garbage collection intensity is determined according to the basic adjustment factor, the amplification factor and the low spare block status adjustment factor.
16. The memory controller according to claim 10, wherein: The processing unit is used to perform: Splitting a first garbage collection operation into a plurality of first partial garbage collection operations, and splitting a second garbage collection operation into a plurality of second partial garbage collection operations, wherein the first garbage collection operation and the second garbage collection operation are of different types; Determining a first portion of garbage collection intensity and a second portion of garbage collection intensity according to at least one mixed mode basic adjustment factor and a mixed mode amplification factor; as well as The first part of garbage collection operations are performed according to the first part of garbage collection intensity and the preset time period of the part of garbage collection operations, and the second part of garbage collection operations are performed according to the second part of garbage collection intensity and the preset time period of the part of garbage collection operations.
17. The memory controller according to claim 16, wherein: The processing unit is used to perform: The hybrid mode basic adjustment factor is determined according to the sum of an expected number of spare blocks expected to be obtained after completing the first garbage collection operation a predetermined number of times and an expected number of spare blocks expected to be obtained after completing the second garbage collection operation once.
18. The memory controller according to claim 16, wherein: The processing unit is used to perform: A lower bound of the hybrid mode amplification factor is set based on the sum of an expected number of spare blocks expected to be obtained after completing the first garbage collection operation a predetermined number of times and an expected number of spare blocks expected to be obtained after completing the second garbage collection operation once.
19. A storage system comprising: a flash memory; and A memory controller for controlling the flash memory and managing garbage collection operations on the flash memory, wherein the memory controller is used to: Splitting a garbage collection operation into multiple partial garbage collection operations; Determining a preset time period for a portion of the garbage collection operation for each partial garbage collection operation; Determining a portion of the garbage collection intensity based on at least one base adjustment factor and an amplification factor; determining the basic adjustment factor according to a type of one or more source blocks corresponding to the garbage collection operation; determining the amplification factor based on a percentage of invalid pages in the one or more source blocks corresponding to the garbage collection operation; as well as The partial garbage collection operations are performed according to the partial garbage collection intensity and the preset time period of the partial garbage collection operation.
Citation Information
Cited By
Memory control method and storage device
CN122111883A
