CN115599706B - Garbage recycling method of data storage device and data storage device - Google Patents

Garbage recycling method of data storage device and data storage device Download PDF

Info

Publication number
CN115599706B
CN115599706B CN202211592389.4A CN202211592389A CN115599706B CN 115599706 B CN115599706 B CN 115599706B CN 202211592389 A CN202211592389 A CN 202211592389A CN 115599706 B CN115599706 B CN 115599706B
Authority
CN
China
Prior art keywords
flash memory
memory block
type
recovered
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211592389.4A
Other languages
Chinese (zh)
Other versions
CN115599706A (en
Inventor
叶中杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hefei Kangxinwei Storage Technology Co Ltd
Original Assignee
Hefei Kangxinwei Storage Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hefei Kangxinwei Storage Technology Co Ltd filed Critical Hefei Kangxinwei Storage Technology Co Ltd
Priority to CN202211592389.4A priority Critical patent/CN115599706B/en
Publication of CN115599706A publication Critical patent/CN115599706A/en
Application granted granted Critical
Publication of CN115599706B publication Critical patent/CN115599706B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0253Garbage collection, i.e. reclamation of unreferenced memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The invention discloses a garbage recycling method of a data storage device and the data storage device, and belongs to the technical field of storage. The garbage recycling and processing method comprises the following steps: acquiring the number of idle flash memory blocks, and judging whether the number of the idle flash memory blocks is smaller than a first threshold value or not; when the number of the idle flash memory blocks is larger than or equal to the first threshold value, judging whether the ratio of the effective data in the first type of flash memory blocks to be recovered and the second type of flash memory blocks to be recovered is smaller than a second threshold value; when the ratio of the effective data in the first type of flash memory block to be recovered and the effective data in the second type of flash memory block to be recovered is smaller than a second threshold value, performing garbage recovery; otherwise, copying the data in the flash memory page with the bit reversal in the first type of flash memory block to be recovered to a backup flash memory block. The garbage recycling method of the data storage equipment can improve the garbage recycling efficiency and prolong the service life of the flash memory block.

Description

Garbage recycling method of data storage device and data storage device
Technical Field
The invention belongs to the technical field of storage, and particularly relates to a garbage recycling method of a data storage device and the data storage device.
Background
A Solid State Disk (SSD) is a computer storage device based on a persistent memory, such as a flash memory. The intelligent control system has the advantages of high reading and writing speed, low power consumption, no noise, vibration resistance, low heat, small volume and large working range, and is widely applied to the fields of military affairs, vehicle-mounted, industrial control, video monitoring, network terminals, electric power, medical treatment, aviation and the like, navigation equipment and the like.
In a part of flash memory blocks of the solid state disk, when the data stored in the flash memory pages reaches the deadline, the data can have bit flipping, and the data with the bit flipping can be corrected. Uncorrectable errors occur when the data bits in a flash page flip too much or too long. When the flash memory blocks are garbage collected, when the effective data in the flash memory blocks are too much, the garbage collection efficiency is extremely low, and a large amount of time is consumed.
Disclosure of Invention
The invention aims to provide a garbage recycling method of a data storage device and the data storage device.
In order to solve the technical problems, the invention is realized by the following technical scheme:
the invention provides a garbage recycling method of data storage equipment, which at least comprises the following steps:
acquiring the number of idle flash memory blocks, and judging whether the number of the idle flash memory blocks is smaller than a first threshold value or not;
when the number of the idle flash memory blocks is larger than or equal to the first threshold value, acquiring a first type of flash memory blocks to be recovered and a second type of flash memory blocks to be recovered, wherein the first type of flash memory blocks to be recovered is flash memory blocks to be recovered, which have bit reversal caused by the time limit of data storage and need garbage recovery, and the second type of flash memory blocks is flash memory blocks to be recovered, which need garbage recovery because the data on the flash memory blocks become invalid data;
judging whether the ratio of the effective data in the first type of flash memory block to be recovered and the effective data in the second type of flash memory block to be recovered is smaller than a second threshold value;
when the ratio of the effective data in the first type to-be-recovered flash memory block and the second type to-be-recovered flash memory block is smaller than the second threshold value, performing garbage recovery;
when the ratio of the effective data in the first type of flash memory block to be recovered and the effective data in the second type of flash memory block to be recovered is larger than or equal to a second threshold value, copying the data in the flash memory page with the bit reversal in the first type of flash memory block to be recovered to a backup flash memory block.
In an embodiment of the present invention, when the number of the idle flash memory blocks is smaller than the first threshold, performing forced garbage collection.
In an embodiment of the present invention, when the first type of flash memory block to be recycled is obtained, one or more first type of flash memory blocks to be recycled are obtained.
In an embodiment of the present invention, when acquiring the second type of to-be-recycled flash memory block, one or more second type of to-be-recycled flash memory blocks with least valid data are acquired.
In an embodiment of the present invention, the backup flash memory block is a flash memory block in which the storage unit in the flash memory page is in a single-layer flash memory storage mode.
In an embodiment of the present invention, after copying data in a flash memory page with a bit flip in the first type of flash memory block to be recovered to a backup flash memory block, the garbage recovery processing method further includes the following steps: and establishing a physical-to-physical address mapping table, and storing the physical address of the backed-up flash memory block in the backup flash memory block.
In an embodiment of the present invention, the number of backup flash blocks is greater than or equal to 2.
In an embodiment of the present invention, the garbage recycling method further includes the following steps: and when one backup flash memory block is fully written, performing garbage recovery processing on the backup flash memory block corresponding to the backup flash memory block.
In an embodiment of the present invention, when performing garbage collection processing on the backed-up flash memory block, another backup flash memory block is used to back up a flash memory page with a bit reversal in the first type of flash memory block to be collected.
The present invention also provides a data storage device comprising:
a cache unit storing program instructions;
and the control unit runs the program instructions to realize the data writing method of the data storage device.
As described above, the garbage collection processing method of the data storage device and the data storage device provided by the present invention first determine the necessity of garbage collection, and perform forced garbage collection when the number of idle flash memory blocks is too small. When the number of idle flash memory blocks is sufficient, if the garbage recovery efficiency is not high, the flash memory pages in the flash memory blocks to be recovered, which have bit reversal, are backed up. Thereby increasing the efficiency of garbage recovery and simultaneously prolonging the service life of the flash memory block.
Of course, it is not necessary for any product in which the invention is practiced to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic structural diagram of a data storage device.
FIG. 2 is a schematic diagram of a memory cell structure.
FIG. 3 is a diagram of a structure of a linked list of flash blocks.
Fig. 4 is a flowchart of a garbage collection processing method of a data storage device.
Fig. 5 is a block diagram of a computer-readable storage medium.
Fig. 6 is a schematic block diagram of a structure of an electronic device.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to FIG. 1, a data storage device 20 is described herein that includes a novel architecture for controlling a mass storage module that includes flash memory chips. The entire data storage device 20 is shown in a highly schematic form in fig. 1. As with the other block diagrams herein, the elements shown in FIG. 1 are conceptual in nature, illustrating the nature of the interrelationship between these functional blocks and are not intended to represent an actual physical circuit level implementation.
Referring to fig. 1, the present application provides an electronic device, which includes a host 10 and a data storage device 20. Wherein the host 10 and the data storage device 20 may be implemented as separate chips, modules, or devices, or may be included in a single device. In this embodiment, the data storage device 20 may be an integrated unitary storage device, which is then connected to the host 10. However, the present disclosure is not limited to this example. That is, in another embodiment, the host 10 and the data storage device 20 may be integrated into a single device.
Referring to fig. 1, in an embodiment of the present invention, the host 10 is formed by, for example, a personal computer, a CPU core, or a server connected to a network. The user sends a request to the electronic device 20 at the application level of the operating system of the host 10, the file system 101 converts the read-write request into corresponding read-write and other instruction data conforming to the protocol through the bottom driver 102, and after the data storage device 20 receives the instruction data through the interface, the instruction data is executed through internal calculation and processing logic, and a corresponding reply is fed back to the host 10.
Referring to fig. 1, in an embodiment of the invention, the data storage device 20 is a storage device using a semiconductor flash memory as a medium, such as an Embedded multimedia memory Card (eMMC). And in this embodiment the data storage device 20 comprises a front end layer 21, an intermediate layer 22 and a back end layer 23. The front-end Layer 21 includes a control unit 211 and a cache unit 212, where the cache unit 212 is, for example, a Random Access Memory (RAM), the middle Layer 22 is, for example, a Flash Translation Layer (FTL), and the back-end Layer 23 includes a plurality of Flash memory blocks 231. After the data storage device 20 receives the instruction data sent by the host 10, the data is verified, the related data is stored in the cache unit 212 first, the intermediate layer 22 allocates a flash memory address to each logical data block, after the data has a certain number, the intermediate layer 22 sends a flash memory writing request to the back-end layer 23, and the back-end layer 23 writes the data in the cache unit 212 into the corresponding flash memory block 231 or reads the data in the corresponding flash memory block 231 according to the instruction data request.
Referring to fig. 1, in an embodiment of the invention, the intermediate layer 22 includes an address translation unit 222 for performing the translation or mapping of the logical data block to the flash physical space. Meanwhile, the intermediate layer 22 is also provided with a garbage collection unit 223 for erasing invalid data, the flash memory block 231 cannot be overwritten, as user data is continuously written, garbage data (invalid data) can be generated in the flash memory block 231, the garbage data can occupy the space of the flash memory block 231, when the available space of the flash memory block 231 is insufficient, the garbage collection unit 223 needs to collect garbage, that is, the valid data on a plurality of flash memory blocks 231 is moved out and written into a new flash memory block 231, and then the previous flash memory blocks 231 are erased to obtain the available flash memory blocks. In addition, the middle layer 22 includes a wear leveling unit 208 for ensuring balanced writing of each flash block 231, and a bad block management unit 205 for managing bad blocks.
Referring to fig. 1 and fig. 2, in an embodiment of the present invention, in the back-end layer 23, a plurality of Channels (CH) are disposed on the bottom layer of the data storage device 20, and fig. 2 illustrates an embodiment of a channel 0. And inside each channel there are multiple parallel Logical Units (LUs). In the present embodiment, two logic cells, i.e., logic cell 0 and logic cell 1, are provided in each channel. In other embodiments, multiple logic units may be disposed in each channel. Each logic unit includes a plurality of planes, a Page Register (Page Register) and a Cache Register (Cache Register), wherein the Page Register and the Cache Register store data to be written into a physical storage unit or read out from the storage unit. In the present embodiment, two planes, i.e., a plane 0 and a plane 1, are provided in each logic cell. In other embodiments, multiple planes may be provided in each logic cell. In each plane, a page register and a cache register are provided. In each plane, a plurality of flash blocks (blocks) 231 are provided, and a plurality of flash pages (pages) are provided in each flash block 231, each flash Page further including a plurality of memory cells therein. In the present embodiment, 990 flash blocks, for example, are provided in each plane, and 1152 flash pages, for example, are provided in each flash block. In this embodiment, each memory cell is, for example, a floating gate transistor. Where the address of the memory where data actually exists is referred to as a physical address, the control unit 211 uses a logical address, which corresponds to the physical address. The intermediate layer 22 may be utilized to manage physical and logical addresses. And the physical address and the logical address may be stored in the form of a mapping table. The memory Cell data blocks in the flash memory block 231 may be configured into different storage modes according to actual requirements, and the memory cells include, for example, an SLC (Single-Level Cell,1 bit/Cell) storage mode and an XLC storage mode. The SLC storage mode means that only one bit of data is stored in each character string cell (cell) of the flash block 231, and the memory cells of the SLC storage mode have a high erase count, for example, 50000 to 100000 times. The XLC storage mode refers to that each character string Cell (Cell) in the flash block 231 stores a plurality of bits of data, and includes an MLC (Multi-Level Cell,2 bit/Cell) storage mode, a TLC (triple-Level Cell,3 bit/Cell) storage mode, and a QLC (Quad-Level Cell,4 bit/Cell) storage mode, and the memory cells of the XLC storage mode have a lower erase count, for example, 500 to 10000 times. The performance of the SLC storage mode memory cell is more stable than the XLC storage mode memory cell. When storing data, the data is written in memory cells of the XLC storage mode, and more important data is stored in memory cells of the SLC storage mode.
Referring to fig. 3, in an embodiment of the present invention, the flash memory blocks may be classified according to the purpose of the flash memory block class, and the flash memory blocks are stored in a linked list form to form a flash memory block linked list 230, so as to prevent loss due to power failure. In the application, the flash memory blocks are divided into a flash memory block linked list for storing host data in an XLC storage mode, a flash memory block linked list for storing host data in an SLC storage mode, a flash memory block linked list for storing a mapping table from a logical address to a physical address, and an idle flash memory block linked list, and the number of the flash memory blocks in each linked list is set according to requirements. The host data storage method comprises the steps that a flash memory block chain table for storing host data in an XLC storage mode and a flash memory block in a flash memory block chain table for storing the host data in an SLC storage mode are used for storing data written by a host, a flash memory block in the flash memory block chain table for storing a mapping table from a logical address to a physical address is used for storing a mapping table from the logical address to the physical address, and a flash memory block in an idle flash memory block chain table is used as a reserved space and used for storing transferred effective data during garbage collection.
Referring to fig. 1 to 4, in an embodiment of the present invention, a garbage collection processing method of a data storage device is provided, the garbage collection processing method of the data storage device can be stored in a cache unit, and a control unit runs a program instruction to implement the garbage collection processing method of the data storage device stored in the cache unit. The garbage recycling processing method of the data storage device comprises the following steps:
and S110, acquiring the number of idle flash blocks.
S111, judging whether the number of the idle flash memory blocks is smaller than a first threshold value, executing the step S112 when the number of the idle flash memory blocks is smaller than the first threshold value, and executing the step S113 when the number of the idle flash memory blocks is larger than or equal to the first threshold value.
And S112, performing forced garbage collection.
S113, acquiring a first type of flash block to be recovered due to bit flipping and a second type of flash block to be recovered with invalid data.
S114, judging whether the ratio of the effective data in the first type of flash memory block to be recovered and the second type of flash memory block to be recovered is smaller than a second threshold value, if the ratio of the effective data in the first type of flash memory block to be recovered and the second type of flash memory block to be recovered is smaller than the second threshold value, executing a step S115, and if the ratio of the effective data in the first type of flash memory block to be recovered and the second type of flash memory block to be recovered is larger than or equal to the second threshold value, executing a step S116.
And S115, carrying out garbage collection.
And S116, copying the data in the flash memory page with the bit reversal in the first type of flash memory block to be recovered to the backup flash memory block.
Referring to fig. 4, in an embodiment of the present invention, in the garbage collection processing method, the number of idle flash blocks is first determined from step S111 to step S112. At this time, the number of the flash memory blocks in the idle flash memory blocks can be checked to obtain the number of the idle flash memory blocks. When the number of idle flash memory blocks is smaller than the first threshold, it indicates that the number of available idle flash memory blocks is too small, and forced garbage collection must be performed immediately. At this time, the flash memory blocks with more invalid data in the flash memory blocks can be selected for garbage collection, so that more flash memory blocks are released as idle flash memory blocks. Or selecting the flash memory blocks with bit reversal to perform garbage collection so as to release more flash memory blocks as idle flash memory blocks. The number of the first threshold values can be flexibly set according to the working state of the data storage device. In this embodiment, the first threshold is, for example, 4 to 10, and specifically, for example, 4. Namely, when the number of the idle flash memory blocks is less than 4, the garbage is forcibly recycled so as to avoid using no idle flash memory blocks when the garbage is recycled.
Referring to fig. 4, in an embodiment of the invention, as shown in steps S113 to S116, when the number of idle flash blocks in the data storage device exceeds a first threshold, the garbage collection is not required to be performed. In this case, when garbage collection is performed, not only the type of garbage collection but also the efficiency of garbage collection need to be considered. When the efficiency of garbage collection is too low, garbage collection may not be performed temporarily. In the application, for example, the ratio of the valid data in the flash memory block to be recovered is used to measure the efficiency of garbage recovery, the larger the ratio of the valid data in the flash memory block to be recovered is, the lower the efficiency of garbage recovery is, and the smaller the ratio of the valid data in the flash memory block to be recovered is, the higher the efficiency of garbage recovery is. The number of the flash memory blocks to be recovered is, for example, 5, and the proportion of the valid data in each flash memory block to be recovered is 20%, after garbage is recovered, one flash memory block is used for storing the valid data in the 5 flash memory blocks to be recovered, which is equivalent to releasing 4 idle flash memory blocks. At this time, the efficiency of garbage collection was 80%. Therefore, the smaller the proportion of the valid data in the flash memory block to be recovered is, the higher the garbage recovery efficiency is.
Referring to FIG. 4, in one embodiment of the present invention, there are two types of flash blocks to be recycled in the data storage device. Some flash memory pages to be recycled are caused by the fact that the storage time of data reaches the deadline, the data can be subjected to bit flipping, and at the moment, the data can be repaired. However, if the data bits in the flash memory page are flipped too much or too long, uncorrectable errors occur, so that it is necessary to garbage-collect the flash memory blocks with bit flips. In the application, a to-be-recycled flash memory block which has bit reversal caused by the fact that the data storage time reaches the deadline and needs garbage recycling is defined as a first type to-be-recycled flash memory block. When data in the flash memory block becomes invalid data after the host repeatedly writes, erases or invalidates the flash memory block in the data storage device, garbage collection needs to be performed on the flash memory block with too much invalid data and too little valid data. And defining the flash memory block to be recycled which needs garbage recycling as the second type flash memory block to be recycled because the data on the flash memory block becomes invalid data.
Referring to fig. 4, in an embodiment of the invention, in steps S113 to S116, it is further required to improve the efficiency of garbage collection during garbage collection. If the garbage collection efficiency is too low, the space of the flash memory released in each garbage collection is too small, which not only affects the speed of the host, but also affects the service life of the flash memory block.
Referring to fig. 4, in an embodiment of the present invention, garbage collection is performed on a plurality of flash memory blocks each time garbage collection is performed. And when garbage recovery is carried out each time, the quantity of the recovered first type to-be-recovered flash memory blocks and the quantity of the recovered second type to-be-recovered flash memory blocks are not limited so that the garbage recovery of the first type to-be-recovered flash memory blocks and the second type to-be-recovered flash memory blocks is realized. In this embodiment. At each line garbage collection, for example, 5 flash blocks are subjected to garbage collection, and the number of the first type flash blocks to be collected is, for example, 1, and the number of the second type flash blocks to be collected is, for example, 4. And when garbage collection is carried out each time, whether the first type of flash memory blocks to be collected can be judged, and the collected second type of flash memory blocks to be collected is one or more flash memory blocks with least effective data and most invalid data.
Referring to fig. 4, in an embodiment of the invention, in step S114, the second threshold may be set according to a requirement, for example, 10% to 40%. In the present embodiment, the second threshold value is, for example, 20%. Namely, when the ratio of the effective data in the first type of flash memory block to be recovered and the second type of flash memory block to be recovered is less than 20%, performing garbage recovery. Namely, when 1 first type of flash memory block to be recovered and 4 second type of flash memory blocks to be recovered are recovered, the quantity of valid data on the first type of flash memory block to be recovered and the second type of flash memory block to be recovered is less than the data quantity stored by one flash memory block. And when the effective data ratio of the first type to-be-recovered flash memory block and the second type to-be-recovered flash memory block is greater than or equal to 20%, copying the data in the flash memory page with the bit reversal in the first type to-be-recovered flash memory block into the backup flash memory block.
Referring to fig. 4, in an embodiment of the present invention, since the flash page with XLC storage mode is more prone to bit flipping due to the expiration of storage time than the flash page with SLC storage mode, the backup flash block is a flash block with SLC storage mode flash page, i.e. the flash block with single layer flash storage mode.
Referring to fig. 4, in an embodiment of the present invention, after data in a flash memory page with bit flipping in a first type of flash memory block to be recycled is copied to a backup flash memory block, a mapping table from a physical address to a physical address (P2P) is created and stored in the flash memory block. The backup flash memory block stores the physical address of the flash memory block where the physical address-to-physical address mapping table is located. The backup flash memory block stores the physical address of the backup flash memory block, and a plurality of backup flash memory blocks are stored in a linked list form, such as a backup flash memory block linked list. When the relevant data needs to be read, the physical address can be found through the logical address, and whether the flash memory block where the physical address is located is in the backup flash memory block linked list or not can be checked. And if the backup flash block linked list does not exist, directly reading the data stored in the physical address. If the backup flash block linked list exists, the physical address is searched in a mapping table from the physical address to the physical address, when the physical address is searched, the data stored in the physical address corresponding to the physical address is searched, and if the physical address is not searched, the data stored in the physical address is directly read.
Referring to fig. 4, the number of the backup flash memory blocks is not limited to a large number, but the number of the backup flash memory blocks is at least 2, that is, the number of the backup flash memory blocks is equal to or greater than 2. In the garbage recovery processing process, when a backup flash memory block is fully written, garbage recovery processing is performed on a backed-up flash memory block corresponding to the backup flash memory block, and garbage recovery processing is performed on the backup flash memory block at the same time. And when the backed-up flash memory blocks are subjected to garbage recovery processing, the other backup flash memory block is used for backing up the flash memory pages with bit reversal in the first type of flash memory blocks to be recovered. When a backup flash block is fully written, it indicates that the data in the backup flash block is stored in two copies, and if garbage collection processing is not performed, the waste of flash memory resources is caused by excessive backup data. After garbage recovery processing is carried out on the backup flash memory block, the backup flash memory block can be used for next backup. At least 2 backup flash blocks are required.
Referring to fig. 4, after the data in the flash memory page with bit flipping in the first type of flash memory block to be recycled is copied to the backup flash memory block, the data storage device will continue to operate. After the host repeatedly writes, erases or invalidates the flash memory blocks in the data storage device, the proportion of valid data on the first type of flash memory blocks to be recovered and the second type of flash memory blocks to be recovered is less and less. And the garbage recovery processing method is executed all the time, and when the proportion of the effective data on the second type of flash memory block to be recovered is smaller than a second threshold value, the first type of flash memory block to be recovered and the second type of flash memory block to be recovered are subjected to garbage recovery processing.
Referring to fig. 5, the embodiment further provides a computer-readable storage medium 3, where the computer-readable storage medium 3 stores computer instructions 30, and the computer instructions 30 are used for a garbage collection processing method using the data storage device. The computer readable storage medium 3 may be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system or a propagation medium. The computer-readable storage medium 3 may also include semiconductor or solid state memory, magnetic tape, a removable computer diskette, a Random Access Memory (RAM), a read-only memory (ROM), a rigid magnetic disk and an optical disk. Optical disks may include compact disk-read only memory (CD-ROM), compact disk-read/write (CD-RW), and DVD.
Referring to fig. 6, the present invention further provides an electronic device, which includes a processor 40 and a memory 50, where the memory 50 stores program instructions, and the processor 40 runs the program instructions to implement the garbage collection processing method of the data storage device. Processor 40 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; or a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component; the Memory 50 may include a Random Access Memory (RAM) and may further include a Non-Volatile Memory (Non-Volatile Memory), such as at least one disk Memory. The Memory 50 may also be an internal Memory of Random Access Memory (RAM) type, and the processor 40 and the Memory 50 may be integrated into one or more independent circuits or hardware, such as: application Specific Integrated Circuit (ASIC). Note that the computer program in the memory 50 may be implemented in the form of a software functional unit and may be stored in a computer readable storage medium when it is sold or used as a separate product. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, an electronic device, or a network device) to perform all or part of the steps of the method according to the embodiments of the present invention.
The invention provides a garbage recycling method of a data storage device, which comprises the steps of firstly obtaining the number of idle flash memory blocks and judging whether the number of the idle flash memory blocks is smaller than a first threshold value or not. When the number of idle flash memory blocks is smaller than a first threshold value, garbage recycling is forced, and the stability of the flash memory is guaranteed. When the number of the idle flash memory blocks is larger than or equal to a first threshold value, acquiring a first type of flash memory blocks to be recovered and a second type of flash memory blocks to be recovered, and judging whether the ratio of effective data in the first type of flash memory blocks to be recovered and the second type of flash memory blocks to be recovered is smaller than a second threshold value or not; and when the ratio of the effective data in the first type to-be-recovered flash memory block and the second type to-be-recovered flash memory block is smaller than a second threshold value, performing garbage recovery. When the ratio of the effective data in the first type of flash memory block to be recovered and the effective data in the second type of flash memory block to be recovered is greater than or equal to a second threshold value, copying the data in the flash memory page with the bit reversal in the first type of flash memory block to be recovered into the backup flash memory block, and improving the garbage recovery efficiency.
The embodiments of the invention disclosed above are intended merely to aid in the explanation of the invention. The examples are not intended to be exhaustive or to limit the invention to the precise forms disclosed. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the invention and the practical application, to thereby enable others skilled in the art to best utilize the invention. The invention is limited only by the claims and their full scope and equivalents.

