Data storage device and timeout avoidance method for forced garbage collection
By implementing a timeout avoidance method for forced garbage collection in the controller of the data storage device, the problem of garbage collection failing to complete after a sudden power outage is solved, the forced garbage collection timeout is prevented, and the normal operation during the power-on phase is ensured.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 深圳市欣芯半导体有限公司
- Filing Date
- 2024-12-31
- Publication Date
- 2026-06-30
AI Technical Summary
When the data storage device suddenly loses power, the power outage during the garbage collection process prevents the garbage collection blocks from being completed, resulting in blank blocks being occupied. Consequently, the system enters the forced garbage collection phase during the power-on phase and then times out.
By implementing a timeout avoidance method for forced garbage collection in the controller, the number of blank blocks and whether there are garbage collection blocks after a power outage are determined. The host data write buffer block is marked as a garbage collection block to avoid the garbage collection failure caused by a power outage, thus preventing forced garbage collection from timeout.
After a power outage, the host data is written to the buffer block as a garbage collection block, which avoids the inability of garbage collection to be completed due to power outage, prevents the continuous reduction of blank blocks and forced garbage collection timeout, and ensures that the power-on phase proceeds normally.
Smart Images

Figure CN122309387A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a mandatory waste collection technology, and more particularly to a data storage device and a method for avoiding timeouts in mandatory waste collection. Background Technology
[0002] Currently, the spare area of flash memory has two blank blocks: a host data write buffer and a garbage collection block to receive host write data and garbage collection (GC) write data. The main purpose of garbage collection is to concentrate scattered valid data to free up blank blocks. In the event of a sudden power-off recovery (SPOR), due to time constraints, the power-on phase (build link) will only rebuild the host data write buffer. Therefore, if the sudden power-off occurs during garbage collection, the garbage collection block will be discarded during the power-on phase. However, since the original blocks of the garbage collected data still exist, there is no data loss. But the act of discarding the garbage collection block will cause insufficient time to complete garbage collection, resulting in blank blocks being continuously occupied by host writes. This necessitates a forced garbage collection (Force GC) during the power-on phase. Forced garbage collection will complete one round of garbage collection to free up enough blank blocks before leaving the power-on phase. However, if forced garbage collection exceeds a certain time, it will be judged as a timeout. Summary of the Invention
[0003] This invention provides a data storage device and a method for avoiding timeouts in forced garbage collection. This method allows previously collected data to be recovered within the timeout period after power-on even if the data storage device is suddenly interrupted by a power outage, thus avoiding the need for forced garbage collection and timeouts in the end.
[0004] The data storage device provided by this invention includes a controller and non-volatile memory. The non-volatile memory is used to store multiple instructions and includes a system area, a data area, and a spare area. The spare area includes multiple blocks, including blank blocks, host data write buffer blocks, and garbage collection blocks. The controller is coupled to the non-volatile memory and is used to execute multiple instructions to implement a timeout avoidance method for forced garbage collection, including: determining that the number of blank blocks is lower than a threshold; determining that there are no garbage collection blocks after a sudden power outage; and marking the host data write buffer block as both a garbage collection block and a host data write buffer block.
[0005] The forced garbage collection timeout avoidance method provided by this invention is applicable to a data storage device, wherein the data storage device includes a controller and non-volatile memory, the non-volatile memory includes a system area, a data area and a spare area, the spare area includes multiple blocks, the multiple blocks include blank blocks, host data write buffer blocks and garbage collection blocks, and the forced garbage collection timeout avoidance method includes: determining that the number of blank blocks is lower than a threshold; determining that there are no garbage collection blocks after a sudden power outage and recovery; and marking the host data write buffer block as both a garbage collection block and a host data write buffer block.
[0006] In one embodiment of the present invention, the threshold is 5.
[0007] In one embodiment of the invention, the time limit for forced garbage collection is 600 milliseconds.
[0008] In one embodiment of the present invention, a host data write buffer block is used to receive host-written data.
[0009] In one embodiment of the present invention, the absence of a garbage collection block after a sudden power outage and subsequent recovery is either due to the absence of a garbage collection block during the power-on phase of forced garbage collection or the discarding of a garbage collection block upon sudden power outage and subsequent recovery.
[0010] Because the host data write buffer block is simultaneously a garbage collection block and a host data write buffer block, this invention can prevent power outages from causing garbage collection to fail, resulting in a continuous decrease in blank blocks, and prevent timeouts during the forced garbage collection phase after power-on.
[0011] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0012] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings, wherein:
[0013] Figure 1 This is a system block diagram of a data storage device provided in an embodiment of the present invention;
[0014] Figure 2 This is a system block diagram of a controller provided in an embodiment of the present invention;
[0015] Figure 3 This is a flowchart of a method for avoiding timeouts in mandatory waste collection according to an embodiment of the present invention. Detailed Implementation
[0016] This invention is described in particular by way of the following examples, which are merely illustrative. Various modifications and refinements can be made by those skilled in the art without departing from the spirit and scope of this disclosure. Therefore, the scope of protection of this disclosure is determined by the appended claims. Throughout this specification and the claims, unless explicitly stated otherwise, the words “a” and “described” include a description comprising “a or at least one” element or component. Furthermore, as used herein, the singular article also includes a description of multiple elements or components unless clearly excluded from the specific context. Moreover, when applied in this description and throughout the claims below, unless explicitly stated otherwise, “in which” may include both “in which” and “therein”. The terms used throughout this specification and the claims, unless otherwise specified, generally have their ordinary meaning in the art, in the disclosure, and in the specific context. Certain terms used to describe this invention will be discussed below or elsewhere in this specification to provide additional guidance to those skilled in the art in describing this invention. Examples found anywhere in this specification, including any instance of any terminology used in the discussion herein, are merely illustrative and do not limit the scope or meaning of the invention or any of the illustrative terms. Similarly, the invention is not limited to the various embodiments set forth in this specification.
[0017] The terms “substantially,” “around,” “about,” or “approximately” as used herein should generally mean within 20%, preferably within 10%, of a given value or range. Furthermore, quantities provided herein may be approximate, thus meaning that unless otherwise stated, they may be expressed using the terms “about,” “approximately,” or “approximately.” When a quantity, concentration, or other numerical value or parameter has a specified range, preferred range, or lists upper and lower ideal values, it should be considered as specifically disclosing all ranges consisting of pairs of numbers or ideal values of any upper and lower limits, regardless of whether such ranges are separately disclosed. For example, if a range of length X cm to Y cm is disclosed, it should be considered as disclosing a length of H cm, where H can be any real number between X and Y.
[0018] Furthermore, the use of the terms "coupled" or "connected" herein includes any direct and indirect electrical connection. For example, if the text describes a first device as electrically coupled to a second device, it means that the first device can be directly connected to the second device, or indirectly connected to the second device through other devices or connection means. Additionally, regarding the description of the transmission or provision of electrical signals, those skilled in the art will understand that attenuation or other non-ideal variations may occur during the transmission of electrical signals. However, unless otherwise specified, the source and receiver of the transmitted or provided electrical signal should be considered as essentially the same signal. For example, if an electrical signal S is transmitted (or provided) from terminal A of an electronic circuit to terminal B of the same electronic circuit, a voltage drop may occur across the source and drain terminals of a transistor switch and / or possible stray capacitances. However, unless the purpose of this design is to intentionally utilize the attenuation or other non-ideal variations that occur during transmission (or provision) to achieve certain specific technical effects, the electrical signal S at terminals A and B of the electronic circuit should be considered as essentially the same signal.
[0019] It is understood that terms such as “comprising,” “including,” “having,” “containing,” “involving,” etc., as used herein are open-ended, meaning they include but are not limited to. Furthermore, no embodiment or claim of the present invention is required to achieve all the objects, advantages, or features disclosed herein. In addition, the abstract and headings are merely for assisting in patent document searching and are not intended to limit the scope of the claims.
[0020] Please see Figure 1 and 2The figures shown are system block diagrams of a data storage device and a controller provided in an embodiment of the present invention. The data storage device 1 provided in this embodiment includes non-volatile memory 2 and a controller 3. The controller 3 includes a host interface 31, a cache memory 32, a read-only memory 33, a microprocessor 34, and a memory interface 35, and is coupled to each other via a bus 36. The controller 3 is coupled to a host 4 via the host interface 31 and to the non-volatile memory 2 via the memory interface 35. The read-only memory 33 includes multiple instructions, and the memory interface 35 includes an encoder 351 and a decoder 352. The non-volatile memory 2 includes a system area 21, a data area 22, and... The spare area 23, system area 21, data area 22, and spare area 23 each include multiple blocks 231. The multiple blocks 231 in spare area 23 include blank blocks 2311, host data write buffer blocks 2312, and garbage collection blocks 2313. Controller 3 is coupled to non-volatile memory 2 and executes multiple instructions to implement a timeout avoidance method for forced garbage collection. The host data write buffer block 2312 receives host write data, and the garbage collection block 2313 consolidates the scattered valid data in multiple blocks of non-volatile memory 2 to free up blank blocks. Furthermore, data storage device 1 preferably uses a physical interface such as Peripheral Component Interconnect Express (PCI-E) or Serial Advanced Technology Attachment (SATA) for high-speed transmission.
[0021] According to one embodiment of the present invention, the data storage device 1 can be a flash memory, which can adopt a Universal Serial Bus (USB), Serial Advanced Technology Attachment (SATA), Parallel Advanced Technology Attachment (PATA), Peripheral Component Interconnect (PCI) physical interface or a memory such as a memory card, USB flash device, solid-state drive (SSD), or embedded multimedia card (eMMC) communication protocol using USB, Non-Volatile Memory Express (NVME), Advanced Host Controller Interface (AHCI), or Small Computer System Interface (SCSI).
[0022] According to one embodiment of the present invention, the non-volatile memory 2 is, for example, but not limited to, NAND flash memory, and the type of NAND flash memory is, for example, but not limited to, single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc.
[0023] According to an embodiment of the present invention, the controller 3, such as but not limited to a processor, or including a microprocessor, is used to execute the writing, reading, erasing and programming of non-volatile memory 2 according to the commands of the host terminal, such as the host 4, and to automatically execute multiple instructions to implement the timeout avoidance method for forced garbage collection of data storage device 1 provided in the embodiment of the present invention.
[0024] Please see Figure 3 The diagram shows a flowchart of a forced garbage collection timeout avoidance method provided in an embodiment of the present invention. The forced garbage collection timeout avoidance method of the data storage device 1 provided in this embodiment is executed by the controller 3 and includes the following steps, wherein the time limit for forced garbage collection is 600 milliseconds.
[0025] Step S1: Determine whether the number of blank blocks 2311 in the spare area 23 is lower than a threshold, where the threshold is 5. If the determination is yes, proceed to step S3; if the determination is no, return to step S1.
[0026] Step S3: Determine whether garbage collection block 2313 is missing after a sudden power outage. If yes, proceed to step S5; if no, return to step S1. Specifically, the absence of garbage collection block 2313 after a sudden power outage means that garbage collection block 2313 was not present during the power-on phase of forced garbage collection, or that garbage collection block 2313 was discarded upon power recovery from a sudden power outage. This indicates that the garbage collection operation was completed before the sudden power outage or that garbage collection block 2313 was directly discarded after the sudden power outage.
[0027] Step S5: Mark host data write buffer block 2312 as both garbage collection block 2313 and host data write buffer block 2312. Specifically, when no sudden power failure occurs, host data write buffer block 2312 in the spare area 23 is used to receive host write data, and garbage collection block 2313 is used to collect data from multiple blocks in data area 22 to free up useful blocks as blank blocks 2311. When a sudden power failure occurs, host data write buffer block 2312 in the spare area 23 is still used to receive host write data, and is simultaneously marked as garbage collection block 2313 to collect data from multiple blocks in non-volatile memory 2. This avoids forced garbage collection during power-on, thus preventing timeouts in creating blank blocks 2311 during forced garbage collection.
[0028] In summary, the data storage device and its forced garbage collection timeout avoidance method provided by the present invention, because the host data write buffer block is marked as both a garbage collection block and a host data write buffer block, can prevent power failure from causing garbage collection to fail, resulting in a continuous decrease in blank blocks, and prevent the forced garbage collection from timeout during the power-on phase.
[0029] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the methods and techniques disclosed above without departing from the scope of the present invention to create equivalent embodiments. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A method for avoiding overdue mandatory waste collection, characterized in that, A data storage device is applicable, wherein the data storage device includes a controller and a non-volatile memory, the non-volatile memory including a system area, a data area, and a spare area, the spare area including multiple blocks, the multiple blocks including a blank block, a host data write buffer block, and a garbage collection block, the forced garbage collection timeout avoidance method including: The number of blank blocks is determined to be below a threshold. Determine that the garbage collection block does not exist after a sudden power outage and subsequent recovery; and The host data write buffer is marked as both the garbage collection block and the host data write buffer.
2. The method for avoiding timeouts in mandatory waste collection as described in claim 1, characterized in that, The threshold is 5.
3. The method for avoiding timeouts in mandatory waste collection as described in claim 1, characterized in that, The time limit for mandatory garbage collection is 600 milliseconds.
4. The method for avoiding timeouts in mandatory waste collection as described in claim 1, characterized in that, The host data write buffer is used to receive data written by a host.
5. The method for avoiding timeouts in mandatory waste collection as described in claim 1, characterized in that, The absence of the garbage collection block after a sudden power outage means either the garbage collection block is absent during the power-on phase of the forced garbage collection or the garbage collection block is discarded upon the power outage recovery.
6. A data storage device, characterized in that, include: A non-volatile memory for storing multiple instructions, including a system area, a data area and a spare area, wherein the spare area includes multiple blocks, including a blank block, a host data write buffer block and a garbage collection block; as well as A controller, coupled to the non-volatile memory, is configured to execute the plurality of instructions to implement a timeout avoidance method for forced garbage collection, including: The number of blank blocks is determined to be below a threshold. Determine that the garbage collection block does not exist after a sudden power outage and subsequent recovery; and The host data write buffer is marked as both the garbage collection block and the host data write buffer.
7. The data storage device as described in claim 6, characterized in that, The threshold is 5.
8. The data storage device as described in claim 6, characterized in that, The time limit for mandatory garbage collection is 600 milliseconds.
9. The data storage device as claimed in claim 6, characterized in that, The host data write buffer is used to receive data written by a host.
10. The data storage device as claimed in claim 6, characterized in that, The absence of the garbage collection block after a sudden power outage means either the garbage collection block is absent during the power-on phase of the forced garbage collection or the garbage collection block is discarded upon the power outage recovery.