Hybrid drive comprising write cache spanning non-volatile semiconductor memory and disk

A hybrid drive is disclosed comprising a head actuated over a disk comprising a plurality of data tracks, where each data track comprises a plurality of data sectors. The hybrid drive further comprises a non-volatile semiconductor memory (NVSM) comprising a plurality of memory segments. When a write command is received from a host including write data, the write data is written to one of a disk cache and a NVSM cache, wherein the write data is eventually flushed to a non-cache area of the disk.

BACKGROUND

Hybrid drives are conventional disk drives augmented with a non-volatile semiconductor memory (NVSM) such as a flash which helps improve certain aspects of the disk drive. For example, the non-volatile semiconductor memory may store boot data in order to expedite the boot operation of a host computer. Another use of a NVSM may be to store frequently accessed data and/or non-sequential data for which the access time is typically much shorter than the disk (which suffers from mechanical latency including seek and rotational latency). Other policies may reduce write amplification of the NVSM in order to maximize its longevity, such as storing frequently written data to the disk (or data having a write/read ratio that exceeds a predetermined threshold).

DETAILED DESCRIPTION OF EMBODIMENTS OF THE INVENTION

FIG. 1Ashows a hybrid drive according to an embodiment of the present invention comprising a head2actuated over a disk4comprising a plurality of data tracks6, where each data track comprises a plurality of data sectors. The hybrid drive further comprises a non-volatile semiconductor memory (NVSM)8comprising a plurality of memory segments. Control circuitry10executes the flow diagram ofFIG. 1B, wherein when a write command is received from a host including write data (step12), a determination is made (step14) whether to write the write data to one of a disk cache (step16) and a NVSM cache (step18). The write data is written to one of a disk cache and a NVSM cache, and during a flush operation (step20) the write data is flushed to a non-cache area of the disk (step22).

In the embodiment ofFIG. 1A, the disk4comprises embedded servo sectors240-24Nthat define the data tracks6. The control circuitry10processes a read signal26emanating from the head2to demodulate the servo sectors240-24Nand generate a position error signal (PES) representing an error between the actual position of the head and a target position relative to a target track. The control circuitry10filters the PES using a suitable compensation filter to generate a control signal28applied to a voice coil motor (VCM)30which rotates an actuator arm32about a pivot in order to actuate the head2radially over the disk in a direction that reduces the PES.

Any suitable NVSM8may be employed in the embodiments of the present invention such as a suitable flash memory. In one embodiment, the NVSM8comprises a plurality of blocks, wherein each block comprises a plurality of memory segments referred to as pages, and each page may store one or more data sectors. The blocks are programmed a page at a time, and an entire block is erased in a unitary operation. In one embodiment, there is a limit to the number of times the blocks of the NVSM may be programmed and erased (referred to as endurance). When the NVSM reaches the limit of program/erase cycles it essentially reaches end of life (for subsequent write operations). Accordingly, in one embodiment of the present invention the disk cache helps extend the life of the NVSM by implementing a write cache that spans both the NVSM and the disk. In this manner, at least some of the write commands are cached in the disk cache which reduces write amplification in the NVSM.

In another embodiment of the present invention, implementing a write cache using both the disk and NVSM helps improve performance by writing data to both channels concurrently. For example, multiple write commands may be queued in a command queue (or a single large write command broken into multiple write commands) wherein a first part of the write data may be written to the disk cache while concurrently writing a second part of the write data to the NVSM cache.

Employing a write cache in a hybrid drive improves performance by avoiding the mechanical latency involved with accessing the disk (seek latency and rotational latency) when servicing non-sequential write commands. Instead of seeking the head around the disk to service non-sequential write commands, the write data is cached in one of the disk cache and the NVSM cache, and then later flushed to the non-cache area of the disk, for example, when the hybrid drive is idle or otherwise ready to flush the write cache. In one embodiment, the disk cache is implemented as a circular buffer so that non-sequential write commands can be written to sequential data sectors (thereby avoiding long seeks within the disk cache).

In the embodiment ofFIG. 1A, the NVSM8comprises a cache area and a non-cache area. The non-cache area of the NVSM may be used to store data that helps improve performance of the hybrid drive, such as frequently accessed data and/or boot data for the host operating system. In one embodiment, the logical block addresses (LBAs) mapped to the non-cache area of the NVSM8may change over time depending on the historical use of the hybrid drive. In another embodiment, the entire NVSM8may be used as a write cache, and in yet another embodiment described below, the size of the NVSM cache may change over time, such as decreasing the size of the NVSM cache as the life remaining of the NVSM decreases.

FIG. 1Cis a flow diagram according to an embodiment of the present invention that extends on the flow diagram ofFIG. 1B, wherein a write command is received from a host comprising an LBA (step34). The LBA is mapped to a physical block address (PBA) of the target data sectors (step36), wherein if the PBA is mapped to a data sector in the non-cache area of the NVSM (step38), the write data is written to the NVSM (step40). If the PBA is mapped to a data sector in the non-cache area of the disk (step38), then the write data is cached in one of the disk cache and the NVSM cache before being flushed to the non-cache area of the disk at a later time.

In one embodiment when flushing the data from the NVSM cache, the data may first be written to the disk cache in order to flush the NVSM cache quickly. The data may then be flushed from the disk cache to the non-cache area of the disk at a later time (e.g., while servicing access commands using the NVSM or while the hybrid drive is idle). In another embodiment when flushing the data from the NVSM cache, the data may be migrated to the non-cache area of the NVSM (instead of flushing the data to the disk) based on a migration policy. For example, if data stored in the NVSM cache is accessed several times by the host prior to being flushed to the disk, the migration policy may migrate the data by flushing it to the non-cache area of the NVSM instead of flushing the data to the non-cache area of the disk. In one embodiment, flushing the data from the NVSM cache to the non-cache area of the NVSM is implemented by copying the data between blocks. In an alternative embodiment, the blocks storing the cached data are simply re-assigned from the NVSM cache to the non-cache area of the NVSM.

FIG. 2is a flow diagram according to an embodiment of the present invention wherein a disk/NVSM counter ratio is maintained at a target level in order to spread the write commands over the disk cache and the NVSM cache at a target ratio (e.g., spread the write commands evenly over the NVSM cache and the disk cache). When a write command is received from the host (step42) a disk/NVSM counter ratio is compared to a threshold (step44). If the ratio is less than the threshold (meaning that fewer write commands have been serviced by the disk cache), then the write data is written to the disk cache (step46) and a disk cache counter is incremented (step48). If the ratio is greater than the threshold (meaning that fewer write commands have been serviced by the NVSM cache), then the write data is written to the NVSM cache (step50) and a NVSM cache counter is incremented (step52). The counters in this embodiment may represent any suitable value, such as a number of write commands, or a total number of data sectors over the write commands.

FIG. 3is a flow diagram according to an embodiment of the present invention that extends on the flow diagram ofFIG. 2, wherein when a write command is received from the host (step54) and the disk/NVSM counter ratio is less than the threshold (step56) such that the disk cache is selected to cache the write data, but the head is away from the disk cache (step58) (e.g., parked on a ramp or servicing other commands), the write data is written to the NVSM cache (thereby overriding the ratio threshold condition). Accordingly, in this embodiment the NVSM counter may increase until the head is positioned back over the disk cache wherein subsequent write commands are serviced by the disk cache until the counter ratio again reaches the target threshold. In one embodiment, the head may be considered over the disk cache at step58as long as the head is near the disk cache (e.g., within a threshold number of data tracks).

FIG. 4is a flow diagram according to an embodiment of the present invention that extends on the flow diagram ofFIG. 2, wherein when a write command is received from the host (step60) and the disk/NVSM counter ratio is greater than the threshold (step62) such that the NVSM cache is selected to cache the write data, but the NVSM is busy servicing other commands (step64), the write data is written to the disk cache (thereby overriding the ratio threshold condition). Accordingly, in this embodiment the disk counter may increase until the NVSM is no longer busy wherein subsequent write commands are serviced by the NVSM cache until the counter ratio again reaches the target threshold.

