WO2019174205A1 - Trash recovery method and device and storage equipment - Google Patents

Trash recovery method and device and storage equipment Download PDF

Info

Publication number
WO2019174205A1
WO2019174205A1 PCT/CN2018/105305 CN2018105305W WO2019174205A1 WO 2019174205 A1 WO2019174205 A1 WO 2019174205A1 CN 2018105305 W CN2018105305 W CN 2018105305W WO 2019174205 A1 WO2019174205 A1 WO 2019174205A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
data block
target data
valid
valid data
Prior art date
Application number
PCT/CN2018/105305
Other languages
French (fr)
Chinese (zh)
Inventor
梁小庆
李志雄
邓恩华
Original Assignee
深圳市江波龙电子有限公司
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 深圳市江波龙电子有限公司 filed Critical 深圳市江波龙电子有限公司
Publication of WO2019174205A1 publication Critical patent/WO2019174205A1/en

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/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1008Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices
    • G06F11/1048Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices using arrangements adapted for a specific error detection or correction feature
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1041Resource optimization
    • G06F2212/1044Space efficiency improvement

Definitions

  • the present invention relates to the field of data processing, and in particular, to a method, an apparatus, and a storage device for garbage collection.
  • USB flash drive USB flash disk
  • SSD Solid State Drive
  • eMMC embedded Multi Media Card
  • eMCP embedded multi-chip package, embedded Multi Chip
  • UFS Universal Flash Storage
  • SD cards Secure Digital Memory Card
  • the technical problem to be solved by the embodiments of the present invention is to provide a method, a device and a storage device for garbage collection, which can solve the problem of data loss in garbage collection and ensure the accuracy of data garbage collection.
  • the obtaining the valid data of the data block to be moved includes: acquiring valid data content of the data block to be moved, or acquiring a valid data physical address of the data block to be moved.
  • the method further includes determining the target data block capacity space and an address according to the valid data content or the valid data physical address.
  • the writing the valid data to the target data block comprises: reading the valid data content or the valid data physical address; writing the valid data content or the valid data physical address The target data block address.
  • the verifying the data of the target data block includes: determining whether the valid data is all written into the target data block, and if the valid data is all written into the target data block, The data of the target data block is verified, otherwise the data of the target data block fails to pass the verification; or whether the number of errors of the error check and correction of the valid data exceeds a preset threshold, if the error check and If the corrected number of errors does not exceed the preset threshold, the data of the target data block passes the check, otherwise the data of the target data block fails the verification.
  • the method further includes: adding a mark to the valid data; writing the mark and the valid data together to the target data block; determining whether the target data block includes the mark, if Including, the data of the target data block is verified, otherwise the data of the target data block fails to pass the verification.
  • an embodiment of the present invention provides a device for garbage collection, which is applied to a storage device, where the device includes: an obtaining module, configured to acquire valid data of a data block to be moved; and a writing module, configured to: The valid data is written into the target data block; the verification module is configured to check the data of the target data block, and if the data of the target data block fails the verification, the valid data is rewritten into the target data. Block until the data of the target data block passes the check.
  • the obtaining module includes: a first acquiring unit, configured to acquire valid data content of the data block to be moved, or a second acquiring unit, configured to acquire a valid data physical address of the data block to be moved .
  • the device further includes: a determining module, configured to determine a target data block capacity space and an address according to the valid data content or the valid data physical address.
  • a determining module configured to determine a target data block capacity space and an address according to the valid data content or the valid data physical address.
  • the writing module includes: a reading unit, configured to read the valid data content or the valid data physical address; and a writing unit, configured to physically use the valid data content or the valid data The address is written to the target data block address.
  • the verification module includes: a first verification unit, configured to determine whether the valid data is all written into the target data block, and if the valid data is all written into the target data block, The data of the target data block is verified, otherwise the data of the target data block fails to pass the verification; or the second check unit is configured to determine whether the error check and the corrected error number of the valid data exceed a preset threshold If the number of errors of the error check and correction does not exceed the preset threshold, the data of the target data block passes the check, otherwise the data of the target data block fails the check.
  • a first verification unit configured to determine whether the valid data is all written into the target data block, and if the valid data is all written into the target data block, The data of the target data block is verified, otherwise the data of the target data block fails to pass the verification
  • the second check unit is configured to determine whether the error check and the corrected error number of the valid data exceed a preset threshold If the number of errors of the error check and correction does not exceed the preset threshold, the data of the target data block passes the
  • the device further includes: a marking module, configured to add a mark to the valid data; a mark writing module, configured to write the mark and the valid data together into the target data block;
  • the determining module is configured to determine whether the target data block includes the tag, and if yes, the data of the target data block passes the verification, otherwise the data of the target data block fails to pass the verification.
  • an embodiment of the present invention provides a storage device, where the storage device includes: a controller; and a memory communicably connected to the controller; wherein the memory stores a memory that can be executed by the controller An instruction executed by the controller to enable the controller to perform the method of garbage collection as described above.
  • an embodiment of the present invention provides an electronic device, including the foregoing storage device.
  • an embodiment of the present invention provides a non-transitory computer readable storage medium, where the non-transitory computer-readable storage medium stores computer-executable instructions that are executed by an electronic device.
  • an embodiment of the present invention provides a computer program product, including a computing program stored on a non-transitory computer readable storage medium, the computer program including program instructions, when the program instructions are executed by a computer And causing the computer to perform the above method of garbage collection.
  • the garbage collection method by obtaining valid data of the data block to be moved, the valid data is written into the target data block, and then the data of the target data block is verified, and when the data of the data block fails the verification. When valid data is written back to the target data block until the data of the target data block passes the check.
  • the method can solve the problem of data loss in garbage collection, ensure the accuracy of data garbage collection, and improve the data security of the garbage collection process in the storage device firmware.
  • FIG. 1 is a schematic diagram of an internal structure of a storage device according to an embodiment of the present disclosure
  • FIG. 2 is a schematic diagram of a garbage collection process of the storage device of FIG. 1;
  • FIG. 3 is a schematic flowchart diagram of a method for garbage collection according to an embodiment of the present invention.
  • the garbage collection method is applied to the storage device data processing, wherein the storage device may be specifically a device such as a USB flash drive, an SSD, an eMMC, an eMCP, a UFS, or an SD card, and the storage device may be specifically composed of a storage controller and a storage medium, and the storage control
  • the function of the device may be specifically implemented by a control chip, and the function of the storage medium may be specifically implemented by a memory chip, the memory chip is a flash chip, and the flash type chip may be specifically a NAND flash chip.
  • the method includes:
  • valid data is data stored in the data block to be moved and waiting to be moved, and may be update data.
  • the data block to be moved is first written to the unit A, and then the update data A' of the unit A is written.
  • A' is valid data.
  • the valid data may be one or several read/write units in the data block to be moved.
  • the valid data of the data block to be moved is obtained.
  • the specific implementation manner is: acquiring the data block to be moved, and then identifying valid data from the data block to be moved, thereby obtaining valid data of the data block to be moved. For example, suppose there are two physical blocks X and Y, X has read and write units (A, B, C, D) and its updated data units (A', B', C', D'), and it is necessary to garbage X. Recycling, first obtain the physical block X, and then identify the valid data unit (A', B', C', D') from X, so as to obtain the valid data of the data block to be moved (A', B', C ', D').

Abstract

A trash recovery method and device and a storage equipment, relating to the field of data processing. The trash recovery method comprises: acquiring effective data of a data block to be moved (110); writing the effective data into a target data block (120); and verifying data of the target data block, and if the data of the target data block does not pass the verification, rewriting the effective data into the target data block until the data of the target data block passes the verification (130). In this way, it is possible to solve the problem of data loss during trash recovery and ensure the accuracy of data trash recovery.

Description