Claims (10)

1. A garbage recycling method of a data storage device is characterized by at least comprising the following steps:
acquiring the number of idle flash memory blocks, and judging whether the number of the idle flash memory blocks is smaller than a first threshold value or not;
when the number of the idle flash memory blocks is larger than or equal to the first threshold value, acquiring a first type of flash memory blocks to be recovered and a second type of flash memory blocks to be recovered, wherein the first type of flash memory blocks to be recovered is a flash memory block to be recovered which needs garbage recovery due to bit reversal caused by the time limit of data storage, and the second type of flash memory blocks to be recovered is a flash memory block to be recovered which needs garbage recovery due to the fact that data on the flash memory blocks become invalid data;
judging whether the ratio of the effective data in the first type of flash memory block to be recovered and the effective data in the second type of flash memory block to be recovered is smaller than a second threshold value;
when the ratio of the effective data in the first type of flash memory block to be recovered and the effective data in the second type of flash memory block to be recovered is smaller than the second threshold value, performing garbage recovery;
when the ratio of the effective data in the first type of flash memory block to be recovered and the effective data in the second type of flash memory block to be recovered is larger than or equal to the second threshold value, copying the data in the flash memory page with the bit reversal in the first type of flash memory block to be recovered to a backup flash memory block.
2. The method of claim 1, wherein forced garbage collection is performed when the number of free flash blocks is less than the first threshold.
3. The method according to claim 1, wherein one or more of the first type flash blocks to be recycled are obtained when the first type flash blocks to be recycled are obtained.
4. The method according to claim 1, wherein when acquiring the second type of flash memory blocks to be recycled, one or more of the second type of flash memory blocks to be recycled with least valid data are acquired.
5. The method according to claim 1, wherein the backup flash block is a flash block in which the storage unit in the flash page is in a single-layer flash storage mode.
6. The garbage collection processing method of the data storage device according to claim 1, wherein after copying the data in the flash memory page with the bit flipping in the first type of flash memory block to be collected into the backup flash memory block, the garbage collection processing method further comprises the following steps: and establishing a physical-to-physical address mapping table, and storing the physical address of the backed-up flash memory block in the backup flash memory block.
7. A method of garbage collection processing of a data storage device according to claim 1, wherein the number of backup flash blocks is greater than or equal to 2.
8. The garbage collection processing method of claim 7, further comprising the steps of: and when one backup flash memory block is fully written, performing garbage recovery processing on the backup flash memory block corresponding to the backup flash memory block.
9. The garbage collection processing method of the data storage device according to claim 8, wherein when performing garbage collection processing on the backed up flash memory block, another backup flash memory block is used to back up a flash memory page with a bit flip in the first type flash memory block to be collected.
10. A data storage device, comprising:
a cache unit storing program instructions;
a control unit executing the program instructions to implement the data writing method of the data storage device of claim 1.
CN202211592389.4A 2022-12-13 2022-12-13 Garbage recycling method of data storage device and data storage device Active CN115599706B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211592389.4A CN115599706B (en) 2022-12-13 2022-12-13 Garbage recycling method of data storage device and data storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211592389.4A CN115599706B (en) 2022-12-13 2022-12-13 Garbage recycling method of data storage device and data storage device

