CN101408864B - Data protection method for power failure and controller using the method - Google Patents
Data protection method for power failure and controller using the method Download PDFInfo
- Publication number
- CN101408864B CN101408864B CN2007101629951A CN200710162995A CN101408864B CN 101408864 B CN101408864 B CN 101408864B CN 2007101629951 A CN2007101629951 A CN 2007101629951A CN 200710162995 A CN200710162995 A CN 200710162995A CN 101408864 B CN101408864 B CN 101408864B
- Authority
- CN
- China
- Prior art keywords
- data
- relationship
- block
- physical
- update information
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 35
- 230000015654 memory Effects 0.000 claims abstract description 99
- 125000004122 cyclic group Chemical group 0.000 claims abstract description 19
- 230000005055 memory storage Effects 0.000 description 23
- 238000010586 diagram Methods 0.000 description 12
- 238000007726 management method Methods 0.000 description 10
- 238000013507 mapping Methods 0.000 description 8
- 230000002159 abnormal effect Effects 0.000 description 7
- 230000005540 biological transmission Effects 0.000 description 7
- 230000001052 transient effect Effects 0.000 description 5
- 238000012937 correction Methods 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 239000007787 solid Substances 0.000 description 3
- 230000003068 static effect Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 239000003550 marker Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008672 reprogramming Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Landscapes
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
本发明提出一种数据保护方法,其适用于非易失性存储器中逻辑区块所对映的多个物理区块,此数据保护方法包括:在每一个物理区块中记录数据更新信息,数据更新信息用以识别物理区块中数据的更新关系;以及依据数据更新信息重新获得物理区块的更新关系,其中数据更新信息由具有循环关系的多个字符所组成,并且所述字符的个数大于这所述物理区块的个数,其中在每一个物理区块中记录数据更新信息是依据更新关系与循环关系来依序地记录的。
The present invention proposes a data protection method, which is applicable to multiple physical blocks mapped by logical blocks in a non-volatile memory. The data protection method includes: recording data update information in each physical block, the data update information is used to identify the update relationship of data in the physical block; and re-obtaining the update relationship of the physical block based on the data update information, wherein the data update information is composed of multiple characters with a cyclic relationship, and the number of the characters is greater than the number of the physical blocks, wherein the data update information is recorded in each physical block in sequence based on the update relationship and the cyclic relationship.
Description
技术领域technical field
本发明涉及一种数据保护方法,且特别是涉及一种用于断电时的数据保护方法及使用此方法的控制器。The invention relates to a data protection method, and in particular to a data protection method used for power failure and a controller using the method.
背景技术Background technique
数字相机、手机相机与MP3在这几年来的成长十分迅速,使得消费者对储存媒体的需求也急速增加,由于闪速存储器(Flash Memory)具有数据非易失性、省电、体积小与无机械结构等的特性,适合便携式应用,最适合使用于这类便携式由电池供电的产品上。除了便携式产品内建存储器需要之外,对于小型存储卡与随身盘等外接式产品来说,每个人可能同时拥有多个随身盘与小型存储卡,所以市场规模比那些设备更大。因此,近年闪速存储器产业成为电子产业中相当热门的一种。The rapid growth of digital cameras, cell phone cameras, and MP3 players over the past few years has led to a rapid increase in consumers' demand for storage media. Because flash memory (Flash Memory) has data non-volatility, power saving, small size and no Features such as mechanical structure are suitable for portable applications, and are most suitable for use in such portable battery-powered products. In addition to the built-in storage needs of portable products, for external products such as small memory cards and flash drives, each person may have multiple flash drives and small memory cards at the same time, so the market size is larger than those devices. Therefore, the flash memory industry has become a very popular type in the electronics industry in recent years.
闪速存储器的管理一般是以区块(block)为单位,倘若在单一逻辑区块对映多个物理区块的情况下并且不正常断电发生在数据进行写入时,则有可能造成数据的不正确或不稳定的现象。也就是说,在重新恢复电力后系统无法辨识原始数据物理区块与新的数据物理区块。Flash memory is generally managed in units of blocks. If a single logical block maps multiple physical blocks and an abnormal power failure occurs when data is being written, it may cause data loss. incorrect or unstable phenomena. That is to say, the system cannot distinguish between the original data physical block and the new data physical block after the power is restored.
为解决上述问题,传统上会在物理区块每一页的冗余区的一个字节中标记相关信息。例如,以3个物理区块对映1个逻辑区块为例,利用闪速存储器每个位可由1变0的特性,在所选定的字节中以分多次写入方式加注不同的标记,例如以FF代表在第一阶段时所记录、将FF改为0F表示在第二阶段时所记录以及将0F改为00表示在第三阶段时所记录。也就是,若此标记为FF时表示是最新的数据、而0F表示次旧的数据并且00表示最旧的数据。To solve the above problems, traditionally, relevant information is marked in one byte of the redundant area of each page of the physical block. For example, taking 3 physical blocks corresponding to 1 logical block as an example, using the feature that each bit of the flash memory can change from 1 to 0, the selected byte is written in multiple times to add different For example, FF means recorded in the first stage, FF is changed to 0F to represent recorded in the second stage, and 0F is changed to 00 to represent recorded in the third stage. That is, if the flag is FF, it means the newest data, while 0F means the second oldest data and 00 means the oldest data.
然而,已知技术存在下述问题。当所使用的存储器为多层存储单元(Multi Level Cell,MLC)与非(NAND)闪速存储器时,由于此类闪速存储器只能写入一次,因此无法使用上述分多次写入的方法来标记。也就是说,在MLC与非闪速存储器的案例中,此标记一经写入后就无法再改变。However, the known technology has the following problems. When the memory used is multi-level memory unit (Multi Level Cell, MLC) and non-(NAND) flash memory, since this type of flash memory can only be written once, it is impossible to use the above method of writing multiple times to mark. That is, in the case of MLC and non-flash memory, once the mark is written, it cannot be changed.
基于此,有必要发展一种数据保护方法,以有效地在断电之后重新区别区块的更新关系。Based on this, it is necessary to develop a data protection method to effectively re-distinguish the update relationship of blocks after a power failure.
发明内容Contents of the invention
本发明提供一种用于非易失性存储器的数据保护方法,有效地在断电之后重新区别新旧数据。The invention provides a data protection method for a non-volatile memory, which can effectively re-distinguish old and new data after power off.
本发明提供一种控制器,其可执行用于非易失性存储器的数据保护方法,其可有效地在断电之后重新区别新旧数据。The present invention provides a controller that can execute a data protection method for a nonvolatile memory, which can effectively re-distinguish old and new data after power off.
本发明提出一种数据保护方法,其适用于非易失性存储器中逻辑区块所对映的多个物理区块,此数据保护方法包括:在每一个物理区块中记录数据更新信息,数据更新信息用以识别物理区块中数据的更新关系;以及依据数据更新信息重新建立物理区块的更新关系,其中数据更新信息是由具有循环关系的多个字符所组成,并且所述字符的个数大于所述物理区块的个数,其中在每一个物理区块中记录数据更新信息是依据更新关系与循环关系来依序地记录。The present invention proposes a data protection method, which is applicable to a plurality of physical blocks corresponding to logical blocks in a non-volatile memory. The data protection method includes: recording data update information in each physical block, data The update information is used to identify the update relationship of the data in the physical block; and re-establish the update relationship of the physical block according to the data update information, wherein the data update information is composed of a plurality of characters with a cyclic relationship, and each of the characters The number is greater than the number of the physical blocks, wherein the data update information recorded in each physical block is recorded sequentially according to the update relationship and the cycle relationship.
在本发明的一实施例中,上述的字符为多个数字或多个文字。In an embodiment of the present invention, the above-mentioned characters are a plurality of numbers or a plurality of characters.
在本发明的一实施例中,上述的重建更新关系包括依据循环关系以来使用的字符的下一个字符来识别包含下一个字符的数据更新信息的物理区块为具有最旧数据的物理区块,并且依据循环关系依序地识别其它物理区块的更新关系。In an embodiment of the present invention, the above-mentioned reconstruction and update relationship includes identifying the physical block containing the data update information of the next character as the physical block with the oldest data according to the next character of the character used since the cyclic relationship, And sequentially identify the update relationship of other physical blocks according to the cycle relationship.
在本发明的一实施例中,上述的重建更新关系包括依据循环关系以未使用的字符的下一个字符来识别包含下一个字符的数据更新信息的物理区块为具有最新数据的物理区块,并且依据循环关系依序地识别其它物理区块的更新关系。In an embodiment of the present invention, the above-mentioned reconstruction and update relationship includes identifying the physical block containing the data update information of the next character as the physical block with the latest data by using the next character of the unused character according to the cyclic relationship, And sequentially identify the update relationship of other physical blocks according to the cycle relationship.
在本发明的一实施例中,上述的在每一个物理区块中记录数据更新信息是将数据更新信息记录在每一个物理区块的冗余区。In an embodiment of the present invention, the aforementioned recording of data update information in each physical block is recording the data update information in a redundant area of each physical block.
在本发明的一实施例中,上述的非易失性存储器为一页只能编程(Program)一次的闪速存储器。In an embodiment of the present invention, the above-mentioned non-volatile memory is a flash memory whose page can only be programmed once.
在本发明的一实施例中,上述的闪速存储器为SLC(Single Level Cell)或MLC(Multi Level Cell)与非(NAND)闪速存储器。In an embodiment of the present invention, the above-mentioned flash memory is SLC (Single Level Cell) or MLC (Multi Level Cell) NAND flash memory.
本发明提供一种数据保护装置,其适用于一非易失性存储器中一逻辑区块所对映的多个物理区块,该数据保护装置包括:A模块,其在每一个所述 物理区块中记录一数据更新信息,该数据更新信息用以识别所述物理区块中数据的更新关系;B模块,其判断所述物理区块之中是否存有无法识别新旧关系的物理区块;以及C模块,其在B模块判断存有无法辨识新旧关系的物理区块时依据所述数据更新信息获得无法辨识新旧关系的物理区块的该更新关系,其中所述数据更新信息由具有一循环关系的多个字符所组成,并且所述字符的个数大于所述物理区块的个数,其中在每一个所述物理区块中记录该数据更新信息的A模块是依据该更新关系与该循环关系来依序地记录。The present invention provides a data protection device, which is suitable for a plurality of physical blocks corresponding to a logical block in a non-volatile memory. The data protection device includes: A module, which is located in each of the physical areas A data update information is recorded in the block, and the data update information is used to identify the update relationship of the data in the physical block; the B module judges whether there is a physical block that cannot identify the old and new relationship among the physical blocks; And the C module, which obtains the update relationship of the physical block whose new-old relationship cannot be identified according to the data update information when the B module judges that there is a physical block whose old-new relationship cannot be identified, wherein the data update information consists of a cycle relationship, and the number of the characters is greater than the number of the physical blocks, wherein the A module that records the data update information in each of the physical blocks is based on the update relationship and the Circular relationship to record sequentially.
本发明提出一种数据保护方法,其可有效地记录一对多区块的数据更新信息并且在不正常断电之后从数据更新信息中获取区块的更新关系,由此避免数据在不正常断电之后遗失。The present invention proposes a data protection method, which can effectively record the data update information of one-to-many blocks and obtain the update relationship of the blocks from the data update information after an abnormal power failure, thereby avoiding Lost after power on.
为使本发明的上述特征和优点能更明显易懂,下文特举较佳实施例,并结合附图详细说明如下。In order to make the above-mentioned features and advantages of the present invention more comprehensible, preferred embodiments are specifically cited below and described in detail with reference to the accompanying drawings.
附图说明Description of drawings
图1A是根据本发明实施例绘示使用非易失性存储器储存装置的主机。FIG. 1A illustrates a host using a non-volatile memory storage device according to an embodiment of the present invention.
图1B示出了图1A所示非易失性存储器储存装置的详细方块图。FIG. 1B shows a detailed block diagram of the non-volatile memory storage device shown in FIG. 1A.
图1C是根据本发明另一实施例绘示控制器的方块图。FIG. 1C is a block diagram illustrating a controller according to another embodiment of the present invention.
图2A与2B是根据本发明实施例绘示非易失性存储器及其运作的详细方块图。2A and 2B are detailed block diagrams illustrating a non-volatile memory and its operation according to an embodiment of the present invention.
图3是根据本发明实施例绘示图1B中页的冗余区R的详细方块图。FIG. 3 is a detailed block diagram illustrating the redundant region R of the page in FIG. 1B according to an embodiment of the present invention.
图4A是根据本发明实施例绘示一个逻辑区块对三个物理区块时数据更 新信息的示意图。4A is a schematic diagram illustrating data update information when one logical block corresponds to three physical blocks according to an embodiment of the present invention.
图4B是根据图4A绘示另一数据更新信息的示意图。FIG. 4B is a schematic diagram illustrating another data update information according to FIG. 4A .
图5是根据本发明第一实施例绘示数据保护方法的流程图。FIG. 5 is a flowchart illustrating a data protection method according to a first embodiment of the present invention.
图6是根据本发明第二实施例绘示数据保护方法的流程图。FIG. 6 is a flowchart illustrating a data protection method according to a second embodiment of the present invention.
图7是绘示本发明实施例的平均磨损方法可应用的装置的示意图。FIG. 7 is a schematic diagram illustrating a device to which the wear leveling method of the embodiment of the present invention is applicable.
附图符号说明Description of reference symbols
100:主机100: Host
102:微处理器102: Microprocessor
104:随机存取存储器104: random access memory
106:输入/输出装置106: Input/Output Device
108:系统总线108: System bus
110:数据传输接口110: data transmission interface
120:非易失性存储器储存装置120: Non-volatile memory storage device
122、122’:控制器122, 122': Controller
122a:存储器管理模块122a: Memory management module
122b:非易失性存储器接口122b: Non-volatile memory interface
122c:主机传输接口122c: host transmission interface
122d:缓冲存储器122d: buffer memory
122e:编程存储器122e: Program memory
122f:错误校正模块122f: Error correction module
122g:电源管理模块122g: power management module
122h:微处理单元122h: Microprocessing unit
124:非易失性存储器124: Non-volatile memory
124-0、124-1、124-2、124-N:区块124-0, 124-1, 124-2, 124-N: blocks
202:系统区202: System area
204:数据区204: data area
206:备用区206: Spare area
208:替换区208: Replacement area
210:瞬时区210: Momentary Zone
M、C、T:区块M, C, T: blocks
302:寻址标记302: Addressing tag
304:更新关系标记304: Update relationship marker
306:区块状态标记306: block status flag
308:其它标记308: Other tags
310:储存系统信息的字节310: bytes for storing system information
320:储存错误校正码(error correcting code)的字节320: Byte to store error correcting code
401:逻辑区块401: logical block
402、403、404:物理区块402, 403, 404: physical blocks
S501、S503、S505、S507、S509:步骤S501, S503, S505, S507, S509: steps
S601、S603、S605、S607、S609:步骤S601, S603, S605, S607, S609: steps
702:USB闪速盘702: USB flash drive
704:数位相机704: Digital camera
704a:SD卡704a: SD card
704b:MMC卡704b: MMC card
704c:CF卡704c: CF card
704d:存储棒704d: memory stick
706:固态硬盘706: SSD
具体实施方式Detailed ways
非易失性存储器储存系统一般而言包括非易失性存储器与控制器(控制芯片)。通常非易失性存储器储存系统会与主机系统一起使用,以使主机系统可将数据写入至非易失性存储器储存系统或从非易失性存储器储存系统中读取数据。另外,亦有非易失性存储器储存系统是包括嵌入式非易失性存储器与可执行于主机系统上以实质地作为此嵌入式闪速存储器的控制器的软件。A non-volatile memory storage system generally includes a non-volatile memory and a controller (control chip). Typically, a non-volatile memory storage system is used with a host system so that the host system can write data to or read data from the non-volatile memory storage system. In addition, there is also a non-volatile memory storage system that includes an embedded non-volatile memory and software executable on a host system that essentially acts as a controller for the embedded flash memory.
图1A是根据本发明实施例绘示使用非易失性存储器储存装置的主机。FIG. 1A illustrates a host using a non-volatile memory storage device according to an embodiment of the present invention.
请参考图1A,主机100一般包括微处理器102、随机存取存储器(randomaccess memory,RAM)104、输入/输出(input/output,I/O)装置106、系统总线108以及数据传输接口110。必须了解的是,主机100可还包括其它组件,例如显示器装置或网络装置等。1A, the
主机100可以是计算机、数字相机、摄影机、通信装置、音频播放器或 视讯播放器等系统。一般而言,主机100可实质地为可储存数据的任意系统。The
在本发明实施例中非易失性存储器储存装置120通过数据传输接口110与主机100的其它组件电连接。通过微处理器102、随机存取存储器104与输入/输出装置106的处理可将数据写入至非易失性存储器储存装置120或从非易失性存储器储存装置120中读取数据。非易失性存储器储存装置120包括随身盘、存储卡或固态硬盘(Solid State Drive,SSD)。In the embodiment of the present invention, the non-volatile
图1B示出了图1A所示非易失性存储器储存装置的详细方块图。FIG. 1B shows a detailed block diagram of the non-volatile memory storage device shown in FIG. 1A.
请参考图1B,非易失性存储器储存装置120一般包括控制器122与非易失性存储器124。Please refer to FIG. 1B , the nonvolatile
控制器122用以控制非易失性存储器储存装置120的整体运作,例如数据的储存、读取与擦除等。控制器122包括存储器管理模块122a、非易失性存储器接口122b、缓冲存储器122d与微处理单元122h。The
存储器管理模块122a用以管理非易失性存储器124,例如执行平均磨损(wear leveling)方法、坏区块管理、维护对映表(mapping table)等。The
非易失性存储器接口122b用以存取非易失性存储器124,也就是主机100要写入至的数据会经由非易失性存储器接口122b转换为非易失性存储器124所能接受的格式。The
缓冲存储器122d用以暂时地储存系统数据(例如对映表)或者主机所读取或写入的数据。在本实施例中,缓冲存储器122d为静态随机存取存储器(static random access memory,SRAM)。然而,必须了解的是,本发明不限于此,动态随机存取存储器(DRAM)、磁阻式存储器(MRAM)、相变化存储器(PRAM)或其它适合的存储器也可应用于本发明。The
微处理单元122h用以控制控制器122的整体运作。The micro-processing unit 122h is used to control the overall operation of the
在本发明另一实施例中,请参考图1C,控制器122’还包括主机传输接口122c、编程存储器122e、错误校正模块122f与电源管理模块122g。In another embodiment of the present invention, please refer to FIG. 1C , the controller 122' further includes a
主机传输接口122c用以与主机100通讯,主机传输接口122c可以是USB接口、IEEE 1394接口、SATA接口、PCI Express接口、MS接口、MMC接口、SD卡接口、CF卡接口或IDE接口。
编程存储器122e用以储存控制器所执行用以控制非易失性存储器储存装置120的编程代码。The
错误校正模块122f用以计算错误校正码(error correcting code)来 检查与校正主机所读取或写入的数据。The
电源管理模块122g用以管理非易失性存储器储存装置120的电源。The
非易失性存储器124用以储存数据。在本实施中非易失性存储器124为闪速存储器,更具体来说,非易失性存储器124为多层存储单元(Multi LevelCell,MLC)与非(NAND)闪速存储器。但必须了解的是,本发明不限于此,例如非易失性存储器124也可为单层存储单元(Single Level Cell,SLC)与非闪速存储器。The
非易失性存储器124通常实质上分割为多个物理区块(physical block)124-0至124-N,为方便说明以下将物理区块简称为区块。一般而言,在闪速存储器中区块为擦除的最小单位。亦即,每一区块含有最小数目的一并被擦除的存储单元。每一区块通常会分割为多个页(page)。页通常为编程(program)的最小单元,但要特别说明的是于有些不同的闪速存储器设计,最小的编程单位也可为一个扇区(sector)大小,即一页中有多个扇区并以一扇区为编程的最小单元。换言之,页为写入数据会读取数据的最小单元。每一页通常包括使用者数据区D与冗余区R。使用者数据区用以储存使用者的数据,而冗余区用以储存系统的数据(例如,上述的ECC code)。The
为对应于磁盘驱动器的扇区(sector)大小,一般而言,使用者数据区D通常为512字节,而冗余区R通常为16字节。也就是,一页为一个扇区。然而,也可以多个扇区形成一页,例如一页包括4个扇区。To correspond to the sector size of a disk drive, generally speaking, the user data area D is usually 512 bytes, and the redundancy area R is usually 16 bytes. That is, one page is one sector. However, a plurality of sectors may form one page, for example, one page includes four sectors.
一般而言,区块可由任意数目的页所组成,例如64页、128页、256页等。区块124-0至124-N通常也可被分组为多个区域(zone),以区域来管理存储器某种程度上是彼此独立地操作以增加操作执行的平行程度且简化管理的复杂度。Generally speaking, a block can be composed of any number of pages, such as 64 pages, 128 pages, 256 pages, and so on. The blocks 124 - 0 to 124 -N can also be generally grouped into multiple zones. The zones are used to manage the memory and operate independently of each other to increase the parallelism of operation execution and simplify the management complexity.
以下将根据本发明并结合附图详细说明非易失性存储器的运作。必须了解的是,在以下描述中使用“提取”、“搬移”、“交换”等词来操作闪速存储器区块是逻辑上的概念。也就是说,闪速存储器区块的实际位置并未更动,而是逻辑上对闪速存储器区块进行操作。The operation of the non-volatile memory will be described in detail below according to the present invention and with reference to the accompanying drawings. It must be understood that the use of words like "extract", "move", "swap" in the following descriptions to manipulate flash memory blocks is a logical concept. That is to say, the actual location of the flash memory block is not changed, but the flash memory block is logically operated.
图2A与2B是根据本发明实施例绘示非易失性存储器124及其运作的详细方块图。2A and 2B are detailed block diagrams illustrating the
请参考图2A,在本发明实施例中,为了有效率地编程(即写入与擦除)非易失性存储器124,非易失性存储器124的区块124-1至124-N会在逻辑 上分组为一系统区202、一数据区204与一备用区206。一般来说,非易失性存储器124中属于数据区204的区块会占90%以上,剩下的才是系统区202与备用区206。Please refer to FIG. 2A. In an embodiment of the present invention, in order to efficiently program (ie, write and erase) the
系统区202中的区块用以记录系统数据,系统数据例如是关于非易失性存储器124的区域数、每一区域的区块数、每一区块的页数、逻辑物理对映表等。The blocks in the
数据区204中的区块用以储存使用者的数据,一般来说就是主机100所操作的逻辑区块地址所对应的区块。The blocks in the
备用区206中的区块是用以替换数据区204中的区块,因此在备用区206中的区块为空或可使用的区块,即无记录数据或标记为已没用的无效数据。具体来说,由于若要对已写过数据位置再次写入数据时,必须先执行擦除的操作。然而,如前所述闪速存储器写入单位为页,而擦除单位为区块。一个擦除的单位大于写入的单位,这表示若要执行区块擦除操作,必须先将要擦除区块中的有效页复制至其它区块后才可进行。因此,当要在数据区204中已写过数据位置的区块M中写入新数据时,一般会在备用区206中提取一区块C,然后将区块M中的有效数据复制至区块C且将新数据写入区块C后,将区块M擦除后搬移至备用区206同时将区块C搬移至数据区204。必须了解的是,将区块M擦除后搬移至备用区206同时将区块C搬移至数据区204是逻辑上将区块M关联于备用区206而将区块C关联于数据区204。其中本领域技术人员皆能了解数据区204中区块的逻辑关系可由逻辑物理对映表来维护。The blocks in the
在本发明实施例中,为了更有效率地使用非易失性存储器124,区块124-1至124-N在逻辑上还分为一替换区208与一瞬时区210。In the embodiment of the present invention, in order to use the
请参考图2B,替换区208是用以暂时存放准备替换数据区204的区块的区块。更详细地说,当上述备用区206的区块C被提取来取代数据区204的区块M时,在本发明实施例中会将新数据写入至区块C,但不会立刻将区块M中的有效数据搬移至区块C而擦除区块M。这是因为,区块M中的有效数据有可能在下个操作中变成无效,因此立刻将区块M中的有效数据搬移至物理区块C会造成无谓的搬移。在本发明实施例中,会将写入新数据的区块C暂时地关联为替换区,并且在逻辑区块地址与物理区块地址的对映上会记录多个物理区块地址对应到一个逻辑区块地址的情况,也就是区块M与区块 C的内容整合起来才是所对映逻辑区块的内容,由此提升区块的使用效率。此等母子区块(区块M与区块C)的关系可依据控制器122中缓冲存储器122d的大小而定,在本发明实施例中是以五组来实作。Please refer to FIG. 2B , the
瞬时区210的功能与替换区208类似。如上所述,在本发明实施例中是使用MLC NAND闪速存储器。此MLC NAND闪速存储器为多层存储单元,其1页中可包括4个扇区,即1页中有4个512 bytes的扇区,共2048 bytes。如上所述,闪速存储器在写入时是以页为单位,因此在使用MLC NAND闪速存储器的情况下每次必须编程4个扇区,因此当写入不满一页的小量数据时会造成资源的浪费。在本发明实施例中,瞬时区210是用以暂时存放此类小量数据。具体来说,如上所述当要写入替换区208的区块C的数据为不满一页的小量数据时,会从备用区206中提取一区块T,然后将此小量数据写入至区块T并且将区块T关联为瞬时区210。之后,当后续写入的数据量足够写入一页时再将所述数据写入至区块C,然后再将区块T擦除且从瞬时区210中搬移至备用区206。The function of the
如上所述,为了避免频繁的擦除区块,会使用区块C与区块T来进行区块M的数据的更新。然而,当非易失性存储器储存装置120运作期间系统处于存有区块M、C与T的瞬时下,倘若发生不正常断电时,则区块M、C与T之间的更新关系将会遗失。具体来说,在非易失性存储器储存装置120运作期间,区块M、C与T的瞬时关系会储存在控制器122的缓冲存储器122d中,当非易失性存储器储存装置120不正常断电时,缓冲存储器122d中的数据将会遗失。因此,在非易失性存储器储存装置120重新恢复电力后,控制器122虽然可从重新建立的逻辑物理对映表中获得区块M、C与T对映同一个逻辑区块的信息,但却无法辨别区块M、C与T的更新关系。As mentioned above, in order to avoid frequently erasing blocks, block C and block T are used to update the data of block M. However, when the system is storing the blocks M, C, and T during the operation of the nonvolatile
为了解决上述的问题,本发明在区块的页的冗余区中标记关于此区块更新关系的信息。图3是根据本发明实施例绘示图1B中页的冗余区R的详细方块图。In order to solve the above problems, the present invention marks the information about the update relationship of the block in the redundant area of the page of the block. FIG. 3 is a detailed block diagram illustrating the redundant region R of the page in FIG. 1B according to an embodiment of the present invention.
如上所述,冗余区R一般为16个字节,其中分为储存系统信息的6个字节310和储存错误校正码(error correcting code)的10个字节320。而储存系统信息的字节310包括寻址标记302、更新关系标记304、区块状态标记306与其它标记308。As mentioned above, the redundant area R is generally 16 bytes, which is divided into 6
寻址标记302包括3个字节,其中2个字节用以标记此区块所属的区域 (zone),1个字节用以标记此区块对映的逻辑区块。The
更新关系标记304包括1个字节,其用以在存有区块M、C与T的瞬时关系的状态下标记此区块数据的数据更新信息,而此数据更新信息可表示区块的更新关系(即新旧关系)。The
根据本发明,当系统中存有区块M、C与T的瞬时关系时,存储器管理模块122a会在更新关系标记304中记录数据更新信息。数据更新信息是由具有一循环关系的多个字符所组成,并且所述字符的个数是大于组成此瞬时关系的区块的个数,也就是说,倘若组成此瞬时关系的区块有n个时,则表示数据更新信息的字符必须至少有n+1个。此外,在每一个物理区块中记录数据更新信息是依据区块的更新关系与字符的循环关系来依序地记录。According to the present invention, when the instantaneous relationship between the blocks M, C and T exists in the system, the
图4A是根据本发明实施例绘示一个逻辑区块对三个物理区块时数据更新信息的示意图。FIG. 4A is a schematic diagram illustrating data update information when one logical block corresponds to three physical blocks according to an embodiment of the present invention.
请参考图4A,逻辑区块401对映物理区块402、403与404。其中物理区块402存有最旧的数据,物理区块403存有次旧的数据,并且物理区块404存有最新的数据。Please refer to FIG. 4A , the
在图4A中是以循环数字0-3作为表示数据更新信息的字符。假设物理区块402的更新关系标记为0时,当有较新的物理区块产生时物理区块403的更新关系会被标记为1且当再有更新的物理区块404产生时,物理区块404的更新关系会被标记为2。在非易失性存储器储存装置120不正常断电之后控制器122可依据数据更新信息识别未使用的字符为3,而0-3的循环中字符3的下一个字符为0,因此具有最旧数据的区块为物理区块402,并且依此循环识别物理区块403存有次旧的数据,并且识别物理区块404存有最新的数据。In FIG. 4A, cyclic numbers 0-3 are used as characters representing data update information. Assuming that the update relation of the
图4B是根据图4A绘示另一数据更新信息的示意图。FIG. 4B is a schematic diagram illustrating another data update information according to FIG. 4A .
请参考图4B,同样是以循环数字0-3作为表示数据更新信息的字符。假设物理区块402的更新关系标记为2时,当有较新的物理区块产生时物理区块403的更新关系会被标记为3且当再有更新的物理区块404产生时,物理区块404的更新关系会被标记为0。在非易失性存储器储存装置120不正常断电之后控制器122可依据数据更新信息识别未使用的字符为1,而0-3的循环中字符1的下一个字符为2,因此具有最旧数据的区块为物理区块402,并且依此循环识别物理区块403存有次旧的数据,并且识别物理区块 404存有最新的数据。Please refer to FIG. 4B , which also uses cyclic numbers 0-3 as characters representing data update information. Assuming that the update relation of the
本实施例是以数字作为数据更新信息,然而,本发明不限于此,其它符号也可应用于本发明,例如使用具循环关系的文字(例如A、B、C、D…)。In this embodiment, numbers are used as data to update information. However, the present invention is not limited thereto, and other symbols can also be applied to the present invention, such as using letters with a circular relationship (such as A, B, C, D . . . ).
在本实施例中是以数据更新信息中未使用字符的下一个字符作为标示具最旧数据的区块,然而,在本发另一实施例中是将数据更新信息中未使用字符的下一个字符作为标示具最新数据的区块。In this embodiment, the next character of the unused character in the data update information is used as the block with the oldest data. However, in another embodiment of the present invention, the next character of the unused character in the data update information is character as a block with the latest data.
请在参考图3,区块状态标记306包括1个字节,其用以标记此区块是否为正常区块或损坏区块。Please refer to FIG. 3 , the
其它标记308包括1个字节,其用以标记其它系统信息。
本实施例是以16个字节的冗余区及其字节配置来解释本发明。但必需了解的是,本发明不限于此,其它字节数目的冗余区或其它字节配置方式也可适用于本发明。This embodiment explains the present invention by using a 16-byte redundant area and its byte configuration. However, it must be understood that the present invention is not limited thereto, and redundant regions with other numbers of bytes or other byte configurations are also applicable to the present invention.
图5是根据本发明第一实施例绘示数据保护方法的流程图,其是由控制器122的存储器管理模块122a来执行,以在不正常断电之后重新获取上述瞬时区块M、C与T之间的关系。FIG. 5 is a flow chart illustrating a data protection method according to the first embodiment of the present invention, which is executed by the
请参考图5,数据保护方法分为两个部分,在图5的(a)中步骤S501会在发生一对多(即1个逻辑区块对映多个物理区块)的每一个物理区块中记录一数据更新信息。数据更新信息的组成与方式已详细描述如前,在此不再赘述。Please refer to Figure 5. The data protection method is divided into two parts. In Figure 5 (a), step S501 will generate one-to-many (that is, one logical block corresponds to multiple physical blocks) in each physical area A data update information is recorded in the block. The composition and manner of the data update information have been described in detail above, and will not be repeated here.
在图5的(b)中,当发生不正常断电后,会判断逻辑物理对映表中是否存有无法识别新旧关系的多个物理区块(步骤S503)。倘若在步骤S503中判断具有无法辨识的物理区块时,则在步骤S505中从所述物理区块的页的冗余区中读取更新关系标记。之后,在步骤S507中依据从更新关系标记中所读取数据更新信息的字符来判断具有最旧(或最新)数据的区块。判断最旧(或最新)数据的区块的方式以结合图4A与图4B描述如前,在此不再赘述。之后,在步骤S509中依数据更新信息的循环关系识别其它无法辨识的物理区块的更新关系。In (b) of FIG. 5 , when an abnormal power failure occurs, it is judged whether there are multiple physical blocks whose relationship between old and new cannot be identified in the logical-physical mapping table (step S503 ). If it is determined in step S503 that there is an unidentifiable physical block, then in step S505 the update relation flag is read from the redundant area of the page of the physical block. Afterwards, in step S507, the block with the oldest (or newest) data is determined according to the character of the data update information read from the update relation tag. The manner of determining the block with the oldest (or newest) data is described above in conjunction with FIG. 4A and FIG. 4B , and will not be repeated here. Afterwards, in step S509 , the update relationship of other unidentifiable physical blocks is identified according to the cycle relationship of the data update information.
图6是根据本发明第二实施例绘示数据保护方法的流程图。执行第二实施例的数据保护方法的控制器硬件结构是相同于第一实施例,在此不再重复说明。FIG. 6 is a flowchart illustrating a data protection method according to a second embodiment of the present invention. The hardware structure of the controller implementing the data protection method of the second embodiment is the same as that of the first embodiment, and will not be repeated here.
请参考图6,数据保护方法也是分为两个部分,在图6的(a)中步骤S601 会在物理区块写入数据同时对发生一对多(即1个逻辑区块对映多个物理区块)的每一个物理区块中记录一数据更新信息。数据更新信息的组成与方式已详细描述如前,在此不再赘述。Please refer to Figure 6. The data protection method is also divided into two parts. In Figure 6 (a), step S601 will write data in the physical block and generate one-to-many at the same time (that is, one logical block corresponds to multiple A piece of data update information is recorded in each physical block. The composition and manner of the data update information have been described in detail above, and will not be repeated here.
在本发明另一实施例中,物理区块中的数据更新信息只可以写入一次。也就是说,在一页只能编程(Program)一次的闪速存储器的案例中,数据只可以写入一次,当必须再编程时必须先擦除后才能再编程。In another embodiment of the present invention, the data update information in the physical block can only be written once. That is to say, in the case of a flash memory that can only be programmed once, the data can only be written once, and when it must be reprogrammed, it must be erased before reprogramming.
在图6的(b)中,当发生不正常断电后,会判断逻辑物理对映表中是否存有无法识别新旧关系的多个物理区块(步骤S603)。倘若在步骤S603中判断具有无法辨识的物理区块时,则在步骤S605中从所述物理区块的页的冗余区中读取更新关系标记。之后,在步骤S607中依据从更新关系标记中所读取数据更新信息的多个循环字符来判断具有最旧(或最新)数据的区块,例如,循环字符的个数介于3-5。判断最旧(或最新)数据的区块的方式已配合图4A与图4B描述如前,在此不再赘述。之后,在步骤S609中依数据更新信息的循环字符识别其它无法辨识的物理区块的更新关系。In (b) of FIG. 6 , when an abnormal power failure occurs, it is determined whether there are multiple physical blocks whose relationship between the old and the new cannot be identified in the logical-physical mapping table (step S603 ). If it is determined in step S603 that there is an unidentifiable physical block, then in step S605 the update relation flag is read from the redundant area of the page of the physical block. Afterwards, in step S607, the block with the oldest (or newest) data is determined according to the number of cyclic characters of the data update information read from the update relation tag, for example, the number of cyclic characters is between 3-5. The manner of determining the block with the oldest (or newest) data has been described above with reference to FIG. 4A and FIG. 4B , and will not be repeated here. Afterwards, in step S609, the update relationship of other unidentifiable physical blocks is identified according to the cycle character of the data update information.
在根据本发明所提出的数据保护方法是适用于非易失性存储器,因此本发明所提出的数据保护方法可应用各种以非易失性存储器作为储存媒体的装置。例如图7所示的USB闪速盘702、数字相机(摄影机)704所使用的SD卡704a、MMC卡704b、CF卡704c与存储棒(memory stick)704d以及固态硬盘706等。The data protection method proposed by the present invention is suitable for non-volatile memory, so the data protection method proposed by the present invention can be applied to various devices using non-volatile memory as storage media. For example, the
综上所述,本发明所提出用于非易失性存储器的数据保护方法可有效地在不正常断电后获取一对多区块的更新关系。由此,避免不正常断电后数据的遗失。To sum up, the data protection method for non-volatile memory proposed by the present invention can effectively obtain the update relationship of one-to-many blocks after abnormal power failure. Thus, data loss after an abnormal power failure is avoided.
虽然本发明已以较佳实施例披露如上,然其并非用以限定本发明,本领域技术人员,在不脱离本发明的精神和范围的前提下,当可作若干的更改与修饰,因此本发明的保护范围应以本发明的权利要求为准。Although the present invention has been disclosed above with preferred embodiments, it is not intended to limit the present invention. Those skilled in the art can make some changes and modifications without departing from the spirit and scope of the present invention. The scope of protection of the invention should be based on the claims of the present invention.
Claims (14)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN2007101629951A CN101408864B (en) | 2007-10-09 | 2007-10-09 | Data protection method for power failure and controller using the method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN2007101629951A CN101408864B (en) | 2007-10-09 | 2007-10-09 | Data protection method for power failure and controller using the method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN101408864A CN101408864A (en) | 2009-04-15 |
| CN101408864B true CN101408864B (en) | 2011-08-24 |
Family
ID=40571884
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN2007101629951A Active CN101408864B (en) | 2007-10-09 | 2007-10-09 | Data protection method for power failure and controller using the method |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN101408864B (en) |
Families Citing this family (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102110121B (en) * | 2009-12-24 | 2015-09-23 | 阿里巴巴集团控股有限公司 | A kind of data processing method and system thereof |
| CN102375779B (en) * | 2010-08-16 | 2015-08-19 | 深圳市朗科科技股份有限公司 | A kind of data processing method and data processing module |
| CN103678162B (en) * | 2012-09-12 | 2020-02-28 | 群联电子股份有限公司 | System data storage method, memory controller and memory storage device |
| TWI520153B (en) * | 2013-11-05 | 2016-02-01 | 威盛電子股份有限公司 | Non-volatile memory device and operation method thereof |
| CN105630404A (en) * | 2015-04-02 | 2016-06-01 | 上海磁宇信息科技有限公司 | Solid-state drive using MRAM and read-write method |
| CN105630704A (en) * | 2015-06-10 | 2016-06-01 | 上海磁宇信息科技有限公司 | Storage device and read-write method applying block-based logic physical address comparison table |
| CN105608016B (en) * | 2015-08-05 | 2018-11-23 | 上海磁宇信息科技有限公司 | Solid state hard disk of the DRAM in conjunction with MRAM and the storage card using MRAM |
| CN107092563B (en) * | 2017-04-20 | 2021-02-26 | 新华三信息技术有限公司 | Method and device for recycling garbage |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1290014A (en) * | 1999-09-29 | 2001-04-04 | 三星电子株式会社 | Flash memory and control method |
| CN1567256A (en) * | 2003-06-20 | 2005-01-19 | 深圳市朗科科技有限公司 | Protection method for data in flash memory media |
-
2007
- 2007-10-09 CN CN2007101629951A patent/CN101408864B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1290014A (en) * | 1999-09-29 | 2001-04-04 | 三星电子株式会社 | Flash memory and control method |
| CN1567256A (en) * | 2003-06-20 | 2005-01-19 | 深圳市朗科科技有限公司 | Protection method for data in flash memory media |
Also Published As
| Publication number | Publication date |
|---|---|
| CN101408864A (en) | 2009-04-15 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8037232B2 (en) | Data protection method for power failure and controller using the same | |
| US8775771B2 (en) | Block management method for a flash memory and flash memory controller and storage system using the same | |
| US9037782B2 (en) | Method of programming memory cells and reading data, memory controller and memory storage apparatus 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 | |
| US10037153B2 (en) | Memory device, electronic system, and methods associated with modifying data and a file of a memory device | |
| US8055873B2 (en) | Data writing method for flash memory, and controller and system using the same | |
| US8516184B2 (en) | Data updating using mark count threshold in non-volatile memory | |
| CN101408864B (en) | Data protection method for power failure and controller using the method | |
| CN104750625A (en) | Data storage device and flash memory control method | |
| CN102157202B (en) | Method and Controller for Preventing Read Disturbance from Non-Volatile Memory | |
| US9268688B2 (en) | Data management method, memory controller and memory storage apparatus | |
| CN106557432B (en) | Buffer memory management method, memory control circuit unit and storage device | |
| TW201712549A (en) | Buffer memory management method, memory control circuit unit and memory storage device | |
| CN101419834B (en) | Wear Averaging Method and Controller Using It | |
| CN101414282B (en) | Wear Averaging Method and Controller Using It | |
| US8607123B2 (en) | Control circuit capable of identifying error data in flash memory and storage system and method thereof | |
| US9383929B2 (en) | Data storing method and memory controller and memory storage device using the same | |
| CN101425338B (en) | Writing method of non-volatile memory and controller using this method | |
| CN102890655A (en) | Memory storage device, its memory controller and effective data identification method | |
| TW201303584A (en) | Memory storage device, memory controller thereof, and method for identifying valid data | |
| CN102567221B (en) | Data management method, memory controller and memory storage device | |
| CN101409108B (en) | Wear Averaging Method and Controller Using It | |
| JP2012068765A (en) | Memory controller, flash memory system with memory controller, and control method of flash memory | |
| CN102779551B (en) | Data writing method, memory controller and memory storage device | |
| JP4000124B2 (en) | MEMORY CONTROLLER, FLASH MEMORY SYSTEM PROVIDED WITH MEMORY CONTROLLER, AND FLASH MEMORY CONTROL METHOD |
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 |