一种垃圾回收的方法、装置及存储设备Method, device and storage device for garbage collection 【技术领域】[Technical Field]
本发明涉及数据处理领域,特别是涉及一种垃圾回收的方法、装置及存储设备。The present invention relates to the field of data processing, and in particular, to a method, an apparatus, and a storage device for garbage collection.
【背景技术】【Background technique】
存储设备包括U盘(USB闪存盘,USB flash disk)、SSD(固态硬盘,Solid State Drive)、eMMC(嵌入式多媒体存储卡,Embedded Multi Media Card)、eMCP(嵌入式多芯片封装,embedded Multi Chip Package)、UFS(通用闪存存储,Universal Flash Storage)、SD卡(安全数码存储卡,Secure Digital Memory Card)等设备,被广泛应用在各种产品中,例如计算机、手机等电子产品。随着电子产品的功能越来越丰富,并且体积朝着轻薄化、小型化发展,这就要求存储设备及时清除无用数据,以腾出空间容纳更多数据。Storage devices include USB flash drive (USB flash disk), SSD (Solid State Drive), eMMC (Embedded Multi Media Card), eMCP (embedded multi-chip package, embedded Multi Chip) Packages, UFS (Universal Flash Storage), SD cards (Secure Digital Memory Card) and other devices are widely used in various products, such as computers, mobile phones and other electronic products. As the functions of electronic products become more and more abundant, and the volume is becoming thinner and lighter, the storage device needs to clear unnecessary data in time to make room for more data.
然而,在操作系统中删除文件时,操作系统只是在其内部文件表中做标记标示该文件已删除,由于闪存设备不能覆盖现有数据,所以在固态硬盘上,当前无效的数据仍然保留在硬盘上,因此会产生大量的数据垃圾。为了提升固态硬盘的利用率,需要进行数据垃圾回收处理。However, when deleting a file in the operating system, the operating system simply marks in its internal file table that the file has been deleted. Since the flash device cannot overwrite the existing data, the currently invalid data remains on the hard disk on the solid state disk. So, it will generate a lot of data garbage. In order to improve the utilization of solid state drives, data garbage collection is required.
数据的垃圾回收过程主要为:固态硬盘的控制器会先复制所有的有效数据,然后将有效数据写入另一数据区中,并擦除当前数据区中的所有数据单元,再将新数据写入擦除后的数据区。The garbage collection process of data is mainly as follows: the controller of the solid state hard disk will copy all the valid data first, then write the valid data into another data area, and erase all the data units in the current data area, and then write the new data. Enter the erased data area.
发明人在实施本发明实施例的过程中,发现现有技术的垃圾回收过程中,由于编程错误或逻辑错误,会导致数据丢失。In the process of implementing the embodiments of the present invention, the inventors found that in the garbage collection process of the prior art, data loss may occur due to programming errors or logic errors.
【发明内容】[Summary of the Invention]
本发明实施例主要解决的技术问题是提供一种垃圾回收的方法、装置及存储设备,能够解决垃圾回收中数据丢失的问题,保证数据垃圾回收的准确率。The technical problem to be solved by the embodiments of the present invention is to provide a method, a device and a storage device for garbage collection, which can solve the problem of data loss in garbage collection and ensure the accuracy of data garbage collection.
为解决上述技术问题,本发明实施例提供以下技术方案:To solve the above technical problem, the embodiment of the present invention provides the following technical solutions:
第一方面,本发明实施例提供了一种垃圾回收的方法,应用于存储设备数据处理,包括:获取待搬移数据块的有效数据;将所述有效数据写入目标数据 块;对所述目标数据块的数据进行校验,如果所述目标数据块的数据未通过校验,则重新将所述有效数据写入目标数据块,直至所述目标数据块的数据通过校验。In a first aspect, an embodiment of the present invention provides a method for garbage collection, which is applied to data processing of a storage device, including: acquiring valid data of a data block to be moved; writing the valid data into a target data block; The data of the data block is verified. If the data of the target data block fails the verification, the valid data is rewritten into the target data block until the data of the target data block passes the verification.
可选地,所述获取待搬移数据块的有效数据,包括:获取所述待搬移数据块的有效数据内容,或者,获取所述待搬移数据块的有效数据物理地址。Optionally, the obtaining the valid data of the data block to be moved includes: acquiring valid data content of the data block to be moved, or acquiring a valid data physical address of the data block to be moved.
可选地,所述方法还包括:根据所述有效数据内容或所述有效数据物理地址确定所述目标数据块容量空间及地址。Optionally, the method further includes determining the target data block capacity space and an address according to the valid data content or the valid data physical address.
可选地,所述将所述有效数据写入目标数据块,包括:读取所述有效数据内容或所述有效数据物理地址;将所述有效数据内容或所述有效数据物理地址写入所述目标数据块地址。Optionally, the writing the valid data to the target data block comprises: reading the valid data content or the valid data physical address; writing the valid data content or the valid data physical address The target data block address.
可选地,所述对所述目标数据块的数据进行校验,包括:判断所述有效数据是否全部写入所述目标数据块,若所述有效数据全部写入所述目标数据块,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验;或者判断所述有效数据的错误检查和纠正的错误数是否超过预设阈值,若所述错误检查和纠正的错误数未超过所述预设阈值,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。Optionally, the verifying the data of the target data block includes: determining whether the valid data is all written into the target data block, and if the valid data is all written into the target data block, The data of the target data block is verified, otherwise the data of the target data block fails to pass the verification; or whether the number of errors of the error check and correction of the valid data exceeds a preset threshold, if the error check and If the corrected number of errors does not exceed the preset threshold, the data of the target data block passes the check, otherwise the data of the target data block fails the verification.
可选地,所述方法还包括:对所述有效数据添加标记;将所述标记和所述有效数据一并写入所述目标数据块;判断所述目标数据块是否包含所述标记,若包含,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。Optionally, the method further includes: adding a mark to the valid data; writing the mark and the valid data together to the target data block; determining whether the target data block includes the mark, if Including, the data of the target data block is verified, otherwise the data of the target data block fails to pass the verification.
第二方面,本发明实施例提供了一种垃圾回收的装置,应用于存储设备,所述装置包括:获取模块,用于获取待搬移数据块的有效数据;写入模块,用于将所述有效数据写入目标数据块;校验模块,用于对所述目标数据块的数据进行校验,如果所述目标数据块的数据未通过校验,则重新将所述有效数据写入目标数据块,直至所述目标数据块的数据通过校验。In a second aspect, an embodiment of the present invention provides a device for garbage collection, which is applied to a storage device, where the device includes: an obtaining module, configured to acquire valid data of a data block to be moved; and a writing module, configured to: The valid data is written into the target data block; the verification module is configured to check the data of the target data block, and if the data of the target data block fails the verification, the valid data is rewritten into the target data. Block until the data of the target data block passes the check.
可选地,所述获取模块包括:第一获取单元,用于获取所述待搬移数据块的有效数据内容,或者,第二获取单元,用于获取所述待搬移数据块的有效数据物理地址。Optionally, the obtaining module includes: a first acquiring unit, configured to acquire valid data content of the data block to be moved, or a second acquiring unit, configured to acquire a valid data physical address of the data block to be moved .
可选地,所述装置还包括:确定模块,用于根据所述有效数据内容或所述有效数据物理地址确定目标数据块容量空间及地址。Optionally, the device further includes: a determining module, configured to determine a target data block capacity space and an address according to the valid data content or the valid data physical address.
可选地,所述写入模块包括:读取单元,用于读取所述有效数据内容或所 述有效数据物理地址;写入单元,用于将所述有效数据内容或所述有效数据物理地址写入所述目标数据块地址。Optionally, the writing module includes: a reading unit, configured to read the valid data content or the valid data physical address; and a writing unit, configured to physically use the valid data content or the valid data The address is written to the target data block address.
可选地,所述校验模块包括:第一校验单元,用于判断所述有效数据是否全部写入所述目标数据块,若所述有效数据全部写入所述目标数据块,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验;或者第二校验单元,用于判断所述有效数据的错误检查和纠正的错误数是否超过预设阈值,若所述错误检查和纠正的错误数未超过所述预设阈值,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。Optionally, the verification module includes: a first verification unit, configured to determine whether the valid data is all written into the target data block, and if the valid data is all written into the target data block, The data of the target data block is verified, otherwise the data of the target data block fails to pass the verification; or the second check unit is configured to determine whether the error check and the corrected error number of the valid data exceed a preset threshold If the number of errors of the error check and correction does not exceed the preset threshold, the data of the target data block passes the check, otherwise the data of the target data block fails the check.
可选地,所述装置还包括:标记模块,用于对所述有效数据添加标记;标记写入模块,用于将所述标记和所述有效数据一并写入所述目标数据块;标记判断模块,用于判断所述目标数据块是否包含所述标记,若包含,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。Optionally, the device further includes: a marking module, configured to add a mark to the valid data; a mark writing module, configured to write the mark and the valid data together into the target data block; The determining module is configured to determine whether the target data block includes the tag, and if yes, the data of the target data block passes the verification, otherwise the data of the target data block fails to pass the verification.
第三方面,本发明实施例提供了一种存储设备,所述存储设备包括:控制器;以及与所述控制器通信连接的存储器;其中,所述存储器存储有可被所述控制器执行的指令,所述指令被所述控制器执行,以使所述控制器能够执行如上所述垃圾回收的方法。In a third aspect, an embodiment of the present invention provides a storage device, where the storage device includes: a controller; and a memory communicably connected to the controller; wherein the memory stores a memory that can be executed by the controller An instruction executed by the controller to enable the controller to perform the method of garbage collection as described above.
第四方面,本发明实施例提供了一种电子设备,包括上述的存储设备。In a fourth aspect, an embodiment of the present invention provides an electronic device, including the foregoing storage device.
第五方面,本发明实施例提供了一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被电子设备执行上述任意方法实施例中垃圾回收的方法。In a fifth aspect, an embodiment of the present invention provides a non-transitory computer readable storage medium, where the non-transitory computer-readable storage medium stores computer-executable instructions that are executed by an electronic device. A method of garbage collection in any method embodiment.
第六方面,本发明实施例提供了一种计算机程序产品,包括存储在非易失性计算机可读存储介质上的计算程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行上述垃圾回收的方法。In a sixth aspect, an embodiment of the present invention provides a computer program product, including a computing program stored on a non-transitory computer readable storage medium, the computer program including program instructions, when the program instructions are executed by a computer And causing the computer to perform the above method of garbage collection.
本发明实施例中提供的垃圾回收的方法,通过获取待搬移数据块的有效数据,将有效数据写入目标数据块,然后目标数据块的数据进行校验,当数据块的数据未通过校验时,重新将有效数据写入目标数据块,直至目标数据块的数据通过校验。该方法通过添加校验过程,能够解决垃圾回收中数据丢失的问题,保证数据垃圾回收的准确率,提高了存储设备固件中垃圾回收流程的数据安全性。In the garbage collection method provided in the embodiment of the present invention, by obtaining valid data of the data block to be moved, the valid data is written into the target data block, and then the data of the target data block is verified, and when the data of the data block fails the verification. When valid data is written back to the target data block until the data of the target data block passes the check. By adding a verification process, the method can solve the problem of data loss in garbage collection, ensure the accuracy of data garbage collection, and improve the data security of the garbage collection process in the storage device firmware.
【附图说明】[Description of the Drawings]
一个或多个实施例通过与之对应的附图中的图片进行示例性说明,这些示例性说明并不构成对实施例的限定,附图中具有相同参考数字标号的元件表示为类似的元件,除非有特别申明,附图中的图不构成比例限制。The one or more embodiments are exemplified by the accompanying drawings in the accompanying drawings, and FIG. The figures in the drawings do not constitute a scale limitation unless otherwise stated.
图1为本发明实施例提供的一种存储设备的内部结构示意图;FIG. 1 is a schematic diagram of an internal structure of a storage device according to an embodiment of the present disclosure;
图2为图1的存储设备的垃圾回收过程的示意图;2 is a schematic diagram of a garbage collection process of the storage device of FIG. 1;
图3为本发明实施例提供的一种垃圾回收的方法的流程示意图;3 is a schematic flowchart of a method for garbage collection according to an embodiment of the present invention;
图4为本发明实施例提供的一种垃圾回收的方法的获取待搬移数据块的有效数据的流程示意图;4 is a schematic flowchart of obtaining valid data of a data block to be moved according to a method for garbage collection according to an embodiment of the present invention;
图5为本发明实施例提供的一种垃圾回收的方法的将所述有效数据写入目标数据块的流程示意图;FIG. 5 is a schematic flowchart of writing the valid data into a target data block according to a method for garbage collection according to an embodiment of the present disclosure;
图6为本发明另一实施例提供的一种垃圾回收的方法的流程示意图;FIG. 6 is a schematic flowchart diagram of a method for garbage collection according to another embodiment of the present invention;
图7为本发明实施例提供的一种垃圾回收的方法的应用实例的流程示意图;FIG. 7 is a schematic flowchart of an application example of a method for garbage collection according to an embodiment of the present disclosure;
图8为本发明实施例提供的一种垃圾回收的装置的结构示意图;FIG. 8 is a schematic structural diagram of a device for garbage collection according to an embodiment of the present invention;
图9为本发明另一实施例提供的一种垃圾回收的装置的结构示意图;FIG. 9 is a schematic structural diagram of an apparatus for garbage collection according to another embodiment of the present invention; FIG.
图10为本发明实施例提供的一种存储设备的结构示意图。FIG. 10 is a schematic structural diagram of a storage device according to an embodiment of the present invention.
【具体实施方式】【detailed description】
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
目前,存储设备主要由存储介质和存储控制器两部分构成,如图1所示,图1为本发明实施例提供的一种存储设备的内部结构示意图。At present, the storage device is mainly composed of a storage medium and a storage controller. As shown in FIG. 1 , FIG. 1 is a schematic diagram of an internal structure of a storage device according to an embodiment of the present invention.
存储操作以页(page)为读写单元,以物理块(block)为擦除单元,设备内部的介质访问提供了通道、颗粒封装、颗粒存储片等多个级别的并行。设备内部以多通道方式组织存储颗粒封装,每个通道上可连接多个颗粒封装,多颗粒封装之间共享传输通道,但可独立执行指令。每个颗粒封装内部包含两个或多个颗粒,每个颗粒可被独立选中执行指令。颗粒内部可分为多个片,每个片含有一个页大小的寄存器缓存,用于暂存读写数据。The storage operation uses a page as a read/write unit and a physical block as an erase unit. The media access inside the device provides multiple levels of parallelism such as channel, granular package, and granular memory slice. The device internally organizes the storage particle package in a multi-channel manner. Multiple channel packages can be connected to each channel, and the transmission channels are shared between the multi-particle packages, but the instructions can be executed independently. Each particle package contains two or more particles inside, and each particle can be independently selected to execute an instruction. The inside of the particle can be divided into multiple slices, each of which contains a page size register buffer for temporary storage of read and write data.
存储控制器主要负责地址映射、垃圾回收和磨损均衡。存储通过异地更新 的方式缓解存储单元写前擦除的延迟,由于存储单元的擦除次数有限,存储控制器通过磨损均衡算法来平衡设备内部物理块之间的擦除次数,同时垃圾回收算法尽量选择擦除效率高的物理块回收以控制写放大。The storage controller is primarily responsible for address mapping, garbage collection, and wear leveling. The storage is relieved by the update of the storage unit before the write is performed. Because the number of erasures of the storage unit is limited, the storage controller balances the number of erasures between the physical blocks of the device through the wear leveling algorithm, and the garbage collection algorithm tries to Physical block recovery with high erasure efficiency is selected to control write amplification.
可以理解的是,其中,常用的垃圾回收大致分为以下两种:第一种为标记清除法,通过一次标记所有无用对象,直接回收其占用内存空间,这种方法效率低,并且会产生不连续的内存空间;第二种为复制算法,将可用内存划分相等的等份,每次只使用其中的一份,当一份用完了,触发垃圾回收操作,对该区域的有效数据复制到另一区域中,然后清除该区域,这种方法效率高,避免产生不连续的内存空间。本发明实施例以第二种方法为例举例说明。Understandably, the commonly used garbage collection is roughly divided into the following two types: The first one is the mark-clearing method, which directly recovers the occupied memory space by marking all useless objects at a time. This method is inefficient and will produce no The contiguous memory space; the second is the copy algorithm, which divides the available memory into equal aliquots, using only one of them at a time. When one copy is used up, the garbage collection operation is triggered, and the valid data of the area is copied to another In an area, then clearing the area, this method is efficient and avoids creating discontinuous memory space. The second embodiment of the present invention is exemplified by an example.
可以理解的是,垃圾回收的过程大致为:闪存控制器先复制所有的有效数据,然后将有效数据写入另一数据区中,并擦除当前数据区中的所有数据单元,再将新数据写入擦除后的数据区。例如,如图2所示,假设闪存设备有X和Y两个物理块,每个物理块分别有12个读写单元,①首先向物理块X写入4个单元(A,B,C,D);②然后再向物理块X写入新的4个单元(E,F,G,H),同时写入单元(A,B,C,D)的更新数据(A’,B’,C’,D’),此时单元(A,B,C,D)变为失效数据;③为了继续向单元(A,B,C,D)的位置写入新的数据,需要将(E,F,G,H,A’,B’,C’,D’)这8个单元先搬到物理块Y中,然后把物理块X清除,这就是垃圾回收的过程。但是,由于在垃圾回收过程中,需要进行数据的写入操作,这些操作可能由于编程错误或逻辑错误,会导致数据丢失。Understandably, the process of garbage collection is roughly as follows: the flash controller first copies all valid data, then writes valid data into another data area, and erases all data units in the current data area, and then new data. Write the erased data area. For example, as shown in FIG. 2, it is assumed that the flash device has two physical blocks of X and Y, each physical block has 12 read/write units, and 1 first writes 4 units (A, B, C, to the physical block X, D); 2 then write the new 4 units (E, F, G, H) to the physical block X, and write the updated data of the unit (A, B, C, D) (A', B', C', D'), at this time the unit (A, B, C, D) becomes invalid data; 3 in order to continue writing new data to the position of the unit (A, B, C, D), it is necessary to , F, G, H, A', B', C', D') These 8 units are first moved to the physical block Y, and then the physical block X is cleared. This is the garbage collection process. However, due to the need to write data during the garbage collection process, these operations may result in data loss due to programming errors or logic errors.
基于此,请参阅图3,图3为本发明实施例提供的一种垃圾回收的方法的流程示意图。该垃圾回收的方法应用于存储设备数据处理,其中,存储设备可以具体为U盘、SSD、eMMC、eMCP、UFS及SD卡等设备,存储设备可具体由存储控制器和存储介质组成,存储控制器的功能可具体由控制芯片实现,存储介质的功能可具体由存储芯片实现,存储芯片为flash芯片,flash类型的芯片可具体为NAND flash芯片等。如图3所述,该方法包括:Based on this, please refer to FIG. 3. FIG. 3 is a schematic flowchart diagram of a method for garbage collection according to an embodiment of the present invention. The garbage collection method is applied to the storage device data processing, wherein the storage device may be specifically a device such as a USB flash drive, an SSD, an eMMC, an eMCP, a UFS, or an SD card, and the storage device may be specifically composed of a storage controller and a storage medium, and the storage control The function of the device may be specifically implemented by a control chip, and the function of the storage medium may be specifically implemented by a memory chip, the memory chip is a flash chip, and the flash type chip may be specifically a NAND flash chip. As described in FIG. 3, the method includes:
110、获取待搬移数据块的有效数据。110. Obtain valid data of the data block to be moved.
上述“待搬移数据块”为等待进行垃圾回收的物理块,其中,物理块为存储介质的存储数据的物理区域,是数据在磁盘上的存储单位,是上层软件中操作文件时使用的最小操作单元。物理块由扇区组成,从硬件设备上读取一个物理块,实际是从硬件设备读取一个或多个扇区。物理块对应逻辑块,逻辑块与 文件相对应。The above-mentioned "data block to be moved" is a physical block waiting for garbage collection, wherein the physical block is a physical area in which the storage medium stores data, is a storage unit of data on the disk, and is a minimum operation used when operating the file in the upper layer software. unit. A physical block consists of sectors, and a physical block is read from a hardware device, actually reading one or more sectors from the hardware device. The physical block corresponds to a logical block, and the logical block corresponds to a file.
上述“有效数据”为存储在待搬移数据块中等待进行搬移的数据,可以为更新数据,例如,在待搬移数据块先写入单元A,然后写入单元A的更新数据A’,则单元A’为有效数据。其中,有效数据可以为待搬移数据块中的一个或若干个读写单元。The above-mentioned "valid data" is data stored in the data block to be moved and waiting to be moved, and may be update data. For example, the data block to be moved is first written to the unit A, and then the update data A' of the unit A is written. A' is valid data. The valid data may be one or several read/write units in the data block to be moved.
在本实施例中,获取待搬移数据块的有效数据,具体实施方式为:获取待搬移数据块,然后从待搬移数据块中识别有效数据,从而获取待搬移数据块的有效数据。例如,假设有X和Y两个物理块,X有读写单元(A,B,C,D)和其更新数据单元(A’,B’,C’,D’),需对X进行垃圾回收,则先获取物理块X,然后从X中识别出有效数据单元(A’,B’,C’,D’),从而获取待搬移数据块的有效数据为(A’,B’,C’,D’)。In this embodiment, the valid data of the data block to be moved is obtained. The specific implementation manner is: acquiring the data block to be moved, and then identifying valid data from the data block to be moved, thereby obtaining valid data of the data block to be moved. For example, suppose there are two physical blocks X and Y, X has read and write units (A, B, C, D) and its updated data units (A', B', C', D'), and it is necessary to garbage X. Recycling, first obtain the physical block X, and then identify the valid data unit (A', B', C', D') from X, so as to obtain the valid data of the data block to be moved (A', B', C ', D').
其中,如图4所示,获取待搬移数据块的有效数据,包括:Wherein, as shown in FIG. 4, obtaining valid data of the data block to be moved includes:
111、获取待搬移数据块的有效数据内容,或者,111. Obtain valid data content of the data block to be moved, or,
112、获取待搬移数据块的有效数据物理地址。112. Obtain a valid data physical address of the data block to be moved.
在本实施例中,待搬移数据块的有效数据对应相应的内容和物理地址。其中,有效数据内容为有效数据的数据信息,有效数据物理地址为有效数据的地址信息,例如,假设待搬移数据块的地址单元0000、0001、0010、0011分别写入数据1011、1100、1101、1110,则有效数据内容为1011、1100、1101、1110,有效数据物理地址为0000、0001、0010、0011。In this embodiment, the valid data of the data block to be moved corresponds to the corresponding content and physical address. The valid data content is the data information of the valid data, and the valid data physical address is the address information of the valid data. For example, it is assumed that the address units 0000, 0001, 0010, and 0011 of the data block to be moved are respectively written into the data 1011, 1100, and 1101. In 1110, the valid data contents are 1011, 1100, 1101, and 1110, and the valid data physical addresses are 0000, 0001, 0010, and 0011.
其中,如图4所示,该方法还包括:Wherein, as shown in FIG. 4, the method further includes:
113、根据所述有效数据内容或所述有效数据物理地址确定所述目标数据块容量空间及地址。113. Determine, according to the valid data content or the valid data physical address, the target data block capacity space and address.
上述“目标数据块容量空间”为目标数据块的剩余容量大小,根据目标数据块容量空间选择剩余容量大于有效数据内容的长度的目标数据块。上述“目标数据块地址”为目标数据块的所在物理地址,例如,物理块X、Y的物理地址分别为00、01,需要将待搬移数据块X的数据搬到目标数据块Y,然后对X进行垃圾回收,则目标数据块地址为Y的物理地址01。在本实施例中,根据有效数据获取目标数据块容量空间后,根据容量空间确定目标数据块,然后获取该目标数据块的地址。The above-mentioned "target data block capacity space" is the remaining capacity size of the target data block, and the target data block whose remaining capacity is larger than the length of the valid data content is selected according to the target data block capacity space. The above-mentioned "target data block address" is the physical address of the target data block. For example, the physical addresses of the physical blocks X and Y are respectively 00 and 01, and the data of the data block X to be moved needs to be moved to the target data block Y, and then X performs garbage collection, and the target data block address is the physical address 01 of Y. In this embodiment, after the target data block capacity space is acquired according to the valid data, the target data block is determined according to the capacity space, and then the address of the target data block is obtained.
在本实施例中,获取待搬移数据块的有效数据内容,可以通过识别有效数据内容的长度确定目标数据块的容量空间,并根据目标数据块的容量空间获取 容量足够的目标数据块的地址,从而将有效数据写入目标数据块。获取待搬移数据块的有效数据物理地址,可以根据有效数据物理地址确定有效数据内容的长度,从而确定目标数据块的容量空间,然后根据目标数据块的容量空间获取容量足够的目标数据块的地址,从而将有效数据写入目标数据块。In this embodiment, the valid data content of the data block to be moved is obtained, and the capacity space of the target data block is determined by identifying the length of the valid data content, and the address of the target data block having sufficient capacity is obtained according to the capacity space of the target data block. Thereby valid data is written to the target data block. Obtaining a valid data physical address of the data block to be moved, determining a length of the valid data content according to the valid data physical address, thereby determining a capacity space of the target data block, and then obtaining an address of the target data block with sufficient capacity according to the capacity space of the target data block , thereby writing valid data to the target data block.
120、将所述有效数据写入目标数据块。120. Write the valid data into the target data block.
上述“目标数据块”为等待接受数据写入的物理块,其中,目标数据块可以为任意空闲物理块,目标数据块的剩余空间可以大于或者等于有效数据所占用的空间。例如,有X、Y、Z三个物理块,假设X为待搬移数据块,其有效数据有三个单元A、B、C,识别得到Y的剩余空间为2个单元,Z的剩余空间为4个单元,则选择Z为目标数据块。The above-mentioned "target data block" is a physical block waiting to accept data writing, wherein the target data block may be any free physical block, and the remaining space of the target data block may be greater than or equal to the space occupied by the valid data. For example, there are three physical blocks of X, Y, and Z. If X is a data block to be moved, the valid data has three units A, B, and C. The remaining space for identifying Y is 2 units, and the remaining space of Z is 4. For each unit, select Z as the target data block.
在本实施例中,获取待搬移数据块的有效数据后,然后将有效数据写入目标数据块,从而对待搬移数据块进行清除,以实现垃圾回收。In this embodiment, after the valid data of the data block to be moved is acquired, the valid data is then written into the target data block, so that the data block to be moved is cleared to implement garbage collection.
其中,如图5所示,将所述有效数据写入目标数据块,包括:Wherein, as shown in FIG. 5, writing the valid data into the target data block includes:
121、读取所述有效数据内容或所述有效数据物理地址;121. Read the valid data content or the valid data physical address;
122、将所述有效数据内容或所述有效数据物理地址写入所述目标数据块地址。122. Write the valid data content or the valid data physical address to the target data block address.
在本实施例中,在根据有效数据内容或有效数据物理地址确定目标数据块容量空间及地址后,从待搬移数据块中读取有效数据内容或者有效数据物理地址,然后根据确定的目标数据块地址,将有效数据内容或者有效数据物理地址写入目标数据块地址。In this embodiment, after determining the target data block capacity space and the address according to the valid data content or the valid data physical address, the valid data content or the valid data physical address is read from the data block to be moved, and then according to the determined target data block. Address, which writes valid data content or valid data physical address to the target data block address.
其中,从待搬移数据块中读取有效数据内容,将有效数据内容写入目标数据块地址,例如:物理块X、Y的地址分别为00、01,假设待搬移数据块为X,目标数据块为Y,读取得到X的有效数据内容为1011、1100、1101、1110,则将1011、1100、1101、1110写入目标数据块地址01。The valid data content is read from the data block to be moved, and the valid data content is written into the target data block address. For example, the addresses of the physical blocks X and Y are respectively 00 and 01, and the data block to be moved is assumed to be X, and the target data is When the block is Y and the valid data contents of X are read as 1011, 1100, 1101, and 1110, 1011, 1100, 1101, and 1110 are written to the target data block address 01.
其中,从待搬移数据块中读取有效数据物理地址,将有效数据物理地址写入目标数据块地址,例如:物理块X、Y的地址分别为00、01,假设待搬移数据块为X,目标数据块为Y,读取得到X的有效数据物理地址为0000、0001、0010、0011,分别对应数据1011、1100、1101、1110,将有效数据物理地址为0000、0001、0010、0011的内容,即数据1011、1100、1101、1110写入目标数据块地址01。The valid data physical address is read from the data block to be moved, and the valid data physical address is written into the target data block address. For example, the addresses of the physical blocks X and Y are respectively 00 and 01, and the data block to be moved is assumed to be X. The target data block is Y, and the valid data physical addresses of X are read as 0000, 0001, 0010, and 0011, corresponding to the data 1011, 1100, 1101, and 1110, respectively, and the contents of the valid data physical addresses are 0000, 0001, 0010, and 0011. That is, the data 1011, 1100, 1101, 1110 is written to the target data block address 01.
需要说明的是,将所述有效数据内容或所述有效数据物理地址写入所述目 标数据块地址时,可以从有效数据的首地址开始写入,也可以从有效数据的末地址开始写入,可以顺序写入,也可以倒序写入。It should be noted that when the valid data content or the valid data physical address is written into the target data block address, the writing may be started from the first address of the valid data, or may be started from the last address of the valid data. Can be written sequentially or in reverse order.
130、对所述目标数据块的数据进行校验,如果所述目标数据块的数据未通过校验,则重新将所述有效数据写入目标数据块,直至所述目标数据块的数据通过校验。130. Perform verification on the data of the target data block, and if the data of the target data block fails the verification, rewrite the valid data into the target data block until the data of the target data block passes the calibration. Test.
在数据的存储与传输中,有时会发生随机的写入错误。由于存储介质的物理特性,在数据保存过程中,由于外界环境的影响,可能造成少量数据在存储过程中发生改变。因此,需要对写入目标数据块的数据进行校验,保证垃圾回收时的数据正确性。Random write errors sometimes occur during the storage and transfer of data. Due to the physical characteristics of the storage medium, during the data storage process, due to the influence of the external environment, a small amount of data may be changed during the storage process. Therefore, it is necessary to verify the data written to the target data block to ensure the correctness of the data during garbage collection.
在将有效数据写入目标数据块后,对目标数据块的数据进行校验,以检验写入目标数据块的数据是否正确写入。若目标数据块的数据通过检验,则表明有效数据写入目标数据块已正确写入,则垃圾回收过程完成。若目标数据块的数据未通过检验,表明有效数据的写入出现错误,则重新将有效数据写入目标数据块,再对目标数据块的数据进行校验,直至目标数据块的数据通过校验。After the valid data is written to the target data block, the data of the target data block is verified to verify whether the data written to the target data block is correctly written. If the data of the target data block passes the check, it indicates that the valid data write target data block has been correctly written, and the garbage collection process is completed. If the data of the target data block fails the verification, indicating that the writing of the valid data is wrong, the valid data is rewritten into the target data block, and the data of the target data block is verified until the data of the target data block passes the verification. .
其中,目标数据块的数据未通过检验,表明有效数据的写入出现错误,则重新将有效数据写入目标数据块,再对目标数据块的数据进行校验,若目标数据块的数据进行校验仍未通过校验,则循环重新将有效数据写入目标数据块,对目标数据块的数据进行校验,直至目标数据块的数据通过校验。Wherein, if the data of the target data block fails the verification, indicating that the writing of the valid data is wrong, the valid data is rewritten into the target data block, and then the data of the target data block is verified, and if the data of the target data block is performed, If the test still fails the verification, the loop rewrites the valid data to the target data block, and the data of the target data block is verified until the data of the target data block passes the verification.
其中,当重新将有效数据写入目标数据块时,若原目标数据块容量空间不足,则重新读取有效数据,并重新确定目标数据块,将有效数据写入新的目标数据块中。例如,假设待搬移数据块为X,原目标数据块为Y,将X的有效数据内容1011、1100、1101、1110写入目标数据块Y中,对Y的数据进行校验,校验未通过,并且Y的剩余空间小于有效数据内容1011、1100、1101、1110占用的空间,则重新确定目标数据块Z,并重新从X读取有效数据内容1011、1100、1101、1110,将有效数据内容1011、1100、1101、1110写入目标数据块Z。When the valid data is rewritten into the target data block, if the original target data block has insufficient capacity, the valid data is re-read, and the target data block is re-determined, and the valid data is written into the new target data block. For example, if the data block to be moved is X and the original target data block is Y, the valid data contents 1011, 1100, 1101, and 1110 of X are written in the target data block Y, and the data of Y is verified, and the verification fails. And the remaining space of Y is smaller than the space occupied by the valid data content 1011, 1100, 1101, 1110, then the target data block Z is re-determined, and the valid data content 1011, 1100, 1101, 1110 is read again from X, and the valid data content is 1011, 1100, 1101, and 1110 are written to the target data block Z.
其中,对所述目标数据块的数据进行校验,包括:The data of the target data block is verified, including:
131、判断所述有效数据是否全部写入所述目标数据块,若所述有效数据全部写入所述目标数据块,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验;或者,And determining whether the valid data is all written into the target data block. If the valid data is all written into the target data block, the data of the target data block is verified, otherwise the target data block is The data has not passed the verification; or,
132、判断所述有效数据的错误检查和纠正的错误数是否超过预设阈值,若所述错误检查和纠正的错误数未超过预设阈值,则所述目标数据块的数据通过 校验,否则所述目标数据块的数据未通过校验。132. Determine whether the error check and the corrected error number of the valid data exceed a preset threshold. If the error check and the corrected error number does not exceed a preset threshold, the data of the target data block passes the verification, otherwise The data of the target data block does not pass the check.
其中,判断有效数据是否全部写入目标数据块,可以通过获取有效数据的单元数和写入目标数据块的单元数,若有效数据的单元数与写入目标数据块的单元数相等,则有效数据全部写入目标数据块,否则有效数据未全部写入目标数据块,例如:有效数据有四个单元(A,B,C,D),若写入目标数据块的单元数为4个,则有效数据全部写入目标数据块,若写入目标数据块的单元数为3个,则有效数据未全部写入目标数据块。还可以通过获取有效数据内容的长度和目标数据块的原始空间和剩余空间,计算写入目标数据块的数据的占用空间,若有效数据内容的长度等于写入目标数据块的数据的占用空间,则有效数据全部写入目标数据块,否则有效数据未全部写入目标数据块。Wherein, determining whether the valid data is all written into the target data block may be effective by obtaining the number of units of the valid data and the number of units of the write target data block, and if the number of units of the valid data is equal to the number of units of the write target data block, All data is written to the target data block, otherwise the valid data is not all written to the target data block. For example, valid data has four units (A, B, C, D), and if the number of units written to the target data block is four, Then, all the valid data is written into the target data block. If the number of cells written to the target data block is three, the valid data is not all written to the target data block. The occupied space of the data written in the target data block can also be calculated by obtaining the length of the valid data content and the original space and the remaining space of the target data block. If the length of the valid data content is equal to the occupied space of the data written to the target data block, The valid data is all written to the target data block, otherwise the valid data is not all written to the target data block.
其中,错误检查和纠正(Error Correcting Cod,ECC),是一种能够实现“错误检查和纠正”的技术,被广泛应用于各种领域的计算机指令中,经过内存的纠错,计算机的操作指令才可以继续执行,系统在工作是才更趋于安全稳定。错误检查和纠正是通过编码实现的,根据香农定理,为存储的数据增加冗余度,通过冗余校验以实现错误检查和纠正。错误检查和纠正的错误数为通过错误检查和纠正获得的错误数,预设阈值为预先设置的错误数值,用于判断目标数据块的数据是否通过校验,其中,预设阈值可以为100bit,若错误检查和纠正的错误数超过100bit,则目标数据块的数据未通过校验。Among them, Error Correcting Cod (ECC) is a technology that can realize "error checking and correction". It is widely used in computer instructions in various fields. After memory error correction, computer operation instructions. Only then can the implementation continue, and the system is more secure and stable at work. Error checking and correction are achieved by coding. According to Shannon's theorem, redundancy is added to the stored data, and redundancy check is performed to achieve error checking and correction. The number of errors that are checked and corrected is the number of errors obtained by error checking and correction. The preset threshold is a preset error value, which is used to determine whether the data of the target data block passes the verification. The preset threshold may be 100 bits. If the number of errors checked and corrected exceeds 100 bits, the data of the target data block does not pass the check.
本发明实施例提供的一种垃圾回收的方法,该方法通过获取待搬移数据块的有效数据,将有效数据写入目标数据块,然后目标数据块的数据进行校验,当数据块的数据未通过校验时,重新将有效数据写入目标数据块,直至目标数据块的数据通过校验。该方法通过添加校验过程,能够解决垃圾回收中数据丢失的问题,保证数据垃圾回收的准确率,提高了存储设备固件中垃圾回收流程的数据安全性。The method for garbage collection provided by the embodiment of the invention provides the valid data to be written into the target data block by acquiring the valid data of the data block to be moved, and then the data of the target data block is verified, when the data of the data block is not When passing the verification, the valid data is rewritten into the target data block until the data of the target data block passes the verification. By adding a verification process, the method can solve the problem of data loss in garbage collection, ensure the accuracy of data garbage collection, and improve the data security of the garbage collection process in the storage device firmware.
请参阅图6,图6为本发明另一实施例提供的一种垃圾回收的方法的流程示意图。如图6所示,该方法包括:Please refer to FIG. 6. FIG. 6 is a schematic flowchart diagram of a method for garbage collection according to another embodiment of the present invention. As shown in FIG. 6, the method includes:
210、获取待搬移数据块的有效数据,并对所述有效数据添加标记;210. Obtain valid data of the data block to be moved, and add a flag to the valid data.
220、将所述有效数据写入目标数据块,并将所述标记和所述有效数据一并写入所述目标数据块;220. Write the valid data into the target data block, and write the mark and the valid data together into the target data block;
230、对所述目标数据块的数据进行校验,判断所述目标数据块是否包含所述标记,若包含,则所述目标数据块的数据通过校验,否则所述目标数据块的 数据未通过校验,如果所述目标数据块的数据未通过校验,则重新将所述有效数据写入目标数据块,直至所述目标数据块的数据通过校验。230. Check data of the target data block, determine whether the target data block includes the label, and if included, the data of the target data block passes verification, otherwise the data of the target data block is not By verification, if the data of the target data block fails the verification, the valid data is rewritten into the target data block until the data of the target data block passes the verification.
本实施例与上述实施例的主要区别在于,该方法还包括:对所述有效数据添加标记;将所述标记和所述有效数据一并写入所述目标数据块;判断所述目标数据块是否包含所述标记,若包含,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。其中,对有效数据添加标记,可以对整个有效数据添加标记或者对部分有效数据添加标记;判断目标数据块是否包含标记,可以通过检测目标数据块是否有标记,若有标记,则目标数据块包含标记;还可以通过判断目标数据块的标记是否与有效数据的标记相同,若相同,则目标数据块包含标记。通过对有效数据添加标记,可以校验数据搬移的准确性。The main difference between this embodiment and the foregoing embodiment is that the method further includes: adding a flag to the valid data; writing the tag and the valid data together to the target data block; and determining the target data block Whether the flag is included, and if so, the data of the target data block passes the check, otherwise the data of the target data block fails the verification. In addition, adding a mark to the valid data may add a mark to the entire valid data or add a mark to the part of the valid data; determine whether the target data block includes a mark, and may detect whether the target data block has a mark, and if there is a mark, the target data block includes Marking; it is also possible to determine whether the mark of the target data block is the same as the mark of the valid data, and if the same, the target data block contains the mark. By adding tags to valid data, you can verify the accuracy of data movement.
本发明实施例提供的一种垃圾回收的方法,该方法通过获取待搬移数据块的有效数据,并对有效数据添加标记,将有效数据和标记一并写入目标数据块,判断目标数据块是否包含该标记,若包含,则目标数据块的数据通过校验,否则目标数据块的数据未通过校验,如果未通过校验,则重新将有效数据写入目标数据块,直至目标数据块的数据通过校验。该方法通过在校验过程中,对有效数据添加标记,能够解决垃圾回收中数据丢失的问题,保证数据垃圾回收的准确率,提高了存储设备固件中垃圾回收流程的数据安全性。A method for garbage collection provided by an embodiment of the present invention, the method obtains valid data of a data block to be moved, adds a mark to the valid data, and writes the valid data and the mark together into the target data block to determine whether the target data block is Include the flag, if included, the data of the target data block passes the check, otherwise the data of the target data block fails to pass the check. If the check fails, the valid data is rewritten into the target data block until the target data block The data is verified. By adding tags to valid data during the verification process, the method can solve the problem of data loss in garbage collection, ensure the accuracy of data garbage collection, and improve the data security of the garbage collection process in the storage device firmware.
请参阅图7,图7为本发明实施例提供的一种垃圾回收的方法的应用实例的流程示意图。由于在存储设备中垃圾回收是一个非常重要的过程,主要为搬移已写入的有效数据,腾出空闲物理空间来写新数据,其中,在搬移过程中,需要做写入操作等,这些操作都有出错的风险。基于此,本发明实施例在垃圾回收的过程中添加了校验流程,以保证垃圾回收数据的准确率。如图7所示,该方法包括:Please refer to FIG. 7. FIG. 7 is a schematic flowchart diagram of an application example of a garbage collection method according to an embodiment of the present invention. Because garbage collection is a very important process in storage devices, it is mainly to move the valid data that has been written, and free up the free physical space to write new data. Among them, in the process of moving, you need to do write operations, etc. There is a risk of error. Based on this, the embodiment of the present invention adds a verification process in the process of garbage collection to ensure the accuracy of the garbage collection data. As shown in FIG. 7, the method includes:
S1、确定垃圾回收信息:获取待搬移数据块,以及待搬移数据块的有效数据,并根据有效数据确定目标数据块容量空间及地址;S1. Determine garbage collection information: obtain a data block to be moved, and valid data of the data block to be moved, and determine a target data block capacity space and an address according to the valid data;
其中,获取有效数据包括有效数据内容和有效数据物理地址;Wherein obtaining valid data includes valid data content and a valid data physical address;
S2、数据搬移:将有效数据写入目标数据块;S2, data movement: writing valid data into the target data block;
其中,将有效数据写入目标数据块包括:读取有效数据内容或有效数据物理地址,然后将有效数据内容或有效数据物理地址写入目标数据块地址;The writing the valid data to the target data block includes: reading the valid data content or the valid data physical address, and then writing the valid data content or the valid data physical address to the target data block address;
S3、数据校验:读取目标数据块的数据,对目标数据块的数据进行校验, 并判断目标数据块的数据是否通过校验,校验标准为:判断有效数据是否全部写入目标数据块,或者判断有效数据的错误检查和纠正的错误数是否超过预设阈值;S3. Data verification: reading the data of the target data block, verifying the data of the target data block, and determining whether the data of the target data block passes the verification. The verification criterion is: determining whether the valid data is all written to the target data. Block, or determine whether the number of errors in the valid data check and correction exceeds a preset threshold;
其中,判断有效数据是否全部写入目标数据块:若有效数据全部写入目标数据块,则目标数据块的数据通过校验,否则目标数据块的数据未通过校验;其中,判断有效数据的错误检查和纠正的错误数是否超过预设阈值:若错误检查和纠正的错误数未超过预设阈值,则目标数据块的数据通过校验,否则目标数据块的数据未通过校验;Wherein, it is determined whether the valid data is all written into the target data block: if the valid data is all written into the target data block, the data of the target data block passes the verification, otherwise the data of the target data block fails to pass the verification; wherein, the valid data is determined Whether the number of error check and correction errors exceeds a preset threshold: if the number of error check and correction errors does not exceed the preset threshold, the data of the target data block passes the check, otherwise the data of the target data block fails the check;
其中,如果目标数据块的数据未通过校验,则重新将有效数据写入目标数据块,直至目标数据块的数据通过校验。Wherein, if the data of the target data block fails the verification, the valid data is rewritten into the target data block until the data of the target data block passes the verification.
在本发明实施例中,为了进一步保证数据的校验准确性,可以在将待搬移数据块中有效数据写入目标数据块时,对该有效数据添加特定标记,并将特定标记与有效数据一起写入目标数据块,在进行数据校验时,读取目标数据块中的数据,并判断该特定标记是否准确;通过对该有效数据添加特定标记,可以进一步保证校验数据迁移的准确性。In the embodiment of the present invention, in order to further ensure the verification accuracy of the data, when the valid data in the data block to be moved is written into the target data block, a specific tag is added to the valid data, and the specific tag is combined with the valid data. The target data block is written, and when the data is verified, the data in the target data block is read, and whether the specific mark is accurate is determined; by adding a specific mark to the valid data, the accuracy of the check data migration can be further ensured.
本发明实施例的一种垃圾回收的方法,该方法通过确定垃圾回收信息、数据搬移和数据校验,能够解决垃圾回收中数据丢失的问题,保证数据垃圾回收的准确率,提高了存储设备固件中垃圾回收流程的数据安全性。A method for garbage collection according to an embodiment of the present invention, which can solve the problem of data loss in garbage collection by determining garbage collection information, data movement and data verification, ensure the accuracy of data garbage collection, and improve storage device firmware. Data security in the garbage collection process.
请参阅图8,图8为本发明实施例提供的一种垃圾回收的装置的结构示意图。如图8所示,该装置30包括获取模块31、写入模块32和校验模块33。Please refer to FIG. 8. FIG. 8 is a schematic structural diagram of an apparatus for garbage collection according to an embodiment of the present invention. As shown in FIG. 8, the device 30 includes an acquisition module 31, a write module 32, and a verification module 33.
其中,获取模块31用于获取待搬移数据块的有效数据;写入模块32用于将所述有效数据写入目标数据块;校验模块33用于对所述目标数据块的数据进行校验,如果所述目标数据块的数据未通过校验,则重新将所述有效数据写入目标数据块,直至所述目标数据块的数据通过校验。The obtaining module 31 is configured to obtain valid data of the data block to be moved; the writing module 32 is configured to write the valid data into the target data block; and the verification module 33 is configured to verify the data of the target data block. And if the data of the target data block fails the verification, the valid data is rewritten into the target data block until the data of the target data block passes the verification.
在本实施例中,获取模块31与写入模块32连接,写入模块32与检验模块33连接,获取模块31将获取的待搬移数据块的有效数据发送至写入模块32,写入模块32将有效数据写入目标数据块,检验模块33对目标数据块写入的数据进行校验,若目标数据块的数据未通过校验,则返回写入模块32重新将有效数据写入目标数据块,直至目标数据块的数据通过校验,从而保证数据垃圾回收的准确率。In this embodiment, the acquisition module 31 is connected to the write module 32, the write module 32 is connected to the verification module 33, and the acquisition module 31 sends the acquired valid data of the data block to be moved to the write module 32, and the write module 32 The valid data is written into the target data block, and the verification module 33 checks the data written by the target data block. If the data of the target data block fails the verification, the write back module 32 returns the valid data to the target data block. Until the data of the target data block passes the verification, thereby ensuring the accuracy of data garbage collection.
其中,获取模块31包括第一获取单元311或者第二获取单元312。其中第 一获取单元311用于获取待搬移数据块的有效数据内容,第二获取单元312用于获取待搬移数据块的有效数据物理地址。The obtaining module 31 includes a first acquiring unit 311 or a second acquiring unit 312. The first obtaining unit 311 is configured to acquire valid data content of the data block to be moved, and the second obtaining unit 312 is configured to obtain a valid data physical address of the data block to be moved.
其中,该装置30还包括确定模块313。确定模块313用于根据所述有效数据内容或有效数据物理地址确定目标数据块容量空间及地址。The device 30 further includes a determining module 313. The determining module 313 is configured to determine a target data block capacity space and an address according to the valid data content or the valid data physical address.
其中,写入模块32包括读取单元321和写入单元322。其中,读取单元321用于读取所述有效数据内容或所述有效数据物理地址;写入单元322用于将所述有效数据内容或所述有效数据物理地址写入所述目标数据块地址。The write module 32 includes a read unit 321 and a write unit 322. The reading unit 321 is configured to read the valid data content or the valid data physical address; the writing unit 322 is configured to write the valid data content or the valid data physical address into the target data block address .
其中,校验模块33包括第一校验单元331或者第二校验单元332。第一校验单元331用于判断所述有效数据是否全部写入所述目标数据块,若所述有效数据全部写入所述目标数据块,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验;第二校验单元332用于判断所述有效数据的错误检查和纠正的错误数是否超过预设阈值,若所述错误检查和纠正的错误数未超过预设阈值,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。The verification module 33 includes a first verification unit 331 or a second verification unit 332. The first check unit 331 is configured to determine whether the valid data is all written into the target data block. If the valid data is all written into the target data block, the data of the target data block passes the verification, otherwise The data of the target data block does not pass the check; the second check unit 332 is configured to determine whether the error check and the corrected error number of the valid data exceed a preset threshold, if the error check and the corrected error number are not If the preset threshold is exceeded, the data of the target data block passes the verification, otherwise the data of the target data block fails the verification.
在一些实施例中,请参阅图9,图9与图8的主要区别在于,该装置30还包括标记模块341、标记写入模块342和标记判断模块343。标记模块341,用于对所述有效数据添加标记;标记写入模块342,用于将所述标记和所述有效数据一并写入所述目标数据块;标记判断模块343,用于判断所述目标数据块是否包含所述标记,若包含,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。In some embodiments, please refer to FIG. 9. The main difference between FIG. 9 and FIG. 8 is that the device 30 further includes a marking module 341, a marking writing module 342 and a marking determination module 343. a marking module 341, configured to add a mark to the valid data; a mark writing module 342, configured to write the mark and the valid data together into the target data block; and a mark determining module 343, configured to determine Whether the target data block includes the tag, and if so, the data of the target data block passes the verification, otherwise the data of the target data block fails the verification.
需要说明的是,本发明实施例中的垃圾回收的装置中的各个模块之间的信息交互、执行过程等内容,由于与本发明方法实施例基于同一构思,具体内容同样适用于垃圾回收的装置。本发明实施例中的各个模块能作为单独的硬件或软件来实现,并且可以根据需要使用单独的硬件或软件来实现各个单元的功能的组合。It should be noted that the information interaction, the execution process, and the like between the modules in the garbage collection device in the embodiment of the present invention are the same as the method of the present invention, and the specific content is also applicable to the garbage collection device. . The various modules in the embodiments of the present invention can be implemented as separate hardware or software, and a combination of functions of the respective units can be implemented using separate hardware or software as needed.
本发明实施例提供的一种垃圾回收的装置,该装置通过获取模块31获取待搬移数据块的有效数据,写入模块32将有效数据写入目标数据块,检验模块33对目标数据块写入的数据进行校验,若目标数据块的数据未通过校验,则返回写入模块32重新将有效数据写入目标数据块,直至目标数据块的数据通过校验。该装置通过添加校验模块,能够解决垃圾回收中数据丢失的问题,保证数据垃圾回收的准确率,提高了存储设备固件中垃圾回收流程的数据安全性。The device for garbage collection provided by the embodiment of the present invention obtains valid data of the data block to be moved by the obtaining module 31, the writing module 32 writes the valid data into the target data block, and the verification module 33 writes the target data block. The data is verified. If the data of the target data block fails the verification, the return write module 32 rewrites the valid data into the target data block until the data of the target data block passes the check. By adding a verification module, the device can solve the problem of data loss in garbage collection, ensure the accuracy of data garbage collection, and improve the data security of the garbage collection process in the storage device firmware.
请参阅图10,图10为本发明实施例提供的一种存储设备的结构示意图。如图10所示,该存储设备40包括:控制器41和存储器42,控制器41和存储器42之间电性连接。Referring to FIG. 10, FIG. 10 is a schematic structural diagram of a storage device according to an embodiment of the present invention. As shown in FIG. 10, the storage device 40 includes a controller 41 and a memory 42, and the controller 41 and the memory 42 are electrically connected.
存储器42作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块,如本发明实施例中的垃圾回收的方法对应的程序指令/模块(例如,附图8所示的获取模块31、写入模块32和校验模块33)。控制器41通过运行存储在存储器42中的非易失性软件程序、指令以及模块,从而执行服务器的各种功能应用以及数据处理,即实现上述方法实施例垃圾回收的方法。The memory 42 is a non-volatile computer readable storage medium and can be used for storing a non-volatile software program, a non-volatile computer executable program, and a module, such as a program corresponding to the garbage collection method in the embodiment of the present invention. An instruction/module (for example, the acquisition module 31, the write module 32, and the verification module 33 shown in FIG. 8). The controller 41 executes various functional applications of the server and data processing by executing non-volatile software programs, instructions, and modules stored in the memory 42, that is, a method of implementing garbage collection of the above method embodiments.
存储器42可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储根据垃圾回收的装置的使用所创建的数据等。The memory 42 may include a storage program area and an storage data area, wherein the storage program area may store an operating system, an application required for at least one function; the storage data area may store data created according to usage of the garbage collection device, and the like.
所述一个或者多个模块存储在所述存储器42中,当被所述一个或者多个控制器41执行时,执行上述任意方法实施例中垃圾回收的方法,例如,执行以上描述的图3中的方法步骤110至步骤130,图4中的方法步骤111至步骤113,图5中的方法步骤121至步骤122,图6中的模块33-35,图6中的方法步骤210至步骤230,图8中的模块31-33的功能等。The one or more modules are stored in the memory 42 and, when executed by the one or more controllers 41, perform a method of garbage collection in any of the above method embodiments, for example, performing the above described FIG. Method step 110 to step 130, method step 111 to step 113 in FIG. 4, method step 121 to step 122 in FIG. 5, module 33-35 in FIG. 6, method step 210 to step 230 in FIG. The functions of the modules 31-33 in Fig. 8 and the like.
上述产品可执行本发明实施例所提供的方法,具备执行方法相应的功能模块和有益效果。未在本实施例中详尽描述的技术细节,可参见本发明实施例所提供的方法。The above product can perform the method provided by the embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the method provided by the embodiments of the present invention.
本发明实施例提供了一种电子设备,包括上述实施例中的存储设备。其中,该电子设备可以为智能手机、计算机、智能手表、智能手环、平板电脑、掌上电脑等等具有存储功能的电子设备。An embodiment of the present invention provides an electronic device, including the storage device in the foregoing embodiment. The electronic device may be an electronic device with a storage function, such as a smart phone, a computer, a smart watch, a smart bracelet, a tablet computer, a palmtop computer, or the like.
本发明实施例提供了一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被电子设备执行上述任意方法实施例中垃圾回收的方法,例如,执行以上描述的图3中的方法步骤110至步骤130,图4中的方法步骤111至步骤113,图5中的方法步骤121至步骤122,图6中的模块33-35,图6中的方法步骤210至步骤230,图8中的模块31-33的功能等。Embodiments of the present invention provide a non-transitory computer readable storage medium storing computer-executable instructions that are executed by an electronic device to perform any of the above-described method embodiments The method of garbage collection, for example, performs the method steps 110 to 130 in FIG. 3, the method steps 111 to 113 in FIG. 4, the method steps 121 to 122 in FIG. 5, and the module in FIG. 33-35, method steps 210 to 230 in Fig. 6, functions of modules 31-33 in Fig. 8, and the like.
本发明实施例提供了一种计算机程序产品,包括存储在非易失性计算机可读存储介质上的计算程序,所述计算机程序包括程序指令,当所述程序指令被 计算机执行时,使所述计算机执行上述任意方法实施例中垃圾回收的方法,例如,执行以上描述的图3中的方法步骤110至步骤130,图4中的方法步骤111至步骤113,图5中的方法步骤121至步骤122,图6中的模块33-35,图6中的方法步骤210至步骤230,图8中的模块31-33的功能等。Embodiments of the present invention provide a computer program product, including a computing program stored on a non-transitory computer readable storage medium, the computer program including program instructions, when the program instructions are executed by a computer, The computer performs the method of garbage collection in any of the above method embodiments, for example, performing the method steps 110 to 130 in FIG. 3, the method steps 111 to 113 in FIG. 4, and the method steps 121 to 113 in FIG. 122, the modules 33-35 in Fig. 6, the method steps 210 to 230 in Fig. 6, the functions of the modules 31-33 in Fig. 8, and the like.
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
通过以上的实施方式的描述,本领域普通技术人员可以清楚地了解到各实施方式可借助软件加通用硬件平台的方式来实现,当然也可以通过硬件。本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。Through the description of the above embodiments, those skilled in the art can clearly understand that the various embodiments can be implemented by means of software plus a general hardware platform, and of course, by hardware. A person skilled in the art can understand that all or part of the process of implementing the above embodiments can be completed by a computer program to instruct related hardware, and the program can be stored in a computer readable storage medium. When executed, the flow of an embodiment of the methods as described above may be included. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;在本发明的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,步骤可以以任意顺序实现,并存在如上所述的本发明的不同方面的许多其它变化,为了简明,它们没有在细节中提供;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not limited thereto; in the idea of the present invention, the technical features in the above embodiments or different embodiments may also be combined. The steps may be carried out in any order, and there are many other variations of the various aspects of the invention as described above, which are not provided in the details for the sake of brevity; although the invention has been described in detail with reference to the foregoing embodiments, It should be understood by those skilled in the art that the technical solutions described in the foregoing embodiments may be modified or equivalently substituted for some of the technical features; and the modifications or substitutions do not deviate from the embodiments of the present invention. The scope of the technical solution.

