1. Field of the Invention
The present invention relates to a method of dynamically adjusting a mapping manner in a non-volatile memory and a non-volatile storage device using the same, and more particularly, to a method of dynamically adjusting a mapping manner in a non-volatile memory capable of dynamically mapping logical address to physical address using cluster mapping and block mapping in the non-volatile memory according to an amount of valid data existing in the non-volatile memory and a non-volatile storage device using the same.
2. Description of the Prior Art
A memory controller is commonly utilized for task management in a memory system, especially in a non-volatile memory system. In general, since data stored in a non-volatile memory system may not be lost after electric power of the non-volatile memory system is cut off, the non-volatile memory system becomes an important means to store system data. Among those non-volatile memory systems, NAND flash memory, which has advantages of low power and high speed, becomes popular with the popularization of portable devices in recent years.
In the NAND flash memory, read/write operation is performed based on a unit of page, and erasing operation is performed based on a unit of block, where a block size is usually far greater than a page size. In general, a block may be composed of 64 or 128 pages. When a user needs to access data in the NAND flash memory, the corresponding data address should be mapped from the logical block to the physical block. There are two commonly used methods for this mapping: page mapping and block mapping. According to the page mapping method, the data address is mapped from the logical page to the physical page. In other words, when a page of new data needs to be written in the memory, an empty physical page is found and this new data is written in the physical page. At least one mapping table then records the address of the physical page corresponding to the logical page. When the page mapping method is applied, however, the size of the mapping tables becomes very large. Therefore, if there is a large amount of valid data in the NAND flash memory and page mapping is applied, when sequential write is performed, the memory controller may have to make a lot of efforts to merge valid data (ex: garbage collection) and update the mapping tables, which significantly reduces writing performance of the NAND flash memory.
In order to enhance the writing performance, the block mapping method can be applied. According to the block mapping method, the data address is mapped from the logical block to the physical block, so that the mapping table only needs to record the address of the physical block corresponding to each logical block. As mentioned above, a block size is far greater than a page size, which means that the number of blocks is far smaller than the number of pages in a memory system; hence the size of the mapping table can be reduced. According to the block mapping method, when a page of data in a first block needs to be updated by new data, a second block is selected and the new data is written into the corresponding physical page in the second block. In addition, data in other pages in the first block should be copied to the corresponding pages in the second block. When there is a large amount of valid data and sequential write is performed, the efficiency of updating the mapping table and performing data merge are enhanced if block mapping is applied.
However, when the amount of valid data is less, block mapping updates an entire block even if there is only one page of data required to be updated, which reduces efficiency considerably. Therefore, the industry has developed a hybrid mapping method combining block mapping and page mapping. The hybrid mapping method divides the physical block into a page mapping portion and a block mapping portion. However, in a conventional hybrid mapping system, the number of physical blocks in the page mapping portion and the number of physical blocks in the block mapping portion are always fixed. The physical blocks using page mapping cannot be re-allocated to the block mapping portion, and the physical blocks using block mapping cannot be re-allocated to the page mapping portion. Since page mapping and block mapping are preferable in different cases, such a hybrid mapping system cannot enjoy the benefits of page mapping and block mapping effectively in each case. Thus, there is a need for improvement over the prior art.
It is therefore an objective of the present invention to provide a method of dynamically adjusting a mapping manner in a non-volatile memory capable of dynamically mapping logical address to physical address using cluster mapping and using block mapping in the non-volatile memory according to an amount of valid data existing in the non-volatile memory and a non-volatile storage device using the same.
The present invention discloses a method of dynamically adjusting a mapping manner for a non-volatile memory. The non-volatile memory comprises a plurality of physical blocks, and each of the plurality of physical blocks comprises a plurality of physical pages. The method comprises mapping a plurality of logical addresses to a plurality of physical addresses by a first mapping unit; storing data in the non-volatile memory by the first mapping unit; and mapping at least one logical address to at least one physical address by a second mapping unit according to the stored data.
The present invention further discloses a non-volatile storage device. The non-volatile storage device comprises a non-volatile memory, comprising a plurality of physical blocks, each of the plurality of physical blocks comprising a plurality of physical pages; and a memory controller, coupled to the non-volatile memory, for dynamically adjusting a mapping manner for the non-volatile memory by executing the following steps: mapping a plurality of logical addresses to a plurality of physical addresses by a first mapping unit; storing data in the non-volatile memory by the first mapping unit; and mapping at least one logical address to at least one physical address by a second mapping unit according to the stored data.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
Please refer to
Please note that, the memory controller 102 is capable of dynamically adjusting the mapping manner for the data stored in the non-volatile memory 100. More specifically, a block originally using block mapping may be re-allocated to use cluster mapping, and a block originally using cluster mapping may be re-allocated to use block mapping. For example, if there are X physical blocks in the non-volatile memory 100, there may be N physical blocks B1-BN using block mapping and M physical blocks C1-CM using cluster mapping, and the values N and M should be variable. For the physical blocks B1-BN, the logical block addresses are mapping to the physical block addresses. For the physical blocks C1-CM, the logical cluster addresses are mapping to the physical cluster addresses. N should be equal to a value between 0 and X, and when N=0, the mapping manner for the non-volatile memory 100 is equivalent to pure cluster mapping. M should also be equal to a value between 0 and X, and when M=0, the mapping manner for the non-volatile memory 100 is equivalent to pure block mapping.
As mentioned above, a mapping with a smaller unit such as page mapping or cluster mapping is preferable when the amount of valid data is less, and block mapping is preferable when the amount of valid data is large. Therefore, the amount of valid data can be considered as a threshold for determining the number of physical blocks to be allocated to use block mapping. In an embodiment, the memory controller 102 may monitor the amount of valid data in each logical block of the non-volatile memory 100. Data stored in the logical block may originally be mapping to physical clusters in several physical blocks using cluster mapping, and when the amount of valid data in the logical clusters within the logical block exceeds a specific amount, this logical block maybe re-allocated to use block mapping. In detail, data in the corresponding physical clusters may be moved to another physical block, and block mapping is applied to map the logical block to this physical block.
Please refer to
In an embodiment, the memory controller 102 may determine a number of physical blocks among the plurality of physical blocks to use block mapping according to the total amount of valid data in the whole non-volatile memory 100. When the amount of valid data is smaller than a threshold, a larger number of the physical blocks may be allocated to use cluster mapping. When the amount of valid data is greater than the threshold, a smaller number of the physical blocks may be allocated to use cluster mapping. For example, the threshold may be determined to be 80 percent of the storage space of the non-volatile memory 100. If more than 80% of the storage space in the non-volatile memory 100 is filled with valid data, there may be 60% of the logical blocks mapping to the physical blocks using block mapping, and 40% of the logical blocks having logical clusters mapping to physical clusters in the physical blocks using cluster mapping. If less than 80% of the storage space in the non-volatile memory 100 is filled with valid data, there may be only 30% of the logical blocks mapping to the physical blocks using block mapping, and 70% of the logical blocks having logical clusters mapping to physical clusters in the physical blocks using cluster mapping.
Please refer to
At time T(Z), the amount of valid data may exceed the specific threshold; hence block mapping starts to be applied. In an embodiment, when the amount of valid data in a specific logical block exceeds a threshold, this logical block is transferred to use block mapping. In detail, a new physical block is assigned and data stored in physical clusters mapping to logical clusters of the logical block is copied to the new physical block, and thus the logical block can be mapping to this new physical block using block mapping. In an embodiment, the amount of valid data in the whole non-volatile memory 100 exceeds a threshold, and the memory controller 102 may allocate a part of logical blocks originally using cluster mapping to change to use block mapping. In general, a logical block with more valid data is more likely to change to use block mapping.
At time T(W), the amount of valid data is increased continuously and exceeds another threshold, so that more logical blocks are mapping to physical blocks using block mapping. Since the amount of valid data is too large, the operation of collecting valid data through the non-volatile memory 100 may cause a lot of efforts on the memory controller 102 if cluster mapping is applied. In such a condition, it is more desirable to apply block mapping to the new arrival data or to transfer the original cluster mapping blocks to use block mapping instead.
At time T(S), a trim or discard instruction may be sent to the non-volatile memory 100. When data is moved within the non-volatile memory 100 due to the operations such as trim, wear-leveling and mapping transformation, some data stored in the non-volatile memory may be marked as invalid data. When the amount of invalid data increases and occupies considerable storage space, the memory controller 102 may use the garbage collection to erase the invalid data, in order to clear out the memory space. In general, a physical block with more invalid data is more likely to undergo the garbage collection. After garbage collection is performed on a physical block, the physical block is cleared out to be an unmapped block and can be utilized for storing new data. Therefore, the number of unmapped blocks may be increased.
Please note that, the present invention is capable of dynamically adjusting a mapping manner between logical addresses and physical addresses in the non-volatile memory by using either cluster mapping or block mapping. The ratio of storage space using block mapping or cluster mapping can be managed in different conditions such as the amount of valid data. Those skilled in the art can make modifications and alternations accordingly. For example, the threshold for the amount of valid data in a logical block or in the non-volatile memory can be determined arbitrarily. These parameters may be determined according to system requirements, in order to achieve maximum writing performance. Besides, the above method of dynamically adjusting the mapping manner can be applied for any types of non-volatile memories, which may include, but should not be limited to, a single-level cell (SLC) NAND flash memory, multi-level cell (MLC) NAND flash memory, magnetoresistive random access memory (MRAM) or ferroelectric random access memory (FRAM). In addition, the adjustment of block mapping blocks and cluster mapping blocks may be determined by any reasons or in any manners, which should not be limited to the amount of valid data only.
For example, the mapping manner of block mapping or cluster mapping may be controlled according to the properties of arrival data. If a data needs to be written into the non-volatile memory, the memory controller may determine whether the arrival data is hot data (e.g. data with size smaller than 4 kB) or cold data (e.g. data with greater size). If the arrival data is hot data, the memory controller may map a logical address to a physical address using cluster mapping. If the arrival data is cold data, the memory controller may map a logical address to a physical address using block mapping.
The above method of dynamically adjusting the mapping manner for a plurality of logical blocks in the non-volatile memory performed by the memory controller can be summarized into a process 40, as shown in
Step 400: Start.
Step 402: Map a plurality of logical addresses to a plurality of physical addresses by a first mapping unit.
Step 404: Store data in the non-volatile memory by the first mapping unit.
Step 406: Map at least one logical address to at least one physical address by a second mapping unit according to the stored data.
Step 408: End.
The abovementioned mapping manners include a cluster mapping, page mapping and block mapping. It deserves to be mentioned here that the cluster mapping unit is smaller than the page mapping unit, and that the page mapping unit is smaller than the block mapping unit. In the above embodiments, the method of dynamically adjusting the mapping manners in the non-volatile memory uses cluster mapping and block mapping interchangeably. In other embodiments, the method of dynamically adjusting the mapping manners in the non-volatile memory may also use page mapping and block mapping interchangeably. In general, when there is less valid data, it is more desirable to apply the page mapping or cluster mapping (with smaller mapping unit); when there is more valid data, it is more desirable to apply the block mapping (with larger mapping unit).
In the prior art, if there is a large amount of valid data in the non-volatile memory and page mapping is applied, when sequential write is performed, the memory controller has to make a lot of efforts to merge valid data and update the mapping tables, which significantly reduces writing performance of the non-volatile memory. If the amount of valid data is less and block mapping is applied, the controller has to process an entire block even if there is only one page of data required to be updated, so that the efficiency will be reduced. Even if the hybrid mapping is applied, the number of blocks in the page mapping portion and the number of blocks in the block mapping portion are always fixed. Since page mapping and block mapping are preferable in different cases, such hybrid mapping systems cannot enjoy the benefits of page mapping and block mapping effectively in each case. In comparison, the present invention provides a method of dynamically adjusting a mapping manner in the non-volatile memory. The method is capable of storing data using cluster mapping and using block mapping dynamically in the non-volatile memory in different conditions. Therefore, the mapping manner of the present invention can be optimized for the writing performance of the non-volatile memory.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.
This application claims the benefit of U.S. Provisional Application No. 61/818,884, filed on May 2, 2013 and entitled “Address transfer & data management for a non-volatile memory”, the contents of which are incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
61818884 | May 2013 | US |