1. Field of the Invention
The present disclosure relates generally to a solid state drive (SSD), and more particularly to a method for implementing trim commands to modify a flash translation layer (FTL) when the SSD receives the trim commands from a host.
2. Description of the Prior Art
A solid state drive (SSD) is a single storage device in which a NAND flash memory array is integrated, and the SSD is usually used as a storage device of an electronic device. A host of the electronic device sends a logical address for accessing data from a central processing unit (CPU) to the SSD connected to a transmission interface. A controller installed in the SSD cooperates with a buffer to receive the logical address from the host, to access the data stored in a physical address of a flash memory array corresponding to the logical address, and to transmit the accessed data to a dynamic random access memory (DRAM) of the host. The accessed data transmitted to the DRAM would be reserved for the host.
Since the erasing times of a flash memory is limited, data would be dispersedly stored in the flash memory array. To manage the relationships between the logical addresses of data and the physical addresses of the flash memory array, the SSD would read management information of each data block in the flash memory array when the SDD starts up, so as to form a logical to physical lookup table of the data and to establish a flash translation layer (FTL) for storing and managing the logical to physical lookup table and related parameters thereof.
Data stored in the flash memory of the SSD cannot be arbitrarily overwritten. Old data should be erased before new data is stored. Moreover, the data of the flash memory is erased in unit of data blocks. The SSD utilizes a mechanism of garbage collection in unit of data blocks to move data stored in valid pages of a data block and then erase all of data stored in the data block to recycle the data block, which would be used as a spare block for storing data. Therefore, the faster the host informs the SSD about invalid pages, the easier the number of invalid pages of the data block reaches a threshold of the recycling, and the greater the efficiency of the recycling of garbage. Accordingly, enough spare blocks might be provided, data might be written without waiting for the recycled spare blocks, and the performance of the SSD might be improved.
Please refer to
However, according to the prior art, since the four execution steps should be executed for implementing each of the trim commands, the response time for informing the host about the completion of implementing the whole batch of the trim commands would be elongated. More particularly, if the range of the logical addresses of the trim commands is too broad and too scattered, the response time would be elongated excessively because the logic addresses accessed by the SSD are non-continuous and it needs more time for executing the execution steps 2 and 3 to clear the logical to physical lookup table and adjust the parameters of the FTL. As a result, the host would be standby for most of time, such that other operations of the host would be supplanted and the performance of the SSD would be reduced. Therefore, there is an issue needs to be solved when the SSD implementing the trim commands according to the prior art.
It is an objective of the present invention to provide an SSD, which sets a deletion flag in a lookup table entry of the logical to physical lookup table. The deletion flag marks a logically address as a logically address without the implementing of the trim commands, such that the SSD would implement the trim commands according to the deletion flags.
It is another objective of the present invention to provide a method for implementing trim commands of an SSD. The SSD notifies a host that the implementing of the trim commands have been completed when the SSD just modifies the deletion flags of the lookup table entries based on the received trim commands. Accordingly, the duration for responding to the host is shortened.
It is another objective of the present invention to provide a method for implementing trim commands of an SSD. The SSD implements the trim commands, in the background, on the logical addresses where are marked by the deletion flags, so as to improve the performance of the SSD.
Accordingly, an embodiment of the present invention provides a method for implementing the trim commands received by a SSD. The SSD uses a controller to receive the trim commands and temporarily stores the received trim commands in a buffer. The SSD uses a flash memory array to store data, and the SSD uses a flash translation layer (FTL) unit to determine to establish the FTL either in the buffer or in the flash memory array. The FTL unit instructs the controller to read data stored in the flash memory array to form a logical to physical lookup table, so as to establish the FTL and manage parameters of the FTL. The logical to physical lookup table comprises physical addresses and lookup table entries. A deletion flag field of one bit is marked out in a reserved field of the lookup table entries. The deletion flag is configured to mark a logical address as a logical address without the implementing of the trim commands. The SSD would implement the trim commands in the background or in a standby mode according to the deletion flags.
According to an embodiment of the present invention, the SSD receives a batch of trim commands, which inform the SSD about the invalid pages of the SSD. The deletion flag of the lookup table entry of the logical to physical lookup table in each logical address located within the range of one of the trim commands is modified to mark the logical address as a logical address without the implementing of the trim commands. Then, the host is informed the implementing of the trim command is completed. After the implementing of a trim command is completed, the foresaid steps would be repeated to implement another trim command until the implementing of the last trim command is completed. For the logically addresses marked by the deletion flags as logically addresses without the implementing of the trim commands, the SSD clears the data of the lookup table entry and adjusts the parameters of the FTL in the background or in a standby mode.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
The present invention can be more fully understood by reading the subsequent detailed description and examples with references made to the accompanying drawings, wherein:
The following description is of the best-contemplated mode of carrying out the invention. This description is made for the purpose of illustrating the general principles of the invention and should not be taken in a limiting sense. The scope of the invention is best determined by reference to the appended claims.
Please refer to
When the SSD 20 starts up, the FTL unit 24 determines to establish the FTL either in the buffer 22 or in the flash memory array 23, and the FTL unit 24 instructs the controller 21 to read management information of each data block in the flash memory array 23 to form the logical to physical lookup table 30 in
Please refer to
As for the logical address, in which no trim command has been implemented, because the host is informed the data page in the logical address is an invalid page, the host would not request to access the data page. Although only the deletion flag is modified, the data page is still valid in view of the SSD, such that the number of invalid pages of each data block would not increase to influence the performance of the mechanism of garbage collection of the SSD. As long as the spare blocks of the SSD are enough to maintain the normal operations of the SSD, it has no urgency to implement the trim commands. Therefore, according to the present invention, the SSD might, selectively in the background or in a standby mode, execute the procedure of clearing the data of the lookup table entry in the execution step 2 and the procedure of adjusting the parameters of the FTL in the execution step 3 for the logically addresses marked by the deletion flags as logically addresses without the implementing of the trim commands. Meanwhile, because the host would not wait for the completion of implementing the trim commands, such that the time and speed of executing other operations of the SSD would not be influenced and that the performance of the SSD would be improved.
Please refer to
Therefore, a SSD of the present invention sets a deletion flag by using the lookup table entry of the logical to physical lookup table. According to the method of the present invention for implementing the trim commands, the SSD notifies a host that the implementing of the trim commands have been completed when the SSD just modifies the deletion flags of the lookup table entries according to the logical addresses of the received trim commands. Therefore, the duration for responding to the host is shortened. Moreover, according to the method of the present invention, the SSD might, selectively in the background or in a standby mode, implement of the trim commands on the logically addresses marked by the deletion flags as logically addresses without the implementing of the trim commands, such that the time and speed of executing other operations of the SSD would not be influenced and that the performance of the SSD would be improved.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
201510876173.4 | Dec 2015 | CN | national |