Fragmentation of files due to host fragmentation or storage module fragmentation can degrade system performance. With host fragmentation, files are scattered across many non-consecutive logical block address (LBA) ranges of the storage module. So, the more LBA ranges are used to store a file, the more fragmented the file becomes. Further, in some file systems, such as EXT4, the file allocation table (FAT) is mixed with stored data. Reading a fragmented file in such a system requires more operations, as the structure of the file is more complicated. This can degrade read performance.
With storage module fragmentation, files are scattered among many physical blocks in memory. The more physical blocks that are allocated for the same file, the more fragmented the file is. Because a fragmented file often does not occupy the entire physical block, a physical block that stores part of a fragmented file will often store data of other files. So, when a host deletes a file that is fragmented over several physical blocks, this may result in fewer free blocks than intended, as the blocks still hold data for other files. Because such a file deletion will leave “holes” of free space in an otherwise-occupied physical block, the storage module will need to perform several “housekeeping” operations to create a free block, which can degrade system performance.
Additionally, in some environments, such as in mobile computing systems, when a file is fragmented by the storage module, the host does not know how fragmented the file is, so it does not know what action is needed to attempt to defragment the file. Further, while a host is aware of the host-fragmentation problem and can attempt to solve it by moving a scattered file to consecutive LBA ranges, such moving can actually degrade performance because of the storage fragmentation problem.
Embodiments of the present invention are defined by the claims, and nothing in this section should be taken as a limitation on those claims.
By way of introduction, various embodiments relate to a storage module and host device for storage module defragmentation. In one embodiment, a host controller sends a storage module a first set of logical block addresses of a file stored in the storage module. The host controller receives a metric from the storage module indicative of a fragmentation level of the file in physicals blocks of memory in the storage module. If the metric is greater than a threshold, the host controller reads the file and then writes it back to the storage module using a different set of logical block addresses. To avoid sending the file back and forth, in another embodiment, the host controller sends the fragmentation threshold and the different set of logical block addresses to the storage module. The storage module then moves the file itself if the metric indicative of the fragmentation level is greater than the threshold. To perform this embodiment on a plurality of files, the host controller can send the information about the files on a file-by-file basis to the storage module or can send the information as a group to the storage module. In another embodiment, a host controller sends, to the storage module, a set of logical block addresses of a file stored in the storage module, and the storage module generates, and sends to the host controller, a metric indicative of a level of fragmentation level of the file in physical blocks of memory in the storage module. In yet another embodiment, a host controller reads a file stored in a storage module and writes it back to the storage module according to a specified writing mode.
Other embodiments are possible, and each of the embodiments can be used alone or together in combination. Accordingly, various embodiments will now be described with reference to the attached drawings.
As mentioned above, a host typically does not know how fragmented a file is in physical blocks of memory in the storage module, so it does not know what action is needed to attempt to defragment the file. The following embodiments can be used to address the storage module fragmentation problem discussed above by giving the host an understanding of storage module fragmentation and providing the host with a set of tools to handle storage device fragmentation with various levels of involvement. Before turning to these and other embodiments, the following paragraphs provide a discussion of an exemplary storage module and host that can be used with these embodiments. Of course, these are just examples, and other suitable types of storage modules can be used.
As illustrated in
As shown in
As shown in
In
Returning to
The non-volatile memory 120 can also take any suitable form. For example, in one embodiment, the non-volatile memory 120 takes the form of a solid-state (e.g., flash) memory and can be one-time programmable, few-time programmable, or many-time programmable. The non-volatile memory 120 can also use single-level cell (SLC), multiple-level cell (MLC), triple-level cell (TLC), or other memory technologies, now known or later developed. Also, the non-volatile memory 120 can be a two-dimensional memory or a three-dimensional memory.
As mentioned above, a host typically does not know how fragmented a file is in physical blocks of memory in the storage module, so it does not know what action is needed to attempt to defragment the file.
Typically, a host does not have insight into the level of storage module fragmentation. So, in one embodiment, a new communication between the host 240 and storage module 100 is provided. This will be illustrated in conjunction with the flow chart 400 of
As used herein, a defragmentation metric reflects the level of fragmentation for a file, and its value relates to the degree of such fragmentation. An example of a defragmentation metric can include the number of physical blocks containing the file. So, in the example shown in
Based on the received defragmentation metric, the host 240 can choose to take various actions. For example, as shown in
The following chart is a high-level description of the commands and response arguments for the embodiment discussed above. Of course, this is merely one example, and other arguments can be used.
As can be seen by the above examples, this embodiment allows the host 240 to have visibility into the storage module fragmentation for a given file and provides the host 240 with a set of tools to handle storage device fragmentation with various levels of involvement. For example, the host 240 can read and write the file back to the storage module 100 with a better fragmentation metric (e.g., fewer number of physical blocks), if desired. In another embodiment, instead of the host 240 reading the file out of the storage module 100 and then writing the file back to the storage module 100, this defragmentation process is performed without moving the file back and forth between the storage module 100 and the host 240, thereby avoiding the data transfer on the bus.
The advantage of this embodiment over the previous embodiment is that the host implementation is simpler because the transfer of unnecessary data on host-storage bus is eliminated. In this case, the file system on the host 240 has the knowledge on each file, and it sends a Defrag File command one by one. The following chart is a high-level description of the commands and response arguments for this embodiment. Of course, this is merely one example, and other arguments can be used.
Further optimization can be achieved if the host 240 sends list of files or a directory, with the host 240 optionally providing priorities and scheduling information. This embodiment is shown in the flow chart 600 of
Irrespective of whether the host 240 communicates the files on a file-by-file basis (
The following chart is a high-level description of the commands and response arguments for this embodiment. Of course, this is merely one example, and other arguments can be used.
There are many alternatives that can be used with these embodiments. For example, in addition to or instead of moving the file to reduce storage device fragmentation, the host 340 can also use the received defragmentation metric to decide whether to activate host defragmentation. Unlike storage module fragmentation which focuses on physical blocks in the memory 120 of the storage module 100, host fragmentation focuses on the logical block address (LBA) ranges of a file. A host can address this problem by moving a scattered file to consecutive LBA ranges. However, if the file is fragmented across many physical blocks, host defragmentation can actually lead to worse performance than if the LBA ranges of the file were left as-is. So, by using this embodiment, the host 240 can base the determination of whether to perform host defragmentation on the storage module defragmentation metric.
In another embodiment, the defragmentation techniques discussed herein can be used with storage modules using the NVM Express (NVMe) protocol. Such storage modules can benefit from these embodiments by leveraging data set management commands that allow the host 240 to indicate to the storage module 100 when multiple non-consecutive LBA ranges are part of the same file. This uses the DATASET MANAGEMENT command and the Integral Read flag of the WRITE command in NVMe protocol. This embodiment will be discussed in more detail in conjunction with the flow chart 800 of
As shown in the flow chart 800, the host 240 first determines that a write is to a partial or complete file (act 810). The host 240 then allocates or updates the allocation of an LBA range in the file system (act 820). Next, the host 240 performs a loop for each contiguous range of LBAs (“extent”) (act 830). First, the host 240 determines whether there is new data written to the extent (act 840). If there isn't, the host 240 submits a data set management command with an integral read flag (IDR) for the extent LBA range (act 850). If there is, the host 240 submits a write command with an IDR flag for the extent LBA range (act 860). When the end of the file occurs (act 870), the storage module 100 consolidates blocks and completes the command (act 880). In this embodiment, the storage module 100 consolidates blocks as per the above embodiments before completing the dataset management commands issued by the host 240. The host 240 thus knows that the file is stored optimally.
A variation of this involves new file writes. Typically, new writes are programmed to the next available free block without regard for whether the following writes are part of the same sequence. When multiple files are written simultaneously using multiple queues, this can lead to the write interleaving shown in
During a host-driven defragmentation cycle (as described above), the host 240 may send a data set management range table with the integral read flag in order to trigger consolidation. Typical SSDs can contain thousands of files, making sending individual data set management commands clumsy and inefficient. In another embodiment, the host 240 sends a command to the storage module 100 indicating LBA ranges that already contain extent lists that map to individual files (as is common in file systems). The storage module 100 then parses these extent lists and consolidates the files accordingly. The format of the extent list may match the structures found in file systems (such as FAT, NTFS, and HFS+) that utilize extent lists for fragmented files. The storage module 100 does not update the extent list autonomously but rather reorganizes the physical blocks indicated by the LBAs in each extent such that they are not physically fragmented.
It should be noted that in a highly-asynchronous protocol like NVMe and with the large number of fragmented extents found in a typical SSD, it may be easier for the storage module to just make the determination of fragmentation level of each file without informing the host of each file's fragmentation level. However, both the technique of reporting metrics back to the host prior to defrag and the technique of sending a hint on a specific sequence of extents can be used.
It is intended that the foregoing detailed description be understood as an illustration of selected forms that the invention can take and not as a definition of the invention. It is only the following claims, including all equivalents, that are intended to define the scope of the claimed invention. Finally, it should be noted that any aspect of any of the preferred embodiments described herein can be used alone or in combination with one another.
This application claims the benefit of U.S. provisional patent application No. 61/936,170, filed Feb. 5, 2014, which is hereby incorporated by reference.
Number | Name | Date | Kind |
---|---|---|---|
8818966 | Nanda | Aug 2014 | B1 |
20050091445 | Chang | Apr 2005 | A1 |
20050228963 | Rothman et al. | Oct 2005 | A1 |
20050256696 | Gooding | Nov 2005 | A1 |
20070143566 | Gorobets | Jun 2007 | A1 |
20080010395 | Mylly et al. | Jan 2008 | A1 |
20080307192 | Sinclair et al. | Dec 2008 | A1 |
20090055620 | Feldman et al. | Feb 2009 | A1 |
20090157948 | Trichina | Jun 2009 | A1 |
20090172040 | Mosek | Jul 2009 | A1 |
20100146195 | Lee | Jun 2010 | A1 |
20100312983 | Moon et al. | Dec 2010 | A1 |
20110119455 | Tsai et al. | May 2011 | A1 |
20110188319 | Harada | Aug 2011 | A1 |
20110225215 | Ukai | Sep 2011 | A1 |
20130111199 | Watanabe | May 2013 | A1 |
20130282955 | Parker | Oct 2013 | A1 |
20140223083 | Park | Aug 2014 | A1 |
20140359198 | Zaltsman | Dec 2014 | A1 |
Entry |
---|
NVM Express, Jul. 2, 2014, Revision 1.1b, pp. 124-125. |
International Search Report and Written Opinion for PCT/U52015/012585 dated Jul. 6, 2015, 20 pages. |
Invitation to Pay Additional Fees for PCT/US2015/012585 dated Apr. 22, 2015, 5 pages. |
Application as filed for U.S. Appl. No. 13/753,144 entitled, “Logical Block Address Remapping”, filed Jan. 29, 2013, 22 pages. |
Office Action for U.S. Appl. No. 14/249,063 dated Nov. 18, 2015, 14 pages. |
Office Action for U.S. Appl. No. 14/249,082 dated Nov. 5, 2015, 22 pages. |
Office Action for U.S. Appl. No. 14/249,096 dated Nov. 4, 2015, 22 pages. |
Office Action for U.S. Appl. No. 14/249,063 dated May 18, 2016, 12 pages. |
Office Action for U.S. Appl. No. 14/249,082 dated May 18, 2016, 22 pages. |
Office Action for U.S. Appl. No. 14/249,096 dated May 18, 2016, 19 pages. |
Number | Date | Country | |
---|---|---|---|
20150220268 A1 | Aug 2015 | US |
Number | Date | Country | |
---|---|---|---|
61936170 | Feb 2014 | US |