FIG. 5shows an embodiment of the present invention wherein as the life remaining of the NVSM decreases (due to the number of program/erase cycles increasing), the size of the NVSM cache is decreased. This embodiment helps extend the life of the NVSM since using the NVSM as a write cache increase write amplification of the NVSM. In an alternative embodiment show inFIG. 6, the threshold for the disk/NVSM counter ratio may be increased as the life remaining of the NVSM decreases so that more write data is cached in the disk cache. Both of these embodiments help reduce write amplification of the NVSM by routing more of the write data to the disk cache rather than the NVSM cache.

FIG. 7Ashows an embodiment of the present invention wherein the threshold for the disk/NVSM counter threshold is increased as the amount of free space in the NVSM cache decreases. This embodiment helps prevent the NVSM cache from overflowing by routing more write data to the disk cache until the write data can be flushed from the NVSM cache.FIG. 7Bshows the converse embodiment wherein the disk/NVSM counter threshold is decreased as the amount of free space in the disk cache decreases. This embodiment helps prevent the disk cache from overflowing by routing more write data to the NVSM cache until the write data can be flushed from the disk cache.

In one embodiment, the NVSM cache can be used to cache write data of new write commands while old write data stored in the disk cache is flushed to the non-cache area of the disk. Conversely, the disk cache can be used to cache write data of new commands while old write data stored in the NVSM cache is flushed to the non-cache area of the disk. In one embodiment, the write commands routed to the NVSM cache and the disk cache may be selected based on a rotational position optimization (RPO) algorithm which attempts to minimize the access time to the non-cache area of the disk by minimizing the seek and rotational latency. For example, a first group of write commands having closest proximity may be cached in the disk cache, and a second group of write commands having closest proximity may be cached in the NVSM cache. In this manner, the access latency is minimized when flushing either the disk cache or the NVSM cache to the non-cache area of the disk. In one embodiment, the disk cache and the NVSM cache may be flushed together during the same flush operation in which case the write data is read in an optimal order from both caches based on the RPO algorithm.

FIG. 8is a flow diagram according to an embodiment of the present invention wherein when a read command is received from a host (step66) the LBA is converted into one or more PBAs of target data sectors (step68). For example, an LBA may identify data that is cached in one of the NVSM and the disk cache, and/or the data may have been flushed to the non-cache area of the disk. Accordingly, in one embodiment a decision is made (step70) to determine where to read the data. For example, in one embodiment the data is read from the NVSM cache (step72) if stored there since the NVSM typically provides the highest performance. If the data is not stored in the NVSM cache but instead stored in the disk cache, then it may be read from the disk cache (step74). If the data is not stored in the NVSM cache or the disk cache, it may be read from the non-cache area of the disk or from the non-cache area of the NVSM (step76).

In one embodiment, data may be stored in multiple locations. For example, data may be stored in the NVSM cache and in the non-cache area of the disk after flushing the NVSM cache and before erasing the NVSM cache. Similarly, data may be stored in the disk cache and in the non-cache area of the disk after flushing the disk cache and before overwriting the disk cache. In this manner, a decision may be made to read the data from the location that provides the best performance, and in one embodiment, the data for different read commands may be read concurrently from multiple locations (e.g., concurrently from the NVSM cache and from the disk). In one embodiment, after flushing the NVSM cache and/or the disk cache the old data remains in the cache as long as possible before erasing the block in the NVSM cache or overwriting the data in the disk cache. This embodiment improves performance by allowing the data to be read from either the write cache (NVSM or disk) and/or the non-cache area of the disk. In one embodiment, the data may be evicted from either write cache using any suitable eviction policy, such as evicting the least recently accessed data or least frequently accessed data.