WO2016037560A1 - Data writing method and apparatus and memory - Google Patents

Data writing method and apparatus and memory Download PDF

Info

Publication number
WO2016037560A1
WO2016037560A1 PCT/CN2015/089156 CN2015089156W WO2016037560A1 WO 2016037560 A1 WO2016037560 A1 WO 2016037560A1 CN 2015089156 W CN2015089156 W CN 2015089156W WO 2016037560 A1 WO2016037560 A1 WO 2016037560A1
Authority
WO
WIPO (PCT)
Prior art keywords
data block
sample data
sample
written
target
Prior art date
Application number
PCT/CN2015/089156
Other languages
French (fr)
Chinese (zh)
Inventor
沙行勉
诸葛晴凤
朱冠宇
王元钢
石亮
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2016037560A1 publication Critical patent/WO2016037560A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

A data writing method and apparatus and a memory, which are used to write data to a non-volatile storage medium NVM. The method comprises: determining a sample data block of a to-be-written data block from the to-be-written data block (S100); separately comparing the sample data block of the to-be-written data block with N sample data blocks in a preset sample set (S200); determining, from the N sample data blocks, a sample data block having the highest matching degree with the sample data block of the to-be-written data block to serve as a target sample data block (S300); and writing the to-be-written data block to a free address space corresponding to the target sample data block (S400). The method reduces the number of write operations during data writing and thus can solve the problems of high energy consumption and reduced service life of the NVM caused by a large number of write operations during data writing.

Description

数据写入方法、装置及存储器Data writing method, device and memory 技术领域Technical field
本发明涉及数据存储技术领域,特别是涉及一种数据写入方法、装置及存储器。The present invention relates to the field of data storage technologies, and in particular, to a data writing method, apparatus, and memory.
背景技术Background technique
非易失性存储器NVM(Non-Volatile Memory)的特点是在断电时不会丢失内容。例如闪速存储器(Flash Memory)、PCM(Phase Change Memory,相变存储器)、FRAM(Ferroelectric Random Access Memory,铁电介质存储器)等,这些存储器即使在断电后仍能保持片内信息。目前非易失性存储器中应用最广的是Flash,但它的读写速度很难与DRAM(Dynamic Random Access Memory,动态随机存取存储器)相媲美,所以只能替代磁盘作为外存。而像PCM和FRAM这类存储器具有读写速度快、密度大、可字节寻址等特点,被视为下一代新型非易失性存储器,并可以用来替换DRAM和SDRAM。其中PCM是NVM中最典型的代表,下面以PCM为例进行说明。Non-Volatile Memory (NVM) features no loss of content when power is lost. For example, a flash memory, a PCM (Phase Change Memory), a FRAM (Ferroelectric Random Access Memory), etc., can maintain on-chip information even after power is turned off. At present, the most widely used non-volatile memory is Flash, but its read and write speed is difficult to compete with DRAM (Dynamic Random Access Memory), so it can only replace disk as external memory. Memory such as PCM and FRAM is characterized by fast read and write speed, high density, and byte addressability. It is regarded as the next generation of new non-volatile memory and can be used to replace DRAM and SDRAM. PCM is the most typical representative of NVM. The following is an example of PCM.
PCM是利用特殊材料(硫族化合物GST)在晶态和非晶态之间相互转化时所表现出来的导电性差异来存储数据的,并且存储数据通过写操作来实现,写操作包括:SET操作(写入0)和RESET操作(写入1)。现有的NVM设备中,在写入数据时,通常在存储介质中选取一个存储块,并且将待写入数据写入到该存储块,而不考虑所选的存储块中的存储位的值,这使得相同位置上存储块中存储位的值与待写入数据的数据位的值可能不同,甚至可能完全不同,例如:待写入数据为8*8大小,并且待写入数据的每个数据位的值都为1,而存储块中的存储位的值都为0,那么在写入时需要对存储块中的每个存储位的值都进行改写,导致在数据写入时,需要对存储中存储位的写操作较多。PCM is to store data by using a special material (chalcogenide GST) to reflect the difference in conductivity between the crystalline and amorphous states, and the stored data is realized by a write operation including: SET operation (write 0) and RESET operation (write 1). In an existing NVM device, when data is written, one memory block is usually selected in the storage medium, and data to be written is written to the memory block regardless of the value of the storage bit in the selected memory block. This makes the value of the memory bit in the memory block at the same location different from the value of the data bit of the data to be written, and may even be completely different, for example, the data to be written is 8*8 size, and each data to be written is The value of each data bit is 1, and the value of the memory bit in the memory block is 0. Therefore, the value of each memory bit in the memory block needs to be rewritten during writing, resulting in data writing. More writes to the memory bits in the store are required.
在NVM的应用设备中,不管是NVM的RESET操作,还是SET操作,NVM的写操作能耗比读操作能耗要高10-100倍左右。所以在NVM在工作过程中,大量写操作不仅会带来高能耗,而且还会降低NVM的使用寿命。In the NVM application device, whether it is the RESET operation of the NVM or the SET operation, the NVM write operation consumes about 10 to 100 times more energy than the read operation. Therefore, during the working process of NVM, a large number of write operations will not only bring high energy consumption, but also reduce the service life of the NVM.
发明内容Summary of the invention
本发明实施例中提供了一种数据写入方法、装置及存储器,可减少写入数据时的写操作次数,降低了由于写操作的能耗,提高了NVM的使用寿命。The embodiment of the invention provides a data writing method, device and memory, which can reduce the number of write operations when writing data, reduce the energy consumption of the write operation, and improve the service life of the NVM.
为了解决上述技术问题,本发明实施例公开了如下技术方案:In order to solve the above technical problem, the embodiment of the present invention discloses the following technical solutions:
第一方面,本发明实施例提供了一种数据写入方法,用于向非易失性存储介质NVM中写入数据,所述方法包括:In a first aspect, an embodiment of the present invention provides a data writing method for writing data to a non-volatile storage medium NVM, the method comprising:
从待写入数据块中确定所述待写入数据块的样本数据块; Determining, from the data block to be written, the sample data block of the data block to be written;
将所述待写入数据块的样本数据块分别与预设样本集中的N个样本数据块进行比较,其中,所述N个样本数据块中的每一个样本数据块的大小与所述待写入数据块的样本数据块的大小相同,所述N个样本数据块分别从所述NVM中的N个空闲地址空间的数据块中获得,其中,N为不小于2的整数;Comparing the sample data blocks of the data block to be written with N sample data blocks in a preset sample set, wherein a size of each of the N sample data blocks and the to-be-written The size of the sample data block of the inbound data block is the same, and the N sample data blocks are respectively obtained from the data blocks of the N free address spaces in the NVM, where N is an integer not less than 2;
在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块;Determining, in the N sample data blocks, one sample data block having the highest matching degree with the sample data block of the to-be-written data block as a target sample data block;
将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中。Writing the to-be-written data block into a free address space corresponding to the target sample data block.
结合第一方面,在第一方面第一种可能的实现方式中,所述将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中,包括:With reference to the first aspect, in a first possible implementation manner of the first aspect, the writing the to-be-written data block into the free address space corresponding to the target sample data block includes:
在所述N个空闲地址空间的数据块中确定与所述目标样本数据块对应的目标数据块;Determining a target data block corresponding to the target sample data block in the data block of the N free address spaces;
确定所述目标数据块中与所述待写入数据块不同的数据位;Determining, in the target data block, a data bit different from the data block to be written;
在存储所述目标数据块的地址空间中,根据所述待写入数据块对确定的与所述待写入数据块不同的数据位的数据进行改写。In the address space in which the target data block is stored, the determined data of the data bit different from the to-be-written data block is rewritten according to the to-be-written data block.
结合第一方面,在第一方面第二种可能的实现方式中,所述在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块,包括:With reference to the first aspect, in a second possible implementation manner of the first aspect, the determining, in the N sample data blocks, a sample data block with the highest matching degree with the sample data block of the data block to be written As the target sample data block, including:
分别计算所述待写入数据块的样本数据块与所述N个样本数据块的相似率,所述相似率为所述待写入数据块的样本数据块中与所述样本集中样本数据块中相同的数据位的数量与所述待写入数据块的样本数据块内所有数据位的数量的比值;Calculating a similarity rate of the sample data block of the to-be-written data block and the N sample data blocks, where the similarity is the sample data block in the data block to be written and the sample data block in the sample set The ratio of the number of identical data bits in the middle to the number of all data bits in the sample data block of the data block to be written;
将所述N个样本数据块中与所述待写入数据块的样本数据块相似率最高的样本数据块确定为目标样本数据块。A sample data block having the highest similarity rate of the sample data block of the to-be-written data block among the N sample data blocks is determined as a target sample data block.
结合第一方面,在第一方面第三种可能的实现方式中,所述方法还包括:With reference to the first aspect, in a third possible implementation manner of the first aspect, the method further includes:
从所述预设样本集中删除与所述目标样本数据块对应的样本数据块;Deleting a sample data block corresponding to the target sample data block from the preset sample set;
判断所述预设样本集中的样本数据块的数量是否小于预设数量;Determining whether the number of sample data blocks in the preset sample set is less than a preset number;
当所述预设样本集中的样本数据块的数量小于所述预设数量时,从所述NVM中的空闲地址空间的数据块中获取新的样本数据块并加入到所述预设样本集中,对所述预设样本集进行更新。When the number of sample data blocks in the preset sample set is less than the preset number, acquiring a new sample data block from the data block of the free address space in the NVM and adding to the preset sample set, Updating the preset sample set.
第二方面,本发明实施例提供了数据写入装置,用于向非易失性存储介质NVM中写入数据,包括: In a second aspect, an embodiment of the present invention provides a data writing apparatus for writing data to a non-volatile storage medium NVM, including:
样本数据块确定模块,用于从待写入数据块中确定所述待写入数据块的样本数据块;a sample data block determining module, configured to determine a sample data block of the data block to be written from the data block to be written;
样本数据块比较模块,用于将所述待写入数据块的样本数据块分别与预设样本集中的N个样本数据块进行比较,其中,所述N个样本数据块中的每一个样本数据块的大小与所述待写入数据块的样本数据块的大小相同,所述N个样本数据块分别从所述NVM中的N个空闲地址空间的数据块中获得,其中,N为不小于2的整数;a sample data block comparison module, configured to compare the sample data block of the data block to be written with N sample data blocks in a preset sample set, wherein each sample data of the N sample data blocks The size of the block is the same as the size of the sample data block of the data block to be written, and the N sample data blocks are respectively obtained from data blocks of N free address spaces in the NVM, where N is not less than An integer of 2;
目标样本数据块确定模块,用于在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块;a target sample data block determining module, configured to determine, in the N sample data blocks, one sample data block having the highest matching degree with the sample data block of the data block to be written as a target sample data block;
写入模块,用于将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中。And a writing module, configured to write the to-be-written data block into a free address space corresponding to the target sample data block.
结合第二方面,在第二方面第一种可能的实现方式中,所述写入模块,包括:With reference to the second aspect, in a first possible implementation manner of the second aspect, the writing module includes:
目标数据块确定单元,在所述N个空闲地址空间的数据块中确定与所述目标样本数据块对应的目标数据块;a target data block determining unit that determines a target data block corresponding to the target sample data block in the data block of the N free address spaces;
数据位确定单元,用于确定所述目标数据块中与所述待写入数据块不同的数据位;a data bit determining unit, configured to determine a data bit in the target data block that is different from the data block to be written;
数据改写单元,用于在存储所述目标数据块的地址空间中,根据所述待写入数据块对确定的与所述待写入数据块不同的数据位的数据进行改写。And a data rewriting unit, configured to rewrite data of the determined data bit different from the to-be-written data block according to the to-be-written data block in an address space in which the target data block is stored.
结合第二方面,在第二方面第二种可能的实现方式中,所述目标样本数据块确定模块,包括:With reference to the second aspect, in a second possible implementation manner of the second aspect, the target sample data block determining module includes:
相似率计算单元,分别计算所述待写入数据块的样本数据块与所述N个样本数据块的相似率,所述相似率为所述待写入数据块的样本数据块中与所述样本集样本数据块中相同的数据位的数量与所述待写入数据块的样本数据块内所有数据位的数量的比值;a similarity rate calculating unit, respectively calculating a similarity rate of the sample data block of the to-be-written data block and the N sample data blocks, the similarity rate being in the sample data block of the to-be-written data block and the a ratio of the number of identical data bits in the sample set sample data block to the number of all data bits in the sample data block of the data block to be written;
确定单元,用于将所述N个样本数据块中与所述待写入数据块的样本数据块相似率最高的样本数据块确定为目标样本数据块。And a determining unit, configured to determine, as the target sample data block, a sample data block with the highest similarity rate of the sample data block of the to-be-written data block among the N sample data blocks.
结合第二方面,在第二方面第三种可能的实现方式中,所述装置还包括:With reference to the second aspect, in a third possible implementation manner of the second aspect, the device further includes:
样本数据块删除模块,用于从所述预设样本集中删除与所述目标样本数据块对应的样本数据块;a sample data block deleting module, configured to delete a sample data block corresponding to the target sample data block from the preset sample set;
判断模块,用于判断所述预设样本集中的样本数据块的数量是否小于预设数量;a determining module, configured to determine whether the number of sample data blocks in the preset sample set is less than a preset number;
更新模块,用于当所述预设样本集中的样本数据块的数量小于所述预设数量时,从所述NVM中的空闲地址空间的数据块中获取新的样本数据块并加入到所述预设样本集中,对所述预设样本集进行更新。 And an update module, configured to: when the number of sample data blocks in the preset sample set is less than the preset number, acquire a new sample data block from a data block of a free address space in the NVM and add the The preset sample set is updated by the preset sample set.
第三方面,本发明实施例提供了一种存储器,包括:非易失性存储介质NVM和NVM控制器,其中,In a third aspect, an embodiment of the present invention provides a memory, including: a non-volatile storage medium NVM and an NVM controller, where
所述VNM,用于存储数据;The VNM is configured to store data;
所述NVM控制器,用于从待写入数据块中确定所述待写入数据块的样本数据块;The NVM controller is configured to determine a sample data block of the to-be-written data block from a to-be-written data block;
将所述待写入数据块的样本数据块分别与预设样本集中的N个样本数据块进行比较,其中,所述N个样本数据块中的每一个样本数据块的大小与所述待写入数据块的样本数据块的大小相同,所述N个样本数据块分别从所述NVM中的N个空闲地址空间的数据块中获得,其中,N为不小于2的整数;Comparing the sample data blocks of the data block to be written with N sample data blocks in a preset sample set, wherein a size of each of the N sample data blocks and the to-be-written The size of the sample data block of the inbound data block is the same, and the N sample data blocks are respectively obtained from the data blocks of the N free address spaces in the NVM, where N is an integer not less than 2;
在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块;Determining, in the N sample data blocks, one sample data block having the highest matching degree with the sample data block of the to-be-written data block as a target sample data block;
将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中。Writing the to-be-written data block into a free address space corresponding to the target sample data block.
结合第三方面,在第三方面第一种可能的实现方式中,所述NVM控制器具体用于:In conjunction with the third aspect, in a first possible implementation manner of the third aspect, the NVM controller is specifically configured to:
在所述N个空闲地址空间的数据块中确定与所述目标样本数据块对应的目标数据块;Determining a target data block corresponding to the target sample data block in the data block of the N free address spaces;
确定所述目标数据块中与所述待写入数据块的样本数据块不同的数据位;Determining, in the target data block, a data bit different from the sample data block of the data block to be written;
在存储所述目标数据块的地址空间中,根据所述待写入数据块对确定的与所述待写入数据块的样本数据块不同的数据位的数据进行改写。In the address space in which the target data block is stored, the determined data of the data bit different from the sample data block of the data block to be written is rewritten according to the to-be-written data block.
结合第三方面,在第三方面第二种可能的实现方式中,所述NVM控制器具体用于:In conjunction with the third aspect, in a second possible implementation manner of the third aspect, the NVM controller is specifically configured to:
分别计算所述待写入数据块的样本数据块与所述N个样本数据块的相似率,所述相似率为所述待写入数据块的样本数据块中与所述样本集中样本数据块中相同的数据位的数量与所述待写入数据块的样本数据块内所有数据位的数量的比值;Calculating a similarity rate of the sample data block of the to-be-written data block and the N sample data blocks, where the similarity is the sample data block in the data block to be written and the sample data block in the sample set The ratio of the number of identical data bits in the middle to the number of all data bits in the sample data block of the data block to be written;
将所述N个样本数据块中与所述待写入数据块的样本数据块相似率最高的样本数据块确定为目标样本数据块。A sample data block having the highest similarity rate of the sample data block of the to-be-written data block among the N sample data blocks is determined as a target sample data block.
结合第三方面,在第三方面第三种可能的实现方式中,所述NVM控制器还用于:In conjunction with the third aspect, in a third possible implementation manner of the third aspect, the NVM controller is further configured to:
从所述预设样本集中删除与所述目标样本数据块对应的样本数据块;Deleting a sample data block corresponding to the target sample data block from the preset sample set;
判断所述预设样本集中的样本数据块的数量是否小于预设数量;Determining whether the number of sample data blocks in the preset sample set is less than a preset number;
当所述预设样本集中的样本数据块的数量小于所述预设数量时,从所述NVM中的空闲地址空间的数据块中获取新的样本数据块并加入到所述预设样本集中,对所述预设样本集进行更新。 When the number of sample data blocks in the preset sample set is less than the preset number, acquiring a new sample data block from the data block of the free address space in the NVM and adding to the preset sample set, Updating the preset sample set.
由以上技术方案可见,本发明实施例提供的该方法,在将待写入数据块写入到NVM中时,从待写入数据块中选取一个样本数据块,然后将从NVM中预先获取的N个样本数据块分别与选取的待写入数据块的样本数据块进行比较,并将在N个样本数据块中确定出与待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块,最后将待写入数据块写入与该目标样本数据块对应的空闲地址空间中。在本发明实施例提供的数据写入方法中,由于向NVM写入数据时,并不是将待写入数据块随机写入到NVM中,而是将待写入数据块写入从NVM中获取的N个样本数据块中确定的一个与待写入数据块的样本数据块最匹配的样本数据块所对应的空闲存储空间。因此,本发明实施例提供的数据写入方法在写入数据时可以减少对NVM中数据位的改写数量,从而减少了写操作的次数。从而降低了写操作能耗,提高了NVM的使用寿命。It can be seen from the above technical solution that the method provided by the embodiment of the present invention selects a sample data block from the to-be-written data block when the data block to be written is written into the NVM, and then pre-acquires from the NVM. The N sample data blocks are respectively compared with the selected sample data block of the data block to be written, and a sample data block having the highest matching degree with the sample data block of the data block to be written is determined in the N sample data blocks. As the target sample data block, the data block to be written is finally written into the free address space corresponding to the target sample data block. In the data writing method provided by the embodiment of the present invention, when data is written to the NVM, the data block to be written is not randomly written into the NVM, but the data block to be written is written and retrieved from the NVM. The determined one of the N sample data blocks corresponds to the free storage space corresponding to the sample data block that best matches the sample data block of the data block to be written. Therefore, the data writing method provided by the embodiment of the present invention can reduce the number of rewriting of data bits in the NVM when writing data, thereby reducing the number of write operations. Thereby reducing the energy consumption of the write operation and increasing the service life of the NVM.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it will be apparent to those skilled in the art that In other words, other drawings can be obtained based on these drawings without paying for creative labor.
图1为本发明实施例提供的一种存储器的结构示意图;1 is a schematic structural diagram of a memory according to an embodiment of the present invention;
图2为本发明实施例提供的一种数据写入方法的流程示意图;2 is a schematic flowchart of a data writing method according to an embodiment of the present invention;
图3为图2中步骤S300的流程示意图;3 is a schematic flow chart of step S300 in FIG. 2;
图4为本发明实施例提供的一种数据写入示意图;4 is a schematic diagram of data writing according to an embodiment of the present invention;
图5为图2中步骤S400的流程示意图;FIG. 5 is a schematic flowchart of step S400 in FIG. 2;
图6为本发明实施例提供的另一种数据写入方法的流程示意图;FIG. 6 is a schematic flowchart diagram of another data writing method according to an embodiment of the present disclosure;
图7为本发明实施例提供的一种数据写入装置的结构示意图;FIG. 7 is a schematic structural diagram of a data writing apparatus according to an embodiment of the present disclosure;
图8为图7中写入模块的结构示意图;8 is a schematic structural view of a write module of FIG. 7;
图9为图7中目标样本数据块确定模块的结构示意图;9 is a schematic structural diagram of a target sample data block determining module in FIG. 7;
图10为本发明实施例提供的另一种数据写入装置的结构示意图。FIG. 10 is a schematic structural diagram of another data writing apparatus according to an embodiment of the present invention.
具体实施方式detailed description
为了使本技术领域的人员更好地理解本发明中的技术方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。In order to make those skilled in the art better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. The embodiments are only a part of the embodiments of the invention, and not all of the embodiments.
本发明实施例提供的该方法,可以用于包括但不局限于非易失性存储器NVM,例如: 闪速存储器(Flash Memory)、PCM(Phase Change Memory,相变存储器)、FRAM(Ferroelectric Random Access Memory,铁电介质存储器)等,对于其它通过改写存储位状态进行写操作的存储设备同样可以适用。The method provided by the embodiment of the present invention may be used for, but not limited to, a non-volatile memory NVM, for example: A flash memory, a PCM (Phase Change Memory), a FRAM (Ferroelectric Random Access Memory), and the like are also applicable to other storage devices that perform a write operation by rewriting the storage bit state.
需要说明的是,本发明实施例中所描述的非易失性存储器可以包括:相变存储器(Phase Change Memory,PCM)、阻变存储器(Resistive Random Access Memory,RRAM)、磁性存储器(Magnetic Random Access Memory,MRAM)或铁电式存储器(Ferroelectric Random Access Memory,FRAM)等新型非易失性存储器。这些新型NVM都具有访问速度快且具有非易失性的特点,并且,这些新型NVM能够按字节(Byte)寻址,将数据以位(bit)为单位写入非易失性存储介质中。It should be noted that the non-volatile memory described in the embodiments of the present invention may include: Phase Change Memory (PCM), Resistive Random Access Memory (RRAM), and Magnetic Random Access (Magnetic Random Access). Memory, MRAM) or new nonvolatile memory such as Ferroelectric Random Access Memory (FRAM). These new NVMs are fast and non-volatile, and these new NVMs can be addressed in Bytes and write data in non-volatile storage media in bits. .
图1为本发明实施例提供的一种非易失性存储器100的结构示意图。如图1所示,非易失性存储器100可以包括NVM控制器102、内存104、主机接口106以及存储介质108。FIG. 1 is a schematic structural diagram of a nonvolatile memory 100 according to an embodiment of the present invention. As shown in FIG. 1, the non-volatile memory 100 can include an NVM controller 102, a memory 104, a host interface 106, and a storage medium 108.
主机接口106用于连接主机,与主机进行通信。例如,用于接收主机下发的I/O请求,或将从存储介质108中读出的数据返回给主机。其中,主机接口106可以包括串行高级技术附件(Serial Advanced Technology Attachment,SATA)接口、通用串行总线(Universal Serial Bus,USB)接口、光纤通道技术(Fibre Channel,FC)接口或快捷外设互联标准(Peripheral Component Interconnect Express,PCI-E)接口等。可以理解的是,主机接口106仅仅是通信接口的一种示例,在NVM100中,除了与主机进行通信的主机接口106外,还可以包括与后端存储介质108进行通信的后端通信接口。The host interface 106 is used to connect to the host and communicate with the host. For example, it is used to receive an I/O request issued by the host, or return data read from the storage medium 108 to the host. The host interface 106 may include a Serial Advanced Technology Attachment (SATA) interface, a Universal Serial Bus (USB) interface, a Fibre Channel (FC) interface, or a fast peripheral interconnection. Peripheral Component Interconnect Express (PCI-E) interface. It will be appreciated that host interface 106 is merely one example of a communication interface in which, in addition to host interface 106 in communication with the host, a backend communication interface in communication with backend storage medium 108 may be included.
内存104,用于存放处理器1022当前正在使用的(即执行中)的数据和程序109。例如,当主机向NVM写入数据时,内存104可以用于缓存主机要写入的数据。当主机从NVM中读取数据时,内存104可以用于缓存从存储介质108中读取的待向主机返回的数据。内存104可以是高速RAM存储器或者非易失性存储器等各种可以存储程序代码的非短暂性的(non-transitory)机器可读介质。The memory 104 is used to store data and programs 109 that the processor 1022 is currently using (ie, in execution). For example, when a host writes data to the NVM, the memory 104 can be used to cache data that the host is to write. When the host reads data from the NVM, the memory 104 can be used to cache data to be returned from the storage medium 108 to be returned to the host. The memory 104 can be a non-transitory machine readable medium that can store program code, such as high speed RAM memory or non-volatile memory.
程序109可以包括程序代码,所述程序代码包括计算机操作指令。 Program 109 can include program code, the program code including computer operating instructions.
存储介质108,用于存储数据。存储介质108可以由多个存储单元组成。在本发明实施例中,存储介质108中的存储单元是指用于存储数据的最小存储介质单元。例如,存储单元可以包括相变存储单元、磁性存储单元、阻变存储单元等非易失性存储单元。A storage medium 108 for storing data. The storage medium 108 can be composed of a plurality of storage units. In the embodiment of the present invention, the storage unit in the storage medium 108 refers to the smallest storage medium unit for storing data. For example, the memory unit may include a nonvolatile memory unit such as a phase change memory unit, a magnetic memory unit, a resistive memory unit, or the like.
NVM控制器102主要包括处理器(processor)1022、缓存(cache)1024以及后端通信接口(Communication Interface)1026。处理器1022、缓存1024、以及后端通信接口1026通过通信总线完成相互间的通信。 The NVM controller 102 mainly includes a processor 1022, a cache 1024, and a back end communication interface 1026. The processor 1022, the cache 1024, and the backend communication interface 1026 complete communication with each other over the communication bus.
其中,缓存1024是位于处理器1022与内存104之间的临时存储器,它的容量比内存104小但是交换速度却比内存104要快。缓存1024用于缓存处理器1022待写入存储介质108的数据或者用于缓存内存104传输的从存储介质108读取的数据。缓存1024可以是RAM、ROM、闪存(Flash memory)等各种可以存储数据的机器可读介质。缓存1024可以包括多级,例如可以包括一级缓存、二级缓存及三级缓存。The cache 1024 is a temporary memory located between the processor 1022 and the memory 104. Its capacity is smaller than the memory 104 but the exchange speed is faster than the memory 104. The cache 1024 is used to cache data that the processor 1022 is to write to the storage medium 108 or data that is read from the storage medium 108 for buffer memory 104 transfers. The cache 1024 may be a variety of machine readable media that can store data, such as RAM, ROM, Flash memory, and the like. The cache 1024 can include multiple levels, for example, can include a level 1 cache, a level 2 cache, and a level 3 cache.
后端通信接口1026,用于与存储介质108进行通信。例如,可以用于管理对处理器1022下发的对存储介质108的访问命令以及进行数据传输。可以理解的是,后端通信接口1026中可以包括多个通信通道,用于连接存储介质108中不同的存储单元。A backend communication interface 1026 is for communicating with the storage medium 108. For example, it can be used to manage access commands to the storage medium 108 issued by the processor 1022 and to perform data transmission. It can be understood that a plurality of communication channels can be included in the backend communication interface 1026 for connecting different storage units in the storage medium 108.
处理器1022可以是一个中央处理器CPU,或者是特定集成电路(Application Specific Integrated Circuit,ASIC),或者是被配置成实施本发明实施例的一个或多个集成电路。在处理器1022中安装有操作系统和其他软件程序,不同的软件程序可以视作一个处理模块,具有不同的功能。例如,处理器1022可以实现对存储介质108的访问请求,或者对存储介质108中的数据进行管理等等。例如,处理器1022可以通过通信总线接收主机接口106转发的输入输出I/O请求,并根据主机下发的I/O请求通过后端通信接口1026访问存储介质108,向存储介质108中写入数据或者从存储介质108中读取数据。The processor 1022 can be a central processing unit CPU, or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. An operating system and other software programs are installed in the processor 1022, and different software programs can be regarded as one processing module having different functions. For example, processor 1022 can implement an access request to storage medium 108, or manage data in storage medium 108, and the like. For example, the processor 1022 can receive the input and output I/O request forwarded by the host interface 106 through the communication bus, and access the storage medium 108 through the backend communication interface 1026 according to the I/O request issued by the host, and write to the storage medium 108. The data is either read from the storage medium 108.
在本发明实施例中,处理器1022在向存储介质108写入数据时,可以执行程序109,具体可以执行下述方法实施例中的相关步骤,以实现磨损均衡。下面将对本发明实施例中NVM100具体如何实现磨损均衡的方法进行详细介绍。In the embodiment of the present invention, when the processor 1022 writes data to the storage medium 108, the program 109 may be executed. Specifically, the related steps in the following method embodiments may be performed to achieve wear leveling. The method for how the NVM 100 specifically implements wear leveling in the embodiment of the present invention will be described in detail below.
图2为本发明实施例提供的一种数据写入方法的流程示意图。如图2所示,该数据写入方法可以包括以下步骤。FIG. 2 is a schematic flowchart diagram of a data writing method according to an embodiment of the present invention. As shown in FIG. 2, the data writing method may include the following steps.
步骤S100:从待写入数据块中确定所述待写入数据块的样本数据块。Step S100: Determine a sample data block of the data block to be written from the data block to be written.
参见上述图1所示,NVM控制器102中的处理器1022通过主机接口106接收主机下发的数据写入请求,在数据写入请求中携带有待写入数据,处理器1022将待写入数据写入到缓存1024中形成待写入数据块。Referring to FIG. 1 above, the processor 1022 in the NVM controller 102 receives a data write request sent by the host through the host interface 106, carries data to be written in the data write request, and the processor 1022 writes data to be written. Writing to the buffer 1024 forms a block of data to be written.
处理器1022可以从待写入数据块中选取一个数据块确定为样本数据块,样本数据块为预设大小,例如:1k、2k或者其他固定大小。在本发明实施例中,如图4所示,图中a为待写入数据块的样本数据块,其大小为8*8。可以理解的是,在该步骤中,处理器1022可以按照预设位置在待写入数据块中按照预设大小选取样本数据块,具体的获取样本数据块的策略可以根据实际情况具体设定,在此不对样本数据块的大小和获取位置做具体限定。 The processor 1022 may determine one data block from the data block to be written as the sample data block, and the sample data block is a preset size, for example, 1 k, 2 k or other fixed size. In the embodiment of the present invention, as shown in FIG. 4, a is a sample data block of a data block to be written, and its size is 8*8. It can be understood that, in this step, the processor 1022 can select the sample data block according to the preset size in the data block to be written according to the preset position, and the specific strategy for acquiring the sample data block can be specifically set according to actual conditions. The size and acquisition location of the sample data block are not specifically limited here.
步骤S200:将所述待写入数据块的样本数据块分别与预设样本集中的N个样本数据块进行比较。Step S200: Compare the sample data blocks of the data block to be written with the N sample data blocks in the preset sample set.
预设样本集中的N个样本数据块中的每一个样本数据块的大小与所述待写入数据块的样本数据块的大小相同,如图4所示,图中b为预设样本集中的样本数据块,同样为8*8。在本发明实施例中,N个样本数据块分别从所述NVM中的N个空闲地址空间的数据块中获得,其中,N为不小于2的整数。参见图1所示,预设样本集中的N个样本数据块可由处理器1022预先通过后端通信接口1026对存储介质108进行扫描,从存储介质108中读取N个空闲地址空间的数据块作为N个样本数据块,并且在读取N个样本数据块时还同时建立了样本集中N个样本数据块与N个空闲地址空间的物理地址之间的对应关系,以便于根据样本集中N个样本数据块可以寻找到与每个样本数据块对应的空闲地址空间的物理地址,的数据块为无用数据块。需要说明的是,在本发明实施例中选取待写入数据块的样本数据块的策略可以与样本集中的样本数据块的获取策略相同,根据这种方式,待写入数据块的样本数据块和样本集中的样本数据块都是按照预设大小在预设位置获取得到的。The size of each of the N sample data blocks in the preset sample set is the same as the size of the sample data block of the data block to be written, as shown in FIG. 4, where b is a preset sample set. The sample data block is also 8*8. In the embodiment of the present invention, N sample data blocks are respectively obtained from data blocks of N free address spaces in the NVM, where N is an integer not less than 2. Referring to FIG. 1, the N sample data blocks in the preset sample set may be scanned by the processor 1022 through the back end communication interface 1026 in advance, and the data blocks of the N free address spaces are read from the storage medium 108. N sample data blocks, and when the N sample data blocks are read, the correspondence between the N sample data blocks in the sample set and the physical addresses of the N free address spaces is also established, so as to facilitate N samples according to the sample set. The data block can find the physical address of the free address space corresponding to each sample data block, and the data block is a garbage block. It should be noted that, in the embodiment of the present invention, the policy of selecting the sample data block to be written into the data block may be the same as the acquisition strategy of the sample data block in the sample set. According to this manner, the sample data block of the data block to be written is determined. And the sample data blocks in the sample set are obtained at preset positions according to a preset size.
在步骤S300:在N个样本数据块中确定与待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块。In step S300, one sample data block having the highest degree of matching with the sample data block of the data block to be written is determined as the target sample data block among the N sample data blocks.
在本发明一实施例中,如图3所示,该步骤可以包括以下步骤:In an embodiment of the invention, as shown in FIG. 3, the step may include the following steps:
步骤S301:分别计算所述待写入数据块的样本数据块与所述N个样本数据块的相似率。Step S301: Calculate the similarity rate of the sample data block of the to-be-written data block and the N sample data blocks, respectively.
在该实施例中,相似率是指所述待写入数据块的样本数据块中与所述样本集中样本数据块中相同的数据位的数量与所述样本集的样本数据块内所有数据位的数量的比值。其中,相同的数据位是指两个数据块中相同位置且数据相同的数据位,如图4所示,待写入数据块的样本数据块a的左上角的数据位的数据为1,预设样本集中的样本数据块b的左上角的数据位的数据也为1,那么位于两者左上角的数据位就是相同的数据位。In this embodiment, the similarity ratio refers to the same number of data bits in the sample data block of the data block to be written and the sample data block in the sample set, and all data bits in the sample data block of the sample set. The ratio of the number. Wherein, the same data bit refers to the same position in the two data blocks and the data bits are the same. As shown in FIG. 4, the data bit of the upper left corner of the sample data block a to be written into the data block is 1, pre- It is assumed that the data bit of the upper left corner of the sample data block b in the sample set is also 1, and the data bits located in the upper left corner of the sample are the same data bits.
以图4为例,图中,待写入数据块的样本数据块a与预设样本集中的样本数据块b中相同的数据位的数量为24,而预设样本集中的样本数据块b中所有数据位的数量为64,那么在图4中,待写入数据块的样本数据块a与预设样本集中的样本数据块b的相似率就为24/64。Taking FIG. 4 as an example, in the figure, the number of data bits in the sample data block a of the data block to be written and the sample data block b in the preset sample set is 24, and the sample data block b in the preset sample set is The number of all data bits is 64, then in Figure 4, the similarity rate of the sample data block a of the data block to be written to the sample data block b of the preset sample set is 24/64.
步骤S302:将N个样本数据块中与所述待写入数据块的样本数据块相似率最高的样本数据块确定为目标样本数据块。Step S302: Determine a sample data block with the highest similarity rate of the sample data block of the to-be-written data block among the N sample data blocks as the target sample data block.
在本发明其它实施例中,在步骤S300中,一种情形下,可以根据待写入数据块的样本数据块与所述N个样本数据块中相同的数据位的数量,直接在所述N个样本数据块 中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块。在另一种情形下,还可以根据待写入数据块的样本数据块与所述N个样本数据块中不相同的数据位的数量,或,不相同的数据位与样本集中样本数据块的所有数据位的数量的比值,来确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块。In other embodiments of the present invention, in step S300, in one case, according to the number of data bits in the sample data block of the data block to be written and the N sample data blocks, directly in the N Sample data block Determining a sample data block with the highest degree of matching with the sample data block of the data block to be written. In another case, the sample data block to be written to the data block may be different from the number of data bits in the N sample data blocks, or different data bits and sample data blocks in the sample set. A ratio of the number of all data bits to determine a sample data block that has the highest degree of matching with the sample data block of the data block to be written.
步骤S400:将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中。Step S400: Write the to-be-written data block into a free address space corresponding to the target sample data block.
在本发明实施例中,如图5所示,该步骤可以包括以下步骤:In the embodiment of the present invention, as shown in FIG. 5, the step may include the following steps:
步骤S401:在所述N个空闲地址空间的数据块中确定与所述目标样本数据块对应的目标数据块。Step S401: Determine a target data block corresponding to the target sample data block in the data block of the N free address spaces.
根据上述步骤S200中建立的样本集中N个样本数据块与N个空闲地址空间的物理地址之间的对应关系,当确定目标样本数据块后,可以根据该对应关系查找到与目标样本数据块对应的目标数据块。According to the correspondence between the N sample data blocks in the sample set and the physical addresses of the N free address spaces established in the above step S200, after determining the target sample data block, the corresponding sample data block may be found according to the corresponding relationship. Target data block.
步骤S402:确定所述目标数据块中与所述待写入数据块不同的数据位。Step S402: Determine a data bit in the target data block that is different from the data block to be written.
参见上述步骤300中关于样本数据块的描述可知,目标数据块中与所述待写入数据块的样本数据块不同的数据位上的数据不相同。Referring to the description of the sample data block in the above step 300, the data on the data bit different from the sample data block of the data block to be written in the target data block is different.
步骤S403:在存储所述目标数据块的地址空间中,根据所述待写入数据块对确定的与所述待写入数据块不同的数据位的数据进行改写。Step S403: In the address space in which the target data block is stored, rewriting data of the determined data bit different from the to-be-written data block according to the to-be-written data block.
根据这种方式,在该步骤中,可以通过在目标数据块的地址空间中,仅对目标数据块内与所述待写入数据块的样本数据块不同的数据位的数据进行改写。In this way, in this step, only the data of the data bits different from the sample data block of the data block to be written in the target data block can be overwritten in the address space of the target data block.
例如,在图4中,若将待写入数据块的样本数据块a写入到预设样本集中的样本数据块b中,那么写入后得到的数据块为c。其中,阴影所示的数据位为数据不同的数据位,而未填充阴影的数据位为数据相同的数据位。在将数据写入时,如图4所示,可以只需要对阴影所示的数据位的数据进行改写,例如,以PCM为例,可以只改变对应的数据为的存储介质的晶体状态。可以理解的是,在图4所示的示意图中,数据块中c中未填充阴影的数据位的数据与待写入数据块的样本数据块a、预设样本集中的样本数据块b中相同数据位的数据都相同,因此无需对为填充阴影的数据位的数据进行改写。可见,在图4中,由于待写入数据块的样本数据块a与预设样本集中的样本数据块b相同的数据位为24个,所以在图4中将待写入数据块的样本数据块a写入到预设样本集中的样本数据块b时,需要进行改写40次。For example, in FIG. 4, if the sample data block a of the data block to be written is written into the sample data block b in the preset sample set, the data block obtained after the writing is c. The data bits shown by the shadows are different data bits of the data, and the data bits that are not filled with the shadows are the same data bits of the data. When data is written, as shown in FIG. 4, it is only necessary to rewrite the data of the data bits indicated by the hatching. For example, in the case of PCM, only the crystal state of the storage medium corresponding to the data can be changed. It can be understood that, in the schematic diagram shown in FIG. 4, the data of the unfilled data bits in c of the data block is the same as the sample data block a of the data block to be written and the sample data block b of the preset sample set. The data bits are all the same, so there is no need to rewrite the data for the data bits that fill the shadows. It can be seen that in FIG. 4, since the sample data block a of the data block to be written has the same data bits as the sample data block b in the preset sample set, the sample data of the data block to be written is shown in FIG. When the block a is written to the sample data block b in the preset sample set, it needs to be rewritten 40 times.
本发明实施例提供的该方法,在将待写入数据块写入到NVM中时,从待写入数据块中选取一个样本数据块,然后在从NVM中预先获取的N个样本数据块分别与选取的待写 入数据块的样本数据块进行比较,并在N个样本数据块中确定出与待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块,最后将待写入数据块写入与该目标样本数据块对应的空闲地址空间中。In the method provided by the embodiment of the present invention, when a data block to be written is written into the NVM, one sample data block is selected from the data block to be written, and then N sample data blocks pre-acquired from the NVM are respectively With the selected to be written Comparing the sample data blocks of the ingress data block, and determining, in the N sample data blocks, one sample data block having the highest matching degree with the sample data block of the data block to be written as the target sample data block, and finally the data to be written The block is written into the free address space corresponding to the target sample data block.
由于向NVM写入数据时,并不是将待写入数据块随机写入到NVM中,而是在预先从NVM中获取的N个样本数据块中选取出一个与待写入数据块的样本数据块最匹配的样本数据块,最匹配的样本数据块是指与待写入数据块的样本数据块中相同数据位的数量最多,这样在将待写入数据块写入到目标样本数据块时,可以只对与目标样本数据块对应的目标数据块内、与待写入数据块不同的数据位进行改写,而对于相同的数据位则不进行改写,因此,本发明实施例提供的数据写入方法在写入数据时可以减少对NVM中数据位的改写数量,从而减少了写操作的次数。从而降低了写操作能耗,提高了NVM的使用寿命。When data is written to the NVM, the data block to be written is not randomly written into the NVM, but a sample data of the data block to be written is selected from the N sample data blocks previously acquired from the NVM. The block most closely matched sample data block, the most matching sample data block means that the same number of data bits are the same in the sample data block to be written to the data block, so that when the data block to be written is written to the target sample data block The data bits different from the data block to be written may be rewritten only in the target data block corresponding to the target sample data block, and the same data bit is not rewritten. Therefore, the data writing provided by the embodiment of the present invention is The ingress method reduces the number of rewrites of data bits in the NVM when writing data, thereby reducing the number of write operations. Thereby reducing the energy consumption of the write operation and increasing the service life of the NVM.
在上述图2所示的实施例中,描述的是对待写入数据块的写入过程,当待写入数据块完成写入到与目标样本数据块对应的空闲地址空间后,与目标样本数据块相对应的空闲地址空间将不再是空闲地址,无法再继续写入数据,即预设样本集中的样本数据块一旦被选择为目标样本数据块后,该样本数据块将会失效,在后续对其它待写入数据块的写入过程中,将不会选择与之前被选择为目标样本数据块的样本数据块进行比较。In the embodiment shown in FIG. 2 above, the writing process of the data block to be written is described. When the data block to be written is written to the free address space corresponding to the target sample data block, the target sample data is The corresponding free address space of the block will no longer be a free address, and the data cannot be further written. That is, once the sample data block in the preset sample set is selected as the target sample data block, the sample data block will be invalid, During the writing of other blocks to be written, the sample data block that was previously selected as the target sample data block will not be selected for comparison.
这样,在持续写入待写入数据块的过程中,预设样本集中的可用的样本数据块的数量会减少,当预设样本集中样本数据块的数量少于预设数量时,后续在与预设样本集中样本数据块进行比较时,选择得到的目标样本数据块与待写入数据块中的样本数据块的匹配度可能不理想,使得数据写入时的改写次数较多。为了减少数据写入时的改写次数,在预设样本集中的可用的样本数据块的数量减少的过程中,还会对预设样本集中进行更新。In this way, in the process of continuously writing the data block to be written, the number of available sample data blocks in the preset sample set is reduced. When the number of sample data blocks in the preset sample set is less than the preset number, the subsequent When the sample data blocks in the preset sample set are compared, the matching degree between the selected target sample data block and the sample data block in the data block to be written may not be ideal, so that the number of times of rewriting is more when the data is written. In order to reduce the number of rewrites when data is written, the preset sample set is also updated during the process of reducing the number of available sample data blocks in the preset sample set.
如图6所示,该方法还可以包括以下步骤:As shown in FIG. 6, the method may further include the following steps:
步骤S500:在所述预设样本集中删除与所述目标样本数据块对应的样本数据块。Step S500: deleting a sample data block corresponding to the target sample data block in the preset sample set.
由于预设样本集中的所有样本数据块都是存储在图1中的缓存1024中,当目标样本数据块被选择后,与所述目标样本数据块对应的空闲地址空间就会时效,那么在该步骤中可以将与目标样本数据块对应样本数据块从缓存1024中删除,这样还会提高缓存1024的空间利用率。Since all the sample data blocks in the preset sample set are stored in the buffer 1024 in FIG. 1, when the target sample data block is selected, the free address space corresponding to the target sample data block is timed, then In the step, the sample data block corresponding to the target sample data block can be deleted from the cache 1024, which also improves the space utilization of the cache 1024.
在本发明其它实施例的又一种情形下与目标样本数据块对应的样本数据块还可以不被删除,而是被标记出来,并且预设样本集中被标记出来的样本数据块将不再参与后续的待写入数据块写入时的比较过程。无论哪种方式,其目的都是为了避免在后续写入 过程中仍选择与该目标样本数据块对应的样本数据块。In still another case of other embodiments of the present invention, the sample data block corresponding to the target sample data block may not be deleted, but may be marked, and the sample data block marked in the preset sample set will no longer participate. The subsequent comparison process when the data block to be written is written. Either way, the purpose is to avoid subsequent writes The sample data block corresponding to the target sample data block is still selected in the process.
步骤S600:判断所述预设样本集中的样本数据块的数量是否小于预设数量。Step S600: Determine whether the number of sample data blocks in the preset sample set is less than a preset number.
在实际应用中,预设数量可以根据用户需要自由设定,例如N为100。在本发明其它实施例中,预设数量还可以为预设比例,例如:预设比例为40%或60%。另外,为了避免对预设样本集更新频率过高,还可以同时根据预设样本集的更新频率以及预设样本集中剩余的样本数据块的数量同时设置该预设数量或预设比例。In practical applications, the preset number can be freely set according to user needs, for example, N is 100. In other embodiments of the present invention, the preset number may also be a preset ratio, for example, the preset ratio is 40% or 60%. In addition, in order to avoid the update frequency of the preset sample set is too high, the preset number or the preset ratio may be simultaneously set according to the update frequency of the preset sample set and the number of remaining sample data blocks in the preset sample set.
当所述预设样本集中的样本数据块的数量小于所述预设数量时,进行步骤S700,否则,结束流程。When the number of sample data blocks in the preset sample set is less than the preset number, step S700 is performed; otherwise, the process ends.
步骤S700:从所述NVM中的空闲地址空间的数据块中获取新的样本数据块并加入到所述预设样本集中,对所述预设样本集进行更新。Step S700: Acquire a new sample data block from the data block of the free address space in the NVM and add to the preset sample set, and update the preset sample set.
在该步骤中,NVM控制器102中的处理器1022可以重新对存储介质108进行扫描,从存储介质108中获取新的样本数据块,并且获取的新的样本数据块的数量正好为预设样本集中缺少的样本数据块的数量。In this step, the processor 1022 in the NVM controller 102 can re-scan the storage medium 108, acquire a new sample data block from the storage medium 108, and acquire the number of new sample data blocks that are exactly the preset samples. The number of sample data blocks that are missing from the set.
本发明实施例中,通过对预设样本集进行更新,可以在持续待写入数据块不同的样本数据块写入到NVM中,保证后续在与样本集中样本数据块进行比较时,可以使得选择得到的目标样本数据块与待写入数据块中的样本数据块的匹配度较为理想,进而可以进一步减少数据写入时的改写次数。In the embodiment of the present invention, by updating the preset sample set, the sample data blocks that are different in the data block to be written may be written into the NVM to ensure that the subsequent selection may be made when compared with the sample data block in the sample set. The matching degree between the obtained target sample data block and the sample data block in the data block to be written is ideal, and the number of times of rewriting at the time of data writing can be further reduced.
图7为本发明实施例提供的一种数据写入装置的结构示意图。如图7所示,该数据写入装置可以包括:样本数据块确定模块11、样本数据块比较模块12、目标样本数据块确定模块13和写入模块14,其中,FIG. 7 is a schematic structural diagram of a data writing apparatus according to an embodiment of the present invention. As shown in FIG. 7, the data writing device may include: a sample data block determining module 11, a sample data block comparing module 12, a target sample data block determining module 13, and a writing module 14, wherein
样本数据块确定模块11,用于从待写入数据块中确定所述待写入数据块的样本数据块;a sample data block determining module 11 configured to determine a sample data block of the data block to be written from the data block to be written;
样本数据块比较模块12,用于将所述待写入数据块的样本数据块分别与预设样本集中的N个样本数据块进行比较,其中,所述N个样本数据块中的每一个样本数据块的大小与所述待写入数据块的样本数据块的大小相同,所述N个样本数据块分别从所述NVM中的N个空闲地址空间的数据块中获得,其中,N为不小于2的整数;The sample data block comparison module 12 is configured to compare the sample data blocks of the data block to be written with N sample data blocks in a preset sample set, wherein each of the N sample data blocks The size of the data block is the same as the size of the sample data block of the data block to be written, and the N sample data blocks are respectively obtained from data blocks of N free address spaces in the NVM, where N is not An integer less than 2;
目标样本数据块确定模块13,用于在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块;The target sample data block determining module 13 is configured to determine, in the N sample data blocks, one sample data block having the highest matching degree with the sample data block of the data block to be written as the target sample data block;
写入模块14,用于将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中。 The writing module 14 is configured to write the to-be-written data block into a free address space corresponding to the target sample data block.
本公开实施例提供的该装置,可以减少写入数据时对NVM中数据位的改写数量,即减少了写入数据时的写操作的次数。因此,该装置可以解决由于数据写入时大量写操作而带来的高能耗以及降低NVM的使用寿命的问题。The apparatus provided by the embodiment of the present disclosure can reduce the number of rewriting of data bits in the NVM when writing data, that is, reduce the number of write operations when writing data. Therefore, the device can solve the problem of high power consumption due to a large number of write operations at the time of data writing and a reduction in the service life of the NVM.
在本发明一实施例中,如图8所示,写入模块14可以包括:目标数据块确定单元141、数据位确定单元142和数据改写单元143,其中:In an embodiment of the present invention, as shown in FIG. 8, the writing module 14 may include: a target data block determining unit 141, a data bit determining unit 142, and a data rewriting unit 143, wherein:
目标数据块确定单元141,在所述N个空闲地址空间的数据块中确定与所述目标样本数据块对应的目标数据块;The target data block determining unit 141 determines a target data block corresponding to the target sample data block in the data blocks of the N free address spaces;
数据位确定单元142,用于确定所述目标数据块中与所述待写入数据块不同的数据位;a data bit determining unit 142, configured to determine a data bit in the target data block that is different from the data block to be written;
数据改写单元143,用于在存储所述目标数据块的地址空间中,根据所述待写入数据块对确定的与所述待写入数据块不同的数据位的数据进行改写。The data rewriting unit 143 is configured to rewrite the determined data of the data bit different from the to-be-written data block according to the to-be-written data block in the address space in which the target data block is stored.
在本发明另一实施例中,如图9所示,目标样本数据块确定模块13可以包括:相似率计算单元131和确定单元132,其中:In another embodiment of the present invention, as shown in FIG. 9, the target sample data block determining module 13 may include a similarity rate calculating unit 131 and a determining unit 132, where:
相似率计算单元131,分别计算所述待写入数据块的样本数据块与所述N个样本数据块的相似率,所述相似率为所述待写入数据块的样本数据块中与所述样本集样本数据块中相同的数据位的数量与所述待写入数据块的样本数据块内所有数据位的数量的比值;The similarity rate calculation unit 131 calculates a similarity rate of the sample data block of the to-be-written data block and the N sample data blocks, where the similarity ratio is in the sample data block of the to-be-written data block. a ratio of the number of identical data bits in the sample set sample data block to the number of all data bits in the sample data block of the data block to be written;
确定单元132,用于将所述N个样本数据块中与所述待写入数据块的样本数据块相似率最高的样本数据块确定为目标样本数据块。The determining unit 132 is configured to determine, as the target sample data block, a sample data block with the highest similarity rate of the sample data block of the to-be-written data block among the N sample data blocks.
在本发明另一实施例中,如图10所示,该装置还可以包括:样本数据块删除模块15、判断模块16和更新模块17,其中,In another embodiment of the present invention, as shown in FIG. 10, the apparatus may further include: a sample data block deleting module 15, a determining module 16, and an updating module 17, wherein
样本数据块删除模块15,用于从所述预设样本集中删除与所述目标样本数据块对应的样本数据块;a sample data block deleting module 15 is configured to delete a sample data block corresponding to the target sample data block from the preset sample set;
判断模块16,用于判断所述预设样本集中的样本数据块的数量是否小于预设数量;The determining module 16 is configured to determine whether the number of sample data blocks in the preset sample set is less than a preset number;
更新模块17,用于当所述预设样本集中的样本数据块的数量小于所述预设数量时,从所述NVM中的空闲地址空间的数据块中获取新的样本数据块并加入到所述预设样本集中,对所述预设样本集进行更新。The updating module 17 is configured to: when the number of sample data blocks in the preset sample set is less than the preset number, acquire a new sample data block from a data block of the free address space in the NVM and add to the The preset sample set is updated to update the preset sample set.
从上述描述可知,本发明实施例提供的数据写入装置可以将待写入数据块写入从NVM中获取的N个样本数据块中确定的一个与待写入数据块的样本数据块最匹配的样本数据块所对应的空闲存储空间。因此,本发明实施例提供的数据写入装置在写入数据时可以减少对NVM中数据位的改写数量,从而减少了写操作的次数。从而降低了写操作能 耗,提高了NVM的使用寿命。It can be seen from the above description that the data writing apparatus provided by the embodiment of the present invention can write the data block to be written to the one of the N sample data blocks acquired from the NVM and the one of the sample data blocks to be written to the data block. The free storage space corresponding to the sample data block. Therefore, the data writing apparatus provided by the embodiment of the present invention can reduce the number of rewriting of data bits in the NVM when writing data, thereby reducing the number of write operations. Thereby reducing the write operation energy Consumption increases the life of the NVM.
图1为本发明实施例提供的一种存储器的结构示意图。如图1所示,该存储器至少包括:存储介质108和NVM控制器102,其中,FIG. 1 is a schematic structural diagram of a memory according to an embodiment of the present invention. As shown in FIG. 1, the memory includes at least: a storage medium 108 and an NVM controller 102, wherein
存储介质108,用于存储数据;a storage medium 108 for storing data;
NVM控制器102与存储介质108通过数据接口相连接,用于从待写入数据块中确定所述待写入数据块的样本数据块;The NVM controller 102 is connected to the storage medium 108 through a data interface, and is used to determine a sample data block of the data block to be written from the data block to be written;
将所述待写入数据块的样本数据块分别与预设样本集中的N个样本数据块进行比较,其中,所述N个样本数据块中的每一个样本数据块的大小与所述待写入数据块的样本数据块的大小相同,所述N个样本数据块分别从所述NVM中的N个空闲地址空间的数据块中获得,其中,N为不小于2的整数;Comparing the sample data blocks of the data block to be written with N sample data blocks in a preset sample set, wherein a size of each of the N sample data blocks and the to-be-written The size of the sample data block of the inbound data block is the same, and the N sample data blocks are respectively obtained from the data blocks of the N free address spaces in the NVM, where N is an integer not less than 2;
在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块;Determining, in the N sample data blocks, one sample data block having the highest matching degree with the sample data block of the to-be-written data block as a target sample data block;
将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中。Writing the to-be-written data block into a free address space corresponding to the target sample data block.
在本发明另一实施例中,NVM控制器102,还具体用于:In another embodiment of the present invention, the NVM controller 102 is further configured to:
在所述N个空闲地址空间的数据块中确定与所述目标样本数据块对应的目标数据块;Determining a target data block corresponding to the target sample data block in the data block of the N free address spaces;
确定所述目标数据块中与所述待写入数据块的样本数据块不同的数据位;Determining, in the target data block, a data bit different from the sample data block of the data block to be written;
在存储所述目标数据块的地址空间中,根据所述待写入数据块的样本数据块对确定的与所述待写入数据块的样本数据块不同的数据位的数据进行改写。In the address space in which the target data block is stored, the determined data of the data bit different from the sample data block of the data block to be written is rewritten according to the sample data block of the data block to be written.
在本发明又一实施例中,NVM控制器102,还具体用于:In another embodiment of the present invention, the NVM controller 102 is further configured to:
分别计算所述待写入数据块的样本数据块与所述N个样本数据块的相似率,所述相似率为所述待写入数据块的样本数据块中与所述样本集中样本数据块中相同的数据位的数量与所述待写入数据块的样本数据块内所有数据位的数量的比值;Calculating a similarity rate of the sample data block of the to-be-written data block and the N sample data blocks, where the similarity is the sample data block in the data block to be written and the sample data block in the sample set The ratio of the number of identical data bits in the middle to the number of all data bits in the sample data block of the data block to be written;
将所述N个样本数据块中与所述待写入数据块的样本数据块相似率最高的样本数据块确定为目标样本数据块。A sample data block having the highest similarity rate of the sample data block of the to-be-written data block among the N sample data blocks is determined as a target sample data block.
在本发明又一实施例中,NVM控制器102,还具体用于:In another embodiment of the present invention, the NVM controller 102 is further configured to:
从所述预设样本集中删除与所述目标样本数据块对应的样本数据块;Deleting a sample data block corresponding to the target sample data block from the preset sample set;
判断所述预设样本集中的样本数据块的数量是否小于预设数量; Determining whether the number of sample data blocks in the preset sample set is less than a preset number;
当所述预设样本集中的样本数据块的数量小于所述预设数量时,从所述NVM中的空闲地址空间的数据块中获取新的样本数据块并加入到所述预设样本集中,对所述预设样本集进行更新。When the number of sample data blocks in the preset sample set is less than the preset number, acquiring a new sample data block from the data block of the free address space in the NVM and adding to the preset sample set, Updating the preset sample set.
需要说明的是,图1所示的NVM控制器可以用于上述方法实施例中的方法,关于本发明实施例提供的存储器的具体描述,可以参见上述方法实施例的描述,在此不再赘述。It should be noted that the NVM controller shown in FIG. 1 can be used in the method in the foregoing method embodiment. For a detailed description of the memory provided in the embodiment of the present invention, refer to the description of the foregoing method embodiment, and details are not described herein again. .
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本发明时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, the above devices are described separately by function into various units. Of course, the functions of the various units may be implemented in one or more software and/or hardware in the practice of the invention.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置或系统实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的装置及系统实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。The various embodiments in the specification are described in a progressive manner, and the same or similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for a device or system embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and the relevant portions can be referred to the description of the method embodiment. The apparatus and system embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie It can be located in one place or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without any creative effort.
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this context, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these There is any such actual relationship or order between entities or operations. Furthermore, the term "comprises" or "comprises" or "comprises" or any other variations thereof is intended to encompass a non-exclusive inclusion, such that a process, method, article, or device that comprises a plurality of elements includes not only those elements but also Other elements, or elements that are inherent to such a process, method, item, or device. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
以上所述仅是本发明的具体实施方式,使本领域技术人员能够理解或实现本发明。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。 The above is only the specific embodiments of the present invention, and those skilled in the art can understand or implement the present invention. Various modifications to these embodiments are obvious to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but the scope of the invention is to be accorded

Claims (12)

  1. 一种数据写入方法,用于向非易失性存储介质NVM中写入数据,其特征在于,所述方法包括:A data writing method for writing data to a non-volatile storage medium NVM, the method comprising:
    从待写入数据块中确定所述待写入数据块的样本数据块;Determining, from the data block to be written, the sample data block of the data block to be written;
    将所述待写入数据块的样本数据块分别与预设样本集中的N个样本数据块进行比较,其中,所述N个样本数据块中的每一个样本数据块的大小与所述待写入数据块的样本数据块的大小相同,所述N个样本数据块分别从所述NVM中的N个空闲地址空间的数据块中获得,其中,N为不小于2的整数;Comparing the sample data blocks of the data block to be written with N sample data blocks in a preset sample set, wherein a size of each of the N sample data blocks and the to-be-written The size of the sample data block of the inbound data block is the same, and the N sample data blocks are respectively obtained from the data blocks of the N free address spaces in the NVM, where N is an integer not less than 2;
    在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块;Determining, in the N sample data blocks, one sample data block having the highest matching degree with the sample data block of the to-be-written data block as a target sample data block;
    将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中。Writing the to-be-written data block into a free address space corresponding to the target sample data block.
  2. 根据权利要求1所述的方法,其特征在于,所述将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中,包括:The method according to claim 1, wherein the writing the data block to be written into the free address space corresponding to the target sample data block comprises:
    在所述N个空闲地址空间的数据块中确定与所述目标样本数据块对应的目标数据块;Determining a target data block corresponding to the target sample data block in the data block of the N free address spaces;
    确定所述目标数据块中与所述待写入数据块不同的数据位;Determining, in the target data block, a data bit different from the data block to be written;
    在存储所述目标数据块的地址空间中,根据所述待写入数据块对确定的与所述待写入数据块不同的数据位的数据进行改写。In the address space in which the target data block is stored, the determined data of the data bit different from the to-be-written data block is rewritten according to the to-be-written data block.
  3. 根据权利要求1所述的方法,其特征在于,所述在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块,包括:The method according to claim 1, wherein the determining, in the N sample data blocks, a sample data block having the highest matching degree with a sample data block of the data block to be written as a target sample data block ,include:
    分别计算所述待写入数据块的样本数据块与所述N个样本数据块的相似率,所述相似率为所述待写入数据块的样本数据块中与所述样本集中样本数据块中相同的数据位的数量与所述待写入数据块的样本数据块内所有数据位的数量的比值;Calculating a similarity rate of the sample data block of the to-be-written data block and the N sample data blocks, where the similarity is the sample data block in the data block to be written and the sample data block in the sample set The ratio of the number of identical data bits in the middle to the number of all data bits in the sample data block of the data block to be written;
    将所述N个样本数据块中与所述待写入数据块的样本数据块相似率最高的样本数据块确定为目标样本数据块。 A sample data block having the highest similarity rate of the sample data block of the to-be-written data block among the N sample data blocks is determined as a target sample data block.
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1 further comprising:
    从所述预设样本集中删除与所述目标样本数据块对应的样本数据块;Deleting a sample data block corresponding to the target sample data block from the preset sample set;
    判断所述预设样本集中的样本数据块的数量是否小于预设数量;Determining whether the number of sample data blocks in the preset sample set is less than a preset number;
    当所述预设样本集中的样本数据块的数量小于所述预设数量时,从所述NVM中的空闲地址空间的数据块中获取新的样本数据块并加入到所述预设样本集中,对所述预设样本集进行更新。When the number of sample data blocks in the preset sample set is less than the preset number, acquiring a new sample data block from the data block of the free address space in the NVM and adding to the preset sample set, Updating the preset sample set.
  5. 一种数据写入装置,用于向非易失性存储介质NVM中写入数据,其特征在于,包括:A data writing device for writing data to a non-volatile storage medium NVM, comprising:
    样本数据块确定模块,用于从待写入数据块中确定所述待写入数据块的样本数据块;a sample data block determining module, configured to determine a sample data block of the data block to be written from the data block to be written;
    样本数据块比较模块,用于将所述待写入数据块的样本数据块分别与预设样本集中的N个样本数据块进行比较,其中,所述N个样本数据块中的每一个样本数据块的大小与所述待写入数据块的样本数据块的大小相同,所述N个样本数据块分别从所述NVM中的N个空闲地址空间的数据块中获得,其中,N为不小于2的整数;a sample data block comparison module, configured to compare the sample data block of the data block to be written with N sample data blocks in a preset sample set, wherein each sample data of the N sample data blocks The size of the block is the same as the size of the sample data block of the data block to be written, and the N sample data blocks are respectively obtained from data blocks of N free address spaces in the NVM, where N is not less than An integer of 2;
    目标样本数据块确定模块,用于在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块;a target sample data block determining module, configured to determine, in the N sample data blocks, one sample data block having the highest matching degree with the sample data block of the data block to be written as a target sample data block;
    写入模块,用于将所述待写入数据块写入与所述目标样本数据块对应的空闲地址空间中。And a writing module, configured to write the to-be-written data block into a free address space corresponding to the target sample data block.
  6. 根据权利要求5所述的装置,其特征在于,所述写入模块,包括:The device according to claim 5, wherein the writing module comprises:
    目标数据块确定单元,在所述N个空闲地址空间的数据块中确定与所述目标样本数据块对应的目标数据块;a target data block determining unit that determines a target data block corresponding to the target sample data block in the data block of the N free address spaces;
    数据位确定单元,用于确定所述目标数据块中与所述待写入数据块不同的数据位;a data bit determining unit, configured to determine a data bit in the target data block that is different from the data block to be written;
    数据改写单元,用于在存储所述目标数据块的地址空间中,根据所述待写入数据块对确定的与所述待写入数据块不同的数据位的数据进行改写。And a data rewriting unit, configured to rewrite data of the determined data bit different from the to-be-written data block according to the to-be-written data block in an address space in which the target data block is stored.
  7. 根据权利要求5所述的装置,其特征在于,所述目标样本数据块确定模块,包括:The apparatus according to claim 5, wherein the target sample data block determining module comprises:
    相似率计算单元,分别计算所述待写入数据块的样本数据块与所述N个样本数据块的相似率,所述相似率为所述待写入数据块的样本数据块中与所述样本集样本数据块中 相同的数据位的数量与所述待写入数据块的样本数据块内所有数据位的数量的比值;a similarity rate calculating unit, respectively calculating a similarity rate of the sample data block of the to-be-written data block and the N sample data blocks, the similarity rate being in the sample data block of the to-be-written data block and the Sample set sample data block a ratio of the number of identical data bits to the number of all data bits in the sample data block of the data block to be written;
    确定单元,用于将所述N个样本数据块中与所述待写入数据块的样本数据块相似率最高的样本数据块确定为目标样本数据块。And a determining unit, configured to determine, as the target sample data block, a sample data block with the highest similarity rate of the sample data block of the to-be-written data block among the N sample data blocks.
  8. 根据权利要求5所述的装置,其特征在于,所述装置还包括:The device according to claim 5, wherein the device further comprises:
    样本数据块删除模块,用于从所述预设样本集中删除与所述目标样本数据块对应的样本数据块;a sample data block deleting module, configured to delete a sample data block corresponding to the target sample data block from the preset sample set;
    判断模块,用于判断所述预设样本集中的样本数据块的数量是否小于预设数量;a determining module, configured to determine whether the number of sample data blocks in the preset sample set is less than a preset number;
    更新模块,用于当所述预设样本集中的样本数据块的数量小于所述预设数量时,从所述NVM中的空闲地址空间的数据块中获取新的样本数据块并加入到所述预设样本集中,对所述预设样本集进行更新。And an update module, configured to: when the number of sample data blocks in the preset sample set is less than the preset number, acquire a new sample data block from a data block of a free address space in the NVM and add the The preset sample set is updated by the preset sample set.
  9. 一种存储器,其特征在于,包括:非易失性存储介质NVM和NVM控制器,其中,A memory, comprising: a non-volatile storage medium NVM and an NVM controller, wherein
    所述NVM,用于存储数据;The NVM is configured to store data;
    所述NVM控制器,用于从待写入数据块中确定所述待写入数据块的样本数据块;The NVM controller is configured to determine a sample data block of the to-be-written data block from a to-be-written data block;
    将所述待写入数据块的样本数据块分别与预设样本集中的N个样本数据块进行比较,其中,所述N个样本数据块中的每一个样本数据块的大小与所述待写入数据块的样本数据块的大小相同,所述N个样本数据块分别从所述NVM中的N个空闲地址空间的数据块中获得,其中,N为不小于2的整数;Comparing the sample data blocks of the data block to be written with N sample data blocks in a preset sample set, wherein a size of each of the N sample data blocks and the to-be-written The size of the sample data block of the inbound data block is the same, and the N sample data blocks are respectively obtained from the data blocks of the N free address spaces in the NVM, where N is an integer not less than 2;
    在所述N个样本数据块中确定与所述待写入数据块的样本数据块匹配度最高的一个样本数据块作为目标样本数据块;Determining, in the N sample data blocks, one sample data block having the highest matching degree with the sample data block of the to-be-written data block as a target sample data block;
    将所述待写入数据块写入所述NVM内与所述目标样本数据块对应的空闲地址空间中。Writing the to-be-written data block into the free address space corresponding to the target sample data block in the NVM.
  10. 根据权利要求9所述的存储器,其特征在于,所述NVM控制器具体用于:The memory of claim 9, wherein the NVM controller is specifically configured to:
    在所述N个空闲地址空间的数据块中确定与所述目标样本数据块对应的目标数据块;Determining a target data block corresponding to the target sample data block in the data block of the N free address spaces;
    确定所述目标数据块中与所述待写入数据块的样本数据块不同的数据位;Determining, in the target data block, a data bit different from the sample data block of the data block to be written;
    在存储所述目标数据块的地址空间中,根据所述待写入数据块对确定的与所述待写入数据块的样本数据块不同的数据位的数据进行改写。 In the address space in which the target data block is stored, the determined data of the data bit different from the sample data block of the data block to be written is rewritten according to the to-be-written data block.
  11. 根据权利要求9所述的存储器,其特征在于,所述NVM控制器具体用于:The memory of claim 9, wherein the NVM controller is specifically configured to:
    分别计算所述待写入数据块的样本数据块与所述N个样本数据块的相似率,所述相似率为所述待写入数据块的样本数据块中与所述样本集中样本数据块中相同的数据位的数量与所述待写入数据块的样本数据块内所有数据位的数量的比值;Calculating a similarity rate of the sample data block of the to-be-written data block and the N sample data blocks, where the similarity is the sample data block in the data block to be written and the sample data block in the sample set The ratio of the number of identical data bits in the middle to the number of all data bits in the sample data block of the data block to be written;
    将所述N个样本数据块中与所述待写入数据块的样本数据块相似率最高的样本数据块确定为目标样本数据块。A sample data block having the highest similarity rate of the sample data block of the to-be-written data block among the N sample data blocks is determined as a target sample data block.
  12. 根据权利要求9所述的存储器,其特征在于,所述NVM控制器还用于:The memory of claim 9 wherein said NVM controller is further configured to:
    从所述预设样本集中删除与所述目标样本数据块对应的样本数据块;Deleting a sample data block corresponding to the target sample data block from the preset sample set;
    判断所述预设样本集中的样本数据块的数量是否小于预设数量;Determining whether the number of sample data blocks in the preset sample set is less than a preset number;
    当所述预设样本集中的样本数据块的数量小于所述预设数量时,从所述NVM中的空闲地址空间的数据块中获取新的样本数据块并加入到所述预设样本集中,对所述预设样本集进行更新。 When the number of sample data blocks in the preset sample set is less than the preset number, acquiring a new sample data block from the data block of the free address space in the NVM and adding to the preset sample set, Updating the preset sample set.
