CN105917303A - Controller, method for identifying data block stability and storage system - Google Patents
Controller, method for identifying data block stability and storage system Download PDFInfo
- Publication number
- CN105917303A CN105917303A CN201480035916.9A CN201480035916A CN105917303A CN 105917303 A CN105917303 A CN 105917303A CN 201480035916 A CN201480035916 A CN 201480035916A CN 105917303 A CN105917303 A CN 105917303A
- Authority
- CN
- China
- Prior art keywords
- logical address
- count value
- target
- data block
- destination logical
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明实施例提供了一种控制器,包括处理器和缓存,所述处理器,用于按照预设的哈希函数对所述多个逻辑地址中的目标逻辑地址进行计算,获得目标哈希值;根据所述目标哈希值确定所述哈希表中与所述目标逻辑地址对应的目标表项,所述目标表项中记录有目标计数值;根据所述目标计数值,和计数值与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别,所述稳定级别用于表示所述目标逻辑地址对应的数据块的稳定性;将所述目标逻辑地址以及所述目标逻辑地址对应的数据块的稳定级别发送给闪存装置。可以使得闪存装置将相同稳定级别的数据块进行集中存储。
An embodiment of the present invention provides a controller, including a processor and a cache, and the processor is configured to calculate a target logical address among the plurality of logical addresses according to a preset hash function to obtain a target hash value; determine the target entry corresponding to the target logical address in the hash table according to the target hash value, and record the target count value in the target entry; according to the target count value, and the count value The corresponding relationship with the stability level determines the stability level of the data block corresponding to the target logical address, and the stability level is used to represent the stability of the data block corresponding to the target logical address; the target logical address and the target The stability level of the data block corresponding to the logical address is sent to the flash memory device. The flash memory device can centrally store data blocks of the same stability level.
Description
本发明实施例涉及存储技术领域,特别是一种控制器、识别数据块稳定性的方法和存储系统。Embodiments of the present invention relate to the field of storage technology, in particular to a controller, a method for identifying the stability of a data block, and a storage system.
Flash Memory(闪存)装置是一种非易失性存储器,其存储介质是NAND Flash,具有断电后数据不消失的特点,因此,被广泛的作为外部和内部存储器使用。以NAND Flash为存储介质的闪存装置可能是固态硬盘(全称:Solid State Device,简称:SSD),又名固态驱动器(全称:Solid State Drive,简称:SSD),还可能是其他存储器。Flash Memory (flash memory) device is a kind of non-volatile memory, and its storage medium is NAND Flash, which has the characteristic that the data will not disappear after power failure, so it is widely used as external and internal memory. The flash memory device using NAND Flash as the storage medium may be a solid-state hard drive (full name: Solid State Device, abbreviated: SSD), also known as a solid-state drive (full name: Solid State Drive, abbreviated: SSD), or other memories.
一个SSD通常由多个闪存芯片组成,每个闪存芯片包含若干个块(block)。由于NAND Flash具有擦除特性,保存在block中的数据不会像普通机械硬盘那样直接被修改。当需要对某个逻辑地址指向的数据进行修改时,需要查找一个空闲的block将修改后的数据写入该空闲的block,然后将所述逻辑地址指向新写入的数据,那么,原来的block中的数据则变为无效数据。对于SSD而言,有效数据是指block中保存的有逻辑地址指向的数据,这部分数据可能会被读取;无效数据是指block中保存的没有逻辑地址指向的数据,这部分数据不可能会被读取。An SSD usually consists of multiple flash memory chips, and each flash memory chip contains several blocks. Due to the erasing feature of NAND Flash, the data stored in the block will not be directly modified like ordinary mechanical hard disks. When it is necessary to modify the data pointed to by a logical address, it is necessary to find an idle block, write the modified data into the idle block, and then point the logical address to the newly written data, then the original block The data in becomes invalid data. For SSD, valid data refers to the data stored in the block that is pointed to by a logical address, and this part of data may be read; invalid data refers to the data stored in the block that does not point to a logical address, and this part of data cannot be read. is read.
随着SSD中存储的数据越来越多,可利用的空闲的block越来越少,因此有必要对SSD进行垃圾回收以便产生可供利用的空闲的block。垃圾回收是指将block中的有效数据搬移到空闲的block中去,然后将旧的block进行擦除,经过擦除之后的block又可以作为空闲的block再次写入数据。通常情况下,SSD在进行垃圾回收时,会查找包含无效数据较多的block,因为包含无效数据较多的block包含的有效数据较少,那么需要搬移到空闲block的有效数据会较少。在SSD的寿命跟NAND Flash的擦除次数相关的情况下, 垃圾回收时搬移的数据越少,SSD的写放大就越小。然而,在现有的存储系统中,控制器无法获知该数据被修改的可能性,那么在将数据发送给SSD时,SSD只能按照现有的存储方式来存储数据,各个block中保存的数据被修改的可能性大致相当,因此每个block包含的无效数据的多少也无明显差别。As more and more data are stored in the SSD, there are fewer and fewer available free blocks, so it is necessary to perform garbage collection on the SSD in order to generate available free blocks. Garbage collection refers to moving valid data in a block to an idle block, and then erasing the old block, and the erased block can be used as an idle block to write data again. Normally, when an SSD performs garbage collection, it will look for blocks containing more invalid data, because blocks containing more invalid data contain less valid data, so less valid data needs to be moved to free blocks. In the case that the life of the SSD is related to the erasure times of the NAND Flash, The less data moved during garbage collection, the smaller the write amplification of the SSD. However, in the existing storage system, the controller cannot know the possibility of the data being modified, so when sending the data to the SSD, the SSD can only store the data according to the existing storage method, and the data stored in each block The probability of being modified is roughly the same, so there is no obvious difference in the amount of invalid data contained in each block.
发明内容Contents of the invention
本发明实施例第一方面提供了一种控制器,所述控制器包括处理器和缓存,所述缓存中保存有多个逻辑地址,并且所述缓存中还保存有哈希表,所述哈希表包括多个表项,每个表项对应一个逻辑地址,并且,每个表项中记录有计数值,所述计数值用于表示所述逻辑地址对应的数据块的修改次数。其中,所述处理器,用于按照预设的哈希函数对所述多个逻辑地址中的目标逻辑地址进行计算,获得目标哈希值。然后,根据所述目标哈希值确定所述哈希表中与所述目标逻辑地址对应的目标表项,所述目标表项中记录有目标计数值。再根据所述目标计数值,和计数值与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别,所述稳定级别用于表示所述目标逻辑地址对应的数据块的稳定性。最后,将所述目标逻辑地址以及所述目标逻辑地址对应的数据块的稳定级别发送给闪存装置。The first aspect of the embodiments of the present invention provides a controller, the controller includes a processor and a cache, the cache stores a plurality of logical addresses, and the cache also stores a hash table, the hash The table includes a plurality of entries, each entry corresponds to a logical address, and each entry records a count value, and the count value is used to indicate the number of times of modification of the data block corresponding to the logical address. Wherein, the processor is configured to calculate a target logical address among the plurality of logical addresses according to a preset hash function to obtain a target hash value. Then, a target entry corresponding to the target logical address in the hash table is determined according to the target hash value, and a target count value is recorded in the target entry. Determine the stability level of the data block corresponding to the target logical address according to the target count value and the corresponding relationship between the count value and the stability level, and the stability level is used to represent the stability of the data block corresponding to the target logic address . Finally, the target logical address and the stability level of the data block corresponding to the target logical address are sent to the flash memory device.
在第一方面的第一种实施方式中,所述计数值与稳定级别的对应关系包括计数值区间与稳定级别的对应关系。所述处理器,具体用于根据所述目标计数值确定目标计数值区间,所述目标计数值位于所述目标计数值区间中。然后,根据所述目标计数值区间,和所述计数值区间与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别。In the first implementation manner of the first aspect, the correspondence between the count value and the stability level includes the correspondence between the count value interval and the stability level. The processor is specifically configured to determine a target count value interval according to the target count value, and the target count value is located in the target count value interval. Then, the stability level of the data block corresponding to the target logical address is determined according to the target count value interval and the corresponding relationship between the count value interval and the stability level.
在第一方面的第二种实施方式中,所述处理器,还用于在所述按照预设的哈希函数对所述多个逻辑地址中的目标逻辑地址进行计算之前,获取所述目标逻辑地址。然后,根据所述目标逻辑地址以及所述哈希函数进行计算,获得所述目标哈希值。再根据所述目标哈希值确定所述目标表项,所述目标 表项中记录有计数值,增加所述目标表项中记录的计数值,所述目标计数值等于所述增加后的所述目标表项中记录的计数值。In the second implementation manner of the first aspect, the processor is further configured to obtain the target logical address before calculating the target logical address among the plurality of logical addresses according to the preset hash function logical address. Then, calculation is performed according to the target logical address and the hash function to obtain the target hash value. Then determine the target entry according to the target hash value, the target A count value is recorded in the entry, and the count value recorded in the target entry is increased, and the target count value is equal to the increased count value recorded in the target entry.
本发明实施例第二方面提供了一种识别数据块稳定性的方法,所述方法应用于控制器中,所述控制器包括处理器和缓存,所述缓存中保存有多个逻辑地址,并且所述缓存中还保存有哈希表,所述哈希表包括多个表项,每个表项对应一个逻辑地址,并且,每个表项中记录有计数值,所述计数值用于表示所述逻辑地址对应的数据块的修改次数。所述方法由所述处理器执行,包括如下步骤:按照预设的哈希函数对所述多个逻辑地址中的目标逻辑地址进行计算,获得目标哈希值。然后,根据所述目标哈希值确定所述哈希表中与所述目标逻辑地址对应的目标表项,所述目标表项中记录有目标计数值。再将所述目标逻辑地址以及所述目标逻辑地址对应的数据块的稳定级别发送给闪存装置。The second aspect of the embodiment of the present invention provides a method for identifying the stability of a data block, the method is applied to a controller, the controller includes a processor and a cache, and multiple logical addresses are stored in the cache, and A hash table is also saved in the cache, the hash table includes a plurality of entries, each entry corresponds to a logical address, and a count value is recorded in each entry, and the count value is used to represent The modification times of the data block corresponding to the logical address. The method is executed by the processor, and includes the following steps: calculating a target logical address among the plurality of logical addresses according to a preset hash function to obtain a target hash value. Then, a target entry corresponding to the target logical address in the hash table is determined according to the target hash value, and a target count value is recorded in the target entry. Then send the target logical address and the stability level of the data block corresponding to the target logical address to the flash memory device.
在第二方面的第一种实施方式中,所述计数值与稳定级别的对应关系包括计数值区间与稳定级别的对应关系。所述根据所述目标计数值,和计数值与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别包括:根据所述目标计数值确定目标计数值区间,所述目标计数值位于所述目标计数值区间中。再根据所述目标计数值区间,和所述计数值区间与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别。In the first implementation manner of the second aspect, the correspondence between the count value and the stability level includes the correspondence between the count value interval and the stability level. The determining the stability level of the data block corresponding to the target logical address according to the target count value and the corresponding relationship between the count value and the stability level includes: determining a target count value interval according to the target count value, and the target count value in the range of the target count value. The stability level of the data block corresponding to the target logical address is then determined according to the target count value interval and the corresponding relationship between the count value interval and the stability level.
在第二方面的第二种实施方式中,在所述按照预设的哈希函数对所述多个逻辑地址中的目标逻辑地址进行计算之前,所述方法还包括:获取所述目标逻辑地址。然后,根据所述目标逻辑地址以及所述哈希函数进行计算,获得所述目标哈希值。再根据所述目标哈希值确定所述目标表项,所述目标表项中记录有计数值,增加所述目标表项中记录的计数值,所述目标计数值等于所述增加后的所述目标表项中记录的计数值。In the second implementation manner of the second aspect, before the calculation of the target logical address among the plurality of logical addresses according to the preset hash function, the method further includes: acquiring the target logical address . Then, calculation is performed according to the target logical address and the hash function to obtain the target hash value. Then determine the target entry according to the target hash value, the count value is recorded in the target entry, and the count value recorded in the target entry is increased, and the target count value is equal to the increased value The count value recorded in the target entry.
本发明实施例第三方面提供了一种存储系统,所述存储系统包括第一方面至第一方面第二种实施方式中任意一种实施方式的控制器,以及闪存装 置。所述闪存装置包括主控制器和闪存芯片,所述闪存芯片包括多个块,所述主控制器包括处理器。所述处理器,用于获取目标逻辑地址对应的稳定级别,所述稳定级别用于表示数据块的稳定性。然后,根据所述目标逻辑地址对应的稳定级别,将所述目标逻辑地址对应的数据块写入所述稳定级别对应的块中。The third aspect of the embodiments of the present invention provides a storage system, the storage system includes a controller in any one of the first to second implementations of the first aspect, and a flash memory device place. The flash memory device includes a main controller and a flash memory chip, the flash memory chip includes a plurality of blocks, and the main controller includes a processor. The processor is configured to acquire a stability level corresponding to the target logical address, and the stability level is used to represent the stability of the data block. Then, according to the stability level corresponding to the target logic address, write the data block corresponding to the target logic address into the block corresponding to the stability level.
在第三方面的第一种实施方式中,所述方法还包括:在所述闪存芯片中查找包含无效数据最多的块,所述包含无效数据最多的块包括所述目标逻辑地址对应的数据块。In the first implementation manner of the third aspect, the method further includes: searching for a block containing the most invalid data in the flash chip, and the block containing the most invalid data includes the data block corresponding to the target logical address .
在第三方面的第二种实施方式中,所述方法还包括:在所述闪存芯片中查找最长时间内未被擦除的块,所述最长时间内未被擦除的块包括所述目标逻辑地址对应的数据块。In the second implementation manner of the third aspect, the method further includes: searching for a block that has not been erased for the longest time in the flash memory chip, and the block that has not been erased for the longest time includes the The data block corresponding to the target logical address.
在第三方面的第三种实施方式中,所述主控制器还包括缓存。所述获取目标逻辑地址对应的稳定级别包括:确定所述缓存中保存的逻辑地址的个数达到预设阈值时,获取所述目标逻辑地址对应的稳定级别,其中,所述逻辑地址对应的稳定级别与所述目标逻辑地址对应的稳定级别相同。In a third implementation manner of the third aspect, the main controller further includes a cache. The obtaining the stability level corresponding to the target logical address includes: when determining that the number of logical addresses stored in the cache reaches a preset threshold, obtaining the stability level corresponding to the target logical address, wherein the stable level corresponding to the logical address The level is the same as the stability level corresponding to the target logical address.
本发明实施例第四方面提供了一种识别数据块稳定性的装置,所述装置位于控制器中。所述装置包括:存储模块,用于保存多个逻辑地址以及哈希表,所述哈希表包括多个表项,每个表项对应一个逻辑地址,并且,每个表项中记录有计数值,所述计数值用于表示所述逻辑地址对应的数据块的修改次数。计算模块,用于按照预设的哈希函数对所述多个逻辑地址中的目标逻辑地址进行计算,获得目标哈希值;根据所述目标哈希值确定所述哈希表中与所述目标逻辑地址对应的目标表项,所述目标表项中记录有目标计数值。确定模块,用于根据所述目标计数值,和计数值与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别,所述稳定级别用于表示所述目标逻辑地址对应的数据块的稳定性。发送模块,用于将所述目标逻辑地址以及所述目标逻辑地址对应的数据块的稳定级别发送给闪存装置。 A fourth aspect of the embodiments of the present invention provides an apparatus for identifying the stability of a data block, where the apparatus is located in a controller. The device includes: a storage module for saving a plurality of logical addresses and a hash table, the hash table includes a plurality of entries, each entry corresponds to a logical address, and a count is recorded in each entry value, and the count value is used to indicate the modification times of the data block corresponding to the logical address. A calculation module, configured to calculate a target logical address among the plurality of logical addresses according to a preset hash function to obtain a target hash value; A target entry corresponding to the target logical address, where the target count value is recorded. A determining module, configured to determine the stability level of the data block corresponding to the target logical address according to the target count value and the corresponding relationship between the count value and the stability level, and the stability level is used to represent the data corresponding to the target logic address block stability. A sending module, configured to send the target logical address and the stability level of the data block corresponding to the target logical address to the flash memory device.
在第四方面的第一种实施方式中,所述计数值与稳定级别的对应关系包括计数值区间与稳定级别的对应关系。所述确定模块,具体用于根据所述目标计数值确定目标计数值区间,所述目标计数值位于所述目标计数值区间中。然后,根据所述目标计数值区间,和所述计数值区间与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别。In the first implementation manner of the fourth aspect, the correspondence between the count value and the stability level includes the correspondence between the count value interval and the stability level. The determining module is specifically configured to determine a target count value interval according to the target count value, and the target count value is located in the target count value interval. Then, the stability level of the data block corresponding to the target logical address is determined according to the target count value interval and the corresponding relationship between the count value interval and the stability level.
本发明实施例第五方面提供了一种计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令用于执行如第二方面至第二方面第二种实施方式中任意一种实施方式所述的方法。The fifth aspect of the embodiments of the present invention provides a computer program product, including a computer-readable storage medium storing program code, the program code includes instructions for executing the second implementation mode of the second aspect to the second aspect The method described in any one of the embodiments.
在本实施例中,控制器可以根据逻辑地址计算获得哈希值,所述哈希值与哈希表中的一个表项对应,所述表项中记录有计数值,所述计数值用于表示所述逻辑地址对应的数据块的修改次数,因此可以根据计数值获得所述逻辑地址对应的数据块的稳定级别,所述稳定级别可以反映所述逻辑地址对应的数据块的稳定性,并且将所述数据块的稳定级别和逻辑地址发送给闪存装置,使得闪存装置将相同稳定级别的数据块进行集中存储,从而在进行后续的垃圾回收操作时搬移较少的有效数据,减小写放大。In this embodiment, the controller can calculate and obtain a hash value according to the logical address, and the hash value corresponds to an entry in the hash table, and a count value is recorded in the entry, and the count value is used for Indicates the number of modifications of the data block corresponding to the logical address, so the stability level of the data block corresponding to the logical address can be obtained according to the count value, and the stability level can reflect the stability of the data block corresponding to the logical address, and Send the stability level and logical address of the data block to the flash memory device, so that the flash memory device will centrally store the data blocks of the same stability level, thereby moving less valid data when performing subsequent garbage collection operations, reducing write amplification .
为了更清楚地说明本发明实施例的技术方案,下面将对现有技术或实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the prior art or the accompanying drawings required in the embodiments. Obviously, the accompanying drawings in the following description are only some implementations of the present invention For example, those of ordinary skill in the art can also obtain other drawings based on these drawings on the premise of not paying creative efforts.
图1是本发明实施例提供的存储系统的组成图;FIG. 1 is a composition diagram of a storage system provided by an embodiment of the present invention;
图2是本发明实施例提供的控制器的结构示意图;Fig. 2 is a schematic structural diagram of a controller provided by an embodiment of the present invention;
图3A是本发明实施例提供的闪存装置的存储介质的结构示意图;FIG. 3A is a schematic structural diagram of a storage medium of a flash memory device provided by an embodiment of the present invention;
图3B是本发明实施例提供的闪存装置的主控制器的结构示意图;3B is a schematic structural diagram of a main controller of a flash memory device provided by an embodiment of the present invention;
图4是本发明实施例提供的识别数据块稳定性的方法的流程示意图;FIG. 4 is a schematic flowchart of a method for identifying data block stability provided by an embodiment of the present invention;
图5是本发明实施例提供的一种在闪存装置中存储数据的方法的流程示 意图;FIG. 5 is a flowchart of a method for storing data in a flash memory device according to an embodiment of the present invention. intention;
图6是本发明实施例提供的哈希表的示意图;Fig. 6 is a schematic diagram of a hash table provided by an embodiment of the present invention;
图7是本发明实施例提供的识别数据块稳定性的装置的结构示意图。Fig. 7 is a schematic structural diagram of an apparatus for identifying data block stability provided by an embodiment of the present invention.
本发明实施例提出了一种控制器、识别数据块稳定性的方法和存储系统,用于控制器识别出逻辑地址对应的数据块的稳定级别,并且将所述逻辑地址和稳定级别发送给闪存装置,使得闪存装置能够将稳定级别相同的数据块集中存储,那么在进行后续的垃圾回收时选择到的块所包含的有效数据尽可能得少,从而减小闪存装置的写放大。Embodiments of the present invention provide a controller, a method for identifying the stability of a data block, and a storage system, for the controller to identify the stability level of the data block corresponding to the logical address, and send the logical address and the stability level to the flash memory device, so that the flash memory device can centrally store data blocks with the same stability level, then the selected block contains as little valid data as possible during subsequent garbage collection, thereby reducing the write amplification of the flash memory device.
在描述本发明实施例之前,首先对下面将要出现的术语进行说明:Before describing the embodiments of the present invention, firstly, the following terms will be explained:
数据对象是指包含实际数据的对象,可以是块数据,也可以是文件或者其他形式的数据。Data objects refer to objects containing actual data, which can be block data, files or other forms of data.
数据块是指由数据对象划分而成的数据单元。为了方便管理,一个数据对象可以被划分为若干个数据块,每个数据块的尺寸相同。A data block refers to a data unit divided by a data object. For the convenience of management, a data object can be divided into several data blocks, and each data block has the same size.
数据块的元数据是指用于描述数据块的信息,例如数据块的逻辑地址、数据块的物理地址、逻辑地址与物理地址之间的对应关系、数据块的写入时间等等。The metadata of the data block refers to information used to describe the data block, such as the logical address of the data block, the physical address of the data block, the correspondence between the logical address and the physical address, the writing time of the data block, and the like.
稳定数据是指被修改的可能性相对较低的数据。Stable data refers to data that has a relatively low probability of being modified.
逻辑块地址,又称逻辑地址(英文全称:Logical Block Address,英文简称:LBA),是指数据块的存放地址,该地址并非数据块存储在SSD中的实际地址,而是对外呈现的可访问的地址。Logical block address, also known as logical address (full name in English: Logical Block Address, English abbreviation: LBA), refers to the storage address of the data block. This address is not the actual address of the data block stored in the SSD, but the externally accessible the address of.
物理块地址,又称物理地址(英文全称:Physical Block Address,英文简称:PBA)是指数据块存储在SSD中的实际地址。The physical block address, also known as the physical address (English full name: Physical Block Address, English abbreviation: PBA) refers to the actual address of the data block stored in the SSD.
SSD中的有效数据是指在SSD的block中有逻辑地址指向的数据块,也就是说其物理地址有对应的逻辑地址。 Valid data in SSD refers to the data block pointed to by logical address in the block of SSD, that is to say, its physical address has corresponding logical address.
SSD中的无效数据通常是指在SSD的block中保存的没有逻辑地址指向的数据块,也就是说其物理地址没有对应的逻辑地址。Invalid data in SSD usually refers to the data block stored in the block of SSD without logical address pointing, that is to say, its physical address has no corresponding logical address.
图1描绘了本发明实施例提供的存储系统的组成图,图1所示的存储系统包括控制器11和多个闪存装置22。其中,闪存装置22是以Flash颗粒为存储介质的存储装置,可以包括固态硬盘(全称:Solid State Device,简称:SSD),又名固态驱动器(全称:Solid State Drive,简称:SSD),还可能包括其他存储器。本实施例中,闪存装置22以SSD为例说明。FIG. 1 depicts a composition diagram of a storage system provided by an embodiment of the present invention. The storage system shown in FIG. 1 includes a controller 11 and multiple flash memory devices 22 . Wherein, the flash memory device 22 is a storage device with Flash particles as a storage medium, which may include a solid state drive (full name: Solid State Device, abbreviated: SSD), also known as a solid state drive (full name: Solid State Drive, abbreviated: SSD). including other memory. In this embodiment, the flash memory device 22 is described by taking an SSD as an example.
图1仅是示例性说明,并不限定具体的组网方式,如:级联树形组网、环状组网都可以。只要控制器11和闪存装置22之间能够相互通信。FIG. 1 is only an illustration, and does not limit a specific networking mode, for example, cascading tree networking and ring networking are all possible. As long as the controller 11 and the flash memory device 22 can communicate with each other.
控制器11可以包括当前技术已知的任何计算设备,如服务器、台式计算机等等。控制器11可以接收主机(图1中未示出)发送的数据对象,并且向闪存装置22发送写数据请求,使得闪存装置22将写数据请求中携带的数据对象写入其闪存芯片中。Controller 11 may include any computing device known in the art, such as a server, desktop computer, and the like. The controller 11 can receive the data object sent by the host (not shown in FIG. 1 ), and send a write data request to the flash memory device 22, so that the flash memory device 22 writes the data object carried in the write data request into its flash chip.
请参考图2,图2是本发明实施例控制器11的结构示意图。如图2所示,控制器11主要包括处理器(processor)118、缓存(cache)120、存储器(memory)122、通信总线(简称总线)126以及通信接口(Communication Interface)128。处理器118、缓存120、存储器122以及通信接口128通过通信总线126完成相互间的通信。Please refer to FIG. 2 , which is a schematic structural diagram of a controller 11 according to an embodiment of the present invention. As shown in FIG. 2 , the controller 11 mainly includes a processor (processor) 118, a cache (cache) 120, a memory (memory) 122, a communication bus (bus for short) 126 and a communication interface (Communication Interface) 128. The processor 118 , the cache 120 , the memory 122 and the communication interface 128 communicate with each other through the communication bus 126 .
处理器118可能是一个中央处理器CPU,或者是特定集成电路ASIC(Application Specific Integrated Circuit),或者是被配置成实施本发明实施例的一个或多个集成电路。在本发明实施例中,处理器118用于接收来自主机的数据对象,将所述数据对象经过一定的处理后再发送给闪存装置22。The processor 118 may be a central processing unit CPU, or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention. In the embodiment of the present invention, the processor 118 is configured to receive a data object from the host, and send the data object to the flash memory device 22 after certain processing.
通信接口128,用于与主机或闪存装置22通信。The communication interface 128 is used for communicating with the host or the flash memory device 22 .
存储器122,用于存放程序124,存储器122可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。可以理解的是,存储器122可以为随机存储器(全称:Random-Access Memory,简称:RAM)、磁碟、硬盘、光盘、固态硬盘(全称:Solid State Disk,简称:SSD)或者非易失性存储器等各种可以存储程序代码的非短暂性的(non-transitory)机器可读介质。The memory 122 is used to store the program 124. The memory 122 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. It can be understood that the memory 122 can be a random access memory (full name: Random-Access Memory, referred to as: RAM), magnetic disk, hard disk, optical disk, solid state disk (full name: Solid State Disk, referred to as: SSD) or non-volatile memory and other non-transitory (non-transitory) that can store program code machine-readable medium.
缓存120(Cache)用于暂时存放从主机接收的数据对象或从闪存装置22读取的数据对象。另外,由于Cache读写数据的速度较快,为了方便读取也可以将一些经常使用的信息存放在Cache中,例如数据块的逻辑地址。缓存120可以是RAM、储存级内存(全称:Storage-Class Memory,简称:SCM)、非易失存储(全称:Non-Volatile Memory,简称:NVM)、闪存(Flash memory)或固态硬盘(全称:Solid State Disk,简称:SSD)等各种可以存储数据的非短暂性的(non-transitory)机器可读介质,在此不做限定。The cache 120 (Cache) is used to temporarily store data objects received from the host or read from the flash memory device 22 . In addition, because the Cache reads and writes data faster, some frequently used information can also be stored in the Cache for the convenience of reading, such as the logical address of the data block. The cache 120 can be RAM, storage-class memory (full name: Storage-Class Memory, abbreviated: SCM), non-volatile storage (full name: Non-Volatile Memory, abbreviated: NVM), flash memory (Flash memory) or solid-state hard disk (full name: Solid State Disk (SSD for short) and other non-transitory (non-transitory) machine-readable media that can store data are not limited here.
缓存120和存储器122可以合设或者分开设置,本发明实施例对此不做限定。The cache 120 and the memory 122 may be set together or separately, which is not limited in this embodiment of the present invention.
程序124可以包括程序代码,所述程序代码包括计算机操作指令。例如,程序代码可以包括稳定性判断模块,通过该模块可以判断每个LBA中保存的数据块被修改的次数,也就是说,判断LBA对应的数据块的稳定性。Program 124 may include program code including computer operating instructions. For example, the program code may include a stability judgment module, through which the number of times the data block stored in each LBA is modified can be judged, that is, the stability of the data block corresponding to the LBA can be judged.
下面简要地介绍稳定性判断模块的功能:The following briefly introduces the functions of the stability judgment module:
首先,为了完成此功能,需要在缓存120中保存一张哈希表(为了防止丢失,可以在闪存装置22中另存一份作为备份),所述哈希表包括多个表项,每个表项中记录有一个计数值。哈希表的表项的个数和图1所示的存储系统的可用容量有关,假设所述存储系统存储有N个数据块(N为正整数),每个数据块的大小为4KB,那么哈希表的表项可以有N的2-8倍个。First, in order to complete this function, a hash table needs to be saved in the cache 120 (in order to prevent loss, another copy can be stored in the flash memory device 22 as a backup), and the hash table includes a plurality of entries, each table There is a count value recorded in the item. The number of entries in the hash table is related to the available capacity of the storage system shown in Figure 1, assuming that the storage system stores N data blocks (N is a positive integer), and the size of each data block is 4KB, then There can be 2-8 times the number of entries in the hash table.
其次,当控制器11接收主机发送的数据对象之后,可以将所述数据对象划分为尺寸相同的若干个数据块。另外,控制器11在接收所述数据对象时,也会接收所述数据对象的地址信息,所述地址信息可以包括逻辑单元号(英文全称:Logical Unit Number,英文简称:LUN)的ID以及LUN的起始地址偏移量;或者文件的ID以及文件的起始地址偏移量等等;或者当存 储系统具有多个文件系统时,所述地址信息可以包括文件系统的ID、文件的ID以及文件的起始地址偏移量等等。在将所述数据对象划分为尺寸相同的若干个数据块之后,可以根据所述数据对象的地址信息以及多级映射表,获取每个数据块的逻辑地址。Secondly, after receiving the data object sent by the host, the controller 11 may divide the data object into several data blocks with the same size. In addition, when the controller 11 receives the data object, it will also receive the address information of the data object, and the address information may include the ID of the logical unit number (English full name: Logical Unit Number, English abbreviation: LUN) and the LUN The start address offset of the file; or the ID of the file and the start address offset of the file, etc.; or when the When the storage system has multiple file systems, the address information may include the ID of the file system, the ID of the file, the offset of the starting address of the file, and the like. After the data object is divided into several data blocks with the same size, the logical address of each data block can be obtained according to the address information of the data object and the multi-level mapping table.
所述稳定性判断模块包括哈希函数,对于一个LBA,可以根据所述哈希函数进行哈希运算,得到哈希值。所述哈希值用于指示上述哈希表中的一个表项的位置,因此根据所述哈希值可以找到该表项中记录的计数值,找到所述LBA对应的计数值之后,对计数值加1(或者其他使其递增的操作,在此不做限定)。依此类推,若后续控制器11接收待写入所述LBA的其他数据块时,所述LBA对应的计数值都会加1。因此,计数值可以用于表示与其对应的LBA中存储的数据块的修改次数。计数值越大,所述LBA中保存的数据块的修改次数越多,就越不稳定;反之,越稳定。The stability judging module includes a hash function, and for an LBA, a hash operation can be performed according to the hash function to obtain a hash value. The hash value is used to indicate the position of an entry in the above hash table, so the count value recorded in the entry can be found according to the hash value, and after the count value corresponding to the LBA is found, the count Add 1 to the value (or other operations to increase it, not limited here). By analogy, when the subsequent controller 11 receives other data blocks to be written into the LBA, the count value corresponding to the LBA will be incremented by 1. Therefore, the count value can be used to represent the modification times of the data block stored in the corresponding LBA. The larger the count value is, the more times the data blocks stored in the LBA are modified, the more unstable they are; otherwise, the more stable they are.
当任务(这里的任务是指控制器11识别每个LBA对应的数据块的稳定性的任务)触发时,处理器118可以依次扫描每个LBA,按照前面描述的哈希函数对LBA进行哈希计算,从而获得哈希值,再根据哈希值找到LBA对应的表项,所述表项中记录有计数值,并且根据计数值获得LBA的稳定级别。稳定级别是一个反映LBA对应的数据块的稳定性的数值,数值越大稳定性越低,反之越高。或者,也可以将稳定级别定义为数值越小稳定性越高,反之越低。When the task (the task here refers to the task that the controller 11 identifies the stability of the data block corresponding to each LBA) is triggered, the processor 118 can scan each LBA in turn, and hash the LBA according to the hash function described above Calculate to obtain the hash value, and then find the entry corresponding to the LBA according to the hash value, the entry records a count value, and obtain the stability level of the LBA according to the count value. The stability level is a value that reflects the stability of the data block corresponding to the LBA. The larger the value, the lower the stability, and vice versa. Alternatively, the stability level can also be defined as the smaller the value, the higher the stability, and vice versa.
控制器11在获得LBA对应的数据块的稳定级别之后,可以将所述LBA与稳定级别发送给闪存装置22,使得闪存装置22将相同级别的数据块集中存储在一个或多个block中。After the controller 11 obtains the stability level of the data block corresponding to the LBA, it can send the LBA and the stability level to the flash memory device 22, so that the flash memory device 22 stores the data blocks of the same level in one or more blocks.
下面介绍闪存装置22的结构与功能。The structure and function of the flash memory device 22 will be described below.
请参考图3A,图3A是本发明实施例闪存装置22的结构示意图。本实施例中,闪存装置22以SSD为例说明。 Please refer to FIG. 3A , which is a schematic structural diagram of a flash memory device 22 according to an embodiment of the present invention. In this embodiment, the flash memory device 22 is described by taking an SSD as an example.
如图3A所示,闪存装置22包括主控制器220和存储介质221。其中,主控制器220用于接收控制器11发送给闪存装置22的I/O请求,或者其他信息,例如数据块的逻辑地址和稳定级别,并且主控制器220还用于执行接收到的I/O请求,例如将I/O请求中携带的数据块写入存储介质221,或者从存储介质221中读取数据块并返回给控制器11。这里的主控制器220是SSD的主控制器。As shown in FIG. 3A , the flash memory device 22 includes a main controller 220 and a storage medium 221 . Wherein, the main controller 220 is used to receive the I/O request sent by the controller 11 to the flash memory device 22, or other information, such as the logical address and stability level of the data block, and the main controller 220 is also used to execute the received I/O request. The /O request, for example, writes the data block carried in the I/O request into the storage medium 221 , or reads the data block from the storage medium 221 and returns it to the controller 11 . The main controller 220 here is the main controller of the SSD.
存储介质221通常由若干个闪存(Flash)芯片组成。每个闪存芯片包括若干个块(block)。每个block包括若干个页(page),主控制器220在将数据块写入block中时是以page为单位写入的。The storage medium 221 is generally composed of several flash memory (Flash) chips. Each flash memory chip includes several blocks. Each block includes several pages (pages), and the main controller 220 writes a data block into a block in units of pages.
由于NAND Flash具有擦除特性,保存在block中的数据不会像普通机械硬盘那样直接被修改。当需要对某个block中的数据进行修改时,需要查找一个空闲的block将修改后的数据写入该空闲的block,那么,原来的block中的数据则变为无效数据。随着SSD中存储的数据越来越多,可利用的空闲的block越来越少,因此有必要对SSD进行垃圾回收以便产生可供利用的空闲的block。本实施例中,在进行垃圾回收时通常会依次选择包含无效数据最多的块进行回收。而垃圾回收的触发条件是所述闪存芯片中包含的空闲的块的数量低于第一阈值,所述第一阈值可以大于10并且小于100的整数。Due to the erasing feature of NAND Flash, the data stored in the block will not be directly modified like ordinary mechanical hard disks. When it is necessary to modify the data in a certain block, it is necessary to find an idle block and write the modified data into the idle block, then the data in the original block becomes invalid data. As more and more data are stored in the SSD, there are fewer and fewer available free blocks, so it is necessary to perform garbage collection on the SSD in order to generate available free blocks. In this embodiment, when performing garbage collection, the blocks containing the most invalid data are usually selected in sequence for recycling. The trigger condition for garbage collection is that the number of free blocks included in the flash memory chip is lower than a first threshold, and the first threshold may be an integer greater than 10 and less than 100.
另外,在闪存装置22内部还需要定期进行巡检,巡检是指为防止闪存芯片中某些block擦除时间过长导致数据丢失,周期性地对闪存芯片中存储的数据进行搬移的操作。对于NAND Flash来说,其保持数据的能力只能维持一定时间,因此需要定期将其中存储的数据重新搬移一次。本实施例中,在进行巡检时通常会依次选择最长时间内未被擦除的块,将所述块中的有效数据搬移到空闲的块中,再擦除原来的块。而巡检的触发条件可以是当预设的巡检周期到达。In addition, regular inspections are required inside the flash memory device 22. Inspection refers to the operation of periodically moving the data stored in the flash memory chip in order to prevent data loss due to the long erasing time of certain blocks in the flash memory chip. For NAND Flash, its ability to retain data can only be maintained for a certain period of time, so the data stored in it needs to be relocated periodically. In this embodiment, during the inspection, the block that has not been erased for the longest time is usually selected sequentially, the valid data in the block is moved to a free block, and then the original block is erased. The trigger condition of the inspection may be when a preset inspection period is reached.
由于SSD的寿命与NAND Flash的擦除次数相关,所以尽量较少SSD内部的数据搬移有利于减小写放大,从而延长SSD的寿命。在本实施例中, SSD内部的数据搬移主要是指垃圾回收或者巡检时对block中有效数据的搬移。可以理解的是,对于待回收的block来说,如果其包含的有效数据越少,需要搬移的数据也越少。因此本发明的目的主要在于控制器识别逻辑地址对应的数据块的稳定性,并且将反映数据块的稳定性的稳定级别发送给SSD,使得SSD中的数据块按照稳定级别来进行集中存储,那么在进行以后的垃圾回收操作时搬移的有效数据就会尽可能得少。Since the lifespan of SSD is related to the erasing times of NAND Flash, minimizing data transfer inside SSD will help reduce write amplification and prolong the lifespan of SSD. In this example, The data movement inside the SSD mainly refers to the movement of valid data in the block during garbage collection or inspection. It is understandable that, for a block to be recycled, if it contains less valid data, the less data needs to be moved. Therefore, the purpose of the present invention is mainly to identify the stability of the data block corresponding to the logical address by the controller, and send the stability level reflecting the stability of the data block to the SSD, so that the data blocks in the SSD are stored centrally according to the stability level, then The amount of valid data moved during subsequent garbage collection operations will be as little as possible.
图3B是本发明实施例描述的闪存装置22中主控制器220的结构示意图。FIG. 3B is a schematic structural diagram of the main controller 220 in the flash memory device 22 described in the embodiment of the present invention.
主控制器220主要包括处理器(processor)218、内存(cache)230、通信总线(简称总线)226以及通信接口(Communication Interface)228。处理器218、缓存230以及通信接口228通过通信总线226完成相互间的通信。The main controller 220 mainly includes a processor (processor) 218 , a memory (cache) 230 , a communication bus (bus for short) 226 and a communication interface (Communication Interface) 228 . The processor 218 , the cache 230 and the communication interface 228 communicate with each other through the communication bus 226 .
处理器218可能是一个中央处理器CPU,或者是特定集成电路ASIC(Application Specific Integrated Circuit),或者是被配置成实施本发明实施例的一个或多个集成电路。在本发明实施例中,处理器218可以用于接收来自控制器11的I/O请求、数据块的逻辑地址以及数据块的稳定级别等信息,另外,处理器218还用于执行I/O请求。The processor 218 may be a central processing unit CPU, or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention. In the embodiment of the present invention, the processor 218 can be used to receive information such as the I/O request from the controller 11, the logical address of the data block, and the stability level of the data block. In addition, the processor 218 is also used to perform I/O ask.
通信接口228,用于与控制器11及存储介质221通信。The communication interface 228 is used for communicating with the controller 11 and the storage medium 221 .
缓存230(Cache)用于缓存从控制器11接收的信息,例如数据块的逻辑地址以及数据块的稳定级别等。缓存230可以是RAM、SCM、NVM等各种可以存储数据的非短暂性的(non-transitory)或者短暂性的(transitory)机器可读介质,在此不做限定。另外,在某些应用场景下,缓存230也可以置于主控制器220的外部。The cache 230 (Cache) is used to cache the information received from the controller 11, such as the logical address of the data block and the stability level of the data block. The cache 230 may be various non-transitory (non-transitory) or transitory (transitory) machine-readable media capable of storing data such as RAM, SCM, NVM, etc., which is not limited herein. In addition, in some application scenarios, the cache 230 may also be placed outside the main controller 220 .
在本实施例中,可以在缓存230中保存一张映射表,用于保存从控制器11接收的数据块的LBA与数据块的稳定级别之间的对应关系。通常情况下,缓存230中还保存有一张记录LBA与PBA之间映射关系的映射表,在本发明实施例中,可以在这张映射表的基础上,增加LBA与稳定级别之间的对 应关系。In this embodiment, a mapping table may be stored in the cache 230 for storing the correspondence between the LBA of the data block received from the controller 11 and the stability level of the data block. Usually, there is also a mapping table that records the mapping relationship between LBA and PBA in the cache 230. In the embodiment of the present invention, on the basis of this mapping table, the correspondence between the LBA and the stability level can be increased. should be related.
或者,在缓存230中保存多个数组,每个数组对应一个稳定级别,所述数组中可以保存对应所述稳定级别的多个数据块的逻辑地址。Alternatively, multiple arrays are stored in the cache 230, each array corresponds to a stability level, and logical addresses of multiple data blocks corresponding to the stability level may be stored in the array.
或者,缓存230中也可以不保存映射表,而是将稳定级别相同的数据块的逻辑地址集中存储到缓存230的一块缓存空间中。例如,控制器11可以事先发送给闪存装置22缓存区域划分信息,所述缓存区域划分信息包括不同的稳定级别(例如,分别为1-10的10个稳定级别),闪存装置22接收到所述缓存区域划分信息后,按照10个稳定级别将缓存230划分为10个缓存区域,每个缓存区域对应一个稳定级别,专门用于存储对应所述稳定级别的数据块的逻辑地址。或者,控制器11也可以不事先发送给闪存装置22缓存区域划分信息,而是直接将数据块的逻辑地址与数据块的稳定级别发送给闪存装置22。闪存装置22根据所述数据块的稳定级别在缓存230中划分出一段缓存区域,将所述缓存区域与所述稳定级别对应(保存所述缓存区域与所述稳定级别之间的对应关系),之后,所述划分出的缓存区域可以专门用于保存对应所述稳定级别的数据块的逻辑地址。以上两种方式都可以实现将稳定级别相同的数据块的逻辑地址集中存储到缓存230的一块缓存空间中。Alternatively, the cache 230 may not save the mapping table, but store logical addresses of data blocks with the same stability level in a cache space of the cache 230 . For example, the controller 11 may send the cache area division information to the flash memory device 22 in advance, the cache area division information includes different stability levels (for example, 10 stability levels of 1-10), and the flash memory device 22 receives the After the cache area is divided into information, the cache 230 is divided into 10 cache areas according to 10 stability levels, each cache area corresponds to a stability level, and is specially used to store the logical address of the data block corresponding to the stability level. Alternatively, the controller 11 may also directly send the logical address of the data block and the stability level of the data block to the flash memory device 22 without sending the cache area division information to the flash memory device 22 in advance. The flash memory device 22 divides a cache area in the cache 230 according to the stability level of the data block, and corresponds the cache area to the stability level (saves the correspondence between the cache area and the stability level), Afterwards, the divided cache area may be specially used to store the logical address of the data block corresponding to the stability level. Both of the above two methods can realize the centralized storage of logical addresses of data blocks with the same stability level in a cache space of the cache 230 .
下面介绍本发明实施例一种识别数据块稳定性的方法,所述方法从控制器11的角度描述根据数据块的逻辑地址获得该数据块的稳定级别,并发送给闪存装置22的过程。请参考图4,图4是所述识别逻辑地址对应的数据块的稳定性的方法的流程示意图,所述方法可以应用在图1所示的存储系统中以及图2所示的控制器11中,在控制器11的缓存120中保存有多个逻辑地址,另外,缓存120中还保存有哈希表,所述哈希表包括多个表项,每个表项对应一个逻辑地址,并且,每个表项中记录有计数值,所述计数值用于表示所述逻辑地址对应的数据块的修改次数;其执行主体是控制器11中的处理器118。所述方法包括:The following describes a method for identifying the stability of a data block according to an embodiment of the present invention. The method describes the process of obtaining the stability level of the data block according to the logical address of the data block and sending it to the flash memory device 22 from the perspective of the controller 11 . Please refer to FIG. 4. FIG. 4 is a schematic flowchart of the method for identifying the stability of the data block corresponding to the logical address. The method can be applied in the storage system shown in FIG. 1 and the controller 11 shown in FIG. 2 , a plurality of logical addresses are stored in the cache 120 of the controller 11, and in addition, a hash table is also stored in the cache 120, and the hash table includes a plurality of entries, each entry corresponds to a logical address, and, A count value is recorded in each entry, and the count value is used to represent the modification times of the data block corresponding to the logical address; the execution body of the count value is the processor 118 in the controller 11 . The methods include:
步骤S102:按照预设的哈希函数对所述多个逻辑地址中的目标逻辑地 址进行计算,获得目标哈希值。Step S102: According to the preset hash function, the objects in the plurality of logical addresses are logically The address is calculated to obtain the target hash value.
具体地,控制器11可以依次从所述多个逻辑地址中获得每个数据块的逻辑地址,从而进行计算并获得哈希值。这里以目标逻辑地址为例进行说明。Specifically, the controller 11 may sequentially obtain the logical address of each data block from the multiple logical addresses, so as to perform calculation and obtain a hash value. Here, the target logical address is taken as an example for description.
另外,步骤S102的触发条件可以是控制器11接收的所有数据块的大小超过预设的容量阈值或者由定时器触发,所述预设的容量阈值可以等于图1所示的存储系统对用户呈现的可用容量,或者所述可用容量的整数倍。In addition, the trigger condition of step S102 may be that the size of all data blocks received by the controller 11 exceeds a preset capacity threshold or is triggered by a timer. The preset capacity threshold may be equal to the storage system shown in FIG. 1 presented to the user. available capacity, or an integer multiple of the available capacity.
步骤S103:根据所述目标哈希值确定所述哈希表中与所述目标逻辑地址对应的目标表项,所述目标表项中记录有目标计数值。Step S103: Determine a target entry corresponding to the target logical address in the hash table according to the target hash value, and a target count value is recorded in the target entry.
具体地,所述哈希表可以包含多个表项,每个表项在所述哈希表中都具有一个位置(例如,可以用编号来表示每个表项的位置),在步骤102中计算获得的目标哈希值可以等于目标表项的编号,或者其他直接指向目标表项的编号的值。并且,由于所述哈希表的每个表项中都记录有一个计数值,因此可以根据目标哈希值获得目标计数值。Specifically, the hash table may contain a plurality of entries, and each entry has a position in the hash table (for example, a number may be used to indicate the position of each entry), and in step 102 The calculated target hash value may be equal to the number of the target entry, or other values directly pointing to the number of the target entry. Moreover, since each entry of the hash table records a count value, the target count value can be obtained according to the target hash value.
步骤S104:根据所述目标计数值,和计数值与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别,所述稳定级别用于表示所述目标逻辑地址对应的数据块的稳定性。Step S104: Determine the stability level of the data block corresponding to the target logical address according to the target count value and the corresponding relationship between the count value and the stability level, and the stability level is used to indicate the stability level of the data block corresponding to the target logical address stability.
其中,控制器11可以预先设定稳定级别的个数。Wherein, the controller 11 may preset the number of stable levels.
可选的,一种实施方式是:将表项中记录的计数值划分为多个计数值区间,其中,每个计数值区间对应一个稳定级别。举例来说,假设预先设定10个稳定级别,那么计数值区间和稳定级别之间的对应关系可以如表1所示:Optionally, an implementation manner is: dividing the count value recorded in the entry into multiple count value intervals, where each count value interval corresponds to a stability level. For example, assuming that 10 stability levels are preset, the corresponding relationship between the count value interval and the stability level can be shown in Table 1:
表1Table 1
那么,相应地,根据所述目标计数值,和计数值与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别具体可以是:根据所述目标计数值确定目标计数值区间,所述目标计数值位于所述目标计数值区间中;根据所述目标计数值区间,以及表1所示的对应关系确定所述目标逻辑地址对应的数据块的稳定级别。例如,目标计数值是3,那么其对应的稳定级别为2。Then, correspondingly, determining the stability level of the data block corresponding to the target logical address according to the target count value and the corresponding relationship between the count value and the stability level may specifically be: determining the target count value interval according to the target count value, The target count value is located in the target count value interval; the stability level of the data block corresponding to the target logical address is determined according to the target count value interval and the corresponding relationship shown in Table 1. For example, a target count value of 3 corresponds to a stability level of 2.
步骤S105:将所述目标逻辑地址以及所述目标逻辑地址对应的数据块的稳定级别发送给闪存装置。Step S105: Send the target logical address and the stability level of the data block corresponding to the target logical address to the flash memory device.
具体地,控制器11可以每次发送一个逻辑地址和稳定级别给闪存装置22,也可以每次发送多个逻辑地址和稳定级别给闪存装置22。Specifically, the controller 11 may send one logical address and stability level to the flash memory device 22 each time, or may send multiple logical addresses and stability levels to the flash memory device 22 each time.
在本实施例中,控制器11可以根据逻辑地址计算获得哈希值,所述哈希值与哈希表中的一个表项对应,所述表项中记录有计数值,所述计数值用于表示所述逻辑地址对应的数据块的修改次数,因此可以根据计数值获得所述逻辑地址对应的数据块的稳定级别,所述稳定级别可以反映所述逻辑地址对应的数据块的稳定性,并且将所述数据块的稳定级别和逻辑地址发送给闪存装置22,使得闪存装置22将相同稳定级别的数据块进行集中存储。In this embodiment, the controller 11 can calculate and obtain a hash value according to the logical address, the hash value corresponds to an entry in the hash table, and the count value is recorded in the entry, and the count value is used as In order to represent the modification times of the data block corresponding to the logical address, the stability level of the data block corresponding to the logical address can be obtained according to the count value, and the stability level can reflect the stability of the data block corresponding to the logical address, And the stability level and logical address of the data block are sent to the flash memory device 22, so that the flash memory device 22 centrally stores the data blocks of the same stability level.
下面介绍本发明实施例另一种在闪存装置中存储数据的方法,请参考图5,图5识别数据块稳定性的流程示意图,所述方法可以应用在图1所示的 存储系统中。Another method for storing data in a flash memory device according to an embodiment of the present invention is introduced below. Please refer to FIG. 5, which is a schematic flowchart of identifying data block stability. The method can be applied to the data block shown in FIG. 1 in the storage system.
在本实施例中,步骤S201-步骤S204描述的是写数据请求如何触发哈希表中的计数值更新的过程。步骤S201-步骤S204可以应用在图2所示的控制器11中,其执行主体是控制器11中的处理器118。In this embodiment, steps S201 to S204 describe the process of how the write data request triggers the update of the counter value in the hash table. Step S201 - step S204 can be applied in the controller 11 shown in FIG. 2 , and the execution subject is the processor 118 in the controller 11 .
在步骤S201中,控制器11接收主机发送的写数据请求,所述写数据请求中包括数据对象以及所述数据对象的地址信息。In step S201, the controller 11 receives a write data request sent by the host, and the write data request includes a data object and address information of the data object.
在步骤S202中,控制器11将所述数据对象划分为尺寸相同的多个数据块。In step S202, the controller 11 divides the data object into multiple data blocks of the same size.
在本实施例中,以数据块的尺寸为4KB为例,当数据对象大于4KB时,需要将其拆分为多个数据块;当数据对象小于4KB时,则不需要拆分。In this embodiment, taking the size of the data block as 4KB as an example, when the data object is larger than 4KB, it needs to be split into multiple data blocks; when the data object is smaller than 4KB, it does not need to be split.
相应地,控制器11可以根据所述地址信息以及多级映射表获取每个数据块的逻辑地址,并且将将这些逻辑地址保存在缓存120中。Correspondingly, the controller 11 can obtain the logical address of each data block according to the address information and the multi-level mapping table, and store these logical addresses in the cache 120 .
在步骤S203中,控制器11从所述多个逻辑地址中确定一个目标逻辑地址。In step S203, the controller 11 determines a target logical address from the plurality of logical addresses.
具体地,控制器11可以对所述多个逻辑地址进行扫描,依次读取每个逻辑地址。为了方便描述,在下面的步骤中以目标逻辑地址的处理方式为例来进行说明,可以理解的是,其他逻辑地址的处理方式和目标逻辑地址相同。Specifically, the controller 11 may scan the multiple logical addresses, and read each logical address in sequence. For the convenience of description, in the following steps, the processing manner of the target logical address is taken as an example for illustration. It can be understood that the processing manner of other logical addresses is the same as that of the target logical address.
在步骤S204中,按照预设的哈希函数对所述目标逻辑地址进行计算,获得目标哈希值,所述目标哈希值指向所述哈希表中的一个表项,增加所述表项中记录的计数值。In step S204, the target logical address is calculated according to a preset hash function to obtain a target hash value, the target hash value points to an entry in the hash table, and the entry is added The count value recorded in .
在某些情况下,由于哈希表的表项有限,多个逻辑地址运用同一个哈希函数运算所生成的哈希值可能会指向同一个表项,那么逻辑地址与表项之间就不是一一对应的关系。在这种情况下,为了获得所述逻辑地址对应的数据块的修改次数,可以预设多个哈希(Hash)函数,运用所述多个哈希函数对所述逻辑地址进行计算,从而得到多个哈希值,然后对每个哈希值指向的表项中的计数值分别进行更新。如图6所示,可以利用四个哈希函数(分别为 H1、H2、H3和H4)对逻辑地址(LBA)进行计算,获得的四个哈希值,每个哈希值分别指向哈希表的一个表项,从而对每个表项中记录的计数值加1。关于如何利用四个哈希值获得最准确的所述逻辑地址对应的数据块的修改次数,可以参考下面步骤S208的描述。In some cases, due to the limited number of entries in the hash table, the hash values generated by multiple logical addresses using the same hash function may point to the same entry, so there is no difference between the logical address and the entry. one-to-one relationship. In this case, in order to obtain the modification times of the data block corresponding to the logical address, multiple hash (Hash) functions can be preset, and the multiple hash functions are used to calculate the logical address, thereby obtaining Multiple hash values, and then update the count value in the entry pointed to by each hash value. As shown in Figure 6, four hash functions (respectively H1, H2, H3, and H4) calculate the logical address (LBA), and obtain four hash values, each of which points to an entry in the hash table, so as to count the records recorded in each entry value plus 1. For how to use the four hash values to obtain the most accurate modification times of the data block corresponding to the logical address, please refer to the description of step S208 below.
下面以一个具体的示例来说明如何根据LBA计算获得其对应表项中的计数值。A specific example is used below to illustrate how to calculate and obtain the count value in its corresponding entry according to the LBA.
假设哈希表包含10000个表项,相当于一个含有10000个元素的一维数组。hash[x]表示哈希表第x个表项保存的值,其中,x是大于或等于1的整数。Suppose the hash table contains 10,000 entries, which is equivalent to a one-dimensional array with 10,000 elements. hash[x] indicates the value stored in the xth entry of the hash table, where x is an integer greater than or equal to 1.
假设LBA为100,在LBA为100的逻辑地址中写入一个数据块时,更新哈希表的计数值的操作如下:Assuming that the LBA is 100, when a data block is written in the logical address with the LBA of 100, the operation of updating the count value of the hash table is as follows:
首先,通过4个哈希函数计算得到4个哈希值,4个哈希函数分别是:First, 4 hash values are calculated by 4 hash functions, and the 4 hash functions are:
哈希值1=(LBA*11)%(哈希表中表项的个数);Hash value 1=(LBA*11)% (the number of entries in the hash table);
哈希值2=(LBA*13)%(哈希表中表项的个数);Hash value 2=(LBA*13)% (number of entries in the hash table);
哈希值3=(LBA*15)%(哈希表中表项的个数);Hash value 3=(LBA*15)% (number of entries in the hash table);
哈希值4=(LBA*17)%(哈希表中表项的个数);Hash value 4=(LBA*17)% (number of entries in the hash table);
其中,“%”表示求余操作。由此,可以得知,哈希值1=1100;哈希值1=1300;哈希值3=1500;哈希值4=1700。Among them, "%" represents the remainder operation. Thus, it can be known that hash value 1=1100; hash value 1=1300; hash value 3=1500; hash value 4=1700.
四个哈希值对应的表项分别是hash[1100]、hash[1300]、hash[1500]和hash[1700],然后分别对这些表项中的计数值加1。The entries corresponding to the four hash values are hash[1100], hash[1300], hash[1500], and hash[1700], and then add 1 to the count values in these entries.
按照步骤S201-步骤S204描述的方式,控制器11可以根据接收到的数据对象更新哈希表中的计数值。对于一个逻辑地址来说,接收的数据块越多,其对应的表项中的计数值也会依次递增。因此,一个表项中记录的计数值反映了其对应的逻辑地址中存储的数据块的稳定性。According to the method described in step S201-step S204, the controller 11 may update the count value in the hash table according to the received data object. For a logical address, the more data blocks are received, the count value in the corresponding entry will be incremented sequentially. Therefore, the count value recorded in an entry reflects the stability of the data block stored in its corresponding logical address.
步骤S205-步骤S209描述的是控制器11识别缓存120存储的每个逻辑地址对应的数据块的稳定级别,并发送给闪存装置22的过程。步骤S205- 步骤S209可以应用在图2所示的控制器11中,其执行主体是控制器11中的处理器118。需要说明的是,所述稳定级别的识别过程与步骤S201-步骤S204描述的计数值更新的过程没有先后顺序之分。Steps S205 to S209 describe the process that the controller 11 identifies the stability level of the data block corresponding to each logical address stored in the cache 120 and sends it to the flash memory device 22 . Step S205- Step S209 may be applied in the controller 11 shown in FIG. 2 , and its execution subject is the processor 118 in the controller 11 . It should be noted that there is no sequence between the process of identifying the stability level and the process of updating the count value described in steps S201-S204.
在步骤S205中,任务触发时,控制器11从缓存120中读取所述多个逻辑地址。In step S205 , when the task is triggered, the controller 11 reads the plurality of logical addresses from the cache 120 .
这里的任务是指控制器11识别缓存120存储的每个逻辑地址存储的数据块的稳定级别的任务,其触发条件可以是预设的时间间隔到达,或者控制器11从主机接收的数据对象的总的大小超过预设阈值等。这两个条件也可以同时设置,当其中一个条件满足时,控制器11开始从缓存120中读取所述多个逻辑地址。The task here refers to the task of the controller 11 identifying the stable level of the data block stored in each logical address stored in the cache 120, and its trigger condition can be the arrival of a preset time interval, or the data object received by the controller 11 from the host. The total size exceeds a preset threshold, etc. These two conditions can also be set at the same time, and when one of the conditions is satisfied, the controller 11 starts to read the plurality of logical addresses from the cache 120 .
在步骤S206中,控制器11从所述多个逻辑地址中确定目标逻辑地址。In step S206, the controller 11 determines a target logical address from the plurality of logical addresses.
具体地,控制器11可以对所述多个逻辑地址进行扫描,依次读取每个逻辑地址。为了方便描述,在下面的步骤中以目标逻辑地址的处理方式为例来进行说明,可以理解的是,其他逻辑地址的处理方式和目标逻辑地址类似。需要说明的是,步骤S206中的目标逻辑地址可以和步骤S203-步骤S204中的目标逻辑地址相同,也可以不同。Specifically, the controller 11 may scan the multiple logical addresses, and read each logical address in sequence. For the convenience of description, in the following steps, the processing manner of the target logical address is taken as an example for illustration. It can be understood that the processing manner of other logical addresses is similar to that of the target logical address. It should be noted that the target logical address in step S206 may be the same as or different from the target logical address in step S203-step S204.
在步骤S207中,控制器11按照预设的哈希函数对所述目标逻辑地址进行计算,获得目标哈希值。In step S207, the controller 11 calculates the target logical address according to a preset hash function to obtain a target hash value.
具体地,预设的哈希函数是指步骤S204中的哈希函数。当哈希函数有多个时,计算获得的哈希值也有多个。Specifically, the preset hash function refers to the hash function in step S204. When there are multiple hash functions, there are also multiple calculated hash values.
在步骤S208中,控制器11根据所述目标哈希值确定所述哈希表中与所述目标逻辑地址对应的目标表项,所述目标表项中记录有目标计数值。In step S208, the controller 11 determines a target entry corresponding to the target logical address in the hash table according to the target hash value, and the target count value is recorded in the target entry.
仍然以LBA为100为例,运用上述四个哈希函数获得的哈希值包括:哈希值1=1100;哈希值1=1300;哈希值3=1500;哈希值4=1700。通过这四个哈希值可以从四个表项中得到四个计数值,从四个计数值中选择最小的计数值作为目标计数值。 Still taking the LBA as 100 as an example, the hash values obtained by using the above four hash functions include: hash value 1=1100; hash value 1=1300; hash value 3=1500; hash value 4=1700. Four count values can be obtained from the four table entries through the four hash values, and the smallest count value is selected from the four count values as the target count value.
可以理解的是,由于同一个计数值可能被多个LBA引用(这里的引用,是指LBA经过哈希函数计算出的哈希值指向所述计数值),因此计数值越小,代表其对应的表项越少被其他LBA引用,因此最小的计数值最准确,最能代表其对应的数据块的修改次数,在本实施例中目标计数值等于最小的计数值。It can be understood that since the same count value may be referenced by multiple LBAs (the reference here means that the hash value calculated by the LBA through the hash function points to the count value), the smaller the count value, the corresponding The fewer entries are referenced by other LBAs, the smallest count value is the most accurate and can best represent the modification times of its corresponding data block. In this embodiment, the target count value is equal to the smallest count value.
在步骤S209中,控制器11根据所述目标计数值获得所述目标逻辑地址对应的数据块的稳定级别。In step S209, the controller 11 obtains the stability level of the data block corresponding to the target logical address according to the target count value.
其具体实施方式,可参考图4所示实施例的步骤S104,这里不再赘述。For a specific implementation manner, reference may be made to step S104 in the embodiment shown in FIG. 4 , which will not be repeated here.
在步骤S210中,控制器11将所述目标逻辑地址以及所述目标逻辑地址对应的数据块的稳定级别发送给闪存装置22。In step S210 , the controller 11 sends the target logical address and the stability level of the data block corresponding to the target logical address to the flash memory device 22 .
其具体实施方式,可参考图4所示实施例的步骤S105,这里不再赘述。For a specific implementation manner, reference may be made to step S105 in the embodiment shown in FIG. 4 , which will not be repeated here.
可以理解的是,按照步骤S206-步骤S210描述的方式,控制器11可以将多个逻辑地址以及与所述逻辑地址对应的稳定级别发送给闪存装置22。It can be understood that, according to the manner described in step S206-step S210, the controller 11 may send multiple logical addresses and stability levels corresponding to the logical addresses to the flash memory device 22.
当控制器11处理完缓存120中保存的每个逻辑地址后,本次任务完成,可以将哈希表中记录的计数值均减去一个固定值,使得下次任务开始时,计数值可以以一个较小的基数开始递增。After the controller 11 has processed each logical address stored in the buffer memory 120, this task is completed, and a fixed value can be subtracted from the count value recorded in the hash table, so that when the next task starts, the count value can be A smaller base to start incrementing.
步骤S211-步骤S213描述的是闪存装置22接收控制器11发送的多个逻辑地址和稳定级别之后,将稳定级别相同的数据块集中存储的过程。步骤S211-步骤S213可以应用在图3A、图3B所示的闪存装置(例如,SSD)中,其执行主体是闪存装置22中的处理器218。Steps S211 to S213 describe the process of collectively storing data blocks with the same stability level after the flash memory device 22 receives multiple logical addresses and stability levels sent by the controller 11 . Steps S211 to S213 may be applied in the flash memory device (eg, SSD) shown in FIG. 3A and FIG. 3B , and the execution body thereof is the processor 218 in the flash memory device 22 .
在步骤S211中,闪存装置22保存所述多个数据块的逻辑地址,以及与所述逻辑地址对应的稳定级别。In step S211, the flash memory device 22 stores the logical addresses of the multiple data blocks and the stability level corresponding to the logical addresses.
可选的,一种保存方式是在闪存装置22的缓存230中建立一张映射表,用于保存从控制器11接收的数据块的逻辑地址与数据块的稳定级别之间的对应关系。Optionally, a storage method is to establish a mapping table in the cache 230 of the flash memory device 22 for storing the correspondence between the logical address of the data block received from the controller 11 and the stability level of the data block.
可选的,另一种保存方式是在缓存230中保存多个数组,每个数组对应 一个稳定级别。所述多个数据块的逻辑地址分别保存在其对应的数组中。Optionally, another storage method is to store multiple arrays in the cache 230, each array corresponding to a level of stability. The logical addresses of the multiple data blocks are respectively stored in their corresponding arrays.
可选的,再一种保存方式是预先将缓存230划分为若干个缓存区域,每个缓存区域对应一个稳定级别。将所述多个数据块的逻辑地址分别记录在其对应的缓存区域中。Optionally, another storage method is to divide the cache 230 into several cache areas in advance, and each cache area corresponds to a stability level. The logical addresses of the multiple data blocks are respectively recorded in their corresponding cache areas.
在步骤S212中,闪存装置22获取目标逻辑地址对应的稳定级别,所述稳定级别用于表示数据块的稳定性。In step S212, the flash memory device 22 obtains a stability level corresponding to the target logical address, and the stability level is used to represent the stability of the data block.
所述目标逻辑地址是闪存装置22中保存的逻辑地址中的其中一个,这里以目标逻辑地址为例来说明。The target logical address is one of the logical addresses stored in the flash memory device 22 , and the target logical address is taken as an example for illustration here.
在步骤S213中,闪存装置22根据所述目标逻辑地址对应的稳定级别,将所述目标逻辑地址对应的数据块写入所述稳定级别对应的块中。In step S213, the flash memory device 22 writes the data block corresponding to the target logical address into the block corresponding to the stable level according to the stable level corresponding to the target logical address.
在本实施例中,为了将相同稳定级别的数据块搬移到同样的block中,可以建立闪存芯片中的block与稳定级别的对应关系。按照这种对应关系,可以将目标逻辑地址对应的数据块从原来的block中读取出来,写入与其稳定级别对应的block中。所述闪存芯片中的block与稳定级别的对应关系可以是预先建立的,也可以是第一次将一个数据块或者多个稳定级别相同的数据块写入一个block后便记录所述稳定级别与block之间的对应关系。In this embodiment, in order to move data blocks of the same stability level into the same block, a corresponding relationship between blocks and stability levels in the flash memory chip may be established. According to this correspondence, the data block corresponding to the target logical address can be read from the original block and written into the block corresponding to its stability level. The corresponding relationship between the block and the stability level in the flash memory chip can be pre-established, and it can also be the first time that a data block or multiple data blocks with the same stability level are written into a block and then the stability level and stability level are recorded. Correspondence between blocks.
对于将目标逻辑地址对应的数据块从原来的block中读取出来具体可以是:通常情况下,闪存装置22的缓存230或者闪存芯片中保存有一张映射表,所述映射表用于保存各个数据块的逻辑地址和物理地址之间的对应关系,所以可以根据逻辑地址和所述映射表,从对应的物理地址所在的存储空间中读取出所述数据块。For reading the data block corresponding to the target logical address from the original block, it can be specifically: usually, a mapping table is stored in the cache memory 230 of the flash memory device 22 or the flash memory chip, and the mapping table is used to save each data Therefore, according to the logical address and the mapping table, the data block can be read from the storage space where the corresponding physical address is located.
采用本实施例提供的方式,可以将相同稳定级别的数据块存储在一个block中。那么,对于存放稳定级别较高的数据块的block,其存储的数据块成为无效数据的可能性较小,整体来看,该block中不含无效数据或仅含少量的无效数据,这样的block属于利用率比较高的block,在对闪存装置22进行垃圾回收时不会回收这样的block;对于存放稳定级别较低的数据块的 block,其存储的数据块成为无效数据的可能性较大,假设一个block中的大部分数据或者绝大部分数据都变成了无效数据,那么相应地,这个block中包含的有效数据较少,垃圾回收时需要迁移的数据也较少,减小了写放大。需要说明的是,本实施例的效果主要体现在之后的垃圾回收时搬移的有效数据会减少。由此可见,无论是存放稳定级别较高的数据块的block,还是存放稳定级别较低的数据块的block,都可以减小闪存装置22的写放大,因此在一定程度上延长了闪存装置22的寿命。Using the method provided by this embodiment, data blocks of the same stability level can be stored in one block. Then, for a block that stores a data block with a high level of stability, the possibility of the stored data block becoming invalid data is small. On the whole, the block does not contain invalid data or only contains a small amount of invalid data. Such a block Belong to the block with relatively high utilization rate, can not recycle such block when carrying out garbage collection to flash memory device 22; block, the data blocks stored in it are more likely to become invalid data, assuming that most or most of the data in a block has become invalid data, then correspondingly, the valid data contained in this block is less, Less data needs to be migrated during garbage collection, reducing write amplification. It should be noted that the effect of this embodiment is mainly reflected in the reduction of valid data moved during subsequent garbage collection. It can be seen that whether it is a block storing a data block with a higher stability level or a block storing a data block with a lower stability level, the write amplification of the flash memory device 22 can be reduced, so the flash memory device 22 can be extended to a certain extent. lifespan.
另外,一种较优的实施方式是:将上面描述的步骤S212-步骤S213与垃圾回收操作结合在一起,也就是说,当闪存装置22需要进行垃圾回收时,按照步骤S212-步骤S213描述的方式进行垃圾回收,具体的,确定所述闪存芯片中包含的空闲的块的数量低于第一阈值时,依次从闪存芯片中查找出包含无效数据最多的块,从这些块中获取待搬移的数据块的逻辑地址,然后根据所述逻辑地址,在所述逻辑地址与稳定级别的对应关系中查找,获取所述逻辑地址对应的稳定级别,再将所述逻辑地址对应的数据块写入对应的块中。In addition, a preferred implementation manner is to combine the above-described step S212-step S213 with the garbage collection operation. Specifically, when it is determined that the number of free blocks contained in the flash memory chip is lower than the first threshold, the blocks containing the most invalid data are sequentially found from the flash memory chip, and the blocks to be moved are obtained from these blocks. The logical address of the data block, and then according to the logical address, search in the corresponding relationship between the logical address and the stability level, obtain the stability level corresponding to the logical address, and then write the data block corresponding to the logical address into the corresponding in the block.
另一种较优的实施方式是:将上面描述的步骤S212-步骤S213与巡检操作结合在一起,也就是说,当闪存装置22需要进行巡检时,按照步骤S212-步骤S213描述的方式进行巡检,具体的,当预设的巡检周期到达时,依次从闪存芯片中查找出最长时间内未被擦除的块,从这些块中获取待搬移的数据块的逻辑地址,然后根据所述逻辑地址,在所述逻辑地址与稳定级别的对应关系中查找,获取所述逻辑地址对应的稳定级别,再将所述逻辑地址对应的数据块写入对应的块中。Another preferred embodiment is to combine the steps S212-S213 described above with the inspection operation, that is to say, when the flash memory device 22 needs to perform an inspection, follow the method described in steps S212-S213 Carry out inspection, specifically, when the preset inspection cycle arrives, find the blocks that have not been erased for the longest time from the flash memory chip in turn, obtain the logical address of the data block to be moved from these blocks, and then According to the logical address, search in the corresponding relationship between the logical address and the stability level, obtain the stability level corresponding to the logical address, and then write the data block corresponding to the logical address into the corresponding block.
按照上面提供的两种较优的实施方式,可以在闪存装置22进行垃圾回收或者巡检时实现将稳定级别相同的数据块集中存储,由于闪存装置22在进行垃圾回收或者巡检时原本会进行数据搬移,因此本实施例并没有额外的数据搬移操作,可以进一步减小写放大。 According to the two preferred implementation modes provided above, it is possible to centrally store data blocks with the same stability level when the flash memory device 22 performs garbage collection or inspection, because the flash memory device 22 originally performs garbage collection or inspection. Data movement, so this embodiment does not require additional data movement operations, which can further reduce write amplification.
再一种较优的实施方式是步骤S212-步骤S213可以不和垃圾回收或者巡检操作结合,也就是说,在这种实施方式中,进行数据块搬移的触发条件和前面两种实施方式有所不同,其触发条件是缓存中保存的相同稳定级别对应的逻辑地址的个数达到预设阈值。Another preferred implementation mode is that step S212-step S213 may not be combined with garbage collection or inspection operations, that is to say, in this implementation mode, the trigger conditions for moving data blocks are different from those of the previous two implementation modes. The trigger condition is that the number of logical addresses corresponding to the same stability level stored in the cache reaches a preset threshold.
那么,对于如何判断是否有相同稳定级别对应的逻辑地址的个数达到预设阈值,可以有如下三种实施方式:Then, for how to judge whether the number of logical addresses corresponding to the same stability level reaches the preset threshold, there are three implementation methods as follows:
第一种实施方式是,根据缓存230中保存的映射表确定是否有相同稳定级别的逻辑地址的个数达到预设阈值。The first implementation manner is to determine whether the number of logical addresses with the same stability level reaches a preset threshold according to the mapping table stored in the cache 230 .
第二种实施方式是判断缓存230中是否有一个数组中保存的逻辑地址的个数达到预设阈值。The second implementation manner is to judge whether the number of logical addresses stored in an array in the cache 230 reaches a preset threshold.
第三种实施方式是判断缓存230中是否有一个缓存区域中保存的逻辑地址的个数达到预设阈值。A third implementation manner is to determine whether the number of logical addresses stored in a cache area in the cache 230 reaches a preset threshold.
其中,可以将所述预设阈值设置成块的容量与数据块的尺寸之间的比值,按照这种实施方式,当逻辑地址的个数达到所述阈值后,所述多个逻辑地址对应的数据块正好将一个空闲的块填满。此时,步骤S213中的所述稳定级别对应的块则可以是一个空闲的块。Wherein, the preset threshold can be set as the ratio between the capacity of the block and the size of the data block. According to this embodiment, when the number of logical addresses reaches the threshold, the corresponding The data block exactly fills a free block. At this time, the block corresponding to the stability level in step S213 may be a free block.
请参考图7,图7是本发明实施例提供的识别数据块稳定性的装置70,所述装置70位于控制器11中,包括:Please refer to FIG. 7. FIG. 7 is a device 70 for identifying data block stability provided by an embodiment of the present invention. The device 70 is located in the controller 11 and includes:
存储模块701,用于保存多个逻辑地址以及哈希表,所述哈希表包括多个表项,每个表项对应一个逻辑地址,并且,每个表项中记录有计数值,所述计数值用于表示所述逻辑地址对应的数据块的修改次数。The storage module 701 is configured to save a plurality of logical addresses and a hash table, the hash table includes a plurality of entries, each entry corresponds to a logical address, and a count value is recorded in each entry, the The count value is used to represent the modification times of the data block corresponding to the logical address.
计算模块702,用于按照预设的哈希函数对所述多个逻辑地址中的目标逻辑地址进行计算,获得目标哈希值;根据所述目标哈希值确定所述哈希表中与所述目标逻辑地址对应的目标表项,所述目标表项中记录有目标计数值。 The calculation module 702 is configured to calculate a target logical address among the plurality of logical addresses according to a preset hash function to obtain a target hash value; a target entry corresponding to the target logical address, and the target count value is recorded in the target entry.
确定模块703,用于根据所述目标计数值,和计数值与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别,所述稳定级别用于表示所述目标逻辑地址对应的数据块的稳定性;A determining module 703, configured to determine the stability level of the data block corresponding to the target logical address according to the target count value and the corresponding relationship between the count value and the stability level, and the stability level is used to indicate the stability level of the data block corresponding to the target logic address. Data block stability;
发送模块704,用于将所述目标逻辑地址以及所述目标逻辑地址对应的数据块的稳定级别发送给闪存装置。The sending module 704 is configured to send the target logical address and the stability level of the data block corresponding to the target logical address to the flash memory device.
在本实施例中,可以根据逻辑地址计算获得哈希值,所述哈希值与哈希表中的一个表项对应,所述表项中记录有计数值,所述计数值用于表示所述逻辑地址对应的数据块的修改次数,因此可以根据计数值获得所述逻辑地址对应的数据块的稳定级别,所述稳定级别可以反映所述逻辑地址对应的数据块的稳定性,并且将所述数据块的稳定级别和逻辑地址发送给闪存装置22,使得闪存装置22将相同稳定级别的数据块进行集中存储。In this embodiment, the hash value can be obtained by calculating according to the logical address, the hash value corresponds to an entry in the hash table, and a count value is recorded in the entry, and the count value is used to represent the The modification times of the data block corresponding to the logical address, so the stability level of the data block corresponding to the logical address can be obtained according to the count value, and the stability level can reflect the stability of the data block corresponding to the logical address, and the obtained The stability level and logical address of the above data blocks are sent to the flash memory device 22, so that the flash memory device 22 centrally stores the data blocks of the same stability level.
可选的,在上述实施例中,所述计数值与稳定级别的对应关系包括计数值区间与稳定级别的对应关系;确定模块703,具体用于根据所述目标计数值确定目标计数值区间,所述目标计数值位于所述目标计数值区间中;根据所述目标计数值区间,和所述计数值区间与稳定级别的对应关系确定所述目标逻辑地址对应的数据块的稳定级别。Optionally, in the above embodiment, the correspondence between the count value and the stability level includes the correspondence between the count value interval and the stability level; the determining module 703 is specifically configured to determine the target count value interval according to the target count value, The target count value is located in the target count value interval; and the stability level of the data block corresponding to the target logical address is determined according to the target count value interval and the corresponding relationship between the count value interval and the stability level.
另外,在上述实施例中,所述计算模块702,还用于在所述按照预设的哈希函数对所述多个逻辑地址中的目标逻辑地址进行计算之前获取所述目标逻辑地址;根据所述目标逻辑地址以及所述哈希函数进行计算,获得所述目标哈希值;根据所述目标哈希值确定所述目标表项,所述目标表项中记录有计数值;增加所述目标表项中记录的计数值,所述目标计数值等于所述增加后的所述目标表项中记录的计数值。In addition, in the above embodiment, the calculation module 702 is further configured to obtain the target logical address before calculating the target logical address among the plurality of logical addresses according to a preset hash function; according to The target logical address and the hash function are calculated to obtain the target hash value; the target entry is determined according to the target hash value, and a count value is recorded in the target entry; A count value recorded in the target entry, where the target count value is equal to the added count value recorded in the target entry.
可选的,所述计算模块702,还用于在所述将所述目标逻辑地址以及所述目标逻辑地址对应的数据块的稳定级别发送给闪存装置之后,将所述目标表项中记录的目标计数值减去固定值。 Optionally, the calculation module 702 is further configured to, after sending the target logical address and the stability level of the data block corresponding to the target logical address to the flash memory device, record the Target count value minus fixed value.
本发明实施例还提供一种数据处理的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令用于执行前述任意一个方法实施例所述的方法流程。An embodiment of the present invention also provides a computer program product for data processing, including a computer-readable storage medium storing program code, and the program code includes instructions for executing the method process described in any one of the foregoing method embodiments.
本领域普通技术人员可以理解,前述的存储介质包括:U盘、移动硬盘、磁碟、光盘、随机存储器(Random-Access Memory,RAM)、固态硬盘(Solid State Disk,SSD)或者非易失性存储器(non-volatile memory)等各种可以存储程序代码的非短暂性的(non-transitory)机器可读介质。Those of ordinary skill in the art can understand that the aforesaid storage medium includes: U disk, mobile hard disk, magnetic disk, optical disk, random-access memory (Random-Access Memory, RAM), solid-state hard disk (Solid State Disk, SSD) or nonvolatile Various non-transitory (non-transitory) machine-readable media that can store program codes such as non-volatile memory.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制。 Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, rather than to limit it.
Claims (18)
- A kind of controller, it is characterized in that, the controller includes processor and caching, preserved in the caching and Hash table is also preserved in multiple logical addresses, and the caching, the Hash table includes multiple list items, one logical address of each list item correspondence, also, record has count value in each list item, the count value is used for the modification number of times for representing the corresponding data block of the logical address;The processor, for being calculated according to default hash function the destination logical address in the multiple logical address, obtains target cryptographic Hash;Determine that record has objective count value in target list item corresponding with the destination logical address in the Hash table, the target list item according to the target cryptographic Hash;According to the objective count value, and count value and the other corresponding relation of stationary level determine the stable rank of the corresponding data block of the destination logical address, and the stable rank is used for the stability for representing the corresponding data block of the destination logical address;The stable rank of the destination logical address and the corresponding data block of the destination logical address is sent to flash memory device.
- Controller according to claim 1, it is characterised in that the count value includes count value interval and the other corresponding relation of stationary level with the other corresponding relation of stationary level;The processor, specifically for determining that objective count value is interval according to the objective count value, the objective count value is located in objective count value interval;It is interval according to the objective count value, and the interval stable rank that the corresponding data block of the destination logical address is determined with the other corresponding relation of stationary level of the count value.
- Controller according to claim 1, it is characterised in thatThe processor, be additionally operable to it is described the destination logical address in the multiple logical address is calculated according to default hash function before, obtain the destination logical address;Calculated according to the destination logical address and the hash function, obtain the target Hash Value;Determine that record has count value in the target list item, the target list item according to the target cryptographic Hash;Increase the count value recorded in the target list item, the objective count value is equal to the count value recorded in the target list item after the increase.
- Controller according to claim 1, it is characterised in thatThe processor, is additionally operable to be sent to after flash memory device in the stable rank by the destination logical address and the corresponding data block of the destination logical address, the objective count value recorded in the target list item is subtracted into fixed value.
- A kind of method of identification data block stability, it is characterized in that, methods described is applied in controller, and the controller includes preserving multiple logical addresses in processor and caching, the caching, and also preserve Hash table in the caching, the Hash table includes multiple list items, and each list item corresponds to a logical address, and, record has count value in each list item, and the count value is used for the modification number of times for representing the corresponding data block of the logical address;Methods described by the computing device, including:The destination logical address in the multiple logical address is calculated according to default hash function, target cryptographic Hash is obtained;Determine that record has objective count value in target list item corresponding with the destination logical address in the Hash table, the target list item according to the target cryptographic Hash;According to the objective count value, and count value and the other corresponding relation of stationary level determine the stable rank of the corresponding data block of the destination logical address, and the stable rank is used for the stability for representing the corresponding data block of the destination logical address;The stable rank of the destination logical address and the corresponding data block of the destination logical address is sent to flash memory device.
- Method according to claim 5, it is characterised in that the count value is with stablizing rank Corresponding relation to include count value interval with the other corresponding relation of stationary level;It is described according to the objective count value, and count value and the other corresponding relation of stationary level determine that the stable rank of the corresponding data block of the destination logical address includes:Determine that objective count value is interval according to the objective count value, the objective count value is located in objective count value interval;It is interval according to the objective count value, and the interval stable rank that the corresponding data block of the destination logical address is determined with the other corresponding relation of stationary level of the count value.
- Method according to claim 5, it is characterised in that it is described the destination logical address in the multiple logical address is calculated according to default hash function before, methods described also includes:Obtain the destination logical address;Calculated according to the destination logical address and the hash function, obtain the target cryptographic Hash;Determine that record has count value in the target list item, the target list item according to the target cryptographic Hash;Increase the count value recorded in the target list item, the objective count value is equal to the count value recorded in the target list item after the increase.
- Method according to claim 5, it is characterised in that be sent in the stable rank by the destination logical address and the corresponding data block of the destination logical address after flash memory device, methods described also includes:The objective count value recorded in the target list item is subtracted into fixed value.
- A kind of storage system, it is characterised in that including the controller and flash memory device as described in claim 1-4 is any;The flash memory device includes master controller and flash chip, and the flash chip includes multiple pieces, and the master controller includes processor;The processor, for obtaining the corresponding stable rank of destination logical address, the stable rank Stability for representing data block;According to the corresponding stable rank of the destination logical address, by the corresponding data block write-in of the destination logical address stable corresponding piece of the rank.
- Method according to claim 9, it is characterised in that methods described also includes:Searched in the flash chip comprising the most block of invalid data, the block most comprising invalid data includes the corresponding data block of the destination logical address.
- Method according to claim 9, it is characterised in that methods described also includes:The block not being wiped free of in the block not being wiped free of in maximum duration, the maximum duration is searched in the flash chip includes the corresponding data block of the destination logical address.
- Method according to claim 9, it is characterised in that the master controller also includes caching;The corresponding stable rank of destination logical address that obtains includes:When determining that the number of the logical address preserved in the caching reaches predetermined threshold value, the acquisition destination logical address is corresponding to stablize rank, wherein, the corresponding stable rank of the logical address stably rank corresponding with the destination logical address is identical.
- Method according to claim 12, it is characterised in that the predetermined threshold value is equal to the business obtained by the capacity of block divided by the size of data block.
- A kind of device of identification data block stability, it is characterised in that described device is located in controller, including:Memory module, for preserving multiple logical addresses and Hash table, the Hash table includes multiple list items, one logical address of each list item correspondence, also, record has count value in each list item, the count value is used for the modification number of times for representing the corresponding data block of the logical address;Computing module, for being calculated according to default hash function the destination logical address in the multiple logical address, obtains target cryptographic Hash;Determine that record has objective count value in target list item corresponding with the destination logical address in the Hash table, the target list item according to the target cryptographic Hash;Determining module, for according to the objective count value, and count value and the other corresponding relation of stationary level determine the stable rank of the corresponding data block of the destination logical address, and the stable rank is used for the stability for representing the corresponding data block of the destination logical address;Sending module, for the stable rank of the destination logical address and the corresponding data block of the destination logical address to be sent into flash memory device.
- Device according to claim 14, it is characterised in that the count value includes count value interval and the other corresponding relation of stationary level with the other corresponding relation of stationary level;The determining module, specifically for determining that objective count value is interval according to the objective count value, the objective count value is located in objective count value interval;It is interval according to the objective count value, and the interval stable rank that the corresponding data block of the destination logical address is determined with the other corresponding relation of stationary level of the count value.
- Device according to claim 14, it is characterised in thatThe computing module, be additionally operable to it is described the destination logical address in the multiple logical address is calculated according to default hash function before obtain the destination logical address;Calculated according to the destination logical address and the hash function, obtain the target cryptographic Hash;Determine that record has count value in the target list item, the target list item according to the target cryptographic Hash;Increase the count value recorded in the target list item, the objective count value is equal to the count value recorded in the target list item after the increase.
- Device according to claim 14, it is characterised in thatThe computing module, is additionally operable to be sent to after flash memory device in the stable rank by the destination logical address and the corresponding data block of the destination logical address, the objective count value recorded in the target list item is subtracted into fixed value.
- A kind of computer program product, it is characterised in that the computer-readable recording medium including storing program code, the instruction that described program code includes is used to perform the method as described in claim 5-8 any one.
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2014/094655 WO2016101145A1 (en) | 2014-12-23 | 2014-12-23 | Controller, method for identifying data block stability and storage system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105917303A true CN105917303A (en) | 2016-08-31 |
CN105917303B CN105917303B (en) | 2019-12-06 |
Family
ID=56148884
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201480035916.9A Active CN105917303B (en) | 2014-12-23 | 2014-12-23 | Controller, method for identifying stability of data block and storage system |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN105917303B (en) |
WO (1) | WO2016101145A1 (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108920108A (en) * | 2018-07-13 | 2018-11-30 | 深圳忆联信息系统有限公司 | Screening technique, device, computer equipment and the storage medium of cold data |
CN108984124A (en) * | 2018-07-13 | 2018-12-11 | 深圳忆联信息系统有限公司 | Reduce the method, apparatus, computer equipment and storage medium for writing amplification |
CN112328512A (en) * | 2020-09-22 | 2021-02-05 | 北京计算机技术及应用研究所 | Cache synchronization system and method applied to multi-control storage system |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110286995B (en) * | 2018-03-19 | 2022-02-25 | 北京兆易创新科技股份有限公司 | Data reading and writing method and device |
CN110502451B (en) * | 2019-07-10 | 2023-01-06 | 深圳市金泰克半导体有限公司 | Solid state disk garbage recycling method and device, solid state disk and storage medium |
CN112732178B (en) * | 2020-12-29 | 2024-02-13 | 北京浪潮数据技术有限公司 | SSD data clearing method and related device |
CN113342615B (en) * | 2021-06-29 | 2022-08-26 | 海光信息技术股份有限公司 | Command monitoring method, device, controller, system, equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5715455A (en) * | 1995-05-18 | 1998-02-03 | International Business Machines Corporation | Apparatus and method for storing file allocation table efficiently in memory |
CN103135945A (en) * | 2013-03-25 | 2013-06-05 | 中国人民解放军国防科学技术大学 | Multi-channel dynamic read-write dispatching method used in solid state drive (SSD) |
CN103942148A (en) * | 2013-01-21 | 2014-07-23 | 擎泰科技股份有限公司 | Wear-leveling system and method for non-volatile memory |
CN103942159A (en) * | 2014-03-19 | 2014-07-23 | 华中科技大学 | Data read-write method and device based on mixed storage device |
CN103942010A (en) * | 2013-01-22 | 2014-07-23 | Lsi公司 | Management of and region selection for writes to non-volatile memory |
-
2014
- 2014-12-23 CN CN201480035916.9A patent/CN105917303B/en active Active
- 2014-12-23 WO PCT/CN2014/094655 patent/WO2016101145A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5715455A (en) * | 1995-05-18 | 1998-02-03 | International Business Machines Corporation | Apparatus and method for storing file allocation table efficiently in memory |
CN103942148A (en) * | 2013-01-21 | 2014-07-23 | 擎泰科技股份有限公司 | Wear-leveling system and method for non-volatile memory |
CN103942010A (en) * | 2013-01-22 | 2014-07-23 | Lsi公司 | Management of and region selection for writes to non-volatile memory |
CN103135945A (en) * | 2013-03-25 | 2013-06-05 | 中国人民解放军国防科学技术大学 | Multi-channel dynamic read-write dispatching method used in solid state drive (SSD) |
CN103942159A (en) * | 2014-03-19 | 2014-07-23 | 华中科技大学 | Data read-write method and device based on mixed storage device |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108920108A (en) * | 2018-07-13 | 2018-11-30 | 深圳忆联信息系统有限公司 | Screening technique, device, computer equipment and the storage medium of cold data |
CN108984124A (en) * | 2018-07-13 | 2018-12-11 | 深圳忆联信息系统有限公司 | Reduce the method, apparatus, computer equipment and storage medium for writing amplification |
CN108920108B (en) * | 2018-07-13 | 2022-02-01 | 深圳忆联信息系统有限公司 | Cold data screening method and device, computer equipment and storage medium |
CN108984124B (en) * | 2018-07-13 | 2022-03-25 | 深圳忆联信息系统有限公司 | Method and device for reducing write amplification, computer equipment and storage medium |
CN112328512A (en) * | 2020-09-22 | 2021-02-05 | 北京计算机技术及应用研究所 | Cache synchronization system and method applied to multi-control storage system |
CN112328512B (en) * | 2020-09-22 | 2023-07-28 | 北京计算机技术及应用研究所 | Cache synchronization system and method applied to multi-control storage system |
Also Published As
Publication number | Publication date |
---|---|
CN105917303B (en) | 2019-12-06 |
WO2016101145A1 (en) | 2016-06-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105980992B (en) | A kind of storage system, the method for identification data block stability and device | |
CN105917303B (en) | Controller, method for identifying stability of data block and storage system | |
CN107608908B (en) | Wear leveling method for data storage devices | |
CN107391774B (en) | Garbage Collection Method for Log File System Based on Data Deduplication | |
US20200012598A1 (en) | Garbage Collection Method for Storage Medium, Storage Medium, and Program Product | |
US9164704B2 (en) | Semiconductor storage device for handling write to nonvolatile memories with data smaller than a threshold | |
EP2665065A2 (en) | Electronic device employing flash memory | |
CN106569742A (en) | Storage management method and storage equipment | |
CN110989918B (en) | Write control method, data storage device and controller thereof | |
CN108027764B (en) | Convertible Leaf Memory Map | |
US20210149597A1 (en) | Controller and operation method thereof | |
JP2014220021A (en) | Information processor, control circuit, control program, and control method | |
CN107203341A (en) | Date storage method, device and flash chip based on flash memory | |
KR20200014175A (en) | Apparatus and method for performing garbage collection to predicting required time | |
CN107273306A (en) | A kind of digital independent of solid state hard disc, method for writing data and solid state hard disc | |
EP2381354A2 (en) | Data recording device | |
KR100987251B1 (en) | Flash memory management method and apparatus for reducing merge operation in flash translation layer using full associative sector conversion technique | |
US10831370B1 (en) | Deduplicated and compressed non-volatile memory cache | |
US11941246B2 (en) | Memory system, data processing system including the same, and operating method thereof | |
CN109002265B (en) | Data processing method and related device | |
US9465747B2 (en) | Controller for controlling non-volatile memory and semiconductor device including the same | |
TWI884826B (en) | Method for performing data access management of memory device in predetermined communications architecture with aid of multi-table checking, memory controller of memory device, memory device, and electronic device | |
US12105621B2 (en) | Logical to physical (L2P) address mapping with fast L2P table load times | |
US20240273068A1 (en) | Electronic devices inheriting lifetime information, and methods of operating the same | |
CN116610595A (en) | Method and device for managing solid state disk |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |