# Patent

## Title
Biasing for wear leveling in storage systems

## Abstract

The various implementations described herein include systems, methods and/or devices used to enable biasing for wear leveling in storage systems. In one aspect, the method includes (1) determining, for each erase unit of a plurality of erase units in the storage medium, an age metric, (2) determining a representative age metric of the plurality of erase units, (3) for each respective erase unit of the plurality of erase units, biasing a respective garbage collection control metric for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units to generate an adjusted garbage collection control metric for the respective erase unit, and (4) performing garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units.

## Background
RELATED APPLICATION
This application claims priority to U.S. Provisional Patent Application Ser. No. 61/893,102, filed Oct. 18, 2013, entitled “Biasing for Wear Leveling in Storage Systems,” which is hereby incorporated by reference in its entirety.


TECHNICAL FIELD
The disclosed embodiments relate generally to memory systems, and in particular, to biasing for wear leveling for a storage medium in a storage system.
BACKGROUND
Semiconductor memory devices, including flash memory, typically utilize memory cells to store data as an electrical value, such as an electrical charge or voltage. A flash memory cell, for example, includes a single transistor with a floating gate that is used to store a charge representative of a data value. Flash memory is a non-volatile data storage device that can be electrically erased and reprogrammed. More generally, non-volatile memory (e.g., flash memory, as well as other types of non-volatile memory implemented using any of a variety of technologies) retains stored information even when not powered, as opposed to volatile memory, which requires power to maintain the stored information.
Historically, wear leveling has been defined as a technique used to distribute program-erase cycles as evenly as possible across units of a memory device. For example, for a flash memory device, if a particular block of memory is programmed and erased repeatedly without writing to any other blocks, the one block of memory would wear out before all the other blocks, prematurely ending the life of the memory device. Ideally, wear leveling would enable every block to be used to its maximum life. However, even with uniform workloads, simply distributing program-erase cycles as evenly as possible across all the units of a memory device may not maximize the life of the memory device. Since different units of a memory device may have different wear characteristics, it is important to utilize a wear leveling scheme that accounts for different wear characteristics.
SUMMARY
Various implementations of systems, methods and devices within the scope of the appended claims each have several aspects, no single one of which is solely responsible for the attributes described herein. Without limiting the scope of the appended claims, after considering this disclosure, and particularly after considering the section entitled “Detailed Description” one will understand how the aspects of various implementations are used to enable biasing for wear leveling in storage systems. In one aspect, garbage collection is performed in accordance with garbage collection control metrics of a plurality of erase units, each garbage collection control metric biased in accordance with an age metric of a respective erase unit in relation to the representative age metric of the plurality of erase units.



BRIEF DESCRIPTION OF THE DRAWINGS
So that the present disclosure can be understood in greater detail, a more particular description may be had by reference to the features of various implementations, some of which are illustrated in the appended drawings. The appended drawings, however, merely illustrate the more pertinent features of the present disclosure and are therefore not to be considered limiting, for the description may admit to other effective features.
FIG. 1 is a block diagram illustrating an implementation of a data storage system, in accordance with some embodiments.
FIG. 2A is a block diagram illustrating an implementation of a management module, in accordance with some embodiments.
FIG. 2B is a block diagram illustrating an implementation of a characterization vector table included in FIG. 2A, in accordance with some embodiments.
FIG. 2C is a block diagram illustrating an implementation of a characterization vector included in FIG. 2B, in accordance with some embodiments.
FIG. 3 is a block diagram of a plurality of erase units, in accordance with some embodiments.
FIGS. 4A-4D illustrate a flowchart representation of a method of wear leveling for a storage medium, in accordance with some embodiments.



In accordance with common practice the various features illustrated in the drawings may not be drawn to scale. Accordingly, the dimensions of the various features may be arbitrarily expanded or reduced for clarity. In addition, some of the drawings may not depict all of the components of a given system, method or device. Finally, like reference numerals may be used to denote like features throughout the specification and figures.
DETAILED DESCRIPTION
The various implementations described herein include systems, methods and/or devices used to enable biasing for wear leveling for a storage medium in a storage system. Some implementations include systems, methods and/or devices to perform garbage collection in accordance with garbage collection control metrics of a plurality of erase units, each garbage collection control metric biased in accordance with an age metric of a respective erase unit in relation to the representative age metric of the plurality of erase units.
More specifically, some implementations include a method of wear leveling for a storage medium in a storage system. In some implementations, the method includes (1) determining, for each erase unit of a plurality of erase units in the storage medium, an age metric, (2) determining a representative age metric of the plurality of erase units, (3) for each respective erase unit of the plurality of erase units, biasing a respective garbage collection control metric for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units to generate an adjusted garbage collection control metric for the respective erase unit, and (4) performing garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units.
In some embodiments, the garbage collection control metric is a valid-page count, and biasing the respective valid-page count for the respective erase unit includes (1) determining the respective valid-page count, wherein the respective valid-page count is a count of valid pages in the respective erase unit, (2) calculating a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units, (3) in accordance with a first determination, the first determination including a determination that the age metric of the respective erase unit is greater than the representative age metric of the plurality of erase units, adding the bias value to the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit, and (4) in accordance with a second determination, the second determination including a determination that the age metric of the respective erase unit is less than the representative age metric of the plurality of erase units, subtracting the bias value from the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit.
In some embodiments, calculating the bias value for the respective erase unit includes (1) calculating a difference between the age metric of the respective erase unit and the representative age metric of the plurality of erase units, (2) calculating a first value, the first value determined by multiplying the absolute value of the calculated difference by a predefined number of valid pages, wherein the first value is limited to a predefined maximum, and (3) setting the bias value equal to the first value.
In some embodiments, performing garbage collection for the storage medium includes selecting an erase unit with the lowest adjusted valid-page count for garbage collection.
In some embodiments, performing garbage collection for the storage medium includes performing garbage collection on a first erase unit with a first adjusted valid-page count prior to performing garbage collection on a second erase unit with a second adjusted valid-page count, wherein the first adjusted valid-page count is less than the second adjusted valid-page count.
In some embodiments, biasing the respective garbage collection control metric for the respective erase unit includes (1) determining the respective garbage collection control metric, (2) calculating a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units, including limiting a range of the bias value to a predefined range, and (3) mathematically adjusting the respective garbage collection control metric for the respective erase unit with the calculated bias value to generate the adjusted garbage collection control metric for the respective erase unit.
In some embodiments, the age metric for each erase unit is determined in accordance with a metric corresponding to an estimated remaining life of each erase unit.
In some embodiments, the erase unit is a single erase block.
In some embodiments, the erase unit is a super block, wherein the super block includes a plurality of erase blocks.
In some embodiments, the storage medium comprises one or more flash memory devices.
In some embodiments, determining, for each erase unit of a plurality of erase units in the storage medium, the age metric includes determining, for each storage unit of a plurality of storage units in the storage medium, an age metric for a respective storage unit, wherein each storage unit comprises a plurality of the erase units.
In another aspect, any of the methods described above are performed by a device operable to perform wear leveling for a storage medium, the device including (1) a storage medium interface for coupling the device to the storage medium, and (2) one or more modules, including a memory management module that includes one or more processors and memory storing one or more programs configured for execution by the one or more processors, the one or more modules coupled to the storage medium interface and configured to perform any of the methods described above.
In yet another aspect, any of the methods described above are performed by a device operable to perform wear leveling for a storage medium. In some embodiments, the device includes (1) a storage medium interface for coupling the device to the storage medium, (2) means for determining, for each erase unit of a plurality of erase units in the storage medium, an age metric, (3) means for determining a representative age metric of the plurality of erase units, (4) means for biasing, for each respective erase unit of the plurality of erase units, a respective garbage collection control metric for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units to generate an adjusted garbage collection control metric for the respective erase unit, and (5) means for performing garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units.
In yet another aspect, any of the methods described above are performed by a storage system comprising (1) a storage medium (e.g., comprising one or more non-volatile storage devices, such as flash memory devices) (2) one or more processors, and (3) memory storing one or more programs, which when executed by the one or more processors cause the storage system to perform or control performance of any of the methods described above.
In yet another aspect, a non-transitory computer readable storage medium stores one or more programs configured for execution by a device coupled to a storage medium, the one or more programs comprising instructions for causing the device and/or storage medium to perform any of the methods described above.
Numerous details are described herein in order to provide a thorough understanding of the example implementations illustrated in the accompanying drawings. However, some embodiments may be practiced without many of the specific details, and the scope of the claims is only limited by those features and aspects specifically recited in the claims. Furthermore, well-known methods, components, and circuits have not been described in exhaustive detail so as not to unnecessarily obscure more pertinent aspects of the implementations described herein.
FIG. 1 is a diagram of an implementation of a data storage system 100, in accordance with some embodiments. While some example features are illustrated, various other features have not been illustrated for the sake of brevity and so as not to obscure more pertinent aspects of the example implementations disclosed herein. To that end, as a non-limiting example, the data storage system 100 includes a memory controller 120, and a storage medium 130, and is used in conjunction with a computer system 110. In some implementations, storage medium 130 is a single flash memory device while in other implementations storage medium 130 includes a plurality of flash memory devices. In some implementations, storage medium 130 is NAND-type flash memory or NOR-type flash memory. Further, in some implementations memory controller 120 is a solid-state drive (SSD) controller. However, other types of storage media may be included in accordance with aspects of a wide variety of implementations.
Computer system 110 is coupled to memory controller 120 through data connections 101. However, in some implementations computer system 110 includes memory controller 120 as a component and/or a sub-system. Computer system 110 may be any suitable computer device, such as a computer, a laptop computer, a tablet device, a netbook, an internet kiosk, a personal digital assistant, a mobile phone, a smart phone, a gaming device, a computer server, or any other computing device. Computer system 110 is sometimes called a host or host system. In some implementations, computer system 110 includes one or more processors, one or more types of memory, a display and/or other user interface components such as a keyboard, a touch screen display, a mouse, a track-pad, a digital camera and/or any number of supplemental devices to add functionality.
Storage medium 130 is coupled to memory controller 120 through connections 103. Connections 103 are sometimes called data connections, but typically convey commands in addition to data, and optionally convey metadata, error correction information and/or other information in addition to data values to be stored in storage medium 130 and data values read from storage medium 130. In some implementations, however, memory controller 120 and storage medium 130 are included in the same device as components thereof. Furthermore, in some implementations memory controller 120 and storage medium 130 are embedded in a host device, such as a mobile device, tablet, other computer or computer controlled device, and the methods described herein are performed by the embedded memory controller. Storage medium 130 may include any number (i.e., one or more) of memory devices including, without limitation, non-volatile semiconductor memory devices, such as flash memory. For example, flash memory devices can be configured for enterprise storage suitable for applications such as cloud computing, or for caching data stored (or to be stored) in secondary storage, such as hard disk drives. Additionally and/or alternatively, flash memory can also be configured for relatively smaller-scale applications such as personal flash drives or hard-disk replacements for personal, laptop and tablet computers.
Storage medium 130 is divided into a number of addressable and individually selectable blocks, such as selectable portion 131. In some implementations, the individually selectable blocks are the minimum size erasable units in a flash memory device. In other words, each block contains the minimum number of memory cells that can be erased simultaneously. Each block is usually further divided into a plurality of pages and/or word lines, where each page or word line is typically an instance of the smallest individually accessible (readable) portion in a block. In some implementations (e.g., using some types of flash memory), the smallest individually accessible unit of a data set, however, is a sector, which is a subunit of a page. That is, a block includes a plurality of pages, each page contains a plurality of sectors, and each sector is the minimum unit of data for reading data from the flash memory device.
For example, one block comprises any number of pages, for example, 64 pages, 128 pages, 256 pages or another suitable number of pages. Blocks are typically grouped into a plurality of zones. Each block zone can be independently managed to some extent, which increases the degree of parallelism for parallel operations and simplifies management of storage medium 130.
In some implementations, memory controller 120 includes a management module 121, a host interface 129, a storage medium interface (I/O) 128, and additional module(s) 125. Memory controller 120 may include various additional features that have not been illustrated for the sake of brevity and so as not to obscure more pertinent features of the example implementations disclosed herein, and a different arrangement of features may be possible. Host interface 129 provides an interface to computer system 110 through data connections 101. Similarly, storage medium I/O 128 provides an interface to storage medium 130 though connections 103. In some implementations, storage medium I/O 128 includes read and write circuitry, including circuitry capable of providing reading signals to storage medium 130 (e.g., reading threshold voltages for NAND-type flash memory).
In some implementations, management module 121 includes one or more processing units (CPUs, also sometimes called processors) 122 configured to execute instructions in one or more programs (e.g., in management module 121). In some implementations, the one or more CPUs 122 are shared by one or more components within, and in some cases, beyond the function of memory controller 120. Management module 121 is coupled to host interface 129, additional module(s) 125 and storage medium I/O 128 in order to coordinate the operation of these components.
Additional module(s) 125 are coupled to storage medium I/O 128, host interface 129, and management module 121. As an example, additional module(s) 125 may include an error control module to limit the number of uncorrectable errors inadvertently introduced into data during writes to memory or reads from memory. In some embodiments, additional module(s) 125 are executed in software by the one or more CPUs 122 of management module 121, and, in other embodiments, additional module(s) 125 are implemented in whole or in part using special purpose circuitry (e.g., to perform encoding and decoding functions).
During a write operation, host interface 129 receives data to be stored in storage medium 130 from computer system 110. The data held in host interface 129 is made available to an encoder (e.g., in additional module(s) 125), which encodes the data to produce one or more codewords. The one or more codewords are made available to storage medium I/O 128, which transfers the one or more codewords to storage medium 130 in a manner dependent on the type of storage medium being utilized.
A read operation is initiated when computer system (host) 110 sends one or more host read commands on control line 111 to memory controller 120 requesting data from storage medium 130. Memory controller 120 sends one or more read access commands to storage medium 130, via storage medium I/O 128, to obtain raw read data in accordance with memory locations (addresses) specified by the one or more host read commands. Storage medium I/O 128 provides the raw read data (e.g., comprising one or more codewords) to a decoder (e.g., in additional module(s) 125). If the decoding is successful, the decoded data is provided to host interface 129, where the decoded data is made available to computer system 110. In some implementations, if the decoding is not successful, memory controller 120 may resort to a number of remedial actions or provide an indication of an irresolvable error condition.
Flash memory devices utilize memory cells to store data as electrical values, such as electrical charges or voltages. Each flash memory cell typically includes a single transistor with a floating gate that is used to store a charge, which modifies the threshold voltage of the transistor (i.e., the voltage needed to turn the transistor on). The magnitude of the charge, and the corresponding threshold voltage the charge creates, is used to represent one or more data values. In some implementations, during a read operation, a reading threshold voltage is applied to the control gate of the transistor and the resulting sensed current or voltage is mapped to a data value.
The terms “cell voltage” and “memory cell voltage,” in the context of flash memory cells, means the threshold voltage of the memory cell, which is the minimum voltage that needs to be applied to the gate of the memory cell's transistor in order for the transistor to conduct current. Similarly, reading threshold voltages (sometimes also called reading signals and reading voltages) applied to a flash memory cells are gate voltages applied to the gates of the flash memory cells to determine whether the memory cells conduct current at that gate voltage. In some implementations, when a flash memory cell's transistor conducts current at a given reading threshold voltage, indicating that the cell voltage is less than the reading threshold voltage, the raw data value for that read operation is a “1,” and otherwise the raw data value is a “0.”
As explained above, a storage medium (e.g., storage medium 130) is divided into a number of addressable and individually selectable blocks and each block is optionally (but typically) further divided into a plurality of pages and/or word lines and/or sectors. While erasure of a storage medium is performed on a block basis, in many embodiments, reading and programming of the storage medium is performed on a smaller subunit of a block (e.g., on a page basis, word line basis, or sector basis). In some embodiments, the smaller subunit of a block consists of multiple memory cells (e.g., single-level cells or multi-level cells). In some embodiments, programming is performed on an entire page.
As an example, if data is written to a storage medium in pages, but the storage medium is erased in blocks, pages in the storage medium may contain invalid (e.g., stale) data, but those pages cannot be overwritten until the whole block containing those pages is erased. In order to write to the pages with invalid data, the pages with valid data in that block are read and re-written to a new block and the old block is erased (or put on a queue for erasing). This process is called garbage collection. After garbage collection, the new block contains pages with valid data and free pages that are available for new data to be written, and the old block that was erased is also available for new data to be written. Since flash memory can only be programmed and erased a limited number of times, the efficiency of the algorithm used to pick the next block(s) to re-write and erase has a significant impact on the lifetime and reliability of flash-based storage systems.
Write amplification is a phenomenon where the actual amount of physical data written to a storage medium (e.g., storage medium 130) is a multiple of the logical amount of data intended to be written by a host (e.g., computer system 110, sometimes called a host). As discussed above, when a storage medium must be erased before it can be re-written, the garbage collection process to perform these operations results in re-writing data one or more times. This multiplying effect increases the number of writes required over the life of a storage medium, which shortens the time it can reliably operate. The formula to calculate the write amplification of a storage system is given by equation (1):




  
    
      
        
          amount
          ⁢
          
            
          
          ⁢
          of
          ⁢
          
            
          
          ⁢
          data
          ⁢
          
            
          
          ⁢
          written
          ⁢
          
            
          
          ⁢
          to
          ⁢
          
            
          
          ⁢
          a
          ⁢
          
            
          
          ⁢
          storage
          ⁢
          
            
          
          ⁢
          medium
        
        
          amount
          ⁢
          
            
          
          ⁢
          of
          ⁢
          
            
          
          ⁢
          data
          ⁢
          
            
          
          ⁢
          written
          ⁢
          
            
          
          ⁢
          by
          ⁢
          
            
          
          ⁢
          a
          ⁢
          
            
          
          ⁢
          host
        
      
    
    
      
        (
        1
        )
      
    
  




