CN101794257B - Data updating method and device for data storage type flash memory - Google Patents

Data updating method and device for data storage type flash memory Download PDF

Info

Publication number
CN101794257B
CN101794257B CN200910189254A CN200910189254A CN101794257B CN 101794257 B CN101794257 B CN 101794257B CN 200910189254 A CN200910189254 A CN 200910189254A CN 200910189254 A CN200910189254 A CN 200910189254A CN 101794257 B CN101794257 B CN 101794257B
Authority
CN
China
Prior art keywords
data
block
cache block
update data
cache
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN200910189254A
Other languages
Chinese (zh)
Other versions
CN101794257A (en
Inventor
李发生
罗胜
张彦伟
成晓华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SHENZHEN SILICONGO SEMICONDUCTOR CO Ltd
Original Assignee
SHENZHEN SILICONGO MICROELECTRONICS CO Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SHENZHEN SILICONGO MICROELECTRONICS CO Ltd filed Critical SHENZHEN SILICONGO MICROELECTRONICS CO Ltd
Priority to CN200910189254A priority Critical patent/CN101794257B/en
Publication of CN101794257A publication Critical patent/CN101794257A/en
Application granted granted Critical
Publication of CN101794257B publication Critical patent/CN101794257B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Memory System Of A Hierarchy Structure (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to NAND Flash, and discloses a data updating method and device of a data storage type Flash memory and a storage device. The data updating method of the data storage type flash memory comprises the following steps: receiving update data; if the address to be written in the updating data is continuous with the storage address of the previous writing operation, writing the updating data next to the storage address; otherwise, judging whether the length of the updated data is larger than a preset value; if the length of the updated data is larger than the preset value, copying the lower half part and the upper half part of data in the block executed by the previous write operation to a new block into which the updated data needs to be written, and writing the updated data into the new block; and otherwise, writing the updated data into a cache block for temporarily storing data in the data storage type flash memory, wherein the cache block corresponds to at least one logic block, and the page included in the cache block corresponds to the page included in the logic block. The number of times of writing and erasing operations to the NAND Flash can be reduced.

Description

资料储存型闪存的数据更新方法及装置Data updating method and device for data storage type flash memory

技术领域 technical field

本发明涉及资料储存型闪存(NAND Flash),特别涉及一种资料储存型闪存的数据更新方法及装置。  The present invention relates to a data storage type flash memory (NAND Flash), in particular to a data updating method and device for a data storage type flash memory. the

背景技术Background technique

随着U盘、数码相机、mp3音乐播放器等移动设备的广泛应用,闪存(FLASH)存储器已经逐步取代其它半导体存储元件,成为嵌入式系统中主要数据和程序的载体。NAND FLASH是一种可在线多次擦除的非易失性存储器,其结构提供了极高的单元密度,可以达到数据的高密度存储,并且写入和擦除的速度也很快,所以NAND FLASH是高密度数据存储的理想解决方案。  With the widespread application of mobile devices such as U disks, digital cameras, and mp3 music players, flash memory (FLASH) memory has gradually replaced other semiconductor storage components and has become the carrier of main data and programs in embedded systems. NAND FLASH is a non-volatile memory that can be erased multiple times online. Its structure provides extremely high cell density, which can achieve high-density storage of data, and the speed of writing and erasing is also very fast, so NAND FLASH is an ideal solution for high-density data storage. the

和磁盘类似,NAND Flash读写数据的基本粒度为页(page)。此外,Flash不允许数据的直接覆盖写,必须首先擦除旧有数据才能写入新的,而擦除的粒度为块(block),通常一个块包含有64个页。NAND Flash的写入机制不像其它的FLASH器件,NAND Flash要求在写入数据时,首先必须进行数据的擦除。因此我们在写数据的时候,先把将要被写入的数据块的内容读出到块缓存,然后再把要写入NAND Flash的数据以页为单位的形式写入块缓存(Block Buffer)中的对应地址。接着把以前存放数据的块进行擦除操作,最后把更新的数据写到NAND Flash去。经过这一系列的操作,实现了NAND Flash数据的逻辑写入。NAND Flash还有一种有操作,叫做copyback,当某个页的数据需要被复制到新的位置时,只需将其读取到块缓存中,然后根据接收到的目标地址将该页的数据写入到NAND Flash上新的位置。而一般情况下NAND数据的写入地址并不连续(通常情况下NAND Flash的数据结构包括文件分配表(FAT,File Allocation Table)、文件目录表(FDT,File Directory Table)以及数据(DATA)区,三种数据结构分别存储FAT、FDT以及DATA数据,图1示出了现有的NAND Flash写操作的具体流程:  Similar to disks, the basic granularity of reading and writing data in NAND Flash is pages. In addition, Flash does not allow direct overwriting of data. Old data must be erased before new data can be written. The granularity of erasing is block, and a block usually contains 64 pages. The writing mechanism of NAND Flash is not like other FLASH devices. NAND Flash requires that when writing data, the data must be erased first. Therefore, when we write data, we first read the content of the data block to be written into the block buffer, and then write the data to be written into the NAND Flash into the block buffer (Block Buffer) in the form of pages. corresponding address. Then erase the block that previously stored the data, and finally write the updated data to the NAND Flash. After this series of operations, the logical writing of NAND Flash data is realized. NAND Flash also has an operation called copyback. When the data of a certain page needs to be copied to a new location, it only needs to be read into the block cache, and then write the data of the page according to the received target address. Enter the new location on the NAND Flash. In general, the write address of NAND data is not continuous (usually, the data structure of NAND Flash includes file allocation table (FAT, File Allocation Table), file directory table (FDT, File Directory Table) and data (DATA) area , three data structures respectively store FAT, FDT and DATA data, Figure 1 shows the specific flow of the existing NAND Flash write operation:

步骤S10,将旧块BOLCKA的上部分数据复制(copy)到新块BLOCKA’中;  Step S10, copy (copy) the upper part of the data of the old block BOLCKA to the new block BLOCKA';

步骤S11,将从外部接收的对旧块BLOCKA的更新数据写入到新块BLOCKA’中;  Step S11, write the update data received from outside to the old block BLOCKA into the new block BLOCKA';

步骤S12,保存当前存储位置;  Step S12, saving the current storage location;

步骤S13,如果下次接收的数据的存储地址与当前保存地址连续,接着保存位置进行存储;如果数据地址不连续,将旧块BOLCKA的下部分数据copy到新块BLOCKA’中;后重复执行步骤S10-S13。  Step S13, if the storage address of the data received next time is continuous with the current storage address, then store at the storage location; if the data address is not continuous, copy the lower part of the data of the old block BOLCKA to the new block BLOCKA'; then repeat the steps S10-S13. the

由上述的流程可知,现有技术中由于NAND Flash接收数据的写地址随时发生变化,使每次从USB接口接收到数据需对NAND Flash进行更新时,写操作都需要先经历从旧块到新块的copy操作之后,才能向新块写入更新后的数据,增加了对NAND Flash进行写与擦除的操作的次数,减少了NAND Flash的使用寿命。  It can be seen from the above process that in the prior art, since the write address of the NAND Flash receiving data changes at any time, each time the data is received from the USB interface and the NAND Flash needs to be updated, the write operation needs to go through the process from the old block to the new block first. After the copy operation of the block, the updated data can be written to the new block, which increases the number of write and erase operations on NAND Flash and reduces the service life of NAND Flash. the

发明内容Contents of the invention

本发明的目的为提供一种资料储存型闪存的数据更新方法及装置、存储设备,可以减少对NAND Flash进行写与擦除的操作的次数。  The purpose of the present invention is to provide a data update method and device and storage device for data storage type flash memory, which can reduce the number of operations for writing and erasing NAND Flash. the

本发明提供一种资料储存型闪存的数据更新方法,包括步骤:  The present invention provides a method for updating data of a data storage type flash memory, comprising steps:

接收更新数据;  receive update data;

判断所述更新数据需写入的地址是否与前一次写操作的存储地址连续;  Judging whether the address to be written to the update data is continuous with the storage address of the previous write operation;

如果所述更新数据需写入的地址与前一次写操作的存储地址连续,紧接所述存储地址写入所述更新数据;  If the address to be written to the update data is continuous with the storage address of the previous write operation, write the update data immediately after the storage address;

如果所述更新数据需写入的地址与前一次写操作的存储地址不连续,判断所述更新数据的长度是否大于预设值;如果所述更新数据的长度大于所述预设值,将前一次写操作所执行块中的下半部分以及上半部分数据复制到所述更新数据需写入的新块中,将所述更新数据写入所述新块;如果所述更新数据的长度小于或等于所述预设值,将所述更新数据写入资料储存型闪存中用于暂存数据的缓存块,所述缓存块与至少一个逻辑块对应,所述缓存块所包括的页与所述逻辑块所包括的页对应。  If the address to be written to the update data is discontinuous with the storage address of the previous write operation, determine whether the length of the update data is greater than a preset value; if the length of the update data is greater than the preset value, write the previous Copy the lower half and upper half of the data in the block executed by one write operation to the new block where the update data needs to be written, and write the update data into the new block; if the length of the update data is less than Or equal to the preset value, write the update data into a cache block for temporarily storing data in the data storage type flash memory, the cache block corresponds to at least one logical block, and the pages included in the cache block correspond to the corresponding to the pages included in the logical block. the

优选的,所述将所述更新数据写入资料储存型闪存中用于暂存数据的缓存块具体包括步骤:  Preferably, writing the update data into a cache block for temporarily storing data in the data storage type flash memory specifically includes the steps of:

为所述更新数据需写入的新块分配缓存块;  Allocate a cache block for the new block to be written to the update data;

将所述更新数据写入所述缓存块。  Writing the updated data into the cache block. the

优选的,为所述更新数据需写入的新块分配缓存块前进一步包括:  Preferably, before allocating the cache block for the new block to be written to the update data further includes:

判断是否有与所述新块对应的缓存块;  Determine whether there is a cache block corresponding to the new block;

如果没有与所述新块对应的缓存块,执行所述为所述更新数据需写入的新块分配缓存块的步骤;  If there is no cache block corresponding to the new block, perform the step of allocating a cache block for the new block to be written to the update data;

如果有与所述新块对应的缓存块,将所述更新数据写入所述与所述新块对应的缓存块。  If there is a cache block corresponding to the new block, write the update data into the cache block corresponding to the new block. the

优选的,如果有与所述新块对应的缓存块,将所述更新数据写入所述与所述新块对应的缓存块前进一步包括:  Preferably, if there is a cache block corresponding to the new block, writing the update data to the cache block corresponding to the new block further includes:

判断所述与所述新块对应的缓存块是否有足够的空间;  Judging whether the cache block corresponding to the new block has enough space;

如果有足够的空间,执行所述将所述更新数据写入所述与所述新块对应的缓存块的步骤;  If there is enough space, perform the step of writing the update data into the cache block corresponding to the new block;

如果没有足够的空间,选择一个缓存块进行回收,回收后为所述新块分配新缓存块,将所述更新数据写入所述新缓存块。  If there is not enough space, select a cache block to reclaim, allocate a new cache block for the new block after recycling, and write the updated data into the new cache block. the

优选的,所述为所述更新数据需写入的新块分配缓存块具体包括步骤:  Preferably, the allocation of cache blocks for the new blocks to be written to the update data specifically includes the steps:

判断是否有未使用的缓存块;  Determine whether there are unused cache blocks;

如果有未使用的缓存块,将所述更新数据写入所述未使用的缓存块;  If there is an unused cache block, write the update data into the unused cache block;

如果没有未使用的缓存块,选择一个缓存块进行回收,回收后为所述新块分配新缓存块,将所述更新数据写入所述新缓存块。  If there is no unused cache block, select a cache block to reclaim, allocate a new cache block for the new block after recycling, and write the updated data into the new cache block. the

优选的,所述选择一个缓存块进行回收具体包括步骤:  Preferably, the selection of a cache block to reclaim specifically includes the steps:

判断是否有长时间未使用的缓存块;  Determine whether there are cache blocks that have not been used for a long time;

如果有长时间未使用的缓存块,对所述长时间未使用的缓存块进行回收。  If there is a cache block that has not been used for a long time, reclaim the cache block that has not been used for a long time. the

优选的,如果没有长时间未使用的缓存块,该方法还包括:  Preferably, if there is no cache block that has not been used for a long time, the method also includes:

获取各个缓存块的使用情况;  Obtain the usage of each cache block;

根据所述各个缓存块的使用情况选择一个缓存块并回收。  A cache block is selected and reclaimed according to the usage of each cache block. the

优选的,所述缓存块的使用情况包括:  Preferably, the usage of the cache block includes:

缓存块的使用页数、对应关系、对应块数。  The number of used pages of the cache block, the corresponding relationship, and the number of corresponding blocks. the

本发明提供一种资料储存型闪存的数据更新装置,包括:  The present invention provides a data update device for data storage flash memory, including:

接收单元,用于接收更新数据;  A receiving unit for receiving update data;

判断单元,用于判断所述接收单元接收的更新数据需写入的地址是否与前一次写操作的存储地址连续;如果所述更新数据需写入的地址与前一次写操作的存储地址不连续,判断所述更新数据的长度是否大于预设值;  A judging unit, configured to judge whether the address to be written to the update data received by the receiving unit is continuous with the storage address of the previous write operation; if the address to be written to the update data is not continuous to the storage address of the previous write operation , judging whether the length of the update data is greater than a preset value;

写单元,用于在所述判断单元判断更新数据需写入的地址与前一次写操作的存储地址连续时,紧接所述存储地址写入所述更新数据;在所述判断单元判断更新数据的长度大于所述预设值时,将前一次写操作所执行块中的下半部分以及上半部分数据复制到所述更新数据需写入的新块中,将所述更新数据写入所述新块;在所述判断单元判断所述更新数据的长度小于或等于所述预设值,将所述更新数据写入资料储存型闪存中用于暂存数据的缓存块,所述缓存块与至少一个逻辑块对应,所述缓存块所包括的页与所述逻辑块所包括的页对应。  A write unit, configured to write the update data next to the storage address when the judgment unit judges that the address to be written into the update data is continuous with the storage address of the previous write operation; when the judgment unit judges that the update data When the length is greater than the preset value, the lower half and upper half of the data in the block executed by the previous write operation are copied to the new block where the update data needs to be written, and the update data is written into the new block. Described new block; Judging in the judgment unit that the length of the update data is less than or equal to the preset value, the update data is written into the cache block used for temporarily storing data in the data storage type flash memory, and the cache block Corresponding to at least one logical block, the pages included in the cache block correspond to the pages included in the logical block. the

优选的,所述写单元包括:  Preferably, the writing unit includes:

分配单元,用于为所述更新数据需写入的新块分配缓存块;  An allocation unit, configured to allocate a cache block for the new block to be written to the update data;

写操作单元,用于将所述更新数据写入所述分配单元分配的缓存块。  A write operation unit, configured to write the update data into the cache block allocated by the allocation unit. the

优选的,所述分配单元包括:  Preferably, the distribution unit includes:

缓存块回收单元,用于在没有未使用的缓存块和与所述更新数据所需写入的新块对应的缓存块没有足够的空间时,选择一个缓存块进行回收;  A cache block recycling unit, used to select a cache block to reclaim when there is no unused cache block and the cache block corresponding to the new block to be written to the update data does not have enough space;

缓存块分配单元,用于在所述缓存块回收单元选择一个缓存块进行回收后为所述新块分配新缓存块。  The cache block allocating unit is configured to allocate a new cache block for the new block after the cache block reclaiming unit selects a cache block to reclaim. the

本发明提供一种存储设备,包括资料储存型闪存和本发明提供的资料储存型闪存的数据更新装置。  The present invention provides a storage device, including a data storage flash memory and a data updating device for the data storage flash memory provided by the present invention. the

本发明所述浏览器历史记录的整理方法、装置以及浏览器,在更新数据小于预设值时,可以将更新数据写入NAND Flash中用于暂存数据的Cache块,从而在更新数据小于预设值时,可以减少对NAND Flash进行写与擦除的操作的次数,提高NAND Flash的使用寿命。  The finishing method, device and browser of the browser historical records of the present invention, when the update data is less than the preset value, the update data can be written into the Cache block used for temporarily storing data in the NAND Flash, thereby when the update data is less than the preset value When setting a value, it can reduce the number of times of writing and erasing operations on NAND Flash, and improve the service life of NAND Flash. the

附图说明Description of drawings

图1是现有技术中NAND Flash的数据更新方法流程示意图;  Fig. 1 is the schematic flow chart of the data updating method of NAND Flash in the prior art;

图2是本发明NAND Flash的数据更新方法的流程示意图;  Fig. 2 is the schematic flow sheet of the data updating method of NAND Flash of the present invention;

图3是本发明Cache块与Logic块关系示意图;  Fig. 3 is a schematic diagram of the relationship between a Cache block and a Logic block of the present invention;

图4是本发明NAND Flash的数据更新装置实施例一的结构示意图;  Fig. 4 is the structural representation of the data updating device embodiment one of NAND Flash of the present invention;

图5是本发明NAND Flash的数据更新装置实施例二的结构示意图;  Fig. 5 is the structural representation of the data updating device embodiment two of NAND Flash of the present invention;

图6是本发明NAND Flash的数据更新装置实施例三的结构示意图。  Fig. 6 is a schematic structural diagram of Embodiment 3 of a data updating device for NAND Flash of the present invention. the

本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。  The realization of the purpose of the present invention, functional characteristics and advantages will be further described in conjunction with the embodiments and with reference to the accompanying drawings. the

具体实施方式Detailed ways

本发明提供了NAND Flash的数据更新方法及装置、存储设备,可以减少对NAND Flash进行写与擦除的操作的次数,从而提高NAND Flash的使用寿命。  The invention provides a data updating method, device and storage device of NAND Flash, which can reduce the number of times of writing and erasing operations on NAND Flash, thereby improving the service life of NAND Flash. the

先介绍本发明提供的NAND Flash的数据更新方法,图2描述了NANDFlash的数据更新方法实施例一的流程,包括:  First introduce the data updating method of NAND Flash that the present invention provides, Fig. 2 has described the flow process of the data updating method embodiment one of NAND Flash, comprise:

步骤s21、接收更新数据;  Step s21, receiving update data;

可以通过通用串行总线(USB:Universal Serial Bus)接口或其他接口接收更新数据;  Update data can be received through the Universal Serial Bus (USB: Universal Serial Bus) interface or other interfaces;

步骤s22、判断更新数据需写入的地址是否与前一次写操作的存储地址连 续;如果更新数据需写入的地址与前一次写操作的存储地址连续,进入步骤s23;如果更新数据需写入的地址与前一次写操作的存储地址不连续,进入步骤s24;  Step s22, judging whether the address to be written to update data is continuous with the storage address of the previous write operation; if the address to be written to update data is continuous to the storage address of the previous write operation, enter step s23; if the update data needs to be written The input address is not continuous with the storage address of the previous write operation, enter step s24;

步骤s23、紧接存储地址写入更新数据;  Step s23, writing update data immediately after the storage address;

紧接存储地址写入更新数据后,保存写入更新数据后的存储地址,等待下一次更新数据;  Immediately after the storage address writes the update data, save the storage address after the update data is written, and wait for the next update data;

步骤s24、判断更新数据的长度是否大于预设值;如果更新数据的长度大于预设值,进入s25;如果更新数据的长度小于或等于预设值,进入s26;  Step s24, judging whether the length of the updated data is greater than the preset value; if the length of the updated data is greater than the preset value, proceed to s25; if the length of the updated data is less than or equal to the preset value, proceed to s26;

预设值可以根据不同的nand flash的规格进行设置,例如可以设置为0x10。  The preset value can be set according to different nand flash specifications, for example, it can be set to 0x10. the

步骤s25、将前一次写操作所执行块中的下半部分以及上半部分数据复制到更新数据需写入的新块中,将更新数据写入新块;  Step s25, copy the lower half and upper half of the data in the block executed by the previous write operation to the new block where the updated data needs to be written, and write the updated data into the new block;

步骤s26、将更新数据写入NAND Flash中用于暂存数据的缓存(Cache)块。  Step s26, write the update data into the cache (Cache) block for temporarily storing data in the NAND Flash. the

在本发明的一个实施例中,步骤s26具体可以包括:为更新数据需写入的新块分配Cache块;将更新数据写入Cache块。  In an embodiment of the present invention, step s26 may specifically include: allocating a Cache block for the new block to be written into the update data; and writing the update data into the Cache block. the

将更新数据写入Cache块后,恢复保存位置的存储地址,,等待下一次更新数据;  After writing the updated data into the Cache block, restore the storage address of the saved location, and wait for the next updated data;

其中,在为更新数据需写入的新块分配Cache块前可以进一步包括:判断是否有与新块对应的Cache块;如果没有与新块对应的Cache块,才执行为更新数据需写入的新块分配Cache块的步骤;如果有与新块对应的Cache块,且与新块对应的Cache块有足够的空间,才将更新数据写入与新块对应的Cache块,否则需要选择一个Cache块进行回收,回收后为新块分配新Cache块,然后将更新数据写入新Cache块。  Wherein, before allocating the Cache block for the new block that needs to be written into the update data, it can further include: judging whether there is a Cache block corresponding to the new block; if there is no Cache block corresponding to the new block, then executing The steps of allocating Cache blocks for new blocks; if there is a Cache block corresponding to the new block, and the Cache block corresponding to the new block has enough space, then the updated data is written into the Cache block corresponding to the new block, otherwise a Cache block needs to be selected The block is recycled, and a new Cache block is allocated for the new block after recycling, and then the updated data is written into the new Cache block. the

其中,为更新数据需写入的新块分配Cache块具体包括步骤:判断是否有未使用的Cache块;如果有未使用的Cache块,将则更新数据写入未使用的Cache块;如果没有未使用的Cache块,选择一个Cache块进行回收,回收后为新块分配新Cache块,将更新数据写入新Cache块。  Wherein, assigning the Cache block for the new block that needs to be written into the update data specifically includes the steps of: judging whether there is an unused Cache block; if there is an unused Cache block, writing the update data into the unused Cache block; For the used Cache block, select a Cache block for recycling, allocate a new Cache block for the new block after recycling, and write the updated data into the new Cache block. the

从上可知,本实施例在更新数据小于预设值时,可以将更新数据写入NAND Flash中用于暂存数据的Cache块,从而在更新数据小于预设值时,可以减少对NAND Flash进行写与擦除的操作的次数,提高NAND Flash的使用寿命。  As can be seen from the above, in this embodiment, when the update data is less than the preset value, the update data can be written into the Cache block for temporarily storing data in the NAND Flash, so that when the update data is less than the preset value, the NAND Flash can be reduced. The number of write and erase operations improves the service life of NAND Flash. the

其中,本发明实施例中Cache块与至少一个逻辑块对应,Cache块所包括的页与逻辑块所包括的页对应,本发明提供的一种缓存块与逻辑(Logic)块的对应关系如图3所示:  Wherein, in the embodiment of the present invention, the Cache block corresponds to at least one logical block, and the pages included in the Cache block correspond to the pages included in the logical block. The corresponding relationship between a cache block and a logic (Logic) block provided by the present invention is shown in the figure 3 shows:

Cache块与Logic块A和Logic块B对应,Logic块A包括A块页1和A块页30, Logic块B包括B块页1、B块页2和B块页3;Logic块A和Logic块B所包括的页与Cache块所包括的页对应。本来写的数据应该写在Logic块A和Logic块B当中,但是引入Cache块管理后写小数据实际写入Cache块中,本来写的数据应该写在LogicB块中,实际写在Cache块中。  Cache block corresponds to Logic block A and Logic block B, Logic block A includes A block page 1 and A block page 30, Logic block B includes B block page 1, B block page 2 and B block page 3; Logic block A and Logic The pages included in block B correspond to the pages included in the Cache block. Originally written data should be written in Logic Block A and Logic Block B, but after the introduction of Cache block management, the written small data is actually written into the Cache block, and the originally written data should be written in the LogicB block, but actually written in the Cache block. the

为了对Cache进行管理,需要限制一个Cache块最大能记录Logic块,在Cache块与Logic块的对应关系不够时,需要回收Logic块A。回收的过程如下,Logic块A与Cache块中属于Logic块A的内容合并到一个新Logic块A1,回收后,Cache块中对Logic块A中页的对应关系是无效的,所以可以不管理Cache块中对应Logic块A的部分,因为在逻辑上Logic块A的页已经回收到了Logic块A1中,即在Cache块物理不回收,形成逻辑上回收而物理上不回收,Cache块中未使用的页可以接着分配给其它的Logic块继续使用;只有当用完了个整个Cache块的所有页时,需要对Cache块中对应的所有Logic块进行回收后,才做物理上的擦除回收Cache块所包括的页。从而减少Logic块需要回收的操作的次数。  In order to manage the Cache, it is necessary to limit the maximum number of Logic blocks that can be recorded in a Cache block. When the corresponding relationship between the Cache block and the Logic block is not enough, the Logic block A needs to be reclaimed. The recycling process is as follows. Logic block A and the content belonging to Logic block A in the Cache block are merged into a new Logic block A1. After recycling, the corresponding relationship between the Cache block and the pages in Logic block A is invalid, so it is not necessary to manage the Cache The part of the block corresponding to Logic block A, because logically the page of Logic block A has been reclaimed into Logic block A1, that is, the cache block is not physically reclaimed, resulting in logical recycle but not physical recycle, and the unused pages in the Cache block Pages can then be allocated to other Logic blocks for continued use; only when all the pages of an entire Cache block are used up, all corresponding Logic blocks in the Cache block need to be reclaimed before physically erasing and reclaiming the Cache blocks. pages included. Thereby reducing the number of operations that Logic blocks need to recycle. the

本发明实施例中,可以采用如下准则选择一个缓存块进行回收:优先选择长时间未使用的缓存块,其中多长时间可以回收可以根据需要进行设置。在没有长时间未使用的缓存块时,则获取各个Cache块的使用情况后,根据所述各个Cache块的使用情况选择一个Cache块并回收,具体可以获取各个缓存块的使用页数、对应关系、对应块数等信息。  In the embodiment of the present invention, the following criteria can be used to select a cache block for recycling: preferentially select a cache block that has not been used for a long time, and how long it can be recycled can be set as required. When there is no cache block that has not been used for a long time, after obtaining the usage of each cache block, select a cache block according to the usage of each cache block and recycle it. Specifically, the number of pages used and the corresponding relationship of each cache block can be obtained , the corresponding block number and other information. the

再介绍本发明实施例提供的NAND Flash的数据更新装置,图4描述了NAND Flash的数据更新装置实施例一的结构,包括:  Introduce the data updating device of the NAND Flash that the embodiment of the present invention provides again, Fig. 4 has described the structure of the data updating device embodiment one of NAND Flash, comprise:

接收单元401,用于接收更新数据;  A receiving unit 401, configured to receive update data;

判断单元402,用于判断接收单元401接收的更新数据需写入的地址是否与前一次写操作的存储地址连续;如果更新数据需写入的地址与前一次写操作的存储地址不连续,判断更新数据的长度是否大于预设值;  The judging unit 402 is used to judge whether the address to be written in the update data received by the receiving unit 401 is continuous with the storage address of the previous write operation; if the address to be written in the update data is not continuous with the storage address of the previous write operation, judge Whether the length of the update data is greater than the preset value;

写单元403,用于在判断单元402判断更新数据需写入的地址与前一次写操作的存储地址连续时,紧接存储地址写入更新数据;在判断单元402判断更新数据的长度大于预设值时,将前一次写操作所执行块中的下半部分以及上半部分数据复制到更新数据需写入的新块中,将更新数据写入新块;在判断单元402判断更新数据的长度小于或等于预设值时,将更新数据写入NANDFlash中用于暂存数据的Cache块,Cache块与至少一个逻辑块对应,Cache块所包括的页与逻辑块所包括的页对应。  The writing unit 403 is used to write the update data next to the storage address when the judging unit 402 judges that the address to be written in the update data is continuous with the storage address of the previous write operation; when the judgment unit 402 judges that the length of the update data is greater than the preset value, copy the lower half and upper half data in the block performed by the previous write operation to the new block where the update data needs to be written, and write the update data into the new block; judge the length of the update data at the judging unit 402 When being less than or equal to the preset value, the update data is written into the Cache block for temporarily storing data in NANDFlash, the Cache block corresponds to at least one logic block, and the pages included in the Cache block correspond to the pages included in the logic block. the

从上可知,本实施例在更新数据小于预设值时,可以将更新数据写入NAND Flash中用于暂存数据的Cache块,从而在更新数据小于预设值时,可以减少对NAND Flash进行写与擦除的操作的次数,提高NAND Flash的使用寿 命。  As can be seen from the above, in this embodiment, when the update data is less than the preset value, the update data can be written into the Cache block for temporarily storing data in the NAND Flash, so that when the update data is less than the preset value, the NAND Flash can be reduced. The number of write and erase operations increases the service life of NAND Flash. the

图5描述了本发明数据更新装置实施例二的结构,与数据更新装置实施例一的不同之处在于写单元403包括:分配单元4031,用于为更新数据需写入的新块分配Cache块;写操作单元4032,用于将更新数据写入分配单元4031分配的Cache块。  Fig. 5 has described the structure of the second embodiment of the data updating device of the present invention, and the difference from the first embodiment of the data updating device is that the writing unit 403 includes: an allocation unit 4031, which is used to allocate a Cache block for a new block to be written to update data ; The write operation unit 4032 is used to write the update data into the Cache block allocated by the allocation unit 4031 . the

图6描述了本发明数据更新装置实施例三的结构,与数据更新装置实施例二的不同之处在于分配单元4031包括:Cache块回收单元40311,用于在没有未使用的Cache块和与更新数据所需写入的新块对应的Cache块没有足够的空间时,选择一个Cache块进行回收;Cache块分配单元40312,用于在Cache块回收单元40311选择一个Cache块进行回收后为新块分配新Cache块。  Fig. 6 has described the structure of the third embodiment of the data updating device of the present invention, and the difference from the second embodiment of the data updating device is that the allocation unit 4031 includes: a Cache block reclaiming unit 40311, which is used for updating when there are no unused Cache blocks and When the Cache block corresponding to the new block that data needs to be written does not have enough space, select a Cache block to reclaim; the Cache block allocation unit 40312 is used to allocate a new block after the Cache block recovery unit 40311 selects a Cache block to reclaim New cache block. the

本发明还提供了存储装置,该存储装置包括NAND Flash和本发明提供的NAND Flash的数据更新装置。  The present invention also provides a storage device, which includes a NAND Flash and a data update device for the NAND Flash provided by the present invention. the

以上所述仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。  The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in other related All technical fields are equally included in the scope of patent protection of the present invention. the

Claims (10)

1.一种资料储存型闪存的数据更新方法,其特征在于,包括步骤:1. A data update method for data storage type flash memory, characterized in that, comprising the steps: 接收更新数据;receive updated data; 判断所述更新数据需写入的地址是否与前一次写操作的存储地址连续;Judging whether the address to be written to the update data is continuous with the storage address of the previous write operation; 如果所述更新数据需写入的地址与前一次写操作的存储地址连续,紧接所述存储地址写入所述更新数据;If the address to be written to the update data is continuous with the storage address of the previous write operation, write the update data immediately after the storage address; 如果所述更新数据需写入的地址与前一次写操作的存储地址不连续,判断所述更新数据的长度是否大于预设值;如果所述更新数据的长度大于所述预设值,将前一次写操作所执行块中的下半部分以及上半部分数据复制到所述更新数据需写入的新块中,将所述更新数据写入所述新块;如果所述更新数据的长度小于或等于所述预设值,将所述更新数据写入资料储存型闪存中用于暂存数据的缓存块,所述缓存块与至少一个逻辑块对应,所述缓存块所包括的页与所述逻辑块所包括的页对应。If the address to be written to the update data is discontinuous with the storage address of the previous write operation, determine whether the length of the update data is greater than a preset value; if the length of the update data is greater than the preset value, write the previous Copy the lower half and upper half of the data in the block executed by one write operation to the new block where the update data needs to be written, and write the update data into the new block; if the length of the update data is less than Or equal to the preset value, write the update data into a cache block for temporarily storing data in the data storage type flash memory, the cache block corresponds to at least one logical block, and the pages included in the cache block correspond to the corresponding to the pages included in the logical block. 2.如权利要求1所述的资料储存型闪存的数据更新方法,其特征在于,所述将所述更新数据写入资料储存型闪存中用于暂存数据的缓存块具体包括步骤:2. The data updating method of the data storage type flash memory as claimed in claim 1, wherein said writing said update data into the cache block for temporarily storing data in the data storage type flash memory specifically comprises the steps of: 为所述更新数据需写入的新块分配缓存块;Allocating a cache block for the new block to be written to the update data; 将所述更新数据写入所述缓存块。Writing the updated data into the cache block. 3.如权利要求2所述的资料储存型闪存的数据更新方法,其特征在于,为所述更新数据需写入的新块分配缓存块前进一步包括:3. The data update method of data storage type flash memory as claimed in claim 2, characterized in that, before allocating a cache block for the new block to be written into the update data, further comprising: 判断是否有与所述新块对应的缓存块;judging whether there is a cache block corresponding to the new block; 如果没有与所述新块对应的缓存块,执行所述为所述更新数据需写入的新块分配缓存块的步骤;If there is no cache block corresponding to the new block, perform the step of allocating a cache block for the new block to be written to the update data; 如果有与所述新块对应的缓存块,将所述更新数据写入所述与所述新块对应的缓存块。If there is a cache block corresponding to the new block, write the update data into the cache block corresponding to the new block. 4.如权利要求3所述的资料储存型闪存的数据更新方法,其特征在于,如果有与所述新块对应的缓存块,将所述更新数据写入所述与所述新块对应的缓存块前进一步包括:4. The data updating method of the data storage type flash memory as claimed in claim 3, wherein if there is a cache block corresponding to the new block, writing the update data into the cache block corresponding to the new block Before the cache block further includes: 判断所述与所述新块对应的缓存块是否有足够的空间;judging whether the cache block corresponding to the new block has enough space; 如果有足够的空间,执行所述将所述更新数据写入所述与所述新块对应的缓存块的步骤;If there is enough space, perform the step of writing the update data into the cache block corresponding to the new block; 如果没有足够的空间,选择一个缓存块进行回收,回收后为所述新块分配新缓存块,将所述更新数据写入所述新缓存块。If there is not enough space, select a cache block to reclaim, allocate a new cache block for the new block after recycling, and write the updated data into the new cache block. 5.如权利要求2所述的资料储存型闪存的数据更新方法,其特征在于,所述为所述更新数据需写入的新块分配缓存块具体包括步骤:5. The data updating method of the data storage type flash memory as claimed in claim 2, wherein said allocating a cache block for a new block to be written into said update data specifically comprises the steps of: 判断是否有未使用的缓存块;Determine whether there are unused cache blocks; 如果有未使用的缓存块,将所述更新数据写入所述未使用的缓存块;If there is an unused cache block, writing the update data into the unused cache block; 如果没有未使用的缓存块,选择一个缓存块进行回收,回收后为所述新块分配新缓存块,将所述更新数据写入所述新缓存块。If there is no unused cache block, select a cache block to reclaim, allocate a new cache block for the new block after recycling, and write the updated data into the new cache block. 6.如权利要求4或5所述的资料储存型闪存的数据更新方法,其特征在于,所述选择一个缓存块进行回收具体包括步骤:6. The data updating method of data storage type flash memory as claimed in claim 4 or 5, wherein said selecting a cache block to reclaim specifically comprises the steps of: 判断是否有长时间未使用的缓存块;Determine whether there are cache blocks that have not been used for a long time; 如果有长时间未使用的缓存块,对所述长时间未使用的缓存块进行回收。If there is a cache block that has not been used for a long time, reclaim the cache block that has not been used for a long time. 7.如权利要求6所述的资料储存型闪存的数据更新方法,其特征在于,如果没有长时间未使用的缓存块,该方法还包括:7. The data updating method of data storage type flash memory as claimed in claim 6, is characterized in that, if there is no cache block that has not been used for a long time, the method also includes: 获取各个缓存块的使用情况;Obtain the usage of each cache block; 根据所述各个缓存块的使用情况选择一个缓存块并回收。A cache block is selected and reclaimed according to the usage of each cache block. 8.如权利要求7所述的资料储存型闪存的数据更新方法,其特征在于,所述缓存块的使用情况包括:8. The data updating method of the data storage type flash memory as claimed in claim 7, wherein the usage of the cache block includes: 缓存块的使用页数、对应关系、对应块数。The number of used pages of the cache block, the corresponding relationship, and the number of corresponding blocks. 9.一种资料储存型闪存的数据更新装置,其特征在于,包括:9. A data update device for data storage flash memory, characterized in that it comprises: 接收单元,用于接收更新数据;a receiving unit, configured to receive update data; 判断单元,用于判断所述接收单元接收的更新数据需写入的地址是否与前一次写操作的存储地址连续;如果所述更新数据需写入的地址与前一次写操作的存储地址不连续,判断所述更新数据的长度是否大于预设值;A judging unit, configured to judge whether the address to be written to the update data received by the receiving unit is continuous with the storage address of the previous write operation; if the address to be written to the update data is not continuous to the storage address of the previous write operation , judging whether the length of the update data is greater than a preset value; 写单元,用于在所述判断单元判断更新数据需写入的地址与前一次写操作的存储地址连续时,紧接所述存储地址写入所述更新数据;在所述判断单元判断更新数据的长度大于所述预设值时,将前一次写操作所执行块中的下半部分以及上半部分数据复制到所述更新数据需写入的新块中,将所述更新数据写入所述新块;在所述判断单元判断所述更新数据的长度小于或等于所述预设值,将所述更新数据写入资料储存型闪存中用于暂存数据的缓存块,所述缓存块与至少一个逻辑块对应,所述缓存块所包括的页与所述逻辑块所包括的页对应。A write unit, configured to write the update data next to the storage address when the judgment unit judges that the address to be written into the update data is continuous with the storage address of the previous write operation; when the judgment unit judges that the update data When the length is greater than the preset value, the lower half and upper half of the data in the block executed by the previous write operation are copied to the new block where the update data needs to be written, and the update data is written into the new block. Described new block; Judging in the judgment unit that the length of the update data is less than or equal to the preset value, the update data is written into the cache block used for temporarily storing data in the data storage type flash memory, and the cache block Corresponding to at least one logical block, the pages included in the cache block correspond to the pages included in the logical block. 10.如权利要求9所述的资料储存型闪存的数据更新装置,其特征在于,所述写单元包括:10. The data updating device of the data storage type flash memory as claimed in claim 9, wherein the writing unit comprises: 分配单元,用于为所述更新数据需写入的新块分配缓存块;An allocation unit, configured to allocate a cache block for a new block to be written into the update data; 写操作单元,用于将所述更新数据写入所述分配单元分配的缓存块。A write operation unit, configured to write the update data into the cache block allocated by the allocation unit.
CN200910189254A 2009-12-22 2009-12-22 Data updating method and device for data storage type flash memory Active CN101794257B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910189254A CN101794257B (en) 2009-12-22 2009-12-22 Data updating method and device for data storage type flash memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910189254A CN101794257B (en) 2009-12-22 2009-12-22 Data updating method and device for data storage type flash memory

Publications (2)

Publication Number Publication Date
CN101794257A CN101794257A (en) 2010-08-04
CN101794257B true CN101794257B (en) 2012-10-03

Family

ID=42586966

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910189254A Active CN101794257B (en) 2009-12-22 2009-12-22 Data updating method and device for data storage type flash memory

Country Status (1)

Country Link
CN (1) CN101794257B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105373338A (en) * 2014-08-20 2016-03-02 深圳市中兴微电子技术有限公司 Control method and controller for FLASH
CN112559384B (en) * 2020-12-17 2022-04-15 南昌航空大学 Dynamic partitioning method for hybrid solid-state disk based on nonvolatile memory
CN113703686B (en) * 2021-08-31 2024-12-17 潍柴动力股份有限公司 Data storage method, device and system
CN121092080A (en) * 2025-09-12 2025-12-09 杭州芯势力半导体有限公司 Data writing method, memory controller and memory device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1536481A (en) * 2003-04-09 2004-10-13 英业达股份有限公司 Device and method for updating content of flash memory
CN101382918A (en) * 2008-07-26 2009-03-11 深圳市硅格半导体有限公司 NAND Flash memory optimization management method based on data exchange area
CN101446924A (en) * 2008-12-16 2009-06-03 成都市华为赛门铁克科技有限公司 Method and system for storing and obtaining data

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1536481A (en) * 2003-04-09 2004-10-13 英业达股份有限公司 Device and method for updating content of flash memory
CN101382918A (en) * 2008-07-26 2009-03-11 深圳市硅格半导体有限公司 NAND Flash memory optimization management method based on data exchange area
CN101446924A (en) * 2008-12-16 2009-06-03 成都市华为赛门铁克科技有限公司 Method and system for storing and obtaining data

Also Published As

Publication number Publication date
CN101794257A (en) 2010-08-04

Similar Documents

Publication Publication Date Title
TWI399644B (en) Block management method for a non-volatile memory
TWI389125B (en) Memory storage device and control method thereof
US8364931B2 (en) Memory system and mapping methods using a random write page mapping table
CN103425588B (en) Block management method of data storage device and flash memory
US9582416B2 (en) Data erasing method, memory control circuit unit and memory storage apparatus
US8055873B2 (en) Data writing method for flash memory, and controller and system using the same
US20180260317A1 (en) Method for managing the copying and storing of data in garbage collection, memory storage device and memory control circuit unit using the same
US9311232B2 (en) Management of memory array with magnetic random access memory (MRAM)
CN101382918B (en) NAND Flash memory optimization management method based on data exchange area
KR101465789B1 (en) Write and merge methods in memory card systems for reducing the number of page copies
US20100011154A1 (en) Data accessing method for flash memory and storage system and controller using the same
KR101403922B1 (en) Apparatus and method for data storing according to an access degree
TW201917581A (en) Method for managing flash memory module and associated flash memory controller
CN110309077B (en) Method and device for constructing flash translation layer of cooperative work of host and equipment
CN106326132B (en) Storage system, storage management device, memory, hybrid storage device, and storage management method
CN101630233B (en) Data access method, storage system and controller for flash memory
CN106815152A (en) A kind of method for optimizing page level flash translation layer (FTL)
US20100318726A1 (en) Memory system and memory system managing method
CN116540950B (en) Memory device and control method for writing data thereof
CN100501868C (en) Method for realizing memory file system based on NAND Flash
US8850160B2 (en) Adaptive write behavior for a system having non-volatile memory
CN101739348B (en) Memory system and control method thereof
CN101794257A (en) Data updating method and device of data storage type flash memory and storage equipment
CN113377282B (en) Data storage device and data processing method
CN101996137A (en) Memory device and data processing method thereof

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C56 Change in the name or address of the patentee
CP01 Change in the name or title of a patent holder

Address after: The southern city of Shenzhen province Guangdong 518057 Keyuan Road, Nanshan District high tech Zone students Pioneering Building No. 2208

Patentee after: SILICONGO MICROELECTRONICS CO., LTD.

Address before: The southern city of Shenzhen province Guangdong 518057 Keyuan Road, Nanshan District high tech Zone students Pioneering Building No. 2208

Patentee before: Shenzhen SiliconGo Semiconductor Co., Ltd.

CP03 Change of name, title or address

Address after: 518057 05-2, 06-08 unit, 6 floor, Changhong science and technology building, 18 Nanshan District science and technology south twelve Road, Shenzhen, Guangdong.

Patentee after: Shenzhen SiliconGo Semiconductor Co., Ltd.

Address before: 518057 international business building 2208, South Yuan Road, Nanshan District high tech Zone, Shenzhen, Guangdong.

Patentee before: SILICONGO MICROELECTRONICS CO., LTD.

CP03 Change of name, title or address