This Application claims priority of China Patent Application No. 200810149370.6, filed on Sep. 23, 2008, the entirety of which is incorporated by reference herein.
1. Field of the Invention
The invention relates to wear leveling methods and related apparatuses for storage medium management systems, and more particularly, to wear leveling methods and related apparatuses for medium management systems of mass storage equipment.
2. Description of the Related Art
Non volatile memory such as an electronically erasable programmable read-only memory (EEPROM), is a mass storage medium having a physical character that writes data by a data unit and erases data by data blocks. The non volatile memory is formed by one or more storage units, wherein each storage unit stores one or more data bits. EEPROM is typically used in Plug & Play cards for storing hardware configuration data and also used in a “hardware lock” for preventing software from being copied by unauthorized users.
Generally, EEPROM performs erase operations by dividing the storage units into erasable blocks. However, during operation, due to physical limitations of the EEPROM, useable lifespan of the erasable blocks are relatively short. Specifically, the number of times a single erasable block of an EEPROM can be erased/rewritten is usually within the 100000-1000000 range. Thus, during erase operations, if a specific block is frequently erased and the useable lifespan is exhausted, the useable lifespan of the entire storage medium is affected.
Therefore, a wear leveling technique is used with the erase operation so that blocks to be erased are distributed more evenly. One direct method for implementing the wear leveling technique is to record an erase count for each block and select the block with the lowest erase count as the block to be erased.
However, a drawback to the direct method for erase count recording is that the erase counts for the data blocks may be lost when a power is off during the block erase operation. In such a case, a deviation may occur in the subsequent block wear leveling processes, wherein the erase count record of blocks may not match the actual useable lifespan of the blocks.
A memory system, wear leveling method and apparatus for a non volatile memory are disclosed to overcome the aforementioned problems.
A wear leveling method for a non-volatile memory, wherein the non-volatile memory includes a plurality of data blocks and a key table corresponding to the plurality of data blocks, the method comprising: arranging the key table according to a sequence of time values corresponding to the plurality of data blocks, determining whether to execute an erase operation for at least one of the plurality of data blocks according to the arranged sequence of the plurality of data blocks indicated in the arranged key table; and updating the time values of the at least one data block in response to the erase operation of the at least one data block is determined to be executed,
A wear leveling apparatus for a non-volatile memory, wherein the non-volatile memory includes a plurality of data blocks and a key table corresponding to the plurality of data blocks, the apparatus comprising a level shifting module, arranging the key table according to a sequence of time values corresponding to the plurality of data blocks, an erase determination module coupled to the level shifting module, determining whether to execute an erase operation for at least one of the plurality of data blocks according to the arranged sequence of the plurality of data blocks indicated in the arranged key table; and a recording module, couple to the erase determination module, updating the time values of the at least one data block in response to the erase operation of the at least one data block is determined to be executed.
A memory system is further disclosed. The memory system comprises a plurality of data blocks and a key table corresponding to the plurality of data blocks, wherein the data blocks are erasable; an address mapping apparatus, storing physical addresses of the plurality of data blocks and recording a time value corresponding to the plurality of data blocks after at least one of the plurality of data blocks have been erased; a wear leveling apparatus connected to the address mapping apparatus, determining whether to execute a recycling erase operation for the plurality of data blocks according to a random number and a wear leveling seed; and a storage space recycling apparatus, managing the erased at least one of the plurality of data blocks for data rewriting or reading.
Embodiments of the invention utilize erase time stamps for erasable blocks as erase marks to reflect wear statuses for the data blocks and utilize a wear leveling seed to restrict wear leveling.
The invention can be more fully understood by reading the subsequent detailed description and examples with reference to the accompanying drawings, wherein:
The following description is of the best-contemplated mode of carrying out of the invention. This description is made for the purpose of illustrating the general principles of the invention and should not be taken in a limiting sense. The scope of the invention is best determined by reference to the appended claims.
To solve the aforementioned problems in the current art, embodiments of the invention utilize erase time stamps for erasable blocks as erase marks to reflect wear statuses for the data blocks and utilize a wear leveling seed to restrict wear leveling.
Concepts of the invention for time stamp and wear leveling seed are first illustrated. The time stamp represents a recorded system time in each erasable block in the EEPROM flash when an erase operation is executed, and the time stamp may be stored in different positions such as being stored within the erasable block, a fixed position in the EEPROM or an external space. The wear leveling seed is defined as a constant for restricting wear leveling time.
The non volatile memory may comprise multiple data blocks and a key table which is formed according to the data blocks. Note that the invention is mainly applied in the wear leveling module 142 of the medium management layer software 14.
The wear leveling module may also comprise a recording module for updating the time values of the data blocks (not shown in the figures). The recording module may be connected to the erase determination module 1422. When the erase operating is determined to be executed by the erase determination module 1422, the recording module obtains a current system time value and compares the current system time value with the latest time value that is stored within the plurality of data blocks when the current system time value is later than the latest time value, the recording module records the current system time value, and when the current system time value is earlier than the latest time value, the level shifting module 1421 adds a predetermined increment to the latest time value and configures the added time value to be the current system time value. Of course, the updating of the system time could be performed by the level shifting module 1421 or the erase determination module 1422 without an additional module. The combination or alternation of the idea in the invention may be understood by the skilled person in the art.
When the erase operation has been performed, a current system time value for when the erasable block was erased, i.e. a time stamp after the erase operation was performed, is needed to be recorded into the erasable block and then the block is linked to the tail of the key table. Referring to
After step 450 or step S470 has been successfully performed, step S460 is further performed such that the block A is linked to the tail of the erasable key table that is arranged according to a sequence of the erase time stamps. Thereafter, the step ends.
When free spaces within the system are less than external request spaces or the background operation of the system needs operations, such as a disk arrangement operation or the like, to be performed, a recycling process will be performed. When the recycling process is required to be performed for the system, a wear leveling seed may further be utilized to efficiently manage both the system performance and wear leveling seed.
The dirtiest block mentioned in step S520 is detailed in the following. As an example, in a NOR flash, it is assumed that size of each erasable block is 64K and storage space of each erasable block can be arranged based on a sector size thereof. It is assumed that, in this embodiment, sector size of each erasable block is 128 bytes and thus one erasable block may comprise 512 sectors, wherein each sector has 128 bytes. When the file system writes data in an erasable block of the NOR flash, programming operations are performed thereto in which a sector is as a minimum written unit. In other words, at least 128 bytes will be written for each write operation.
Due to the characteristics of the NOR flash, data physically stored within the NOR flash can only vary from 1 to 0 rather than from 0 to 1 by the program operation. If the data must be varied from 0 to 1, the entire block must be erased and changed back to 1. In this case, when modification of data in a specific sector within the erasable block is required, the available data to be written can not be directly overlapped to the specific sector and instead, must be written into a free sector that is a sector without data from current blocks or other blocks and the sector that originally maps to the same logical address will be marked as a useless data sector.
To determine the dirtiest block, typically, all erasable blocks will be ergodiced when the system is initializing and a number of available data sectors, a number of useless data sectors and a number of free data sectors within the data blocks are calculated and stored into corresponding data structures in the system memory. During operation, the data structures are simultaneous updated. When attempting to determine the dirtiest block, only statistical information stored within the memory need to be accessed to determine a block that comprises maximum number of useless data sectors as the dirtiest block. In other words, an erasable block is referred to as the dirtiest block when the erasable block comprises the maximum number of useless data sectors, such as the block A in step S520. Techniques regarding determination of the dirtiest block are well-known, and thus detailed descriptions are omitted.
Referring again to
random % (wear-leveling seed)==1 (1),
wherein random represents a random number, which is a pseudo-random number (approximate to an ideal random number) in practice, obtained by standard functions random( ) or others. The wear-leveling seed represents a wear leveling seed which is typically a constant value obtained by experimentation. For example, if the wear leveling seed is set to be 50 and the random is an ideal random number, the probability of wear leveling occurrence is set to be 1/50 with a calculation by the Formula (1), i.e. the probability of wear leveling occurrence is restricted to 1/50. It is to be noted that a remainder of the random number divided by a wear leveling seed may be other values, such as 2, 3, and so on. As one skilled in the art will appreciate, the remainder may be configured to any value dependant upon design requirements.
The value of the wear leveling seed can be flexibly selected based on the capacity of the storage medium, by mainly selecting the experience value. However, as capacity of the storage medium increases, the blocks will grow in number and requirement for the wear leveling process will be reduced due to randomness existing, when the storage medium is used by the user. Thus, a large value can be selected as the value of the wear leveling seed.
Referring again to
Regarding steps S530, S540, S570 to S560, please refer to
Embodiments of the invention utilize erase time stamps for erasable blocks as erase marks to reflect wear statuses for the data blocks and utilize a wear leveling seed to restrict wear leveling. Thus, deviation in subsequent block wear leveling processes, wherein the erase count record of blocks do not match the actual useable lifespan of the blocks are prevented.
Wear leveling apparatuses and control methods thereof, or certain aspects or portions thereof, may take the form of a program code (i.e., executable instructions) embodied in tangible media, such as floppy diskettes, CD-ROMS, hard drives, or any other machine-readable storage medium, wherein, when the program code is loaded into and executed by a machine, such as a computer, the machine thereby becomes an apparatus for practicing the methods. The methods may also be embodied in the form of a program code transmitted over some transmission medium, such as electrical wiring or cabling, through fiber optics, or via any other form of transmission, wherein, when the program code is received and loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the disclosed methods. When implemented on a general-purpose processor, the program code combines with the processor to provide a unique apparatus that operates analogously to application specific logic circuits.
Certain terms are used throughout the description and claims to refer to particular system components. As one skilled in the art will appreciate, consumer electronic equipment manufacturers may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function.
While the invention has been described by way of example and in terms of preferred embodiment, it is to be understood that the invention is not limited thereto. To the contrary, it is intended to cover various modifications and similar arrangements (as would be apparent to the skilled in the art). Therefore, the scope of the appended claims should be accorded to the broadest interpretation so as to encompass all such modifications and similar arrangements.
| Number | Date | Country | Kind |
|---|---|---|---|
| 200810149370.6 | Sep 2008 | CA | national |