This application claims the benefit of People's Republic of China application Serial No. 201010145070.8, filed Mar. 24, 2010, the subject matter of which is incorporated herein by reference.
The present invention relates to a wear leveling method of a non-volatile memory, and more particularly to a wear leveling method of a non-volatile memory according to the corresponding history number.
Typically, memory is categorized to two types, one is volatile memory and the other is non-volatile memory. The main difference between the volatile memory and the non-volatile memory is about the data stored in the memory while the power supplied to the memory is removed. That is, the data stored in the volatile memory, such as a static random access memory (SRAM) and a dynamic random access memory (DRAM), is gone after the power supplied to the volatile memory is removed. On other hand, the data stored in the non-volatile memory, such as an electrically-erasable read-only memory (EEROM) and an electrically-erasable programmable read-only memory (EEPROM), is still existed while the power supplied to the non-volatile memory is removed. However, the read/write speed of the non-volatile memory, compared with the volatile memory, is relatively low.
According to the specifications of the non-volatile memory, a single page is the unit of writing data into or reading data from a non-volatile memory and a single block is the unit of erasing data from a non-volatile memory. In other words, data can be written into an individual page, data can be read from an individual page, but data in several pages belonging to the same block must be erased together. For example, data can be written to or read from the individual Page-5 of Block-1; however, the data contained in the Page-5 cannot be erased individually but must be erased along with all other pages belonging to the Block-1. Moreover, data stored in a page cannot be directly updated. For example, if the data stored in Page-5 needs updating, the updated data must be first written to a new page, and the data stored in the Page-5 is then erased later for writing the updated data.
Because the special read/write data characteristics, the non-volatile memory is not compatible to the main computer file systems (e.g., FAT16/32, NTFS). For the compatibility to the main computer file systems (e.g., FAT16/32, NTFS), a flash translation layer table (FTL Table) is introduced in the non-volatile memory system. The flash translation layer table (FTL Table) is used for mapping addresses between a logical block address (LBA) and a physical block address (PBA). That is, the logical block address (LBA) issued from the host system is first mapped to the physical block address (PBA) according to the flash translation layer table (FTL Table), and then allocated to the non-volatile memory according to the physical block address (PBA). Moreover, the flash translation layer table (FTL Table) is typically stored in the random access memory (RAM) 112, so as the accessing speed of the non-volatile memory is enhanced.
As mentioned above, the unit of erasing data from the non-volatile memory is a block. However, the number of times of each of the block can be erased is limited (e.g., a hundred thousand times) due to the physical structure of the non-volatile memory. If a block is erased more than a specific time and data cannot be correctly or completely stored in the block, the block is worn out and cannot be used anymore.
Data stored in a non-volatile memory is generally categorized to either a cold data or a hot data based on the frequency of updating. In other words, if a data (such as a system program code or a multimedia data) almost has no need to be updated, the data is often categorized to the cold data; alternatively, if a data (such as a log file) which needs frequently to be updated, the data is most likely categorized to the hot data. If clod data is always stored in specific blocks and hot data is always stored in other specific blocks, obviously the blocks always containing hot data will be worn out much earlier than the blocks always containing cold data. For an even and fair use of all the blocks within a non-volatile memory, wear leveling is introduced in the non-volatile memory. The main purpose of wear leveling is to move the cold data from a block with a fewer erase count to another block with a higher erase count, where the above moving of a data is often called a swap and the erase count stands for the number of times of a corresponding block which has been erased. If a clod data is moved to a block with a higher erase count, the block with a higher erase count will not be updated so often from now on due to the cold data is contained in the block. Once all the blocks containing cold data are processed by the wear leveling, blocks in the non-volatile memory may be more evenly utilized, and accordingly the life of the non-volatile memory is enhanced.
A wear leveling method is disclosed in a United State patent (U.S. Pat. No. 7,035,967 B2).
To start, an initialization request may be received by a memory controller which is in communication with the non-volatile memory in step 302. Such a request may be issued by a user via a host at power up, or issued by the host system under some specific conditions.
Once the initialization request is received, all the erased blocks within the non-volatile memory are identified in step 304. In step 306, N erased blocks with relatively high erase counts out of all the erased blocks are assigned to the most-frequently-erased group. The selection of the N erased blocks with relatively high erase counts can be done through comparing the erase counts of all the erased blocks, where the information about the erase count is stored in the overhead data (OH) as mentioned above. Moreover, the number N can be determined based on the total number of the blocks within the non-volatile memory. Moreover, assigning the N erased blocks with relatively high erase counts to the most-frequently-erased group can be achieved through updating the flash translation layer table (FTL Table).
In step 308, M erased blocks with relatively low erase counts out of all the erased blocks are assigned to the least-frequently-erased group. Similarly, the selection of the M erased blocks with relatively low erase counts can be done through comparing the erase counts of all the erased blocks. Moreover, the number M can be determined based on the total number of the blocks within the non-volatile memory. Moreover, assigning the M erased blocks with relatively low erase counts to the least-frequently-erased group can be achieved through updating the flash translation layer table (FTL Table).
Remaining erased blocks, i.e., erased blocks which have not been assigned to either the most-frequently-erased group or the least-frequently-erased group, are assigned to the mapping group along with the unerased blocks in step 310. In other words, remaining erased blocks as well as blocks containing user data are assigned to the mapping group. It is understood that the erase counts of the erased blocks assigned to the mapping group are in between the erase counts of the erased blocks in the most-frequently-erased group and the least-frequently-erased group.
After all the blocks within the non-volatile memory are assigned to either the most-frequently-erased group, the least-frequently-erased group, or the mapping group, an average erase count of the non-volatile memory is obtained in step 312. The average erase count of the non-volatile memory is obtained through summing the erase counts of individual blocks in the non-volatile memory and dividing the sum by the total number of blocks.
Once the process of the initialization of the wear leveling depicted in
Select a block (Block-C) from the least-frequently-erased group and move the block (Block-C) into the most-frequently-erased group in step 412. Typically, block (Block-C) is the block with the highest erase count in the least-frequently-erased group. Moreover, such move of block (Block-C) allows a space in the least-frequently-erased group to effectively be opened up to the block (Block-A). Then, move the block (Block-A) from the mapping group into the least-frequently-erased group in step 414. Afterwards, move the block (Block-B) to the mapping group in step 416 due to the block (Block-B) now is contained with a cold data.
Via the process of the wear leveling depicted in
Once all the blocks containing cold data are processed by the wear leveling depicted in
The known wear leveling method uses the erase count as an indication for evenly utilizing the non-volatile memory. The present invention uses another parameter as the indication for the wear leveling method.
Therefore, the present invention relates to wear leveling method adopting a history number, which stands for an absolute time of a block has been written recently, as a main indication.
The present invention provides a wear leveling method, applied to a non-volatile memory containing a plurality of blocks, comprising steps of: assigning the blocks to either a first group, a second group, or a third group according to the corresponding history numbers and data stored in the blocks, wherein the history number indicates an absolute time of writing data into the corresponding block, the first group contains N erased blocks with relatively high history numbers, the second group contains M erased blocks with relatively low history numbers, and the third group contains the remaining blocks not either assigned to the first group or the second group; calculating an average history number of the non-volatile memory; selecting a first block containing a clod data from the third group; selecting a second block from the first group; copying the cold data from the first block into the second block, and updating the history number of the second block according to the absolute time of writing the cold data into the second block; and erasing the first block.
The above objects and advantages of the present invention will become more readily apparent to those ordinarily skilled in the art after reviewing the following detailed description and accompanying drawings, in which:
Instead of adopting the erase count as the main indication in the conventional wear leveling methods, the wear leveling method of the present invention adopts a history number as a main indication.
Generally, in a host system including a non-volatile memory device, there is a parameter for recording an absolute time of a block last time has been written. The absolute time is counted initially from the first-time powered up of the host system and increased by one every two minutes. For example, if a data is written into a block at a first absolute time after the first-time powered up of the host system, the first absolute time is recorded by the host system and regarded as the history number of the corresponding block. If another data is written into the same block at a second absolute time after the first absolute time, the second absolute time is recorded by the host system and the history number of the corresponding block is updated to the second absolute time.
Obviously, if the history number of a block is far less than an average history number of all the blocks within a non-volatile memory, the last time of the block has been written data is relatively far away from now, so as the data contained in the block has not been updated for a relatively long time, accordingly the data contained in the block is most likely a cold data. Alternatively, if the history number of a block is far higher than an average history number of all the blocks within a non-volatile memory, the last time of the block has been written data is relatively near now, so as the data contained in the block has been updated recently, accordingly the data contained in the block is most likely a hot data. Therefore, based on the characteristic of the history number, the history number is adopted as a main indication in the wear leveling method of the present invention. That is, cold data is moved to a block with a relatively high history number in the wear leveling method of the present invention, so as the blocks within the non-volatile memory are more evenly utilized.
To start, an initialization request may be received by a memory controller which is in communication with the non-volatile memory in step 502. Such a request may be issued by a user via a host at power up, or issued by the host system under some specific conditions.
Once the initialization request is received, all the erased blocks within the non-volatile memory are identified in step 504. In step 506, through comparing the history numbers of all the blocks with a predefined high history number, assign N erased blocks with relatively high history numbers out of all the erased blocks to the highest-history-number-erased group. Moreover, the number N can be determined based on the total number of the blocks within the non-volatile memory. Moreover, assigning the N erased blocks with relatively high history numbers to the highest-history-number-erased group can be achieved through updating the flash translation layer table (FTL Table).
In step 508, through comparing the history numbers of all the blocks with a predefined low history number, assign M erased blocks with relatively low history numbers out of all the erased blocks to the lowest-history-number-erased group. Similarly, the number M can be determined based on the total number of the blocks within the non-volatile memory. Moreover, assigning the M erased blocks with relatively low history numbers to the lowest-history-number-erased group can be achieved through updating the flash translation layer table (FTL Table).
Remaining erased blocks, i.e., erased blocks which have not been assigned to either the highest-history-number-erased group or the lowest-history-number-erased group, are assigned to the mapping group along with the unerased blocks in step 510. In other words, remaining erased blocks as well as blocks containing user data are assigned to the mapping group. It is understood that the history numbers of the erased blocks assigned to the mapping group are in between the history numbers of the erased blocks in the highest-history-number-erased group and the lowest-history-number-erased group.
After all the blocks within the non-volatile memory are assigned to either the highest-history-number-erased group, the lowest-history-number-erased group, or the mapping group, an average history number of the non-volatile memory is obtained in step 512. The average history number of the non-volatile memory is obtained through summing the history numbers of individual blocks in the non-volatile memory and dividing the sum by the total number of blocks.
Once the process of the initialization of the wear leveling depicted in
Select a block (Block-Z) from the lowest-history-number-erased group and move the block (Block-Z) into the highest-history-number-erased group in step 612. Typically, block (Block-Z) is the block with the highest history number in the lowest-history-number-erased group. Moreover, such a move of block (Block-Z) allows a space in the lowest-history-number-erased group to effectively be opened up to the block (Block-X). Then, move the block (Block-X) from the mapping group into the lowest-history-number-erased group in step 614. Afterwards, move the block (Block-Y) to the mapping group in step 616 due to the block (Block-Y) now is contained with a cold data.
Via the process of the wear leveling depicted in
Once all the blocks containing cold data are processed by the wear leveling of the present invention, the wear leveling of the non-volatile memory is done, so as the blocks within the non-volatile memory are more evenly utilized.
In the embodiment, categorizing blocks to either the mapping group, the highest-history-number-erased group, or the lowest-history-number-erased group is based on comparing the history numbers of all blocks with the predefined high history number and the predefined low history number. However, blocks within a non-volatile memory can be categorized more than these three groups if necessary. The process of wear leveling method based on more than three groups is similar to the wear leveling method described above and the detail is not given here.
While the invention has been described in terms of what is presently considered to be the most practical and preferred embodiments, it is to be understood that the invention needs not be limited to the disclosed embodiment. On the contrary, it is intended to cover various modifications and similar arrangements included within the spirit and scope of the appended claims which are to be accorded with the broadest interpretation so as to encompass all such modifications and similar structures.
Number | Date | Country | Kind |
---|---|---|---|
201010145070.8 | Mar 2010 | CN | national |