Generally, garbage collection is performed on erase blocks with the fewest number of valid pages for best performance and best write amplification. However, since different erase blocks have different wear characteristics, it is important to use erase blocks based on how much life a respective erase block has left, rather than simply the number of program-erase cycles performed on the respective erase block thus far. As described below, in some implementations, garbage collection that is performed based on characteristics of erase blocks (e.g., an age metric) helps to improve wear leveling, thus extending the life of the memory device.
FIG. 2A is a block diagram illustrating an exemplary management module 121, in accordance with some embodiments. Management module 121 typically includes one or more processing units (CPUs) 122 for executing modules, programs and/or instructions stored in memory 206 and thereby performing processing operations, memory 206, and one or more communication buses 208 for interconnecting these components. Communication buses 208 optionally include circuitry (sometimes called a chipset) that interconnects and controls communications between system components. Management module 121 is coupled to host interface 129, additional module(s) 125, and storage medium I/O 128 by communication buses 208. Memory 206 includes high-speed random access memory, such as DRAM, SRAM, DDR RAM or other random access solid state memory devices, and may include non-volatile memory, such as one or more magnetic disk storage devices, optical disk storage devices, flash memory devices, or other non-volatile solid state storage devices. Memory 206 optionally includes one or more storage devices remotely located from the CPU(s) 122. Memory 206, or alternately the non-volatile memory device(s) within memory 206, comprises a non-transitory computer readable storage medium. In some embodiments, memory 206, or the computer readable storage medium of memory 206 stores the following programs, modules, and data structures, or a subset thereof:

    
    
        a data read module 216 that is used for reading data from one or more blocks in a storage medium;
        a data write module 218 that is used for writing data to one or more blocks in a storage medium;
        a data erase module 220 that is used for erasing data from one or more blocks in a storage medium;
        a translation table 222 that is used for mapping logical addresses to physical addresses;
        a garbage collection module 224 that is used for garbage collection for one or more blocks in a storage medium;
        a wear leveling module 234 that is used for wear leveling for a storage medium; and
        a characterization vector table 240 that includes a collection of characterization vectors (e.g., characterization vectors 242, FIG. 2B), each characterization vector storing characterization data for a respective portion of a storage medium (e.g., a flash memory device, die, block zone, block, word line, word line zone or page portion of storage medium 130, FIG. 1).
    
    


In some embodiments, the garbage collection module 224 optionally includes the following modules or sub-modules, or a subset thereof:

    
    
        a garbage collection read module 226 that is used for reading data from one or more blocks in a storage medium during a garbage collection operation;
        a garbage collection write module 228 that is used for writing data to one or more blocks in a storage medium during a garbage collection operation;
        a garbage collection erase module 230 that is used for erasing data from one or more blocks in a storage medium during a garbage collection operation; and
        a selection module 232 that is used for selecting one or more blocks (e.g., an erase unit) in a storage medium for garbage collection.
    
    


In some embodiments, the wear leveling module 234 optionally includes the following modules or sub-modules, or a subset thereof:

    
    
        an age module 236 that is used for determining an age metric for one or more erase units (e.g., one or more blocks) in a storage medium; and
        a bias module 238 that is used for biasing a garbage collection control metric (e.g., valid-page count).
    
    


Each of the above identified elements may be stored in one or more of the previously mentioned memory devices, and corresponds to a set of instructions for performing a function described above. The above identified modules or programs (i.e., sets of instructions) need not be implemented as separate software programs, procedures or modules, and thus various subsets of these modules may be combined or otherwise re-arranged in various embodiments. In some embodiments, memory 206 may store a subset of the modules and data structures identified above. Furthermore, memory 206 may store additional modules and data structures not described above. In some embodiments, the programs, modules, and data structures stored in memory 206, or the computer readable storage medium of memory 206, provide instructions for implementing any of the methods described below with reference to FIGS. 4A-4D.
Although FIG. 2A shows a management module 121, FIG. 2A is intended more as functional description of the various features which may be present in a management module than as a structural schematic of the embodiments described herein. In practice, and as recognized by those of ordinary skill in the art, items shown separately could be combined and some items could be separated.
FIG. 2B is a block diagram illustrating an implementation of a characterization vector table 240, in accordance with some embodiments. Characterization vector table 240 includes a collection of characterization vectors 242, that each store characterization data associated with a respective portion of a storage medium (e.g., a distinct device, die, block zone, block, word line, word line zone or page portion of storage medium 130, FIG. 1). In some embodiments, the characterization data stored in characterization vectors 242 is statistically derived. For example, without limitation, in some embodiments in which a storage medium (e.g., storage medium 130, FIG. 1) includes a plurality of erase units (e.g., one or more erase blocks), characterization vector table 240 includes at least one characterization vector for each erase unit. In another example, in some embodiments, characterization vector table 240 includes a set of distinct characterization vectors 242 for each erase unit in the storage medium (e.g., storage medium 130, FIG. 1), and the set of distinct characterization vectors 242 for each erase unit includes at least one distinct characterization vector for each block in the erase unit. In yet another example, in some embodiments in which a storage medium (e.g., storage medium 130, FIG. 1) includes a plurality of storage units and each storage unit includes a plurality of erase units, characterization vector table 240 includes at least one characterization vector for each storage unit. More detailed example embodiments of characterization vectors 242 are described below with reference to FIG. 2C.
FIG. 2C is a block diagram illustrating an implementation of a characterization vector 244 (e.g., corresponding to one of characterization vectors 242 shown in FIG. 2B) for a respective erase unit, in accordance with some embodiments. In some embodiments, characterization data stored in characterization vector 244 for the respective erase unit includes storage medium characterization parameter values such as an age metric field 246 indicating an age of the respective erase unit (e.g., a metric corresponding to estimated remaining life of the respective erase unit), and, optionally, a bias value field 248 indicating a bias value with which to adjust a garbage collection control metric for the respective erase unit. In some embodiments, the one or more storage medium characterization parameter values provide an indication of at least one of: a physical characteristic associated with the respective portion of the storage medium (e.g., a distinct flash memory device, die, block zone, block, word line, word line zone or page portion of storage medium 130, FIG. 1), a mode of operation associated with the respective portion of the storage medium, a history of use associated with the respective portion of the storage medium, a condition characteristic associated with the respective portion of the storage medium, a read type associated with the respective portion of the storage medium, and location(s) associated with the respective portion of the storage medium.
FIG. 3 is a block diagram of a plurality of erase units, in accordance with some embodiments. Since different erase units have different characteristics (e.g., some erase units can withstand more program-erase cycles than other erase units), it is important to use the different erase units accordingly (e.g., applying more program-erase cycles to “stronger” erase units and applying fewer program-erase cycles to “weaker” erase units). In some embodiments, in order to wear level erase units based on estimated remaining life of each erase unit, rather than simply the number of program-erase cycles performed on each erase unit, garbage collection is performed on the “stronger” or “younger” erase units more quickly than average and garbage collection is performed on the “weaker” or “older” erase units more slowly than average. In some implementations, a garbage collection control metric used for prioritizing garbage collection is a valid-page count. As described above, garbage collection is generally performed on erase units with the fewest number of valid pages for best performance and best write amplification. By biasing the valid-page counts for the erase units based on an age metric for a respective erase unit in relation to a representative age metric for the plurality of erase units in the storage medium, garbage collection can be prioritized accordingly.
In the embodiments described next, the age metric for each erase unit is inversely related to the estimated remaining life of the erase unit. Thus, weaker or older erase units are erase units having less estimated remaining life than the average erase units in the storage medium, and these weaker or older erase units have greater (i.e., higher) age metrics than erase units that have more estimated remaining life. Similarly, stronger or younger erase units are erase units having more estimated remaining life than the average erase units in the storage medium, and these stronger or younger erase units have lower age metrics than erase units that have less estimated remaining life.
In the example of FIG. 3, four erase units of a plurality of erase units in a storage medium (e.g., storage medium 130, FIG. 1) are shown: erase unit A 302 (age 7), erase unit B 304 (age 11), erase unit C 306 (age 5), and erase unit D 308 (age 7). In this example, the representative age of erase units in the storage medium is 7. In this example, the average age of erase units in the storage medium is 7, and the median age of erase units in the storage medium is 7. In some embodiments, the average age of erase units in the storage medium is different from the median age of erase units in the storage medium. Since erase unit B 304 is older than average (e.g., older than the representative age of 7), a bias (e.g., stored in bias value field 248, FIG. 2C) is added to the valid-page count for erase unit B 304 so it appears that erase unit B 304 has more valid pages, thus delaying garbage collection. Since erase unit C 306 is younger than average (e.g., younger than the representative age of 7), a bias (e.g., stored in bias value field 248, FIG. 2C) is subtracted from the valid-page count for erase unit C 306 so it appears that erase unit C 306 has fewer valid pages, thus expediting garbage collection. In some implementations, a predefined number of valid pages is added or subtracted for each age that the erase unit differs from the representative age of erase units in the storage medium, up to maximum bias limits imposed by firmware. The maximum bias limits ensure that the biasing for wear leveling does not increase write amplification more than what has been determined as acceptable.
For example, if the predefined number of valid pages is 256 pages, and erase unit B 304 (age 11) is 4 age units older than the representative age of 7, the bias added to the valid-page count for erase unit B 304 is 1,024 pages (i.e., 256 pages*4 age units). As another example, if the predefined number of valid pages is 256 pages, and erase unit C 306 (age 5) is 2 age units younger than the representative age of 7, the bias subtracted from the valid-page count for erase unit C 306 is 512 pages (i.e., 256 pages*2 age units). As yet another example, since erase unit A 302 (age 7) and erase unit D 308 (age 7) are the same age as the representative age of erase units in the storage medium, the valid-page counts for erase unit A 302 and erase unit D 308 are not biased for garbage collection purposes. In some implementations, if the maximum bias limit is, say, 6 times the predefined number of valid pages, even if an erase unit is 7 or more age units older or younger than the representative age, the bias added or subtracted from the valid-page count is limited to 6 times the predefined number of valid pages. For example, say erase unit E (not pictured) is age 14, which is 7 age units older than the representative age of 7, and the predefined number of valid pages is 256, the bias to be added to the valid-page count for erase unit E would be 1,792 pages. However, if the bias value is limited to a predefined maximum of 1,536 pages, only 1,536 pages would be added to the valid-page count for erase unit E.
Although valid-page count is used as an example for the description of FIG. 3, in other embodiments, other garbage collection control metrics are used to prioritize garbage collection and bias values are calculated and the garbage collection control metrics are adjusted accordingly. For example, in some implementations, a garbage collection control metric used for prioritizing garbage collection is an invalid-page count (e.g., a count of invalid or dirty or “freeable” pages) and bias values are subtracted from the invalid-page counts for “older” erase units and added to invalid-page counts for “younger” erase units.
FIGS. 4A-4D illustrate a flowchart representation of a method 400 of wear leveling for a storage medium in a storage system, in accordance with some embodiments. As noted above with respect to FIG. 1, since erasure of a storage medium is performed on a block basis, but in many embodiments, programming of the storage medium is performed on a smaller subunit of a block (e.g., on a page basis), pages with invalid data cannot be overwritten until the whole block containing those pages is erased. The storage system (e.g., data storage system 100, FIG. 1) uses garbage collection to reclaim portions of memory (e.g., storage medium 130, FIG. 1) that no longer contain valid data, which includes performance of method 400.
At least in some implementations, method 400 is performed by a storage system (e.g., data storage system 100, FIG. 1) or one or more components of the storage system (e.g., memory controller 120 and/or storage medium 130, FIG. 1). In some embodiments, method 400 is governed by instructions that are stored in a non-transitory computer readable storage medium and that are executed by one or more processors of a device, such as the one or more processing units (CPUs) 122 of management module 121, shown in FIGS. 1 and 2A.
A storage system (e.g., data storage system 100, FIG. 1) determines (402), for each erase unit of a plurality of erase units in a storage medium (e.g., storage medium 130, FIG. 1), an age metric. In some implementations, an age module (e.g., age module 236, FIG. 2A) is used to determine, for each erase unit of a plurality of erase units in a storage medium, an age metric, as described above with respect to FIG. 2A.
In some embodiments, the erase unit is (404) a single erase block. For example, for a flash memory device, the erase unit is a single erase block, the minimum size erasable unit in a flash memory device.
In some embodiments, the erase unit is (406) a super block, wherein the super block includes a plurality of erase blocks. For example, in some implementations, a super block includes 16 erase blocks.
In some embodiments, the storage medium comprises (408) one or more non-volatile storage devices, such as flash memory devices. In some implementations, the non-volatile storage medium (e.g., storage medium 130, FIG. 1) is a single flash memory device, while in other implementations the non-volatile storage medium includes a plurality of flash memory devices. In some implementations, the non-volatile storage medium (e.g., storage medium 130, FIG. 1) is NAND-type flash memory or NOR-type flash memory.
In some embodiments, the age metric for each erase unit is (410) determined in accordance with a metric corresponding to estimated remaining life of each erase unit. In some embodiments, some erase units can withstand more program-erase cycles than other erase units, and the age metric for each erase unit is determined in accordance with a metric corresponding to estimated remaining life of each erase unit (as opposed to simply the number of program-erase cycles completed for each erase unit). For example, if an erase unit can withstand more program-erase cycles than the average erase unit (e.g., with an age equal to the representative age metric of the plurality of erase units), then that erase unit has more estimated remaining life and is considered “younger” than the average erase unit. As another example, if an erase unit can withstand less program-erase cycles than the average erase unit, then that erase unit has less estimated remaining life and is considered “older” than the average erase unit. In some embodiments, the age metric is determined periodically (e.g., an updated age metric for an erase unit is determined every 100 program-erase cycles of the erase unit).
In some embodiments, determining (402), for each erase unit of a plurality of erase units in the storage medium, the age metric comprises determining (412), for each storage unit of a plurality of storage units in the storage medium, an age metric for a respective storage unit, wherein each storage unit comprises a plurality of the erase units. In some embodiments, the age metric for an erase unit comprises the age metric determined for the corresponding storage unit. In some implementations, the age metric for the storage unit is the worst (e.g., “oldest”) age metric for any of the erase units in the storage unit. In some implementations, the age metric for the storage unit is the average age metric of the erase units in the storage unit. In some implementations, the age metric for the storage unit is the median age metric of the erase units in the storage unit. In some implementations, an age module (e.g., age module 236, FIG. 2A) is used to determine, for each storage unit of a plurality of storage units in the storage medium, an age metric for a respective storage unit, wherein each storage unit comprises a plurality of the erase units, as described above with respect to FIG. 2A.
Next, the storage system determines (414) a representative age metric of the plurality of erase units. In some embodiments, the representative age metric of the plurality of erase units is an average age metric of the plurality of erase units. In some embodiments, the representative age metric of the plurality of erase units is a median age metric of the plurality of erase units. For example, if a storage medium (e.g., storage medium 130, FIG. 1) includes 4 erase units with ages of 5, 7, 7, and 9, respectively, and the representative age metric of the plurality of erase units is an average age metric of the plurality of erase units, the storage system determines the average age metric of the plurality of erase units to be 7 (i.e., (5+7+7+9)/4). In some embodiments, the representative age metric of the plurality of erase units is determined periodically. For example, in some implementations, the storage system accumulates N age metric measurements, where N is a predetermined number (e.g., N is equal to 2048), and then divides the accumulated total by N, once N age metric measurements have been accumulated. In some implementations, an age module (e.g., age module 236, FIG. 2A) is used to determine a representative age metric of the plurality of erase units, as described above with respect to FIG. 2A.
Next, the storage system, for each respective erase unit of the plurality of erase units, biases (416) a respective garbage collection control metric for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units to generate an adjusted garbage collection control metric for the respective erase unit. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to bias, for each respective erase unit of the plurality of erase units, a respective garbage collection control metric for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units to generate an adjusted garbage collection control metric for the respective erase unit, as described above with respect to FIG. 2A.
In some embodiments, the garbage collection control metric is (418) a valid-page count and biasing the respective valid-page count for the respective erase unit includes determining (420) the respective valid-page count, wherein the respective valid-page count is a count of valid pages in the respective erase unit. For example, if an erase unit has 10,240 pages, 2,500 of which are valid and 7,740 of which are invalid, the valid-page count is 2,500. In some implementations, a respective valid-page count is updated when data on the respective erase unit is written to another location (e.g., the host system rewrote the logical location for that data), since at that time, the respective erase unit has an invalid (e.g., stale) version of that data. In some implementations, the valid-page count is tracked loosely while in other implementations, the valid-page count is tracked precisely. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to determine the respective valid-page count, wherein the respective valid-page count is a count of valid pages in the respective erase unit, as described above with respect to FIG. 2A.
Next, biasing the respective valid-page count for the respective erase unit includes calculating (422) a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units. For example, if a first erase unit (e.g., erase unit B 304, FIG. 3) is 4 age units older than the representative age metric of the plurality of erase units, the bias value for the first erase unit will be greater than the bias value for a second erase unit that is 2 age units older than the representative age metric. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to calculate a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units, as described above with respect to FIG. 2A.
In some embodiments, calculating (422) the bias value for the respective erase unit includes calculating (424) a difference between the age metric of the respective erase unit and the representative age metric of the plurality of erase units. For example, if the age metric of the respective erase unit is age 5 and the representative age metric of the plurality of erase units is age 7, the difference between the age metric of the respective erase unit and the representative age metric is 2 age units. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to calculate a difference between the age metric of the respective erase unit and the representative age metric of the plurality of erase units, as described above with respect to FIG. 2A.
Next, calculating (422) the bias value for the respective erase unit includes calculating (426) a first value, the first value determined by multiplying the absolute value of the calculated difference by a predefined number of valid pages, wherein the first value is limited to a predefined maximum. For example, if the calculated difference is 2 age units and the predefined number of valid pages is 256 pages, the first value is 512 pages (i.e., 2*256 pages), assuming the predefined maximum is greater than 512 pages. As another example, if the predefined maximum is 1,280 pages and the calculated difference is 8 age units and the predefined number of valid pages is 256 pages, the first value would have been 2,048 pages (i.e., 8*256 pages), but since the predefined maximum is 1,280 pages, the first value is limited to 1,280 pages. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to calculate a first value, the first value determined by multiplying the absolute value of the calculated difference by a predefined number of valid pages, wherein the first value is limited to a predefined maximum, as described above with respect to FIG. 2A.
Next, calculating (422) the bias value for the respective erase unit includes setting (428) the bias value equal to the first value. For example, if the first value is calculated to be 512 pages, the bias value is set to be 512 pages. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to set the bias value equal to the first value, as described above with respect to FIG. 2A.
After calculating (422) the bias value for the respective erase unit, the storage system, in accordance with a first determination that the age metric of the respective erase unit corresponds to a shorter estimated remaining life than erase units having the representative age metric of the plurality of erase units, adds (430) the bias value to the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit. As explained above, an erase unit with an age metric greater than the representative age metric is weaker, or has a shorter estimated remaining life, than an erase unit with an age metric equal to the representative age metric. For example, if the age metric of the respective erase unit is greater than the representative age metric of the plurality of erase units (e.g., the age metric of the respective erase unit is age 9 and the representative age metric is age 7) and the respective erase unit has a valid-page count of 2,500 pages and the bias value was calculated to be 512 pages, the storage system adds 512 pages to 2,500 pages to generate the adjusted valid-page count of 3,012 pages. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to add, in accordance with a first determination, the first determination including a determination that the age metric of the respective erase unit is greater than the representative age metric of the plurality of erase units, the bias value to the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit, as described above with respect to FIG. 2A.
Further, after calculating (422) the bias value for the respective erase unit, the storage system, in accordance with a second determination that the age metric of the respective erase unit corresponds to a longer estimated remaining life than erase units having the representative age metric of the plurality of erase units, subtracts (432) the bias value from the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit. For example, if the age metric of the respective erase unit is less than the representative age metric of the plurality of erase units (e.g., the age metric of the respective erase unit is age 5 and the representative age metric is age 7) and the respective erase unit has a valid-page count of 2,500 pages and the bias value was calculated to be 512 pages, the storage system subtracts 512 pages from 2,500 pages to generate the adjusted valid-page count of 1,988 pages. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to subtract, in accordance with a second determination, the second determination including a determination that the age metric of the respective erase unit is less than the representative age metric of the plurality of erase units, the bias value from the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit, as described above with respect to FIG. 2A.
In some embodiments, biasing (416) the respective garbage collection control metric for the respective erase unit includes determining (434) the respective garbage collection control metric. Optionally, the respective garbage collection control metric is a count of a metric for prioritizing garbage collection in the respective erase unit. In some embodiments, the garbage collection control metric is a valid-page count and determining the respective garbage collection control metric includes determining the respective valid-page count, wherein the respective valid-page count is a count of valid pages in the respective erase unit. In other embodiments, the garbage collection control metric is an invalid-page count and determining the respective garbage collection control metric includes determining the respective invalid-page count, wherein the respective invalid-page count is a count of invalid (e.g., dirty or “freeable”) pages in the respective erase unit. In yet other embodiments, the garbage collection control metric is a count of some other metric for prioritizing garbage collection. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to determine the respective garbage collection control metric, as described above with respect to FIG. 2A.
Next, biasing (416) the respective garbage collection control metric for the respective erase unit includes calculating (436) a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units, including limiting a range of the bias value to a predefined range. For example, if a first erase unit (e.g., erase unit B 304, FIG. 3) is 4 age units older than the representative age metric of the plurality of erase units, the bias value for the first erase unit will be greater than the bias value for a second erase unit that is 2 age units older than the representative age metric. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to calculate a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units, including limiting a range of the bias value to a predefined range, as described above with respect to FIG. 2A.
Next, biasing (416) the respective garbage collection control metric for the respective erase unit includes mathematically adjusting (438) the respective garbage collection control metric for the respective erase unit with the calculated bias value to generate the adjusted garbage collection control metric for the respective erase unit. For example, if the garbage collection control metric is a valid-page count, the storage system mathematically adjusts the respective garbage collection control metric by adding or subtracting the calculated bias value as described in operations 430 and 432. As another example, if the garbage collection control metric is an invalid-page count, the storage system mathematically adjusts the respective garbage collection control metric by subtracting the calculated bias values for “older” erase units and adding the calculated bias values for “younger” erase units. In some implementations, a bias module (e.g., bias module 238, FIG. 2A) is used to mathematically adjust the respective garbage collection control metric for the respective erase unit with the calculated bias value to generate the adjusted garbage collection control metric for the respective erase unit, as described above with respect to FIG. 2A.
After biasing (416), for each respective erase unit of the plurality of erase units, a respective garbage collection control metric for the respective erase unit to generate an adjusted garbage collection control metric for the respective erase unit, the storage system performs (440) garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units. For example, in some embodiments (e.g., in which the garbage collection control metric is a valid-page count), the storage system performs garbage collection, giving priority to the erase units with the lowest adjusted garbage collection control metric. As another example, in some embodiments (e.g., in which the garbage collection control metric is an invalid-page count), the storage system performs garbage collection, giving priority to the erase units with the highest adjusted garbage collection control metric. In some implementations, a garbage collection module (e.g., garbage collection module 224, FIG. 2A) is used to perform garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units, as described above with respect to FIG. 2A.
In some embodiments, the garbage collection control metric is (418) a valid-page count and performing (440) garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units includes selecting (442) an erase unit with the lowest adjusted valid-page count for garbage collection. As described above, in other embodiments, the garbage collection control metric is an invalid-page count and performing garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units includes selecting an erase unit with the highest adjusted invalid-page count for garbage collection. In some implementations, a selection module (e.g., selection module 232, FIG. 2A) is used to select an erase unit with the lowest adjusted valid-page count for garbage collection, as described above with respect to FIG. 2A.
In some embodiments, garbage collection control metric is (418) a valid-page count and performing (440) garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units includes performing (444) garbage collection on a first erase unit with a first adjusted valid-page count prior to performing garbage collection on a second erase unit with a second adjusted valid-page count, wherein the first adjusted valid-page count is less than the second adjusted valid-page count. For example, if a first erase unit has a first adjusted valid-page count of 280 pages and a second erase unit has a second adjusted valid-page count of 500 pages, the storage system performs garbage collection on the first erase unit (with a first adjusted valid-page count of 280) prior to performing garbage collection on the second erase unit (with a second adjusted valid-page count of 500 pages). In some implementations, a garbage collection module (e.g., garbage collection module 224, FIG. 2A) is used to perform garbage collection on a first erase unit with a first adjusted valid-page count prior to performing garbage collection on a second erase unit with a second adjusted valid-page count, wherein the first adjusted valid-page count is less than the second adjusted valid-page count, as described above with respect to FIG. 2A.
In some implementations, with respect to any of the methods described above, the storage medium is a single flash memory device, while in other implementations, the storage medium includes a plurality of flash memory devices.
In some implementations, any of the methods described above are performed by a device operable to perform wear leveling for a storage medium, the device including (1) a storage medium interface for coupling the device to the storage medium, and (2) one or more modules, including a memory management module that includes one or more processors and memory storing one or more programs configured for execution by the one or more processors, the one or more modules coupled to the storage medium interface and configured to perform or control performance of any of the methods described above.
It will be understood that, although the terms “first,” “second,” etc. may be used herein to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another. For example, a first contact could be termed a second contact, and, similarly, a second contact could be termed a first contact, which changing the meaning of the description, so long as all occurrences of the “first contact” are renamed consistently and all occurrences of the second contact are renamed consistently. The first contact and the second contact are both contacts, but they are not the same contact.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the claims. As used in the description of the embodiments and the appended claims, the singular forms “a”, “an” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term “and/or” as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items. It will be further understood that the terms “comprises” and/or “comprising,” when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
As used herein, the term “if” may be construed to mean “when” or “upon” or “in response to determining” or “in accordance with a determination” or “in response to detecting,” that a stated condition precedent is true, depending on the context. Similarly, the phrase “if it is determined [that a stated condition precedent is true]” or “if [a stated condition precedent is true]” or “when [a stated condition precedent is true]” may be construed to mean “upon determining” or “in response to determining” or “in accordance with a determination” or “upon detecting” or “in response to detecting” that the stated condition precedent is true, depending on the context.
The foregoing description, for purpose of explanation, has been described with reference to specific implementations. However, the illustrative discussions above are not intended to be exhaustive or to limit the claims to the precise forms disclosed. Many modifications and variations are possible in view of the above teachings. The implementations were chosen and described in order to best explain principles of operation and practical applications, to thereby enable others skilled in the art.

## Claims

1. A method of wear leveling for a storage medium in a storage system, the method comprising:
determining, for each erase unit of a plurality of erase units in the storage medium, an age metric;
determining a representative age metric of the plurality of erase units;
for each respective erase unit of the plurality of erase units, biasing a respective garbage collection control metric for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units to generate an adjusted garbage collection control metric for the respective erase unit, wherein biasing the respective garbage collection control metric includes:
calculating a difference between the age metric of the respective erase unit and the representative age metric of the plurality of erase units,
calculating a first value, the first value determined by multiplying the absolute value of the calculated difference by a predefined number of valid pages, and
biasing the respective garbage collection control metric by the calculated first value; and

performing garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units.

2. The method of claim 1, wherein the garbage collection control metric is a valid-page count, and wherein biasing the respective valid-page count for the respective erase unit includes:
determining the respective valid-page count, wherein the respective valid-page count is a count of valid pages in the respective erase unit;
calculating a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units;
in accordance with a first determination that the age metric of the respective erase unit corresponds to a shorter estimated remaining life than erase units having the representative age metric of the plurality of erase units, adding the bias value to the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit; and
in accordance with a second determination that the age metric of the respective erase unit corresponds to a longer estimated remaining life than erase units having the representative age metric of the plurality of erase units, subtracting the bias value from the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit.

3. The method of claim 1, wherein:
the calculated first value is limited to a predefined maximum; and
the garbage collection control metric for the respective erase unit is biased by the limited first value.

4. The method of claim 2, wherein performing garbage collection for the storage medium includes selecting an erase unit with a lowest adjusted valid-page count for garbage collection.

5. The method of claim 2, wherein performing garbage collection for the storage medium includes performing garbage collection on a first erase unit with a first adjusted valid-page count prior to performing garbage collection on a second erase unit with a second adjusted valid-page count, wherein the first adjusted valid-page count is less than the second adjusted valid-page count.

6. The method of claim 1, wherein biasing the respective garbage collection control metric for the respective erase unit includes:
determining the respective garbage collection control metric;
calculating a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units, including limiting a range of the bias value to a predefined range; and
mathematically adjusting the respective garbage collection control metric for the respective erase unit with the calculated bias value to generate the adjusted garbage collection control metric for the respective erase unit.

7. The method of claim 1, wherein the age metric for each erase unit is determined in accordance with a metric corresponding to estimated remaining life of each erase unit.

8. The method of claim 1, wherein the erase unit is a single erase block.

9. The method of claim 1, wherein the erase unit is a super block, wherein the super block includes a plurality of erase blocks.

10. The method of claim 1, wherein the storage medium comprises one or more flash memory devices.