Publications (2)

Publication Number Publication Date
CN115599706A CN115599706A (en) 2023-01-13
CN115599706B true CN115599706B (en) 2023-03-14

Family

ID=84853411

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211592389.4A Active CN115599706B (en) 2022-12-13 2022-12-13 Garbage recycling method of data storage device and data storage device

Country Status (1)

Country Link
CN (1) CN115599706B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116610596B (en) * 2023-07-19 2023-10-03 合肥康芯威存储技术有限公司 Memory device and data processing method thereof
CN117033268B (en) * 2023-10-09 2024-02-09 苏州元脑智能科技有限公司 SSD controller, data processing method, device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112433676A (en) * 2020-11-24 2021-03-02 合肥康芯威存储技术有限公司 Garbage recycling method and system for solid state disk
CN112486415A (en) * 2020-11-30 2021-03-12 北京泽石科技有限公司 Garbage recycling method and device of storage device
CN113590502A (en) * 2021-07-23 2021-11-02 合肥康芯威存储技术有限公司 Garbage recovery method and garbage recovery system of non-volatile memory storage device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10210041B2 (en) * 2015-11-05 2019-02-19 SK Hynix Inc. Systems and methods for low latency copy operations in non-volatile memory
TWI681295B (en) * 2017-07-07 2020-01-01 群聯電子股份有限公司 Memory management method, memory control circuit unit and memory storage device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112433676A (en) * 2020-11-24 2021-03-02 合肥康芯威存储技术有限公司 Garbage recycling method and system for solid state disk
CN112486415A (en) * 2020-11-30 2021-03-12 北京泽石科技有限公司 Garbage recycling method and device of storage device
CN113590502A (en) * 2021-07-23 2021-11-02 合肥康芯威存储技术有限公司 Garbage recovery method and garbage recovery system of non-volatile memory storage device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于逻辑区间冷热分离的NAND闪存垃圾回收算法;覃仁谅等;《微电子学与计算机》(第05期);全文 *

