This application claims the benefit of People's Republic of China Application Serial No. 201510833643.9, filed Nov. 25, 2015, the subject matter of which is incorporated herein by reference.
The present invention relates to a solid state drive and a data programming method thereof, and more particularly to a solid state drive with a garbage collection function and a data programming method comprising the garbage collection.
As is well known, a solid state drive (SSD) is a data storage device that uses a non-volatile memory to store data. A NAND-based flash memory is one kind of the non-volatile memory. After data are written to the flash memory, if the system is powered off, the data are still retained in the flash memory.
A process of programming write data from the host 12 into the flash memory 105 will be illustrated as follows. Firstly, the controller 101 performs an error correction (ECC) encoding operation on the write data, and then temporarily stores the write data into the buffer 107. Moreover, the controller 101 performs a program action at proper time in order to store the write data of the buffer 107 into the flash memory 105.
For example, the buffer 107 is a cache memory such as a static random access memory (SRAM) or a dynamic random access memory (DRAM). Generally, the external bus 20 is a USB bus, an IEEE 1394 bus, an SATA bus, or the like.
Generally, the flash memory 105 comprises plural blocks, for example 1024 blocks. Each block comprises plural pages, for example 64 pages. Each page is typically 4K bytes in size. Due to the inherent properties of the flash memory 105, at least one page is written during the program action, and the erase operation is performed in a block-wise fashion.
Generally, the host 12 accesses the flash memory 105 through logical block addresses (LBA). Each LBA can store data of 512 bytes in size. When the host 12 intends to program the write data into the flash memory 105, the host 12 may provide a write command and a corresponding LBA to the controller 101. Then, the write data is transmitted from the host 12 to the controller 101. The write data is temporarily stored in the buffer 107 by the controller 101.
For example, if one page of the flash memory 105 is 4K bytes in size, the data amount of eight LBAs is equal to the data amount of one page. As known, the flash memory 105 is programmed in a unit of at least one page. If the amount of data temporarily stored in the buffer 107 exceeds the data amount of one page, the controller 101 starts the program action and programs the data to the flash memory 105 in a unit of at least one page.
Moreover, the controller 101 selects one free block of the flash memory 105 as an open block. While the program action is performed, the data temporarily stored in the buffer 107 is programmed into the open block under control of the controller 101. After the open block is occupied by the data, the controller 101 will select another block as another open block and continuously program the data of the buffer 107 into this open block.
Since the erase operation of the flash memory 105 is performed in a block-wise fashion, the data is each page cannot be individually erased and updated. After an updated data is received by the flash memory 105, the updated data is stored in a new page (i.e., a blank page), and the original data in the old page is set as an invalid data. However, after the flash memory 105 has been accessed for a long time, each block of the flash memory 105 may contain some valid data and some invalid data. Consequently, the writable space of the flash memory 105 gradually decreases.
As shown in
For example, the host 12 intends to output the write data Data8′, Data2′, Data9, Data10, Data11, Data7′, Data12 and Data13 to the flash memory 105. The write data Data2′, Data7′ and Data8′ are updated data of the data Data2, Data7 and Data8, respectively. The write data Data9˜Data13 are new data.
Please refer to
Then, the host 12 intends to output the write data Data14, Data3′, Data7″ and Data12′ to the flash memory 105. The write data Data3′, Data7″ and Data12′ are updated data of the data Data3, Data7′ and Data12, respectively. The write data Data14 is a new data.
Please refer to
From the above discussions, after many program actions, the flash memory 105 may contain a great number of invalid data. Consequently, the writable space of the flash memory gradually decreases. Moreover, the erase operation of the flash memory 105 can be performed in a block-wise fashion. Although the flash memory 105 as shown in
As the number of free blocks in the flash memory 105 gradually decreases, it is necessary for the controller 101 of the solid state drive 10 to perform a garbage collection. After the garbage collection is performed, the storing space of the invalid data in the used blocks can be released. Consequently, the writable space of the flash memory 105 increases.
Generally, when the host 12 issues a write command, the write command may be determined as a sequential write command or a random write command according to the logical block address (LBA) from the host 12. For example, if the LBA in the write command is a consecutive logical block address, the write command from the host 12 is determined as the sequential write command. Moreover, according to the sequential write command, the write data from the host 12 is continuously stored into the flash memory 105. For example, the host 12 will continuously overwrite the flash memory 105 or continuously update the data. Hereinafter, the operations of the garbage collection of the conventional flash memory after the situation of
While the valid data in the to-be-released blocks are moved by the controller 101, the write data from the host 12 may be continuously received by the buffer 107. In other words, the controller 101 can simultaneously perform the garbage collection and receive the write data from the host 12. As shown in
As shown in
Then, as shown in
While the controller 101 performs the programming procedure comprising the garbage collection, if the block to be erased contains the valid data and the invalid data, the controller 101 has to move the valid data from the block to the buffer 107, and the controller 101 has to receive the write data from the host 12 and temporarily store the write data into the buffer 107. In other words, while the controller 101 performs the programming procedure comprising the garbage collection, the moved valid data corresponding to the garbage collection and the write data from the host 12 are temporarily stored in the buffer 107 in an interlaced manner. Consequently, after the data in the buffer 107 are programmed to the open blocks of the flash memory 105 by the controller 101, the moved valid data corresponding to the garbage collection and the write data from the host 12 are stored into the first block (Block_1) and the second block (Block_2) in the interlaced manner.
Please refer to
The process of performing another garbage collection will be illustrated with reference to
Similarly, while the valid data in the to-be-released blocks are moved by the controller 101, the write data from the host 12 are continuously received by the buffer 107. As shown in
As shown in
Then, as shown in
Similarly, after the data in the buffer 107 are programmed to the open blocks of the flash memory 105 by the controller 101, the moved valid data corresponding to the garbage collection and the write data from the host 12 are stored into the first block (Block_1) and the second block (Block_2) in the interlaced manner (see
Please refer to
For example, after the above data programming method, the data in the flash memory 105 of the conventional solid state drive 10 has the storage condition as shown in
From the above discussions about the conventional data programming method, the moved valid data (GC) corresponding to the garbage collection and the write data (H) from the host 12 are stored in the flash memory 105 in the interlaced manner. Moreover, if the host 12 intends to update or overwrite the sequential write data, the controller 101 has to re-perform the garbage collection and repeatedly move the valid data corresponding to the previous garbage collection. Moreover, after the valid data in the to-be-released blocks are moved to the buffer 107, the controller 101 performs the block erase operation and programs the data into the flash memory 105. Moreover, since the buffer 107 still contains the valid data (GC) and the write data (H) in the interlaced manner, the valid data (GC) and the write data (H) are programmed into the open block in the interlaced manner.
During the sequential write process, the controller 101 has to continuously re-perform the garbage collection and repeatedly move the valid data corresponding to the previous garbage collection. Consequently, the write speed of the solid state drive 10 fluctuates between a high speed and a low speed. That is, the write speed cannot reach the desired level.
An embodiment of the present invention provides a data programming method for a solid state drive. The solid state drive has a flash memory with plural blocks. If a garbage collection is determined to be performed, a first open block is selected from the plural blocks of the flash memory for storing a moved valid data corresponding to the garbage collection. Then, the moved valid data corresponding to the garbage collection is programmed into the first open block. A second open block is selected from the plural blocks of the flash memory for storing a write data from a host.
Another embodiment of the present invention provides a solid state drive in communication with a host. The solid state drive includes a controller and a flash memory. The controller determines whether to perform a garbage collection. A flash memory is connected with the controller, and includes plural blocks. If the garbage collection is determined to be performed, the controller selects a first open block from the plural blocks of the flash memory for storing a moved valid data corresponding to the garbage collection, and programs the moved valid data corresponding to the garbage collection into the first open block. Moreover, a second open block is selected from the plural blocks of the flash memory for storing a write data from a host.
Numerous objects, features and advantages of the present invention will be readily apparent upon a reading of the following detailed description of embodiments of the present invention when taken in conjunction with the accompanying drawings. However, the drawings employed herein are for the purpose of descriptions and should not be regarded as limiting.
The above objects and advantages of the present invention will become more readily apparent to those ordinarily skilled in the art after reviewing the following detailed description and accompanying drawings, in which:
In accordance with the present invention, the buffer 510 is divided into a first storage zone 512 and a second storage zone 514. The moved valid data (GC) corresponding to the garbage collection are temporarily stored in the first storage zone 512. The write data (H) from the host 52 are temporarily stored in the second storage zone 514.
Moreover, the controller 51 selects two free blocks of the flash memory 505, and defines the two free blocks as a first open block and a second open block. The first open block is used for storing the moved valid data (GC) corresponding to the garbage collection. The second open block is used for storing the write data (H) from the host 52. While the program action is performed, the valid data (GC) in the first storage zone 512 and the write data (H) in the second storage zone 514 are respectively stored into the first open block and the second open block of the flash memory 505 by the controller 501. After the first open block is programmed and is full, the controller 501 selects an additional first open block from the flash memory 505 to store the valid data (GC). Similarly, after the second open block is programmed and is full, the controller 501 selects an additional second open block from the flash memory 505 to store the write data (H).
Since the moved valid data (GC) corresponding to the garbage collection and the write data (H) from the host 52 are programmed into different open blocks by the controller 501, the valid data (GC) and the write data (H) are not simultaneously contained in the same block. Under this circumstance, the write speed of the solid state drive 50 is enhanced.
Please refer to
Similarly, while the valid data in the to-be-released blocks are moved from the flash memory 505 by the controller 501, the write data from the host 52 are continuously received by the controller 501 and stored into the buffer 510. In other words, the controller 501 can simultaneously perform the garbage collection and receive the write data from the host 52. As shown in
As shown in
Then, as shown in
Obviously, the all data in the first block (Block_1) are the moved valid data (GC) corresponding to the garbage collection, and all data in the second block (Block_2) are the write data (H) from the host 52.
Please refer to
After the previous programming procedure comprising the garbage collection is performed, the moved valid data corresponding to the garbage collection are all stored in the first open block, i.e., the first block (Block_1). And, the second open block, i.e., the second block (Block_2), only stores the write data Data15, Data16, Data17 and Data18 from the host 52 but does not store the moved valid data corresponding to the garbage collection. Since the old data Data15, Data16, Data17 and Data18 in the second block (Block_2) are considered as the invalid data because these data have been updated, the controller 501 can directly perform a block erase action on the second block (Block_2) to acquire the storing space. Under this circumstance, it is not necessary to move the valid data.
The process of performing another garbage collection will be illustrated with reference to
Then, as shown in
From the above descriptions, the present invention provides a solid state drive and a data programming method. The controller selects two free blocks as the first open block and the second open block. The first open block is used for storing the moved valid data (GC) corresponding to the garbage collection. The second open block is used for storing the write data (H) from the host. Moreover, the buffer is divided into a first storage zone and a second storage zone. The moved valid data (GC) corresponding to the garbage collection are temporarily stored in the first storage zone. The write data (H) from the host are temporarily stored in the second storage zone.
Moreover, if the storing space of the flash memory 505 is insufficient and the host 52 intends to update or overwrite the sequential write data, the block of the flash memory 505 storing the write data (H) has higher probability of being completely occupied by invalid data because the block of the flash memory 505 storing the write data (H) does not have the moved valid data (GC) corresponding to the garbage collection. Under this circumstance, the controller 501 does not need to repeatedly move the valid data and perform the program action. After the block completely occupied by invalid data is erased, the controller 501 may set the erased free block as the second open block and directly program the write data into the second open block.
While the invention has been described in terms of what is presently considered to be the most practical and preferred embodiments, it is to be understood that the invention needs not be limited to the disclosed embodiment. On the contrary, it is intended to cover various modifications and similar arrangements included within the spirit and scope of the appended claims which are to be accorded with the broadest interpretation so as to encompass all such modifications and similar structures.
Number | Date | Country | Kind |
---|---|---|---|
2015 1 0833643 | Nov 2015 | CN | national |
Number | Name | Date | Kind |
---|---|---|---|
7444462 | Traister et al. | Oct 2008 | B2 |
8990480 | Kanno | Mar 2015 | B2 |
9342458 | Hu | May 2016 | B2 |
20080034175 | Traister | Feb 2008 | A1 |
20080129740 | Itagaki | Jun 2008 | A1 |
20100082890 | Heo | Apr 2010 | A1 |
20100217927 | Song | Aug 2010 | A1 |
20110022778 | Schibilla | Jan 2011 | A1 |
20110029749 | Yang | Feb 2011 | A1 |
20110153911 | Sprouse | Jun 2011 | A1 |
20110246821 | Eleftheriou | Oct 2011 | A1 |
20120054414 | Tsai | Mar 2012 | A1 |
20120084489 | Gorobets | Apr 2012 | A1 |
20120151124 | Baek | Jun 2012 | A1 |
20120173795 | Schuette | Jul 2012 | A1 |
20120284587 | Yu | Nov 2012 | A1 |
20120290769 | Okubo | Nov 2012 | A1 |
20130019057 | Stephens | Jan 2013 | A1 |
20130103889 | Jeong | Apr 2013 | A1 |
20130132647 | Melik-Martirosian | May 2013 | A1 |
20130151892 | Huang | Jun 2013 | A1 |
20130166818 | Sela | Jun 2013 | A1 |
20140019670 | Huang | Jan 2014 | A1 |
20140029341 | In | Jan 2014 | A1 |
20140122774 | Xian | May 2014 | A1 |
20140189209 | Sinclair | Jul 2014 | A1 |
20140281338 | Choi | Sep 2014 | A1 |
20150261797 | Alcantara | Sep 2015 | A1 |
Number | Date | Country | |
---|---|---|---|
20170147232 A1 | May 2017 | US |