11. The method of claim 1, wherein determining, for each erase unit of a plurality of erase units in the storage medium, the age metric comprises determining, for each storage unit of a plurality of storage units in the storage medium, an age metric for a respective storage unit, wherein each storage unit comprises a plurality of the erase units.

12. A device operable to perform wear leveling for a storage medium, the device comprising:
a storage medium interface for coupling the device to the storage medium; and
one or more modules, including a memory management module that includes one or more processors and memory storing one or more programs configured for execution by the one or more processors, the one or more modules coupled to the storage medium interface and configured to:
determine, for each erase unit of a plurality of erase units in the storage medium, an age metric;
determine a representative age metric of the plurality of erase units;
bias, for each respective erase unit of the plurality of erase units, a respective garbage collection control metric for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units to generate an adjusted garbage collection control metric for the respective erase unit, wherein biasing the respective garbage collection control metric includes:
calculating a difference between the age metric of the respective erase unit and the representative age metric of the plurality of erase units,
calculating a first value, the first value determined by multiplying the absolute value of the calculated difference by a predefined number of valid pages, and
biasing the respective garbage collection control metric by the calculated first value; and
perform garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units.

13. The device of claim 12, wherein the garbage collection control metric is a valid-page count, and wherein the one or more modules are configured to bias the respective valid-page count for the respective erase unit, including:
determining the respective valid-page count, wherein the respective valid-page count is a count of valid pages in the respective erase unit;
calculating a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units;
in accordance with a first determination that the age metric of the respective erase unit corresponds to a shorter estimated remaining life than erase units having the representative age metric of the plurality of erase units, adding the bias value to the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit; and
in accordance with a second determination that the age metric of the respective erase unit corresponds to a longer estimated remaining life than erase units having the representative age metric of the plurality of erase units, subtracting the bias value from the respective valid-page count for the respective erase unit to generate the adjusted valid-page count for the respective erase unit.