Also Published As

Publication number Publication date
CN115599706A (en) 2023-01-13

Similar Documents

Publication Publication Date Title
CN115599706B (en) Garbage recycling method of data storage device and data storage device
US10275162B2 (en) Methods and systems for managing data migration in solid state non-volatile memory
US10564690B2 (en) Power interrupt management
TWI399644B (en) Block management method for a non-volatile memory
US9158700B2 (en) Storing cached data in over-provisioned memory in response to power loss
CN103270500B (en) Transaction journal recovers
CN108038026B (en) Flash memory-based data rapid recovery method and system
US20100287217A1 (en) Host control of background garbage collection in a data storage device
US10168940B2 (en) Data storage using SLC and TLC memory banks and data maintenance method thereof
WO2014074449A2 (en) Wear leveling in flash memory devices with trim commands
CN101369451A (en) Solid state memory (ssm), computer system including an ssm, and method of operating an ssm
CN107092563B (en) Garbage recovery method and device
CN106557432B (en) Buffer storage supervisory method, memorizer control circuit unit and storage device
US20200327066A1 (en) Method and system for online recovery of logical-to-physical mapping table affected by noise sources in a solid state drive
CN112130749B (en) Data storage device and non-volatile memory control method
US20190004907A1 (en) Method for management tables recovery
US10339045B2 (en) Valid data management method and storage controller
CN111104045A (en) Storage control method, device, equipment and computer storage medium
CN115114180A (en) Method and related controller for performing wear leveling operation in flash memory and storage system
CN112068782B (en) Memory management method, memory storage device and memory control circuit unit
US11687447B1 (en) Method and apparatus for performing access control of memory device with aid of additional physical address information
TWI747191B (en) Data storage device and data processing method
Khanbadr et al. A novel method for victim block selection for NAND flash-based solid state drives based on scoring
CN115756297A (en) Method and system for preventing reading error and data storage device
Chen et al. Enhancing flash memory reliability by jointly considering write-back pattern and block endurance

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant