CN102637145B - Method for block management, memory device and controller thereof - Google Patents
Method for block management, memory device and controller thereof Download PDFInfo
- Publication number
- CN102637145B CN102637145B CN201110036240.3A CN201110036240A CN102637145B CN 102637145 B CN102637145 B CN 102637145B CN 201110036240 A CN201110036240 A CN 201110036240A CN 102637145 B CN102637145 B CN 102637145B
- Authority
- CN
- China
- Prior art keywords
- block
- loss
- threshold value
- controller
- blocks
- 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 49
- 230000008859 change Effects 0.000 claims description 7
- 238000007726 management method Methods 0.000 description 15
- 238000005516 engineering process Methods 0.000 description 5
- 230000007246 mechanism Effects 0.000 description 4
- 239000007787 solid Substances 0.000 description 4
- 238000010586 diagram Methods 0.000 description 2
- 230000006399 behavior Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000003139 buffering effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000004321 preservation Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
Landscapes
- Techniques For Improving Reliability Of Storages (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
技术领域 technical field
本发明有关于闪存(Flash Memory)的存取(Access),更具体地说,涉及一种用来进行区块管理的方法以及相关的记忆装置及其控制器。The present invention relates to the access (Access) of flash memory (Flash Memory), and more specifically, relates to a method for block management, a related memory device and its controller.
背景技术 Background technique
近年来由于闪存的技术不断地发展,各种可携式记忆装置(例如:符合SD/MMC、CF、MS、XD标准的记忆卡)或具备闪存的固态硬盘(Solid State Drive,SSD)被广泛地实施在诸多应用中。因此,这些记忆装置中的闪存的访问控制遂成为相当热门的议题。In recent years, due to the continuous development of flash memory technology, various portable memory devices (such as memory cards conforming to SD/MMC, CF, MS, XD standards) or solid state drives (Solid State Drive, SSD) with flash memory are widely used. implemented in many applications. Therefore, the access control of the flash memory in these memory devices has become a very hot topic.
以常用的NAND型闪存而言,其主要可区分为单阶细胞(Single LevelCell,SLC)与多阶细胞(Multiple Level Cell,MLC)两大类的闪存。单阶细胞闪存中的每个被当作记忆单元的晶体管只有两种电荷值,分别用来表示逻辑值0与逻辑值1。另外,多阶细胞闪存中的每个被当作记忆单元的晶体管的储存能力则被充分利用,采用较高的电压来驱动,以透过不同级别的电压在一个晶体管中记录两组(或以上)位信息(00、01、11、10);理论上,多阶细胞闪存的记录密度可以达到单阶细胞闪存的记录密度的两倍,这对于曾经在发展过程中遇到瓶颈的NAND型闪存的相关产业而言,是非常好的消息。As far as the commonly used NAND flash memory is concerned, it can be mainly divided into two types of flash memory: single-level cell (Single Level Cell, SLC) and multi-level cell (Multiple Level Cell, MLC). Each transistor in the single-level cell flash memory, which is regarded as a memory unit, has only two charge values, which are used to represent logic value 0 and logic value 1 respectively. In addition, the storage capacity of each transistor used as a memory unit in the multi-level cell flash memory is fully utilized, and it is driven by a higher voltage to record two groups (or more than one) in one transistor through different levels of voltage. ) bit information (00, 01, 11, 10); theoretically, the recording density of multi-level cell flash memory can reach twice the recording density of single-level cell flash memory, which is for NAND flash memory that has encountered bottlenecks in the development process It is very good news for related industries.
相较于单阶细胞闪存,由于多阶细胞闪存的价格较便宜,并且在有限的空间里可提供较大的容量,故多阶细胞闪存很快地成为市面上的可携式记忆装置竞相采用的主流。然而,多阶细胞闪存的不稳定性所导致的问题也一一浮现。为了确保记忆装置对闪存的访问控制能符合相关规范,闪存的控制器通常备有某些管理机制以妥善地管理数据的存取。Compared with single-level cell flash memory, because multi-level cell flash memory is cheaper and can provide a larger capacity in a limited space, multi-level cell flash memory has quickly become a popular choice for portable memory devices on the market. mainstream. However, problems caused by the instability of multi-level cell flash memory have also emerged one by one. In order to ensure that the access control of the memory device to the flash memory complies with relevant specifications, the controller of the flash memory usually has some management mechanisms to properly manage data access.
依据相关技术,有了这些管理机制的记忆装置还是有不足之处。举例来说,相关技术的管理机制无法保证在闪存中进行损耗整平(Wear Leveling)运作时能达到最佳的处理效能。因此,需要一种新颖的方法来进行区块管理,以在进行抹除运作时能适应性地选择用来保存有效数据(Valid Data)的区块。According to related technologies, memory devices with these management mechanisms still have deficiencies. For example, the management mechanism of the related technology cannot guarantee the best processing performance when performing wear leveling (Wear Leveling) operation in the flash memory. Therefore, a novel method for block management is needed to adaptively select a block for saving valid data (Valid Data) during the erasing operation.
发明内容 Contents of the invention
本发明要解决的技术问题在于,针对现有技术的管理机制无法保证在闪存中进行损耗整平运作时能达到最佳的处理效能的缺陷,提供一种用来进行区块管理的方法以及相关的记忆装置及其控制器,以解决上述问题。The technical problem to be solved by the present invention is to provide a block management method and related methods for the defect that the management mechanism of the prior art cannot guarantee the best processing performance when performing loss leveling operations in the flash memory. memory device and its controller to solve the above problems.
本发明的另一目的在于提供一种用来进行区块管理的方法以及相关的记忆装置及其控制器,以在进行损耗整平(Wear Leveling)运作时能达到最佳的处理效能。Another object of the present invention is to provide a method for block management, a related memory device and its controller, so as to achieve the best processing performance when performing wear leveling.
本发明的另一目的在于提供一种用来进行区块管理的方法以及相关的记忆装置及其控制器,以在进行一目标区块的抹除运作时能适应性地选择用来保存/储存该目标区块中的有效数据(Valid Data)的区块。Another object of the present invention is to provide a method for block management, a related memory device and its controller, so that when performing an erase operation on a target block, it can be adaptively selected for preservation/storage A block of valid data (Valid Data) in the target block.
本发明解决其技术问题所采用的技术方案之一是:提供一种来进行区块管理的方法,该方法应用于一闪存(Flash Memory)的控制器,该闪存包含多个区块,该方法包含有:在该闪存的一数据区(Data Region)中的至少一部分区块当中选择抹除次数(Erase Count)最低的一目标区块,作为一待抹除区块,其中该至少一部分区块的序号分别对应于该至少一部分区块的最新更新的顺序;以及依据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至一高损耗区块(Heavily Worn Block)或一低损耗区块(Lightly Worn Block),其中该高损耗区块的损耗程度大于该低损耗区块的损耗程度。One of the technical solutions adopted by the present invention to solve the technical problems is: provide a method for block management, the method is applied to a controller of flash memory (Flash Memory), the flash memory includes a plurality of blocks, the method Including: selecting a target block with the lowest erase count (Erase Count) among at least a part of the blocks in a data area (Data Region) of the flash memory, as a block to be erased, wherein the at least a part of the blocks The sequence numbers of the blocks correspond to the sequence of the latest update of the at least a part of the blocks; and according to the sequence numbers of the target block, the valid data in the target block should be moved/copied to a high loss block (Heavily Worn Block) or A lightly worn block (Lightly Worn Block), wherein the degree of wear of the high loss block is greater than that of the lightly worn block.
上述本发明所述的方法,其中依据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块的步骤另包含:In the above-mentioned method of the present invention, the step of determining that the valid data in the target block should be moved/copied to the high-loss block or the low-loss block according to the sequence number of the target block further includes:
计算该目标区块的序号与一最新存取区块的序号之间的差值;以及calculating the difference between the sequence number of the target block and the sequence number of a latest accessed block; and
依据该差值决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块。It is determined according to the difference that the valid data in the target block should be moved/copied to the high-loss block or the low-loss block.
上述本发明所述的方法,其中依据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块的步骤另包含:In the above-mentioned method of the present invention, the step of determining that the valid data in the target block should be moved/copied to the high-loss block or the low-loss block according to the sequence number of the target block further includes:
比较该差值与一门坎值以决定是否将该有效数据移动/复制至该高损耗区块。The difference is compared with a threshold to determine whether to move/copy the valid data to the high loss block.
上述本发明所述的方法,其中依据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块的步骤另包含:In the above-mentioned method of the present invention, the step of determining that the valid data in the target block should be moved/copied to the high-loss block or the low-loss block according to the sequence number of the target block further includes:
当该差值达到该门坎值时,将该有效数据移动/复制至该高损耗区块。When the difference reaches the threshold, the valid data is moved/copied to the high loss block.
上述本发明所述的方法,其中依据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块的步骤另包含:In the above-mentioned method of the present invention, the step of determining that the valid data in the target block should be moved/copied to the high-loss block or the low-loss block according to the sequence number of the target block further includes:
比较该差值与一门坎值以决定是否将该有效数据移动/复制至该低损耗区块。The difference is compared with a threshold to determine whether to move/copy the valid data to the low-loss block.
上述本发明所述的方法,其中据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块的步骤另包含:In the above-mentioned method of the present invention, the step of determining that the valid data in the target block should be moved/copied to the high-loss block or the low-loss block according to the sequence number of the target block further includes:
当该差值低于该门坎值时,将该有效数据移动/复制至该低损耗区块。When the difference is lower than the threshold, the valid data is moved/copied to the low-loss block.
上述本发明所述的方法,其中依据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块的步骤另包含:In the above-mentioned method of the present invention, the step of determining that the valid data in the target block should be moved/copied to the high-loss block or the low-loss block according to the sequence number of the target block further includes:
比较该差值与该门坎值以决定是否将该有效数据移动/复制至该高损耗区块。The difference is compared with the threshold to determine whether to move/copy the valid data to the high loss block.
上述本发明所述的方法,其另包含有:The above-mentioned method of the present invention further includes:
在该闪存的一备用区中的至少一部分区块当中选择抹除次数达到一门坎值的一区块,作为该高损耗区块。A block whose erasing times reach a threshold value is selected from at least a part of blocks in a spare area of the flash memory as the high loss block.
上述本发明所述的方法,其另包含有:The above-mentioned method of the present invention further includes:
在该闪存的一备用区中的至少一部分区块当中选择抹除次数低于一门坎值的一区块,作为该低损耗区块,其中该低损耗区块并非该备用区当中具有最低抹除次数的区块。Selecting a block whose erasing frequency is lower than a threshold value among at least a part of blocks in a spare area of the flash memory as the low-loss block, wherein the low-loss block is not the least erased block in the spare area number of blocks.
上述本发明所述的方法,其另包含有:The above-mentioned method of the present invention further includes:
在移动/复制该有效数据之后,抹除该目标区块。After moving/copying the valid data, the target block is erased.
上述本发明所述的方法,其中依据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块的步骤另包含:In the above-mentioned method of the present invention, the step of determining that the valid data in the target block should be moved/copied to the high-loss block or the low-loss block according to the sequence number of the target block further includes:
依据该目标区块的序号以及至少一门坎值决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块;以及Determining that valid data in the target block should be moved/copied to the high-loss block or the low-loss block according to the sequence number of the target block and at least one threshold value; and
动态地调整该至少一门坎值,以改变该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块的机率。The at least one threshold value is dynamically adjusted to change the probability of moving/copying valid data in the target block to the high-loss block or the low-loss block.
本发明解决其技术问题所采用的技术方案之二是:提供上述方法的同时,也对应地提供一种记忆装置,其包含有:一闪存,该闪存包含多个区块;以及一控制器,用来存取(Access)该闪存以及管理该多个区块。另外,该控制器在该闪存的一数据区中的至少一部分区块当中选择抹除次数最低的一目标区块,作为一待抹除区块,其中该至少一部分区块的序号分别对应于该至少一部分区块的最新更新的顺序。此外,该控制器依据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至一高损耗区块或一低损耗区块,其中该高损耗区块的损耗程度大于该低损耗区块的损耗程度。The second technical solution adopted by the present invention to solve the technical problem is: while providing the above method, a memory device is also correspondingly provided, which includes: a flash memory, the flash memory includes a plurality of blocks; and a controller, Used to access (Access) the flash memory and manage the multiple blocks. In addition, the controller selects a target block with the lowest erasing times among at least a part of blocks in a data area of the flash memory as a block to be erased, wherein the sequence numbers of the at least a part of blocks correspond to the The order of the most recent update of at least a portion of the blocks. In addition, the controller determines according to the sequence number of the target block that the valid data in the target block should be moved/copied to a high-loss block or a low-loss block, wherein the loss degree of the high-loss block is greater than the The degree of wear for low-loss blocks.
上述本发明所述的记忆装置,其中该控制器计算该目标区块的序号与一最新存取区块的序号之间的差值,以及依据该差值决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块。In the above memory device of the present invention, wherein the controller calculates the difference between the sequence number of the target block and the sequence number of a latest access block, and decides that the valid data in the target block should be determined according to the difference Data is moved/copied to the high loss block or the low loss block.
上述本发明所述的记忆装置,其中该控制器比较该差值与一门坎值以决定是否将该有效数据移动/复制至该高损耗区块。In the above-mentioned memory device of the present invention, the controller compares the difference with a threshold value to determine whether to move/copy the valid data to the high loss block.
上述本发明所述的记忆装置,其中当该差值达到该门坎值时,该控制器将该有效数据移动/复制至该高损耗区块。In the above-mentioned memory device of the present invention, when the difference reaches the threshold value, the controller moves/copyes the valid data to the high loss block.
上述本发明所述的记忆装置,其中该控制器比较该差值与一门坎值以决定是否将该有效数据移动/复制至该低损耗区块。In the above-mentioned memory device of the present invention, the controller compares the difference with a threshold value to determine whether to move/copy the valid data to the low-loss block.
上述本发明所述的记忆装置,其中当该差值低于该门坎值时,该控制器将该有效数据移动/复制至该低损耗区块。In the above-mentioned memory device of the present invention, when the difference is lower than the threshold value, the controller moves/copyes the valid data to the low-loss block.
上述本发明所述的记忆装置,其中该控制器比较该差值与该门坎值以决定是否将该有效数据移动/复制至该高损耗区块。In the above-mentioned memory device of the present invention, the controller compares the difference with the threshold value to determine whether to move/copy the valid data to the high loss block.
上述本发明所述的记忆装置,其中该控制器在该闪存的一备用区中的至少一部分区块当中选择抹除次数达到一门坎值的一区块,作为该高损耗区块。In the above-mentioned memory device of the present invention, the controller selects a block whose erasing times reach a threshold value from at least a part of blocks in a spare area of the flash memory as the high loss block.
上述本发明所述的记忆装置,其中该控制器在该闪存的一备用区中的至少一部分区块当中选择抹除次数低于一门坎值的一区块,作为该低损耗区块,而该低损耗区块并非该备用区当中具有最低抹除次数的区块。In the above-mentioned memory device of the present invention, wherein the controller selects a block whose erasing frequency is lower than a threshold value among at least a part of blocks in a spare area of the flash memory as the low-loss block, and the The low loss block is not the block with the lowest erasure count in the spare area.
上述本发明所述的记忆装置,其中在移动/复制该有效数据之后,该控制器抹除该目标区块。In the above memory device of the present invention, after moving/copying the valid data, the controller erases the target block.
本发明解决其技术问题所采用的技术方案之三是:提供上述方法的同时,也对应地提供一种记忆装置的控制器,该控制器用来存取一闪存,该闪存包含多个区块,该控制器包含有:一只读存储器(Read Only Memory,ROM),用来储存一程序代码;以及一微处理器,用来执行该程序代码以控制对该闪存的存取以及管理该多个区块。另外,透过该微处理器执行该程序代码的该控制器在该闪存的一数据区中的至少一部分区块当中选择抹除次数最低的一目标区块,作为一待抹除区块,其中该至少一部分区块的序号分别对应于该至少一部分区块的最新更新的顺序。此外,透过该微处理器执行该程序代码的该控制器依据该目标区块的序号决定应当将该目标区块中的有效数据移动/复制至一高损耗区块或一低损耗区块,其中该高损耗区块的损耗程度大于该低损耗区块的损耗程度。The third technical solution adopted by the present invention to solve the technical problem is: while providing the above method, a corresponding memory device controller is also provided, the controller is used to access a flash memory, the flash memory includes a plurality of blocks, The controller includes: a read only memory (Read Only Memory, ROM), which is used to store a program code; and a microprocessor, which is used to execute the program code to control the access to the flash memory and manage the multiple blocks. In addition, the controller that executes the program code through the microprocessor selects a target block with the lowest erasing times among at least a part of blocks in a data area of the flash memory as a block to be erased, wherein The sequence numbers of the at least a part of the blocks respectively correspond to the latest updated sequence of the at least a part of the blocks. In addition, the controller executing the program code through the microprocessor decides to move/copy the valid data in the target block to a high loss block or a low loss block according to the sequence number of the target block, Wherein the loss degree of the high loss block is greater than the loss degree of the low loss block.
上述本发明所述的控制器,其中透过该微处理器执行该程序代码的该控制器计算该目标区块的序号与一最新存取区块的序号之间的差值,以及依据该差值决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块。In the above-mentioned controller of the present invention, wherein the controller executing the program code through the microprocessor calculates the difference between the sequence number of the target block and the sequence number of a latest access block, and based on the difference The value determines whether the valid data in the target block should be moved/copied to the high loss block or the low loss block.
上述本发明所述的控制器,其中透过该微处理器执行该程序代码的该控制器比较该差值与一门坎值以决定是否将该有效数据移动/复制至该高损耗区块。In the above-mentioned controller of the present invention, the controller executing the program code through the microprocessor compares the difference with a threshold value to determine whether to move/copy the valid data to the high-loss block.
上述本发明所述的控制器,其中当该差值达到该门坎值时,透过该微处理器执行该程序代码的该控制器将该有效数据移动/复制至该高损耗区块。In the above-mentioned controller of the present invention, when the difference reaches the threshold value, the controller executing the program code through the microprocessor moves/copyes the valid data to the high-loss block.
上述本发明所述的控制器,其中透过该微处理器执行该程序代码的该控制器比较该差值与一门坎值以决定是否将该有效数据移动/复制至该低损耗区块。In the above-mentioned controller of the present invention, the controller executing the program code through the microprocessor compares the difference with a threshold value to determine whether to move/copy the valid data to the low-loss block.
上述本发明所述的控制器,其中当该差值低于该门坎值时,透过该微处理器执行该程序代码的该控制器将该有效数据移动/复制至该低损耗区块。In the above-mentioned controller of the present invention, when the difference is lower than the threshold value, the controller executing the program code through the microprocessor moves/copyes the valid data to the low-loss block.
上述本发明所述的控制器,其中透过该微处理器执行该程序代码的该控制器比较该差值与该门坎值以决定是否将该有效数据移动/复制至该高损耗区块。In the above-mentioned controller of the present invention, the controller executing the program code through the microprocessor compares the difference with the threshold value to determine whether to move/copy the valid data to the high-loss block.
上述本发明所述的控制器,其中透过该微处理器执行该程序代码的该控制器在该闪存的一备用区中的至少一部分区块当中选择抹除次数达到一门坎值的一区块,作为该高损耗区块。In the above-mentioned controller of the present invention, wherein the controller that executes the program code through the microprocessor selects a block whose number of times of erasing reaches a threshold value among at least a part of blocks in a spare area of the flash memory , as the high loss block.
上述本发明所述的控制器,其中透过该微处理器执行该程序代码的该控制器在该闪存的一备用区中的至少一部分区块当中选择抹除次数低于一门坎值的一区块,作为该低损耗区块,而该低损耗区块并非该备用区当中具有最低抹除次数的区块。In the above-mentioned controller of the present invention, wherein the controller that executes the program code through the microprocessor selects an area whose erasing frequency is lower than a threshold value among at least a part of blocks in a spare area of the flash memory block, as the low-loss block, and the low-loss block is not the block with the lowest erasure times in the spare area.
上述本发明所述的控制器,其中在移动/复制该有效数据之后,透过该微处理器执行该程序代码的该控制器抹除该目标区块。In the above-mentioned controller of the present invention, after moving/copying the valid data, the controller executing the program code through the microprocessor erases the target block.
实施本发明的技术方案,具有以下有益效果:依据本发明所实现的区块管理能区别热数据与冷数据,并利用较高损耗程度的区块储存冷数据以及利用较低损耗程度的区块储存热数据。藉此保证在闪存中进行损耗整平运作时达到最佳的处理效能。Implementing the technical solution of the present invention has the following beneficial effects: the block management realized according to the present invention can distinguish between hot data and cold data, and use blocks with a higher degree of loss to store cold data and blocks with a lower degree of loss Store hot data. This ensures optimal processing performance when performing wear-leveling operations in flash memory.
相较于相关技术,本发明在不大幅地增加芯片面积及相关成本的状况下就能达到兼顾运作效能与系统资源使用控管的目标。Compared with related technologies, the present invention can achieve the goal of both operating performance and system resource usage control without greatly increasing the chip area and related costs.
附图说明 Description of drawings
下面将结合附图及实施例对本发明作进一步说明,附图中:The present invention will be further described below in conjunction with accompanying drawing and embodiment, in the accompanying drawing:
图1为依据本发明一第一实施例的一种记忆装置的示意图;1 is a schematic diagram of a memory device according to a first embodiment of the present invention;
图2A为依据本发明一实施例的一种进行区块管理的方法的流程图;FIG. 2A is a flowchart of a method for block management according to an embodiment of the present invention;
图2B与图2C分别绘示图2A所示的方法在不同的实施例中的实施细节;FIG. 2B and FIG. 2C respectively illustrate the implementation details of the method shown in FIG. 2A in different embodiments;
图3绘示图2A所示的方法在一实施例中所涉及的数据区中的区块;FIG. 3 shows blocks in the data area involved in the method shown in FIG. 2A in an embodiment;
图4A与图4B分别绘示图2A所示的方法在不同的实施例中的实施细节。FIG. 4A and FIG. 4B respectively illustrate implementation details of the method shown in FIG. 2A in different embodiments.
【主要组件符号说明】[Description of main component symbols]
具体实施方式 Detailed ways
请参考图1,图1为依据本发明一第一实施例的一种记忆装置100的示意图,其中本实施例的记忆装置100尤其为可携式记忆装置(例如:符合SD/MMC、CF、MS、XD标准的记忆卡)或固态硬盘(SSD,Solid State Drive)等。记忆装置100包含有:一闪存(Flash Memory)120,其包含多个区块,而该多个区块包含至少一信息区块(Block)120B;以及一控制器,用来存取(Access)闪存120,其中该控制器例如一内存控制器110。依据本实施例,内存控制器110包含一微处理器112、一只读存储器(Read Only Memory,ROM)112M、一控制逻辑114、至少一缓冲存储器116、与一接口逻辑118。另外,本实施例的只读存储器112M用来储存一程序代码112C,而微处理器112则用来执行程序代码112C以控制对闪存120的存取。请注意到,程序代码112C也得储存在缓冲存储器116或任何形式的内存内。Please refer to FIG. 1. FIG. 1 is a schematic diagram of a memory device 100 according to a first embodiment of the present invention, wherein the memory device 100 of this embodiment is especially a portable memory device (for example: conforming to SD/MMC, CF, MS, XD standard memory card) or solid state drive (SSD, Solid State Drive), etc. The memory device 100 includes: a flash memory (Flash Memory) 120, which includes a plurality of blocks, and the plurality of blocks includes at least one information block (Block) 120B; and a controller, used for access (Access) The flash memory 120, wherein the controller is, for example, a memory controller 110. According to this embodiment, the memory controller 110 includes a microprocessor 112 , a read only memory (ROM) 112M, a control logic 114 , at least one buffer memory 116 , and an interface logic 118 . In addition, the ROM 112M of this embodiment is used to store a program code 112C, and the microprocessor 112 is used to execute the program code 112C to control access to the flash memory 120 . Please note that the program code 112C also has to be stored in the buffer memory 116 or any form of memory.
如图1所示,上述的至少一信息区块120B用来储存关于区块管理的信息,尤其是至少一索引诸如最新存取区块索引120L。最新存取区块索引120L可用来记录闪存120中的最新存取区块。例如:当上述的控制器(例如:透过微处理器112执行程序代码112C的内存控制器110)将数据写入某一区块时,该控制器可记录/更新最新存取区块索引120L,以指出该区块为最新存取区块。又例如:当更新某一区块时,该控制器可记录/更新最新存取区块索引120L,以指出该区块为最新存取区块。在本实施例中,该控制器可将最新存取区块索引120L的一先前版本储存在闪存120,并将最新存取区块索引120L的一复制版本储存在缓冲存储器116,以供动态地更新最新存取区块索引120L。另外,该控制器可将缓冲存储器116当中最新存取区块索引120L的最新版本储存至闪存120,以取代最新存取区块索引120L的该先前版本。请注意到,信息区块120B中所储存的任何信息,均可储存在内存控制器110中(例如缓冲存储器116),或任何内存控制器110得取用的内存中。将最新存取区块索引120L储存在闪存120中仅为本发明的一实施例,并非本发明的限制。As shown in FIG. 1 , the above-mentioned at least one information block 120B is used to store information about block management, especially at least one index such as the latest accessed block index 120L. The latest access block index 120L can be used to record the latest access block in the flash memory 120 . For example: when the above-mentioned controller (for example: the memory controller 110 executing the program code 112C through the microprocessor 112) writes data into a certain block, the controller can record/update the latest access block index 120L , to indicate that the block is the most recently accessed block. Another example: when updating a certain block, the controller may record/update the latest access block index 120L to indicate that the block is the latest access block. In this embodiment, the controller may store a previous version of the latest access block index 120L in the flash memory 120, and store a copy version of the latest access block index 120L in the buffer memory 116 for dynamic The latest access block index 120L is updated. In addition, the controller can store the latest version of the latest access block index 120L in the buffer memory 116 to the flash memory 120 to replace the previous version of the latest access block index 120L. Please note that any information stored in the information block 120B can be stored in the memory controller 110 (such as the buffer memory 116 ), or in any memory accessible by the memory controller 110 . Storing the latest access block index 120L in the flash memory 120 is only an embodiment of the present invention, and is not a limitation of the present invention.
实作上,透过微处理器112执行程序代码112C的内存控制器110可利用其本身内部的组件来进行诸多控制运作,例如:利用控制逻辑114来控制闪存120的存取运作(尤其是对至少一区块或至少一页的存取运作)、利用缓冲存储器116进行所需的缓冲处理、以及利用接口逻辑118来与一主装置(HostDevice)沟通。In practice, the memory controller 110 that executes the program code 112C through the microprocessor 112 can use its own internal components to perform many control operations, for example: use the control logic 114 to control the access operation of the flash memory 120 (especially for access operations of at least one block or at least one page), use the buffer memory 116 to perform required buffering, and use the interface logic 118 to communicate with a host device (HostDevice).
依据本实施例,除了能存取闪存120,该控制器还能妥善地管理上述的多个区块。更明确而言,在进行抹除运作时,该控制器能适应性地选择用来保存有效数据(Valid Data)的区块,以达到损耗整平(Wear Leveling)的最佳的处理效能。请参考图2A,相关细节进一步说明如下。According to this embodiment, in addition to being able to access the flash memory 120, the controller can properly manage the above-mentioned multiple blocks. More specifically, when performing an erasing operation, the controller can adaptively select a block for storing valid data (Valid Data), so as to achieve the best processing performance of wear leveling (Wear Leveling). Please refer to FIG. 2A , and related details are further described as follows.
图2A为依据本发明一实施例的一种进行区块管理的方法910的流程图。该方法可应用于在图1所示的记忆装置100,尤其是上述的控制器(例如:透过微处理器112执行程序代码112C的内存控制器110)。该方法说明如下:FIG. 2A is a flowchart of a block management method 910 according to an embodiment of the present invention. The method can be applied to the memory device 100 shown in FIG. 1 , especially the above-mentioned controller (eg, the memory controller 110 executing the program code 112C through the microprocessor 112 ). The method is described as follows:
在步骤912中,该控制器在闪存120的一数据区(Data Region)中的至少一部分区块(例如:该数据区中的一部分或全部的区块)当中选择抹除次数(Erase Count)最低的一目标区块,作为一待抹除区块,其中该至少一部分区块的序号分别对应于该至少一部分区块的最新更新的顺序。请注意,针对该至少一部分区块中的任一区块,除了其逻辑地址之外,此区块另具有一序号,而此序号对应于此区块的更新顺序,即此区块相对于该至少一部分区块中的其它区块的更新顺序。依据本实施例,闪存120另包含一备用区(SpareRegion)。尤其是,属于该备用区的区块为自从最新一次抹除之后尚未使用的区块,而属于该数据区的区块为自从最新一次抹除之后已经使用的区块,其中该备用区与该资料区均为针对闪存120中的各个区块的逻辑区域划分,而非实体区域划分。In step 912, the controller selects the lowest erasing times (Erase Count) among at least a part of blocks in a data region (Data Region) of the flash memory 120 (for example: a part or all of the blocks in the data region). A target block is used as a block to be erased, wherein the serial numbers of the at least a part of the blocks respectively correspond to the latest updated sequence of the at least a part of the blocks. Please note that for any block in the at least a part of blocks, in addition to its logical address, this block has a sequence number, and this sequence number corresponds to the update sequence of this block, that is, this block is relative to the An update sequence for other blocks in at least a portion of the blocks. According to this embodiment, the flash memory 120 further includes a spare region (SpareRegion). In particular, the blocks belonging to the spare area are blocks that have not been used since the latest erasure, and the blocks belonging to the data area are blocks that have been used since the latest erasure, wherein the spare area and the The data area is a logical area division for each block in the flash memory 120 , rather than a physical area division.
在步骤914中,该控制器依据该目标区块的序号决定应当将该目标区块中的有效数据(Valid Data)移动/复制至一高损耗区块(Heavily WornBlock)或一低损耗区块(Lightly Worn Block)。请注意,该高损耗区块的损耗程度大于该低损耗区块的损耗程度。尤其是,该高损耗区块代表该多个区块中具有较高损耗程度的区块,而该低损耗区块代表该多个区块中具有较低损耗程度的区块。实作上,该控制器可计算该目标区块的序号与一最新存取区块的序号之间的差值Diff,并且依据差值Diff决定应当将该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块。例如:该控制器比较差值Diff与一门坎值以决定是否将该有效数据移动/复制至该高损耗区块;当差值Diff达到该门坎值时,该控制器将该有效数据移动/复制至该高损耗区块。又例如:该控制器比较差值Diff与一门坎值以决定是否将该有效数据移动/复制至该低损耗区块;当差值Diff低于该门坎值时,该控制器将该有效数据移动/复制至该低损耗区块。In step 914, the controller decides according to the sequence number of the target block that the valid data (Valid Data) in the target block should be moved/copied to a high-loss block (Heavily WornBlock) or a low-loss block ( Lightly Worn Block). Note that the high loss block is more worn than the low loss block. In particular, the high-loss block represents a block with a higher wear level among the plurality of blocks, and the low-loss block represents a block with a lower wear level among the plurality of blocks. In practice, the controller can calculate the difference Diff between the sequence number of the target block and the sequence number of a latest accessed block, and decide that the valid data in the target block should be moved/copied according to the difference Diff to the high loss block or the low loss block. For example: the controller compares the difference Diff with a threshold to decide whether to move/copy the valid data to the high-loss block; when the difference Diff reaches the threshold, the controller moves/copy the valid data to the high loss block. Another example: the controller compares the difference Diff with a threshold value to determine whether to move/copy the valid data to the low-loss block; when the difference Diff is lower than the threshold value, the controller moves the valid data /Copy to this low-loss block.
依据一实施例,诸如图2A所示实施例的变化例,该控制器可依据该目标区块的序号判断该目标区块中的有效数据是否为冷数据(例如:不热门的数据),以对应地决定是否将该有效数据移动/复制至该高损耗区块,其中当该目标区块的序号与最新存取区块的序号之间的差值Diff达到一第一门坎值TH1时,该有效数据被判断为冷数据,此时该控制器将该有效数据移动/复制至该高损耗区块。如此,当将该有效数据移动/复制至该高损耗区块时,该控制器可记录/更新最新存取区块索引120L,以指出该高损耗区块为最新存取区块。According to an embodiment, such as a variation example of the embodiment shown in FIG. 2A, the controller can judge whether the valid data in the target block is cold data (for example: unpopular data) according to the sequence number of the target block, so as to Correspondingly determine whether to move/copy the valid data to the high-loss block, wherein when the difference Diff between the sequence number of the target block and the sequence number of the latest access block reaches a first threshold value TH1, the Valid data is judged as cold data, and the controller moves/copyes the valid data to the high loss block at this time. Thus, when the valid data is moved/copied to the high loss block, the controller can record/update the latest access block index 120L to indicate that the high loss block is the latest access block.
另外,该控制器可依据该目标区块的序号判断该目标区块中的该有效数据是否为热数据(例如:热门的数据),以对应地决定是否将该有效数据移动/复制至该低损耗区块,其中当该目标区块的序号与该最新存取区块的序号之间的差值Diff低于一第二门坎值TH2时,该有效数据被判断为热数据,此时该控制器将该有效数据移动/复制至该低损耗区块。如此,当将该有效数据移动/复制至该低损耗区块时,该控制器可记录/更新最新存取区块索引120L,以指出该低损耗区块为最新存取区块。此外,上述的第一门坎值TH1与第二门坎值TH2,均可由控制器动态地调整。一般而言,第一门坎值TH1大于或等于第二门坎值TH2。In addition, the controller can judge whether the valid data in the target block is hot data (for example: hot data) according to the serial number of the target block, so as to determine whether to move/copy the valid data to the low Lost block, wherein when the difference Diff between the sequence number of the target block and the sequence number of the latest access block is lower than a second threshold value TH2, the valid data is judged as hot data, at this time the control The device moves/copies the valid data to the low-loss block. Thus, when the valid data is moved/copied to the low loss block, the controller can record/update the latest access block index 120L to indicate that the low loss block is the latest access block. In addition, the above-mentioned first threshold TH1 and second threshold TH2 can be dynamically adjusted by the controller. Generally speaking, the first threshold TH1 is greater than or equal to the second threshold TH2.
图2B绘示图2A所示的方法910在一实施例中的实施细节。图2B所示的工作流程说明如下:FIG. 2B illustrates implementation details of the method 910 shown in FIG. 2A in an embodiment. The workflow shown in Figure 2B is explained as follows:
在步骤932中,该控制器在该数据区中选择一目标区块诸如上述的目标区块,作为一待抹除区块。In step 932, the controller selects a target block in the data area, such as the above-mentioned target block, as a block to be erased.
在步骤933中,该控制器计算该目标区块的序号与最新存取区块的序号之间的差值Diff。In step 933, the controller calculates the difference Diff between the sequence number of the target block and the sequence number of the latest accessed block.
在步骤934-1中,该控制器检查差值Diff是否达到门坎值TH1。当差值Diff达到门坎值TH1时,进入步骤936-1;否则,进入步骤934-2。In step 934-1, the controller checks whether the difference Diff reaches the threshold TH1. When the difference Diff reaches the threshold TH1, go to step 936-1; otherwise, go to step 934-2.
在步骤934-2中,该控制器检查差值Diff是否低于门坎值TH2。当差值Diff低于门坎值TH2时,进入步骤936-2;否则,进入步骤936-3。In step 934-2, the controller checks whether the difference Diff is lower than the threshold TH2. When the difference Diff is lower than the threshold TH2, go to step 936-2; otherwise, go to step 936-3.
在步骤936-1中,该控制器将有效数据移动/复制至一高损耗区块诸如上述的高损耗区块。In step 936-1, the controller moves/copy valid data to a high loss block such as the high loss block described above.
在步骤936-2中,该控制器将有效数据移动/复制至一低损耗区块诸如上述的低损耗区块。In step 936-2, the controller moves/copies the valid data to a low-loss block such as the low-loss block described above.
在步骤936-3中,该控制器将有效数据移动/复制至一低损耗区块,尤其是依据不同的条件所选出的另一低损耗区块,而非步骤936-2所述的低损耗区块。实作上,该另一低损耗区块的损耗程度可以介于步骤936-2所述的低损耗区块的损耗程度与步骤936-1所述的高损耗区块的损耗程度之间。In step 936-3, the controller moves/copy valid data to a low loss block, especially another low loss block selected according to different conditions, instead of the low loss block described in step 936-2. loss block. In practice, the wear level of the other low loss block can be between the wear level of the low loss block mentioned in step 936-2 and the wear level of the high loss block mentioned in step 936-1.
在步骤938中,该控制器抹除该目标区块。In step 938, the controller erases the target block.
依据一实施例,诸如图2B所示实施例的一变化例,该控制器可将上述的备用区区分为至少三层,诸如一高损耗区块层、一中损耗区块(AveragelyWorn Block)层、以及一低损耗区块层。尤其是,步骤936-1所述的高损耗区块选自于该高损耗区块层,而步骤936-2所述的低损耗区块选自于该低损耗区块层,其中步骤936-3所述的另一低损耗区块可视为一中损耗区块,且选自于该中损耗区块层。According to an embodiment, such as a variation of the embodiment shown in FIG. 2B , the controller can divide the above-mentioned spare area into at least three layers, such as a high-loss block layer and an averagely worn block (Averagely Worn Block) layer , and a low-loss block layer. In particular, the high-loss block described in step 936-1 is selected from the high-loss block layer, and the low-loss block described in step 936-2 is selected from the low-loss block layer, wherein step 936- The other low-loss block described in 3 can be regarded as a medium-loss block, and is selected from the medium-loss block layer.
实作上,该控制器可依据该备用区中的区块(其可称为备用区块)的损耗区块,将这些区块的任一个分类至该高损耗区块层、该中损耗区块层、以及该低损耗区块层中的一个,其中该高损耗区块层中的备用区块的损耗程度高于该中损耗区块层中的备用区块的损耗程度,且该中损耗区块层中的备用区块的损耗程度高于该低损耗区块层中的备用区块的损耗程度。例如:该控制器可将抹除次数落于区间[13,20]的范围的区块分类至该高损耗区块层,并将抹除次数落于区间[7,12]的范围的区块分类至该中损耗区块层,且将抹除次数落于区间[1,6]的范围的区块分类至该低损耗区块层。这只是为了说明的目的而已,并非对本发明的限制。依据本实施例的某些变化例,上述备用区内的各层的层数可予以改变、及/或上述的各个区间的范围可予以改变。依据该些变化例中的一者,在上述各层的层数超过三层的状况下,上述的高损耗区块层可称为最高损耗区块(Most Heavily Worn Block)层,且上述的低损耗区块层可称为最低损耗区块(Most Lightly Worn Block)层,其中各层所对应的区间对应地改变,使该控制器可依据该备用区中的区块的损耗程度更精细地分类至各层。例如:基于损耗程度的顺序(由最高者开始),该些层可包含:最高损耗区块层、次高损耗区块层、第三高损耗区块层、...、中损耗区块层、...、第三低损耗区块层、次低损耗区块层、最低损耗区块层。In practice, the controller can classify any one of the blocks in the spare area (which may be referred to as spare blocks) into the high loss block layer, the medium loss area according to the loss blocks of the blocks in the spare area. block layer, and one of the low-loss block layers, wherein the wear degree of the spare blocks in the high-loss block layer is higher than the wear degree of the spare blocks in the medium-loss block layer, and the wear degree of the medium-loss block layer is The wear degree of the spare blocks in the block layer is higher than the wear degree of the spare blocks in the low loss block layer. For example: the controller can classify blocks whose erasure times fall within the interval [13, 20] into the high-loss block layer, and classify blocks whose erasure times fall within the interval [7, 12] Classify to the medium-loss block layer, and classify blocks whose erasure times fall within the interval [1, 6] into the low-loss block layer. This is for the purpose of illustration only, not limitation of the present invention. According to some variations of this embodiment, the number of layers of each layer in the above spare area may be changed, and/or the range of each of the above intervals may be changed. According to one of these variations, in the case where the number of the above-mentioned layers exceeds three layers, the above-mentioned high-loss block layer may be called the most heavily-worn block (Most Heavily Worn Block) layer, and the above-mentioned low The loss block layer can be called the most lightly worn block (Most Lightly Worn Block) layer, in which the intervals corresponding to each layer change accordingly, so that the controller can classify more finely according to the degree of wear of the blocks in the spare area to each layer. For example: based on the order of loss level (starting with the highest), the layers may include: highest loss block layer, second highest loss block layer, third highest loss block layer, ..., medium loss block layer , ..., the third low-loss block layer, the second-lowest loss block layer, and the lowest-loss block layer.
图2C绘示图2A所示的方法910在一实施例中的实施细节,其中本实施例为图2B所示实施例的变化例。图2C所示的工作流程说明如下:FIG. 2C shows implementation details of the method 910 shown in FIG. 2A in an embodiment, where this embodiment is a variation of the embodiment shown in FIG. 2B . The workflow shown in Figure 2C is explained as follows:
在步骤932中,该控制器在该数据区中选择一目标区块诸如上述的目标区块,作为一待抹除区块。In step 932, the controller selects a target block in the data area, such as the above-mentioned target block, as a block to be erased.
在步骤933中,该控制器计算该目标区块的序号与最新存取区块的序号之间的差值Diff。In step 933, the controller calculates the difference Diff between the sequence number of the target block and the sequence number of the latest accessed block.
在步骤934-1中,该控制器检查差值Diff是否达到门坎值TH1。当差值Diff达到门坎值TH1时,进入步骤936-1;否则,进入步骤936-2。In step 934-1, the controller checks whether the difference Diff reaches the threshold TH1. When the difference Diff reaches the threshold TH1, go to step 936-1; otherwise, go to step 936-2.
在步骤936-1中,该控制器将有效数据移动/复制至一高损耗区块诸如上述的高损耗区块。In step 936-1, the controller moves/copy valid data to a high loss block such as the high loss block described above.
在步骤936-2中,该控制器将有效数据移动/复制至一低损耗区块诸如步骤914所述的低损耗区块。In step 936 - 2 , the controller moves/copy valid data to a low loss block such as the low loss block described in step 914 .
在步骤938中,该控制器抹除该目标区块。In step 938, the controller erases the target block.
依据一实施例,诸如图2C所示实施例的一变化例,控制器也得动态地调整门坎值TH1。当在步骤932中,该控制器在该数据区所选择的待抹除区块的抹除次数太高,例如高于抹除次数门坎值THE,则代表该区块的抹除次数已较该数据区中的区块(其可称为数据区块)的平均抹除次数高出太多,该区块所储存的数据有非常高的机率为热数据。此时,控制器得动态地调高门坎值TH1,使得在步骤934-1中,该控制器检查差值Diff是否达到门坎值TH1时,有更高的机率进入步骤936-2,以确保该些热数据得移动至低耗损区块。如此,该控制器可动态地调整至少一门坎值诸如门坎值TH1,以改变该目标区块中的有效数据移动/复制至该高损耗区块或该低损耗区块的机率。According to an embodiment, such as a variation of the embodiment shown in FIG. 2C , the controller also has to dynamically adjust the threshold TH1 . When in step 932, the erasing frequency of the block to be erased selected by the controller in the data area is too high, for example, higher than the erasing frequency threshold TH E , it means that the erasing frequency of the block has exceeded The average number of erasures of the blocks in the data area (which may be called data blocks) is too high, and the data stored in the blocks has a very high probability of being hot data. At this time, the controller has to dynamically increase the threshold value TH1, so that in step 934-1, when the controller checks whether the difference Diff reaches the threshold value TH1, it has a higher probability to enter step 936-2 to ensure the Some hot data has to be moved to low-loss blocks. In this way, the controller can dynamically adjust at least one threshold such as the threshold TH1 to change the probability of moving/copying valid data in the target block to the high-loss block or the low-loss block.
图3绘示图2A所示的方法910在一实施例中所涉及的数据区300中的区块,其中这些区块之间的箭头代表被写入或更新的顺序,而非实体上的连接关系。在本实施例中,区块{310-1,310-2,310-3,310-4,310-5,310-6,...,330-m0,...,320-2,320-1}的序号分别为{SN1,SN2,SN3900,SN4800,SN4801,SN4802,...,SN9600,...,SN14998,S N15000}。图3中所示该些区块的连接关系用来表示数据区300中各区块被储存的顺序。如图3中所示,最近一个被写入资料的区块为区块320-1,其序号为SN15000,也可称其为区块序列中的尾部。而最早被写入资料的区块为区块310-1,其序号为SN1,也可称其为区块序列中的头部。关于该些区块的先后次序写入关系可视为一个链结(Link)关系,其系逻辑上的连接关系,并非实体上的连接关系。而此逻辑上的连接关系会随着主装置随机写入数据的行为而改变。由于主装置的随机写入而使该链结中某一或某些区块中所有的数据均已成为无效数据(例如主装置欲更新该些数据,而使得储存在该些区块的旧数据成为无效数据)。则控制器将会抹除该些区块,并将该些区块自数据区移至备用区。此外,控制器也需将该些区块自链结中移除,并重新建立链结。例如,将原本链结在该些被移除区块后的区块替补上来,以重新建立链结。故图3所示的各个序号并非全部连续,例如序号SN2后接序号SN3900,而序号SN3-SN3899已经不存在于链结关系中。请注意到序号SN3-SN3899并非原本即不存在于链结关系中,对应于序号SN3-SN3899的区块,可能因主装置的随机写入而使其中所储存的数据变为无效数据,从而,控制器抹除该些区块,并将该些区块自数据区移至备用区。故控制器也将该些区块所对应的序号(序号SN3-SN3899)自链结中移除,并重新建立链结。FIG. 3 shows the blocks in the data area 300 involved in the method 910 shown in FIG. 2A in an embodiment, wherein the arrows between these blocks represent the order of being written or updated, rather than the physical connection relation. In this embodiment, blocks {310-1, 310-2, 310-3, 310-4, 310-5, 310-6, ..., 330-m 0 , ..., 320-2, The serial numbers of 320-1} are {SN1, SN2, SN3900, SN4800, SN4801, SN4802, ..., SN9600, ..., SN14998, SN15000} respectively. The connection relationship of the blocks shown in FIG. 3 is used to represent the order in which the blocks in the data area 300 are stored. As shown in FIG. 3 , the latest block in which data is written is block 320 - 1 , and its sequence number is SN15000 , which can also be called the end of the block sequence. The block whose data is first written is block 310 - 1 , its sequence number is SN1 , and it can also be called the head of the block sequence. The sequential writing relationship of these blocks can be regarded as a link relationship, which is a logical connection relationship, not a physical connection relationship. And this logical connection relationship will change with the behavior of the main device randomly writing data. Due to the random writing of the master device, all the data in one or some blocks in the link have become invalid data (for example, the master device wants to update these data, so that the old data stored in these blocks become invalid data). Then the controller will erase the blocks and move the blocks from the data area to the spare area. In addition, the controller also needs to remove these blocks from the chain and re-establish the chain. For example, blocks that were originally linked after the removed blocks are replaced to re-establish the link. Therefore, the serial numbers shown in FIG. 3 are not all consecutive. For example, the serial number SN2 is followed by the serial number SN3900, and the serial numbers SN3-SN3899 no longer exist in the link relationship. Please note that the serial number SN3-SN3899 does not originally exist in the link relationship, and the block corresponding to the serial number SN3-SN3899 may cause the data stored in it to become invalid due to the random writing of the master device, thus, The controller erases the blocks and moves the blocks from the data area to the spare area. Therefore, the controller also removes the serial numbers (serial numbers SN3-SN3899) corresponding to these blocks from the link, and re-establishes the link.
请注意,上列序号中的符号SN可以直接去除,只留下序号中的数值,以便于计算差值Diff。例如:在门坎值TH1等于7500且门坎值TH2等于1024的状况下,区块{310-c}诸如区块{310-1,310-2,310-3,310-4,310-5,310-6,...,310-C}中的数据可以视为冷数据(例如,不常被主装置更新的数据),是因为它们的序号{SN1,SN2,SN3900,SN4800,SN4801,SN4802,...}所对应的差值{Diff}(即差值{14999,14998,11100,10200,10199,10198,...})均达到门坎值TH1;而区块{320-h}诸如区块{320-1,320-2,...,320-H}中的数据可以视为热数据(例如,经常被主装置更新的数据),是因为它们的序号{SN15000,SN14998,...}所对应的差值{Diff}(即差值{0,2,...})均低于门坎值TH2;并且其余的区块{330-m}诸如区块{330-1,330-2,...,330-m0,...,330-M}可以视为中等数据,是因为它们的序号(例如:SN9600)所对应的差值{Diff}(例如:差值5400)落入区间[TH2,TH1)的范围。这只是为了说明的目的而已,并非对本发明的限制。依据本实施例的某些变化例,在门坎值TH1等于门坎值TH2的状况下,上述的中等数据不存在。Please note that the symbol SN in the serial number above can be removed directly, leaving only the value in the serial number for easy calculation of the difference Diff. For example: in the case where the threshold TH1 is equal to 7500 and the threshold TH2 is equal to 1024, block {310-c} such as block {310-1, 310-2, 310-3, 310-4, 310-5, 310 The data in -6,...,310-C} can be regarded as cold data (for example, data that is not frequently updated by the master device), because their sequence numbers {SN1, SN2, SN3900, SN4800, SN4801, SN4802, ...} corresponding to the difference {Diff} (that is, the difference {14999, 14998, 11100, 10200, 10199, 10198, ...}) all reach the threshold value TH1; and the block {320-h} such as block The data in blocks {320-1, 320-2, ..., 320-H} can be regarded as hot data (for example, data that is frequently updated by the master device) because their sequence numbers {SN15000, SN14998, .. The difference {Diff} corresponding to .} (that is, the difference {0, 2, ...}) is lower than the threshold value TH2; and the remaining blocks {330-m} such as block {330-1, 330 -2,...,330-m 0 ,...,330-M} can be regarded as medium data because the difference {Diff} (for example: difference 5400 ) falls within the range of the interval [TH2, TH1). This is for the purpose of illustration only, not limitation of the present invention. According to some variations of this embodiment, in the situation where the threshold TH1 is equal to the threshold TH2, the above-mentioned intermediate data does not exist.
图4A与图4B分别绘示图2A所示的方法910在不同的实施例中的实施细节。FIG. 4A and FIG. 4B respectively illustrate implementation details of the method 910 shown in FIG. 2A in different embodiments.
如图4A所示,该控制器在闪存120的备用区400中的至少一部分区块当中选择抹除次数低于一门坎值TH3的一区块,作为步骤914所述的低损耗区块,其中该低损耗区块并非备用区400当中具有最低抹除次数的区块(例如,该低损耗区块的抹除次数并非0次)。尤其是,该低损耗区块可为备用区400当中具有较低抹除次数(但非最低抹除次数)的区块。在该目标区块为一热区块(即包含热数据的区块)诸如区块320-2的状况下,该控制器移动/复制该有效数据至该低损耗区块;并且在移动/复制该有效数据之后,该控制器抹除目标区块320-2,并将目标区块320-2逻辑上地安排在备用区400。另外,该控制器将该低损耗区块逻辑上地安排在数据区300,使该低损耗区块逻辑上地成为图3所示数据区300中的区块序列的新尾部(即图4A所示的新尾部区块320-0)。As shown in FIG. 4A, the controller selects a block whose erasing frequency is lower than a threshold value TH3 among at least a part of the blocks in the spare area 400 of the flash memory 120, as the low loss block described in step 914, wherein The low-loss block is not the block with the lowest erasure count in the spare area 400 (for example, the erase count of the low-loss block is not 0). In particular, the low loss block can be a block with a lower erase count (but not the lowest erase count) in the spare area 400 . In the case that the target block is a hot block (i.e., a block containing hot data) such as block 320-2, the controller moves/copyes the valid data to the low-loss block; and upon moving/copying After the valid data, the controller erases the target block 320 - 2 and logically arranges the target block 320 - 2 in the spare area 400 . In addition, the controller logically arranges the low-loss block in the data area 300, so that the low-loss block logically becomes the new tail of the block sequence in the data area 300 shown in FIG. 3 (that is, shown in FIG. 4A shown in the new trailer block 320-0).
如图4B所示,该控制器在闪存120的备用区400中的至少一部分区块当中选择抹除次数达到一门坎值TH4的一区块,作为步骤914所述的高损耗区块。尤其是,该高损耗区块可为备用区400当中具有较高(或最高)抹除次数的区块。在该目标区块为一冷区块(即包含冷数据的区块)诸如区块310-2的状况下,该控制器移动/复制该有效数据至该高损耗区块;并且在移动/复制该有效数据之后,该控制器抹除目标区块310-2,并将目标区块310-2逻辑上地安排在备用区400。另外,该控制器将该高损耗区块逻辑上地安排在数据区300,使该高损耗区块逻辑上地成为图3所示数据区300中的区块序列的新尾部(即图4B所示的新尾部区块320-0)。As shown in FIG. 4B , the controller selects a block whose erasing times reach a threshold TH4 from at least a part of blocks in the spare area 400 of the flash memory 120 as the high loss block described in step 914 . In particular, the high loss block can be a block with a higher (or highest) erasure count in the spare area 400 . In the case that the target block is a cold block (i.e., a block containing cold data) such as block 310-2, the controller moves/copyes the valid data to the high-loss block; and upon moving/copying After the valid data, the controller erases the target block 310 - 2 and logically arranges the target block 310 - 2 in the spare area 400 . In addition, the controller logically arranges the high-loss block in the data area 300, so that the high-loss block logically becomes the new tail of the block sequence in the data area 300 shown in FIG. 3 (that is, shown in FIG. 4B shown in the new trailer block 320-0).
本发明的好处之一是,依据本发明所实现的区块管理能区别热数据与冷数据,并利用较高损耗程度的区块储存冷数据以及利用较低损耗程度的区块储存热数据。藉此保证在闪存中进行损耗整平运作时达到最佳的处理效能。相较于相关技术,本发明在不大幅地增加芯片面积及相关成本的状况下就能达到兼顾运作效能与系统资源使用控管的目标。One of the advantages of the present invention is that the block management implemented according to the present invention can distinguish between hot data and cold data, and use blocks with higher loss level to store cold data and use blocks with lower loss level to store hot data. This ensures optimal processing performance when performing wear-leveling operations in flash memory. Compared with related technologies, the present invention can achieve the goal of both operating performance and system resource usage control without greatly increasing the chip area and related costs.
以上所述仅为本发明的较佳实施例,凡依本发明申请专利范围所做的均等变化与修饰,皆应属本发明的涵盖范围。The above descriptions are only preferred embodiments of the present invention, and all equivalent changes and modifications made according to the scope of the patent application of the present invention shall fall within the scope of the present invention.
Claims (30)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110036240.3A CN102637145B (en) | 2011-02-11 | 2011-02-11 | Method for block management, memory device and controller thereof |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110036240.3A CN102637145B (en) | 2011-02-11 | 2011-02-11 | Method for block management, memory device and controller thereof |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102637145A CN102637145A (en) | 2012-08-15 |
CN102637145B true CN102637145B (en) | 2015-06-17 |
Family
ID=46621546
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201110036240.3A Active CN102637145B (en) | 2011-02-11 | 2011-02-11 | Method for block management, memory device and controller thereof |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102637145B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109119106B (en) * | 2017-06-26 | 2022-08-02 | 中兴通讯股份有限公司 | Data storage method, device and computer readable storage medium |
CN110109625A (en) * | 2019-05-16 | 2019-08-09 | 深圳市时创意电子有限公司 | A kind of management method improving Free Queue |
TWI748410B (en) * | 2020-04-15 | 2021-12-01 | 慧榮科技股份有限公司 | Method and apparatus for performing block management regarding non-volatile memory |
CN113835638B (en) * | 2021-09-24 | 2023-08-04 | 苏州浪潮智能科技有限公司 | Method, device and equipment for determining garbage recycling destination block in storage system |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010034809A1 (en) * | 1995-09-28 | 2001-10-25 | Takeshi Ogawa | Selecting erase method based on type of power supply for flash eeprom |
US20040177212A1 (en) * | 2002-10-28 | 2004-09-09 | Sandisk Corporation | Maintaining an average erase count in a non-volatile storage system |
CN101236789A (en) * | 2006-12-18 | 2008-08-06 | 三星电子株式会社 | Method and apparatus for detecting static data area, wear-leveling, and merging data units |
US20100174845A1 (en) * | 2009-01-05 | 2010-07-08 | Sergey Anatolievich Gorobets | Wear Leveling for Non-Volatile Memories: Maintenance of Experience Count and Passive Techniques |
-
2011
- 2011-02-11 CN CN201110036240.3A patent/CN102637145B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010034809A1 (en) * | 1995-09-28 | 2001-10-25 | Takeshi Ogawa | Selecting erase method based on type of power supply for flash eeprom |
US20040177212A1 (en) * | 2002-10-28 | 2004-09-09 | Sandisk Corporation | Maintaining an average erase count in a non-volatile storage system |
CN101236789A (en) * | 2006-12-18 | 2008-08-06 | 三星电子株式会社 | Method and apparatus for detecting static data area, wear-leveling, and merging data units |
US20100174845A1 (en) * | 2009-01-05 | 2010-07-08 | Sergey Anatolievich Gorobets | Wear Leveling for Non-Volatile Memories: Maintenance of Experience Count and Passive Techniques |
Also Published As
Publication number | Publication date |
---|---|
CN102637145A (en) | 2012-08-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
TWI466121B (en) | Method for performing block management, and associated memory device and controller thereof | |
TWI446345B (en) | Method for performing block management, and associated memory device and controller thereof | |
TWI437439B (en) | Method for performing block management using dynamic threshold, and associated memory device and controller thereof | |
TWI652679B (en) | Memory controller, memory system and control method | |
CN107526543B (en) | Shape memory device | |
CN105487986B (en) | Sizing a cache memory to account for total byte write requirements | |
CN104750618B (en) | Data storage device and flash memory control method | |
WO2015185002A1 (en) | Method and device for writing data | |
US12086467B2 (en) | Read performance of memory devices | |
US11176035B2 (en) | Data storage devices and data processing methods | |
TWI707232B (en) | Flash memory controller and associated accessing method and electronic device | |
CN101499315B (en) | Flash Memory Wear Leveling Method and Its Controller | |
TWI437569B (en) | Method for managing a plurality of blocks of a flash memory, and associated memory device and controller thereof | |
US20180341418A1 (en) | Morphic storage device | |
CN102637145B (en) | Method for block management, memory device and controller thereof | |
TWI692688B (en) | Flash memory controller and associated electronic device | |
TWI450271B (en) | Method for managing a plurality of blocks of a flash memory, and associated memory device and controller thereof | |
CN108563397A (en) | storage device and data storage method | |
US20170285961A1 (en) | 3d stackable hybrid phase change memory with improved endurance and non-volatility | |
US20190012260A1 (en) | Flash memory package and storage system including flash memory package | |
US20220171562A1 (en) | Garbage collection in a memory component using an adjusted parameter | |
CN110275678B (en) | STT-MRAM-based solid state memory device random access performance improvement method | |
JP2010152778A (en) | Semiconductor storage device | |
TWI420528B (en) | Method for enhancing performance of a flash memory, and associated portable memory device and controller thereof | |
CN102637146B (en) | Method for block management, memory device and controller 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 |