Claims (13)

  1. 一种垃圾回收的方法,应用于存储设备数据处理,其特征在于,包括:A method for garbage collection, applied to data processing of a storage device, comprising:
    获取待搬移数据块的有效数据;Obtaining valid data of the data block to be moved;
    将所述有效数据写入目标数据块;Writing the valid data into the target data block;
    对所述目标数据块的数据进行校验,如果所述目标数据块的数据未通过校验,则重新将所述有效数据写入目标数据块,直至所述目标数据块的数据通过校验。The data of the target data block is verified. If the data of the target data block fails the verification, the valid data is rewritten into the target data block until the data of the target data block passes the verification.
  2. 根据权利要求1所述的方法,其特征在于,所述获取待搬移数据块的有效数据,包括:The method according to claim 1, wherein the obtaining valid data of the data block to be moved comprises:
    获取所述待搬移数据块的有效数据内容,或者,Obtaining valid data content of the data block to be moved, or
    获取所述待搬移数据块的有效数据物理地址。Obtaining a valid data physical address of the data block to be moved.
  3. 根据权利要求2所述的方法,其特征在于,所述方法还包括:The method of claim 2, wherein the method further comprises:
    根据所述有效数据内容或所述有效数据物理地址确定所述目标数据块容量空间及地址。Determining the target data block capacity space and address according to the valid data content or the valid data physical address.
  4. 根据权利要求3所述的方法,其特征在于,所述将所述有效数据写入目标数据块,包括:The method according to claim 3, wherein said writing said valid data to a target data block comprises:
    读取所述有效数据内容或所述有效数据物理地址;Reading the valid data content or the valid data physical address;
    将所述有效数据内容或所述有效数据物理地址写入所述目标数据块地址。Writing the valid data content or the valid data physical address to the target data block address.
  5. 根据权利要求1-4任一项所述的方法,其特征在于,所述对所述目标数据块的数据进行校验,包括:The method according to any one of claims 1 to 4, wherein the verifying the data of the target data block comprises:
    判断所述有效数据是否全部写入所述目标数据块,若所述有效数据全部写入所述目标数据块,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验;或者Determining whether the valid data is all written into the target data block, if the valid data is all written into the target data block, the data of the target data block passes the verification, otherwise the data of the target data block is not Pass verification; or
    判断所述有效数据的错误检查和纠正的错误数是否超过预设阈值,若所述错误检查和纠正的错误数未超过所述预设阈值,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。Determining whether the number of errors of the error check and the correction of the valid data exceeds a preset threshold. If the number of errors of the error check and correction does not exceed the preset threshold, the data of the target data block passes the check, otherwise The data of the target data block does not pass the check.
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:The method of claim 5, wherein the method further comprises:
    对所述有效数据添加标记;Adding a mark to the valid data;
    将所述标记和所述有效数据一并写入所述目标数据块;Writing the mark and the valid data together into the target data block;
    判断所述目标数据块是否包含所述标记,若包含,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。Determining whether the target data block includes the tag, and if so, the data of the target data block passes the verification, otherwise the data of the target data block fails the verification.
  7. 一种垃圾回收的装置,应用于存储设备,其特征在于,包括:A device for garbage collection, which is applied to a storage device, and includes:
    获取模块,用于获取待搬移数据块的有效数据;An obtaining module, configured to obtain valid data of the data block to be moved;
    写入模块,用于将所述有效数据写入目标数据块;a writing module, configured to write the valid data into the target data block;
    校验模块,用于对所述目标数据块的数据进行校验,如果所述目标数据块的数据未通过校验,则重新将所述有效数据写入目标数据块,直至所述目标数据块的数据通过校验。a verification module, configured to check data of the target data block, and if the data of the target data block fails verification, rewrite the valid data into the target data block until the target data block The data is verified.
  8. 根据权利要求7所述的装置,其特征在于,所述获取模块包括:The device according to claim 7, wherein the obtaining module comprises:
    第一获取单元,用于所述获取待搬移数据块的有效数据内容,或者,a first obtaining unit, configured to acquire valid data content of the data block to be moved, or
    第二获取单元,用于所述获取待搬移数据块的有效数据物理地址。And a second acquiring unit, configured to acquire a valid data physical address of the data block to be moved.
  9. 根据权利要求8所述的装置,其特征在于,所述装置还包括:The device according to claim 8, wherein the device further comprises:
    确定模块,用于根据所述有效数据内容或所述有效数据物理地址确定目标数据块容量空间及地址。And a determining module, configured to determine a target data block capacity space and an address according to the valid data content or the valid data physical address.
  10. 根据权利要求9所述的装置,其特征在于,所述写入模块包括:The device according to claim 9, wherein the writing module comprises:
    读取单元,用于读取所述有效数据内容或所述有效数据物理地址;a reading unit, configured to read the valid data content or the valid data physical address;
    写入单元,用于将所述有效数据内容或所述有效数据物理地址写入所述目标数据块地址。a writing unit, configured to write the valid data content or the valid data physical address to the target data block address.
  11. 根据权利要求7-10任一项所述的装置,其特征在于,所述校验模块包括:The apparatus according to any one of claims 7 to 10, wherein the verification module comprises:
    第一校验单元,用于判断所述有效数据是否全部写入所述目标数据块,若所述有效数据全部写入所述目标数据块,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验;或者a first check unit, configured to determine whether the valid data is all written into the target data block, and if the valid data is all written into the target data block, the data of the target data block passes verification, otherwise The data of the target data block has not passed the verification; or
    第二校验单元,用于判断所述有效数据的错误检查和纠正的错误数是否超过预设阈值,若所述错误检查和纠正的错误数未超过所述预设阈值,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。a second checking unit, configured to determine whether the number of errors in the error check and correction of the valid data exceeds a preset threshold, and if the number of errors in the error check and correction does not exceed the preset threshold, the target data The data of the block passes the check, otherwise the data of the target data block does not pass the check.
  12. 根据权利要求11所述的装置,其特征在于,所述装置还包括:The device according to claim 11, wherein the device further comprises:
    标记模块,用于对所述有效数据添加标记;a marking module, configured to add a mark to the valid data;
    标记写入模块,用于将所述标记和所述有效数据一并写入所述目标数据块;a mark writing module, configured to write the mark and the valid data together into the target data block;
    标记判断模块,用于判断所述目标数据块是否包含所述标记,若包含,则所述目标数据块的数据通过校验,否则所述目标数据块的数据未通过校验。The flag determining module is configured to determine whether the target data block includes the tag, and if yes, the data of the target data block passes the verification, otherwise the data of the target data block fails to pass the verification.
  13. 一种存储设备,其特征在于,包括:控制器;以及与所述控制器通信连接的存储器;其中,所述存储器存储有可被所述控制器执行的指令,所述指令被所述控制器执行,以使所述控制器能够执行权利要求1至6任一项所述的方法。A storage device, comprising: a controller; and a memory communicatively coupled to the controller; wherein the memory stores instructions executable by the controller, the instructions being by the controller Executing to enable the controller to perform the method of any of claims 1 to 6.
PCT/CN2018/105305 2018-03-15 2018-09-12 Trash recovery method and device and storage equipment WO2019174205A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810215595.0 2018-03-15
CN201810215595.0A CN108415853A (en) 2018-03-15 2018-03-15 A kind of method, apparatus and storage device of garbage reclamation

Publications (1)

Publication Number Publication Date
WO2019174205A1 true WO2019174205A1 (en) 2019-09-19

Family

ID=63131821

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/105305 WO2019174205A1 (en) 2018-03-15 2018-09-12 Trash recovery method and device and storage equipment

Country Status (2)

Country Link
CN (1) CN108415853A (en)
WO (1) WO2019174205A1 (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108415853A (en) * 2018-03-15 2018-08-17 深圳市江波龙电子有限公司 A kind of method, apparatus and storage device of garbage reclamation
CN109343796B (en) * 2018-09-21 2022-03-01 新华三技术有限公司 Data processing method and device
CN111081284A (en) * 2018-10-19 2020-04-28 合肥沛睿微电子股份有限公司 Memory device and control method
CN111324281B (en) * 2018-12-14 2024-02-06 兆易创新科技集团股份有限公司 Memory and control method and device thereof
CN111949558B (en) * 2019-05-16 2023-11-21 兆易创新科技集团股份有限公司 Garbage data recovery method and device and storage equipment
CN110362500B (en) * 2019-06-03 2023-06-20 深圳市金泰克半导体有限公司 Solid state disk garbage recycling method and device, solid state disk and storage medium
CN110931072B (en) * 2019-11-28 2022-03-22 深信服科技股份有限公司 Bad track scanning method, device, equipment and storage medium
CN111930301A (en) * 2020-06-29 2020-11-13 深圳佰维存储科技股份有限公司 Garbage recycling optimization method and device, storage medium and electronic equipment
CN111966298B (en) * 2020-08-24 2021-07-27 深圳三地一芯电子有限责任公司 Reverse programming implementation method and device based on Flash memory
CN112347001B (en) * 2020-10-13 2023-09-26 深圳市宏旺微电子有限公司 Verification method and device for flash memory garbage collection and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103955431A (en) * 2014-04-11 2014-07-30 深圳市江波龙电子有限公司 Data management method and apparatus in flash memory storage device
CN104794019A (en) * 2015-04-17 2015-07-22 深圳市江波龙电子有限公司 Data protection method and device for embedded memorizer
WO2017173623A1 (en) * 2016-04-07 2017-10-12 华为技术有限公司 Method and storage device for processing stripes in storage device
US20170329532A1 (en) * 2016-05-13 2017-11-16 Seagate Technology Llc Data refresh in flash memory
CN108415853A (en) * 2018-03-15 2018-08-17 深圳市江波龙电子有限公司 A kind of method, apparatus and storage device of garbage reclamation

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101634938A (en) * 2009-08-20 2010-01-27 成都市华为赛门铁克科技有限公司 Data migration method and data migration device of solid state disk and solid state disk
CN103971066A (en) * 2014-05-20 2014-08-06 浪潮电子信息产业股份有限公司 Verification method for integrity of big data migration in HDFS
CN105808612B (en) * 2014-12-31 2019-08-27 北京嘀嘀无限科技发展有限公司 The method and apparatus of data for migrating data library
CN105528301A (en) * 2015-12-07 2016-04-27 中国人民解放军信息工程大学 NAND Flash memory garbage collection method
US10185657B2 (en) * 2016-04-13 2019-01-22 Nanjing University Method and system for optimizing deterministic garbage collection in NAND flash storage systems
CN107301132A (en) * 2017-06-09 2017-10-27 华中科技大学 A kind of flash memory garbage reclamation optimization method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103955431A (en) * 2014-04-11 2014-07-30 深圳市江波龙电子有限公司 Data management method and apparatus in flash memory storage device
CN104794019A (en) * 2015-04-17 2015-07-22 深圳市江波龙电子有限公司 Data protection method and device for embedded memorizer
WO2017173623A1 (en) * 2016-04-07 2017-10-12 华为技术有限公司 Method and storage device for processing stripes in storage device
US20170329532A1 (en) * 2016-05-13 2017-11-16 Seagate Technology Llc Data refresh in flash memory
CN108415853A (en) * 2018-03-15 2018-08-17 深圳市江波龙电子有限公司 A kind of method, apparatus and storage device of garbage reclamation

Also Published As

Publication number Publication date
CN108415853A (en) 2018-08-17

Similar Documents

Publication Publication Date Title
WO2019174205A1 (en) Trash recovery method and device and storage equipment
TWI613652B (en) Data storage device and operating method therefor
TWI645404B (en) Data storage device and control method for non-volatile memory
US9996297B2 (en) Hot-cold data separation method in flash translation layer
US10698809B2 (en) Method, associated flash controller and electronic device for accessing flash module with data validity verification
CN110928807B (en) Apparatus and method for checking valid data in a memory system
US11269722B2 (en) Apparatus for diagnosing memory system and operating method thereof
TWI646535B (en) Data storage device and non-volatile memory operation method
US10108503B2 (en) Methods and systems for updating a recovery sequence map
US9928166B2 (en) Detecting hot spots through flash memory management table snapshots
TWI470431B (en) Data writing method, memory controller and memory storage apparatus
US10635527B2 (en) Method for processing data stored in a memory device and a data storage device utilizing the same
CN108958961B (en) Data storage device and data error management method
US20200327066A1 (en) Method and system for online recovery of logical-to-physical mapping table affected by noise sources in a solid state drive
TWI459198B (en) Memory storage device, memory controller thereof, and method for identifying valid data
TWI523030B (en) Method for managing buffer memory, memory controllor, and memory storage device
TWI616807B (en) Data writing method and storage controller
US20130219244A1 (en) Storage device
US10942678B2 (en) Method of accessing data in storage device, method of managing data in storage device and storage device performing the same
US9384124B2 (en) Data storage device, memory control method, and electronic device with data storage device
TW201732531A (en) Memory device and control unit thereof, and data storage method for memory device
US11620234B2 (en) Operation-deterministic write operations for data recovery and integrity checks
Xiao et al. Per-file secure deletion for flash-based solid state drives
US11429485B1 (en) Memories with end-to-end data protection using physical location check
CN115248748A (en) Storage device performing metadata management and method of operating the same

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18909279

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18909279

Country of ref document: EP

Kind code of ref document: A1