PCT/CN2015/089156 2014-09-10 2015-09-08 Data writing method and apparatus and memory WO2016037560A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410459788.2A CN105468533B (en) 2014-09-10 2014-09-10 Method for writing data, device and memory
CN201410459788.2 2014-09-10

Publications (1)

Publication Number Publication Date
WO2016037560A1 true WO2016037560A1 (en) 2016-03-17

Family

ID=55458349

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/089156 WO2016037560A1 (en) 2014-09-10 2015-09-08 Data writing method and apparatus and memory

Country Status (2)

Country Link
CN (1) CN105468533B (en)
WO (1) WO2016037560A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018013837A (en) * 2016-07-19 2018-01-25 株式会社デンソー Data rewriting device and data rewriting program

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050125384A1 (en) * 2003-12-03 2005-06-09 International Business Machines Corporation Transparent content addressable data storage and compression for a file system
CN1633101A (en) * 2003-12-24 2005-06-29 华为技术有限公司 A data packet storage management method and apparatus
US20090112945A1 (en) * 2007-10-25 2009-04-30 Peter Thomas Camble Data processing apparatus and method of processing data
CN102982180A (en) * 2012-12-18 2013-03-20 华为技术有限公司 Method and device for storing data
CN103414759A (en) * 2013-07-22 2013-11-27 华为技术有限公司 Network disc file transmission method and network disc file transmission device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5784320A (en) * 1996-09-27 1998-07-21 Intel Corporation Method and apparatus for reducing power consumption in a memory by employing a conditional write controller
US7562186B2 (en) * 2006-04-11 2009-07-14 Data Domain, Inc. Efficient data storage using resemblance of data segments
CN101329907B (en) * 2008-07-24 2011-09-07 中国科学院上海微系统与信息技术研究所 System and method for reducing programming power consumption of phase-change memory
CN102592665A (en) * 2011-10-24 2012-07-18 北京时代全芯科技有限公司 High-speed data writing structure and writing method for phase change memory
CN103730155B (en) * 2012-10-10 2018-05-29 华为技术有限公司 Method for writing data and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050125384A1 (en) * 2003-12-03 2005-06-09 International Business Machines Corporation Transparent content addressable data storage and compression for a file system
CN1633101A (en) * 2003-12-24 2005-06-29 华为技术有限公司 A data packet storage management method and apparatus
US20090112945A1 (en) * 2007-10-25 2009-04-30 Peter Thomas Camble Data processing apparatus and method of processing data
CN102982180A (en) * 2012-12-18 2013-03-20 华为技术有限公司 Method and device for storing data
CN103414759A (en) * 2013-07-22 2013-11-27 华为技术有限公司 Network disc file transmission method and network disc file transmission device