14. The device of claim 12, wherein:
the calculated first value is limited to a predefined maximum; and
the garbage collection control metric for the respective erase unit is biased by the limited first value.

15. The device of claim 13, wherein the one or more modules are configured to perform garbage collection for the storage medium, including performing garbage collection on a first erase unit with a first adjusted valid-page count prior to performing garbage collection on a second erase unit with a second adjusted valid-page count, wherein the first adjusted valid-page count is less than the second adjusted valid-page count.

16. The device of claim 12, wherein the one or more modules are configured to bias the respective garbage collection control metric for the respective erase unit, including:
determining the respective garbage collection control metric;
calculating a bias value for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units, including limiting a range of the bias value to a predefined range; and
mathematically adjusting the respective garbage collection control metric for the respective erase unit with the calculated bias value to generate the adjusted garbage collection control metric for the respective erase unit.

17. The device of claim 12, wherein the age metric for each erase unit is determined in accordance with a metric corresponding to estimated remaining life of each erase unit.

18. The device of claim 12, wherein the storage medium comprises one or more flash memory devices.

19. A storage system, comprising:
a storage medium;
one or more processors; and
memory storing one or more programs, which when executed by the one or more processors cause the storage system to:
determine, for each erase unit of a plurality of erase units in the storage medium, an age metric;
determine a representative age metric of the plurality of erase units;
bias, for each respective erase unit of the plurality of erase units, a respective garbage collection control metric for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units to generate an adjusted garbage collection control metric for the respective erase unit, wherein biasing the respective garbage collection control metric includes:
calculating a difference between the age metric of the respective erase unit and the representative age metric of the plurality of erase units,
calculating a first value, the first value determined by multiplying the absolute value of the calculated difference by a predefined number of valid pages, and
biasing the respective garbage collection control metric by the calculated first value; and
perform garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units.

20. A non-transitory computer readable storage medium storing one or more programs configured for execution by a device coupled to a storage medium, the one or more programs comprising instructions for:
determining, for each erase unit of a plurality of erase units in the storage medium, an age metric;
determining a representative age metric of the plurality of erase units;
for each respective erase unit of the plurality of erase units, biasing a respective garbage collection control metric for the respective erase unit in accordance with the age metric of the respective erase unit in relation to the representative age metric of the plurality of erase units to generate an adjusted garbage collection control metric for the respective erase unit, wherein biasing the respective garbage collection control metric includes:
calculating a difference between the age metric of the respective erase unit and the representative age metric of the plurality of erase units,
calculating a first value, the first value determined by multiplying the absolute value of the calculated difference by a predefined number of valid pages, and
biasing the respective garbage collection control metric by the calculated first value; and

performing garbage collection for the storage medium in accordance with the adjusted garbage collection control metrics of the plurality of erase units.