This application relates generally to memory devices. More specifically, this application relates to garbage collection of blocks in reprogrammable non-volatile semiconductor flash memory.
Non-volatile memory systems, such as flash memory, have been widely adopted for use in consumer products. Flash memory may be found in different forms, for example in the form of a portable memory card that can be carried between host devices or as a solid state disk (SSD) embedded in a host device. When writing data to a conventional flash memory system, a host typically writes data to, and reads data from, addresses within a logical address space of the memory system. The memory system then commonly maps data between the logical address space and the physical blocks or metablocks of the memory, where data is stored in fixed logical groups corresponding to ranges in the logical address space. Generally, each fixed logical group is stored in a separate physical block of the memory system. The memory system keeps track of how the logical address space is mapped into the physical memory but the host is unaware of this. The host keeps track of the addresses of its data files within the logical address space but the memory system generally operates without knowledge of this mapping.
A drawback of memory systems that operate in a logical address space is fragmentation. Data written by a host file system may often be fragmented in logical address space, where many fixed logical groups are only partially updated with new data. The fragmentation may occur as a result of cumulative fragmentation of free space by the host file system, and possibly even as a result of inherent fragmentation of individual files by the host file system. Data previously written may become obsolete due to deletion and cause further fragmentation. The fragmented logical groups will need to be rewritten in full in a different physical block. Rewriting the fragmented logical groups may involve copying unrelated data from the prior location of the logical group, a process known as garbage collection. As fragmentation increases, the transfer speed of a memory system may decrease.
To provide a measure of memory system metrics, tests may be applied to the memory system to gauge the write performance of the memory system. For example, memory systems may have transfer speed specifications that can be rated by protocols such as the Speed Class specification from the SD Association, for example. The Speed Class specification includes Speed Classes 2, 4, and 6, which denote the guaranteed minimum transfer speeds for memory systems of 2, 4, and 6 MB/s, respectively. A Speed Class test run on a memory systems measures metrics such as the sequential write performance of an addressable unit (Pw), the time for a file allocation table (FAT) write (Tfw), and the rolling average of time for multiple FAT writes (Tfw(avg)). The Speed Class test run may also measure the performance of the memory system with fragmentation (Pc), which includes the corresponding read performance measurements. Garbage collection activity occurring during a Speed Class test can adversely affect the test results.
In order to address the problems noted above, a method and system for controlling garbage collection in a memory device is disclosed.
According to a first aspect of the invention, a method is disclosed for optimizing performance of a memory device including a controller. The method includes receiving incoming data for writing to a logical addressable unit, determining an amount of garbage collection to be performed for a garbage collection operation, and initiating the garbage collection operation to carry out a predetermined threshold if the determined amount of garbage collection is less than the predetermined threshold. The method further includes writing the incoming data to at least one physical metablock corresponding to the logical addressable unit. In this way, the controller may perform garbage collection pre-emptively, even if garbage collection is not currently necessary. A system is also disclosed including a plurality of memory blocks and a memory controller that implements this method.
According to another aspect, a method of determining a mode of operation when to perform a garbage collection operation in a memory device is disclosed including a controller that determines which mode of operation to perform the garbage collection operation, and perform the garbage collection operation, performing the garbage collection operation in the determined mode. Memory devices may have different modes of operation. The memory devices may perform garbage collection more efficiently in one mode than in another mode. The controller may analyze which mode of operation more efficiently performs the garbage collection by analyzing at least one indicator of garbage collection performance (such as a maximum amount of garbage collection in the mode of operation). Depending on the analysis, the controller may perform the garbage collection in the determined mode. For example, the controller may pre-emptively garbage collection in the determined mode in order to perform garbage collection efficiently. A system is also disclosed including a plurality of memory blocks and a memory controller that implements this method.
A flash memory system suitable for use in implementing aspects of the invention is shown in
One example of a commercially available SSD drive is a 32 gigabyte SSD produced by SanDisk Corporation. Examples of commercially available removable flash memory cards include the CompactFlash (CF), the MultiMediaCard (MMC), Secure Digital (SD), miniSD, Memory Stick, SmartMedia, TransFlash, and microSD cards. Although each of these cards has a unique mechanical and/or electrical interface according to its standardized specifications, the flash memory system included in each is similar. These cards are all available from SanDisk Corporation, assignee of the present application. SanDisk also provides a line of flash drives under its Cruzer trademark, which are hand held memory systems in small packages that have a Universal Serial Bus (USB) plug for connecting with a host by plugging into the host's USB receptacle. Each of these memory cards and flash drives includes controllers that interface with the host and control operation of the flash memory within them.
Host systems that may use SSDs, memory cards and flash drives are many and varied. They include personal computers (PCs), such as desktop or laptop and other portable computers, cellular telephones, personal digital assistants (PDAs), digital still cameras, digital movie cameras and portable audio players. For portable memory card applications, a host may include a built-in receptacle for one or more types of memory cards or flash drives, or a host may require adapters into which a memory card is plugged. The memory system usually contains its own memory controller and drivers but there are also some memory-only systems that are instead controlled by software executed by the host to which the memory is connected. In some memory systems containing the controller, especially those embedded within a host, the memory, controller and drivers are often formed on a single integrated circuit chip.
The host system 100 of
The memory system 102 of
As mentioned above, the block of memory cells is the unit of erase, the smallest number of memory cells that are physically erasable together. For increased parallelism, however, the blocks are operated in larger metablock units. One block from each plane is logically linked together to form a metablock. The four blocks 210, 212, 214, and 216 are shown to form one metablock 218. All of the cells within a metablock are typically erased together. The blocks used to form a metablock need not be restricted to the same relative locations within their respective planes, as is shown in a second metablock 220 made up of blocks 222, 224, 226, and 228. Although it is usually preferable to extend the metablocks across all of the planes, for high system performance, the memory system can be operated with the ability to dynamically form metablocks of any or all of one, two or three blocks in different planes. This allows the size of the metablock to be more closely matched with the amount of data available for storage in one programming operation.
The individual blocks are in turn divided for operational purposes into pages of memory cells, as illustrated in
In one example, the logical addressable unit size of a Secure Digital (SD) memory is 4 MB, as shown by units 402, 404, and 406. However, the physical metablock size in a D3 memory is 3 MB, as shown by metablocks 408, 410, 412, and 414. In
In particular, first, if data is written to addressable unit 402, all of metablock 408 and 1 MB of metablock 410 are written with the incoming data, and is referred to as a Type A addressable unit 502 in
A metablock that has incoming data written to it may also be referred to as an update block. If no unused update blocks are available when incoming data is to be written, one or more garbage collection operations are necessary to create update blocks for storing of the incoming data. As detailed further below, the open update block as a result of a Type A or Type C write would need 2 MB of future garbage collection. A Type B write would result in two open update blocks that each would need 1 MB of future garbage collection. In the case of a Type B write, if only one update block is to be created, then only 1 MB of future garbage collection is needed. Therefore, on average, any of the write types would result in garbage collection of up to 2 MB.
However, in some situations, a garbage collection operation of greater than 2 MB may be needed to create an unused update block in a D3 memory. The first situation occurs when all the open update blocks have 1 MB of data each. If a Type B write occurs, then two unused update blocks are needed to write the incoming data. Accordingly, two garbage collections of 2 MB each would be necessary for a total of 4 MB of garbage collection. The second situation occurs when there is one open update block with 2 MB of data and the remaining open update blocks have 1 MB of data each. Again, if a Type B write occurs, then two unused update blocks are needed to write the incoming data. In this case, a minimum of two garbage collections of 1 MB and 2 MB, respectively, would be necessary, for a total of 3 MB of garbage collection.
During a Speed Class Operation, for each write of an addressable unit, writes of the incoming data are written to the recording units making up the addressable unit. In a conventional memory system, a garbage collection operation is triggered when an update block is full. However, if a garbage collection operation occurs during a measurement segment of the Speed Class Operation, the Pw metric (sequential write performance of an addressable unit) may be negatively affected and the desired minimum transfer speed indicated by the Speed Class specification may not be met. The worst case scenario, as discussed above, would require two garbage collection operations of 2 MB each, for a total of 4 MB. A 4 MB garbage collection operation in a D3 memory would negatively affect the Pw metric.
At step 602, incoming data to be written to a logical addressable unit is received by the memory device. Any type of data, including FAT and non-FAT data, may be written to the memory. The method 600 may not necessarily know whether a Speed Class Operation has begun but instead may operate at all times. At step 604, the amount of garbage collection needed due to the data write is determined. As detailed above, if no unused update blocks are available at the time of a data write, one or more open update blocks undergo a garbage collection operation to create unused update blocks. If an unused update block is available, it is possible that no amount of garbage collection is needed at step 604.
The amount of garbage collection determined at step 602 is compared to a predetermined threshold at step 606. The threshold may be 2 MB as for a D3 memory, for example, or may be another amount. The 2 MB threshold may be selected for a D3 memory such that the sequential write performance Pw of the memory is not negatively affected during a Speed Class Operation. If the amount of garbage collection is less than or equal to the threshold at step 606, then one or more blocks are selected based on an algorithm at step 608 for a garbage collection operation. Alternatively, step 606 may determine whether the amount of garbage collection is less than or equal to a first threshold and greater than or equal to a second threshold. If so, one or more blocks may be selected based on an algorithm at step 608 for a garbage collection operation.
One or more algorithms may be used to select the block at step 608. One example algorithm may include a least work to do (or least amount to copy) algorithm. The least work to do algorithm may analyze the data in one or more update blocks to determine the update block with the least amount of data to consolidate. The least work to do algorithm may examine a write pointer in the update block resource as an indicator of an amount of space needed to fill the update block. Another example algorithm may include a least recently used (LRU) algorithm to select the least recently used update blocks. The LRU algorithm may keep track of what blocks were used when in order to select the one or more least recently used update blocks. Still another example algorithm may include a most recently used (MRU) algorithm to select the most recently used update blocks. The MRU algorithm may keep track of what blocks were used when in order to select the one or more most recently used update blocks.
The threshold amount of garbage collection (such as the threshold in step 606) is forced by the method 600 even if the amount determined at step 604 is less than the threshold amount. The situation where the determined amount of garbage collection is less than the threshold may occur when the memory device is in a steady state, e.g., when all of the update blocks in the memory device are the result of data writes. At step 610, the garbage collection operation of the forced threshold amount is performed by copying data from other blocks to the update blocks selected at step 608. One or more unused update blocks are created as a result of the garbage collection operation. Finally, at step 612, the incoming data is written to the created unused update blocks and the method 600 is complete.
A Type C write of incoming data requires two update blocks to store the data, as discussed above. For a Type C write to a D3 memory, one update block is entirely filled with 3 MB of data and a second update block is filled with 1 MB of data and remains open. Update block 718 in the bottom row of
In the example depicted in
A Type C write of incoming data for a D3 memory entirely fills one update block with 3 MB of data and a second update block with 1 MB of data. The second update block, for example, update block 914, remains open following the Type C data write. If unused update blocks are available, then no garbage collection would be required in a conventional memory device for creating unused update blocks for the data write. However, update block 902 is selected for garbage collection according to the method 600 because it is the least recently used update block. Update block 902 undergoes 2 MB of garbage collection, resulting in an intact update block 908 following the data write. Update blocks 910 and 912 remain the same with the same data as update blocks 904 and 906, respectively, following the data write. Update block 902 is pre-emptively garbage collected in this example because no amount of garbage collection is required by the Type C write.
Referring back to
The alternate update block that is selected at step 614 is dependent on the type of data write at step 602. If a Type A or Type C write occurs, then an open update block with the least amount of required garbage collection is selected for a garbage collection operation at step 614. If the selected open update block does not require more than the threshold amount of garbage collection at step 616, then the garbage collection operation is performed at step 610 by copying data from other blocks to the selected open update block. The incoming data is then written at step 612 to the created unused update blocks. However, if the selected open update block requires more than the threshold amount of garbage collection at step 616, then the incoming data is written to a non-volatile storage area at step 618, such as to a binary cache or random access memory. A garbage collection operation of the threshold amount is still performed at step 620. For example, the data may be written to buffer random access memory (BRAM). The data may be maintained in BRAM until the garbage collection completes the process of freeing an update block.
If a Type B write occurs at step 602, then one or more alternate open update blocks are selected for a garbage collection operation at step 614. If there are no unused update blocks, then one or more open update blocks are selected at step 614. For example, a first open update block may be selected during the write of the first 2 MB, and a second open update block may be selected when writing the second 2 MB. As another example, the multiple update blocks may be selected at the same time. If the total amount of data needed to garbage collect the two selected update blocks is greater than the threshold amount at step 616, then the incoming data is written to a temporary storage area at step 618. A garbage collection of the threshold amount is still performed at step 620. However, if the total amount of data needed to garbage collect the two selected update blocks is less than or equal to the threshold amount at step 616, then garbage collection operation is performed at step 610. In this case, the selected update block with less than or equal to half of the threshold amount is garbage collected first, followed by a garbage collection operation on the other selected update block. The incoming data is written to the created unused update blocks at step 612.
A Type B write of incoming data for a D3 memory would fill two update blocks with 2 MB of data each, leaving both update blocks open with 1 MB of available space following the data write. Update blocks 1014 and 1016, for example, show the resulting open update blocks following a Type B write in this case. Because a Type B write results in two open update blocks, two currently open update blocks need to be garbage collected in order to create two unused update blocks. In this example, if the two least recently used open update blocks are selected, more than the threshold amount of 2 MB would be garbage collected. In particular, update block 1002 would undergo 2 MB of garbage collection and update block 1004 would undergo 1.5 MB of garbage collection, resulting in a total of 3.5 MB of garbage collection.
Because the amount of garbage collection exceeds the threshold, alternate update blocks are selected for garbage collection instead of the least recently used update blocks. In this example, update blocks 1004 and 1006 are selected for garbage collection, with update block 1006 being garbage collected first because it is the block with less than or equal to half the threshold, e.g., 0.5 MB, and the garbage collection of update block 1006 results in the intact update block 1012 following the data write. Update block 1004 undergoes garbage collection with an amount of 1.5 MB, resulting in the intact update block 1010 following the data write. Update block 1008 remains the same as update block 1002 following the data write. By selecting alternate update blocks in this scenario rather than the least recently used update blocks, the threshold amount of garbage collection is still pre-emptively performed.
In the method 1100, two update blocks are always selected for garbage collection operations. The two update blocks are in one of two states, State A or State B, as shown in
Transitioning between and within State A and State B requires 2 MB of garbage collection in a D3 memory. Because 2 MB of garbage collection is always performed in order to transition between and within the states, the garbage collection budget is met and a Speed Class Operation is not negatively affected. At step 1102 of the method 1100, incoming data to be written to a logical addressable unit is received by the memory device. Any type of data, including FAT and non-FAT data, may be written to the memory. The method 1100 does not know whether a Speed Class Operation has begun but instead may operate at all times.
At step 1104, it is determined whether the two selected update blocks are in State A or State B, as described in
On the other hand, at step 1104, if it is determined that the two selected update blocks are in State B, then the method 1100 continues to step 1108. At step 1108, it is determined what type of data write has occurred at step 1102. If the data write is a Type A or Type C data write, then the update blocks 1206 and 1208 are garbage collected at step 1114 such that the update blocks transition to State A and become update blocks 1202 and 1204. In particular, the update blocks 1206 and 1208 transition to State A because a Type A or Type C data write results in an open update block containing 1 MB of data and 2 MB of available space. However, if the type of data write at step 1108 is a Type B write, then the update blocks 1206 and 1208 are garbage collected at step 1116 such that the update blocks remain in State B. In this case, the update blocks 1206 and 1208 remain in State B because the Type B data write results in two open update blocks each containing 2 MB of data and 1 MB of available space. As before, in both steps 1114 and 1116, the incoming data to be written is stored in one or more update blocks.
Using volatile memory, such as the random access memory, to temporarily store a part of the information, such as the control information, may improve the performance of the memory device during a Speed Class Operation. The method 1300 may be performed as a busy time process or idle time process. The memory controller 114 may implement the method 1300, for example. Each of the steps described in
At step 1302, incoming data to be written to a logical addressable unit is received by the memory device. At step 1304, the quantity of the incoming data that has been received is compared to a threshold. Detection of the quantity of data may be restricted to when the start of the data is received in lengths of recording units. When data to be written to a logical addressable unit is received in lengths of recording units, a Speed Class Operation may have been started. If an addressable unit has a length of 4 MB, the recording unit has a length of 16 kB, for example. If the quantity of data detected at step 1304 is below the threshold, then the method 1300 returns to step 1302 to receive more incoming data.
However, if the quantity of data is at or above the threshold at step 1304, then the method 1300 continues to step 1306. The threshold may be 80% of the logical addressable unit, or may be another quantity or percentage. The incoming data is written to the physical blocks of the memory device at step 1306. At step 1308, garbage collection of any open update blocks in the memory device is performed. Any amount of garbage collection may be performed at step 1308 as necessary without negatively affecting the Speed Class Operation. There is no negative effect on the Speed Class Operation because the first addressable unit write of a Speed Class Operation is not used to measure the sequential write performance Pw.
In one embodiment, following the garbage collection operation performed at step 1308, the write type of the next data to be written is identified, as shown at step 1310. The write type, either Type A, B, or C, as described previously, may be determined by examining the logical starting address of the addressable unit being written.
In one embodiment, some or part of the data related to garbage collection may be automatically written to a volatile memory. In an alternate embodiment, some or part of the data related to garbage collection may be written to a volatile memory depending on one or more characteristics of the garbage collection. For example, the determination whether to write a part of the data related to garbage collection may be dependent on the write type. In particular, control information about an update block may be stored in either a random access memory or a flash memory depending on the identified write type. As another example, the determination whether to write a part of the data related to garbage collection may be dependent on whether the write fills the update block. Specifically, a determination is made whether to write a part of the information to a volatile memory. For example, the determination may be based on analyzing the next incoming data. In particular, at step 1312, it is determined whether the identified write type of the next incoming data will fill an update block and create an intact block. If the write type of the next incoming data will completely fill the update block, then a part of the information is stored in volatile memory, such as the control information is stored in a random access memory (RAM) at step 1316. The control information may include mapping information of the logical addressable unit to a physical metablock or other information. Examples of control information include, but are not limited to logical group, metablock number, write pointer, and page tag.
By storing the control information in a RAM instead of the flash memory, the maximum number of usable update blocks in the memory device may be extended, resulting in a reduction of forced garbage collection operations due to lack of resources. However, if the write type of the next incoming data will not completely fill the update block at step 1312, then the control information for the logical addressable unit is stored in the flash memory at step 1314.
If the control information is stored in a RAM, a power cycle flag or other indicator corresponding to the logical addressable unit may be set in the flash memory. By using a power cycle flag, if a loss of power to the memory device occurs before the update block with the control information stored in the RAM is closed, then recovery of the control information may occur upon re-initialization of the memory device. After re-initialization begins, if the power cycle flag is set, then the control information may be reconstructed (even though the control information previously stored in RAM is lost). One manner in which to reconstruct the control information is by using the free update block list, which is a list of the update blocks that are free. In particular, the free update block list may be used to determine the update blocks that are free, and at least a part of the data associated with those free update blocks may be analyzed. For example, the header information may be analyzed (such as the header information in the first page), so that the data contained in the update block may be determined. Once the data contained in the update block is determined, the control information may be constructed. The reconstructed control information for this update block may be subsequently stored in flash memory following the garbage collection of another update block after re-initialization of the memory device. Or, the reconstructed control information for this update block may again be stored in volatile memory (such as RAM).
Previously, garbage collection was performed when it was necessary to be performed due to memory constraints. In contrast, garbage collection may be performed in a selected mode of operation when the flash memory is more efficient to perform the garbage collection, such as illustrated in
At step 1402, incoming data to be written to a logical addressable unit is received by the memory device. Two parameters are accessed at step 1404 after the incoming data is received. The first parameter is the maximum amount of garbage collection that can be performed in a single busy period of the memory device. A busy period may comprise the duration of a read of data from the memory device or a write of data to the memory device. The second parameter is the maximum of garbage collection that can be performed during a write of the logical addressable unit. It is possible that the two parameters may be equal, but it is more likely that the second parameter will be higher than the first parameter. The two parameters may be stored in a RAM. As shown in
At step 1406, if the second parameter is higher than the first parameter, then the method 1400 continues to step 1408. At step 1408, garbage collection of the update block is initiated up to the amount of the second parameter. The garbage collection operation is performed through steps 1408 and 1410 until the amount of garbage collection reaches the amount of the second parameter. If the second parameter is not higher than the first parameter at step 1406, then garbage collection of the update block is initiated up to the amount of the first parameter at step 1412. In this case, the garbage collection operation is performed through steps 1412 and 1414 until the amount of garbage collection reaches the amount of the first parameter. The amount of data copied during a garbage collection operation during a write to a single logical addressable unit is maximized when using the method 1400. In particular, even if the logical addressable unit is completely written to the update block, then garbage collection continues on the update block until the maximum amount according the first or second parameter is reached.
It is intended that the foregoing detailed description be regarded as illustrative rather than limiting, and that it be understood that it is the following claims, including all equivalents, that are intended to define the spirit and scope of this invention.
Number | Name | Date | Kind |
---|---|---|---|
7451265 | Traister et al. | Nov 2008 | B2 |
20020099904 | Conley | Jul 2002 | A1 |
20030110343 | Hagiwara | Jun 2003 | A1 |
20060155922 | Gorobets et al. | Jul 2006 | A1 |
20060161728 | Bennett et al. | Jul 2006 | A1 |
20060184719 | Sinclair | Aug 2006 | A1 |
20080082736 | Chow et al. | Apr 2008 | A1 |
20080155301 | Ahvenainen et al. | Jun 2008 | A1 |
20080172431 | Stephens et al. | Jul 2008 | A1 |
20080209109 | Lasser | Aug 2008 | A1 |
20080279005 | France | Nov 2008 | A1 |
20080288717 | Torabi | Nov 2008 | A1 |
20090006720 | Traister | Jan 2009 | A1 |
20120005406 | Hutchison et al. | Jan 2012 | A1 |
Entry |
---|
International Search Report and Written Opinion issued in corresponding PCT/US2011/041647 dated Jan. 16, 2012 (14 pgs). |
Annex to Form PCT.ISA/206 Communication Relating to the Results of the Partial International Search issued in corresponding PCT Appln. No. PCT/US2011/041647 dated Oct. 20, 2011 (2 pgs). |
Number | Date | Country | |
---|---|---|---|
20120005405 A1 | Jan 2012 | US |