Also Published As

Publication number Publication date
CN105468533A (en) 2016-04-06
CN105468533B (en) 2019-02-19

Similar Documents

Publication Publication Date Title
EP3002671B1 (en) Method and system for improving flash storage utilization using read-threshold tables
US20110208901A1 (en) Memory Systems and Methods of Operating the Same
US20140095555A1 (en) File management device and method for storage system
US20210216220A1 (en) Storage device and operation method thereof
TW200527433A (en) Memory card and semiconductor device
KR102107723B1 (en) Memory controller and operating method thereof
US10235300B2 (en) Memory system including memory device and operation method thereof
US20130103893A1 (en) System comprising storage device and related methods of operation
US11182285B2 (en) Memory system which stores a plurality of write data grouped into a transaction
US11513723B2 (en) Read handling in zoned namespace devices
US20200089619A1 (en) Data storage device and method of deleting namespace thereof
US20160124639A1 (en) Dynamic storage channel
US10346052B2 (en) Memory system with priority processing and operating method thereof
KR20160024546A (en) Data storage device and operating method thereof
US11662932B2 (en) Tiered storage system with defragmentation based on weighted flash fragmentation factor
CN108073524B (en) Memory management method applicable to data storage device
US11892928B2 (en) Delayed thermal throttling and associated data routing techniques
JP7445368B2 (en) Time to live for memory accesses by processors
KR20190106005A (en) Memory system, operating method thereof and electronic apparatus
WO2016037560A1 (en) Data writing method and apparatus and memory
US11775215B2 (en) Storage device with host-controlled operation mode, electronic system including the same, and method of operating the same
US11182329B2 (en) Data processing system and operating method thereof
US11392310B2 (en) Memory system and controller
US20210208808A1 (en) Host Supported Partitions in Storage Device
US10095417B1 (en) Method and system for improving flash storage read performance in partially programmed blocks

Legal Events

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

Ref document number: 15839876

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15839876

Country of ref document: EP

Kind code of ref document: A1