Accelerated write performance

A generic disk driver filter may be used to accelerate performance when writing to a disk. The generic disk driver filter may be connected between a file system and a disk driver and may be configured to be extensible and compatible with a variety of different file systems and different disk drivers. The generic disk driver filter has a filter component that intercepts and filters raw sector write commands from the file system before they are received by the disk driver. The generic disk driver filter may also have a cache memory component that stores a checksum for each sector which is written to the disk. The generic disk driver filter may also have a scavenger thread component that detects and removes latent checksum entries from the cache memory so as to preserve memory availability and reduce memory requirements.

BACKGROUND

A number of commonly employed procedures may reduce performance when writing data to a disk. For example, when writing to portable media, performance may be reduced due to aggressive flushing/write through procedures that provide resiliency in the case of surprise removal of the media. While these flushing procedures are quite important, their resulting performance reductions may be a significant component in determining the amount of time required for writing data to a disk. The performance reductions may be further increased when there is a higher ratio of metadata to actual user data, such as when writing larger quantities of smaller files.

The aggressive flushing/write-through procedures often require an overwhelming number of redundant writes due to the flush granularity of a page size. For example, consider an approximately 4 kilobyte page divided into eight sectors of 512 bytes each, which are subdivided into eight entries of 64 bytes each. In this example, assume that the flushing procedures require 5 flushes when creating a directory entry. Also assume that a filesystem writes through changes to a disk instead of caching the changes and gathering the writes. When files are created, metadata for each file takes up an entry with a size of 64 bytes. So as lots of files are being created, as in the case of a copy of a tree, each entry is created and written out. As a result, eight 64 byte entries can be created per sector, flushing each sector 8 times. Since the filesystem writes each sector through five times, that results in 40 unavoidable redundant flushes. However, in addition to these unavoidable redundant flushes, the filesystem is also writing out the remaining 7 sectors in the page. Each of these additional seven sectors is being flushed forty times, which results in 280 avoidable redundant flushes.

SUMMARY

A generic disk driver filter may be used to accelerate performance when writing to a disk. The generic disk driver filter may be connected between a file system and a disk driver and may be configured to be extensible and compatible with a variety of different file systems and different disk drivers. The generic disk driver filter has a filter component that intercepts and filters raw sector write commands from the file system before they are received by the disk driver. The generic disk driver filter may also have a cache memory component that stores a checksum for each sector which is written to the disk. The generic disk driver filter may also have a scavenger thread component that detects and removes latent checksum entries from the cache memory so as to preserve memory availability and reduce memory requirements.

The filter component may filter a raw sector write command by computing a checksum for each sector that is included in the raw sector write command. Each sector's computed checksum may then be compared with a corresponding stored checksum from the cache memory. Each sector with matching computed and stored checksums may be designated as redundant, while each sector with non-matching computed and stored checksums may be designated as non-redundant. A sub-set of non-redundant sectors within the raw sector write command may then be identified and flushed to the disk. The redundant sectors within the raw sector write command are not flushed to the disk, thereby accelerating write performance.

DETAILED DESCRIPTION

An exemplary system for accelerated write performance is depicted inFIG. 1. A write request101is submitted to file system102. Write request101may, for example, be issued by a user or by an application or other component. Write request101is a request to write data to disk106. Disk106may be, for example, a hard drive or a portable media device such as CD, DVD, or a flash card. Write request101may be a request to write data from one type of disk to another type of disk.

File system102may include a file allocation table (FAT) system that describes the files and directories available on disk106. Such a FAT system may be, for example, FAT16 or FAT32, both from MICROSOFT Corp. of Redmond, Wash. File system102processes the write request and issues a raw sector write command. The write request101is processed in accordance with appropriate procedures which may depend on factors such as, for example, the type of disk106to which data is being written and other general circumstances surrounding the write request101. As set forth above, these procedures may reduce performance when writing data to disk106.

File system102issues the raw sector write command to volume driver103, which is basically an abstraction of disk106. In conventional computing devices, volume driver103may forward the raw sector write command directly to disk driver105, as represented by the dashed line between volume driver103and disk driver105. However, in the exemplary system ofFIG. 1, a generic disk driver filter104is provided between volume driver103and disk driver105. Generally, generic disk driver filter104accelerates write performance by intercepting and filtering the raw sector write request from file system102before it is submitted to the disk driver105.

Generic disk driver filter104may be extensible and compatible with a variety of different file systems102and different disk drivers105. Generic disk driver filter104may be a “hard” component which is built into a computing device or may be a component or application that can be delivered to or from, connected, and/or removed from a computing device. Also, generic disk driver filter104need not necessarily be a component or application which is separate and distinct from other components in the system ofFIG. 1. For example, all or portions of generic disk driver filter104may be part of file system102or disk driver105.

Generic disk driver filter104includes a filter component104awhich receives and filters the raw sector write command. Exemplary filtering techniques which may be employed by filter component104aare described in detail below with reference toFIG. 2. Generic disk driver filter104may also include a cache memory component104bthat stores a checksum for each sector which is written to disk106. Cache memory component104bneed not necessarily be a separate component and may be part of another memory component that is accessible to filter component104a. Generic disk driver filter104may also include a scavenger thread component104cthat detects and removes latent checksum entries from cache memory104bso as to preserve memory availability and reduce memory requirements. Scavenger thread104cneed not necessarily be a separate component. Exemplary techniques which may be employed by scavenger thread104cto regulate cache memory104bare described in detail below with reference toFIG. 4.

A flowchart of an exemplary method for accelerated write performance is shown inFIG. 2. At act200, filter104areceives a raw sector write command from file system102. The raw sector write command may be received directly from file system102or by way of a volume driver103or another similar component. The raw sector write command may be a command to write a page of data to disk106. Such a data page may include a set of contiguous sectors. For example, an approximately 4 kilobyte page may include a set of eight contiguous sectors each with 512 bytes of data. An exemplary eight sector data page300ais depicted inFIG. 3a. As shown, page300aincludes sectors35through42. The raw sector write command may also be for less than or more than a page of data. There is no upper or lower bound on the number of sectors that are written out in a single request.

At act202, filter104aextracts a beginning sector number (“M”) and an end sector number (“N”) from the raw sector write command. For eight sector data page300a, sector35will be extracted as beginning sector number (“M”), and sector42will be extracted as end sector number (“N”).

At act204, filter104acomputes a checksum for each of sectors M through N. The computed checksum may be a cyclic redundancy check (CRC) that is computed over the contents of the entire sector. Alternatively, other checksums such as, for example, MD4 and MD5 checksums may also be employed. Generally, the stronger the checksum, the less likelihood there will be for a false match. However, it has been observed that the likelihood of a false match will be quite low even when a CRC checksum is employed.

At act206, the checksums computed at act204are compared with previously computed checksums that are stored in cache memory104b. Specifically, the newly computed checksum for each sector is compared with the corresponding stored checksum for the sector. Of course, it is possible that this will be the first time that some or all of the sectors M through N have been written to. In this scenario, there will not be a stored checksum for these sectors within cache memory104b.

At act208, it is determined whether any of the sectors have newly computed checksums which do not match their corresponding stored checksums. For purposes of this determination, any sector which does not have a corresponding stored checksum will be considered to have a non-matching stored checksum. If, at act208, it is determined that none of the sectors M through N have non-matching checksums, then all sectors in the write command are redundant, and, at act210, the write command is completed successfully by disk driver filter104without submitting the write command to disk driver105, thereby producing a boost in performance.

If, on the other hand, at act208, it is determined that at least one of the sectors M through N has a non-matching checksum, then the write command will not be canceled. Rather, at act212, a contiguous sub-set of the sectors M through N with non-matching checksums will be identified. The contiguous sub-set may include all of sectors M through N or only some of sectors M through N. The sub-set must, however, include at least one sector. The sectors within the contiguous sub-set will include at least some non-redundant data. An exemplary eight sector data page300bwith a contiguous non-redundant sub-set of sectors is depicted inFIG. 3b. As shown, page300bincludes sectors35through42and non-redundant sub-set37through40, which is represented by horizontal grid lines.

At act214, filter104aextracts a beginning sub-set number (“K”) and an end sub-set number (“L”) from the write command. For exemplary page300b, sector37will be extracted as beginning sub-set number (“K”), and sector40will be extracted as end sub-set number (“L”). If an entire page is non-redundant, then K will be equal to M and L will be equal to N. On the other hand, if there is only a single non-redundant sector in a page, then K will be equal to L. It should be appreciated that, in certain circumstances, a page may have more than one non-redundant contiguous sub-set of sectors. An example of this scenario is depicted inFIG. 3c. As shown, page300chas two non-redundant contiguous sub-sets. The first is sub-set36through37, while the second is sub-set40through41. In this case sector36is designated as “K1” and sector40is designated as “K2”, while sector37is designated as “L1” and sector41is designated as “L2.”

At act216, extracted sectors K through L are flushed to disk driver105. If there are multiple non-redundant contiguous sub-sets, then K through L will be flushed for each of the sub-sets (e.g. K1through L1; K2through L2; . . . ; Kn through Ln). At act218, checksums for each sector in the redundant sub-set(s) K through L are stored in cache memory104b.

Given the number of sectors which may eventually be written and rewritten to disk106, cache memory104bwill fill up very quickly if the checksums for every sector are maintained in memory over the duration of writes to disk106. This will result in potentially huge memory requirements for cache memory104b. However, since redundant flushes normally occur in close proximity to one another, memory for “latent” checksums that have not been recently written to may be reclaimed, while memory for “active” checksums that have been recently written or rewritten may be preserved. Cache memory104bmay be regulated in this fashion through the use of scavenger thread104c. Specifically, each memory slot within cache memory104bmay have a corresponding use bit which is regulated by scavenger thread104cto indicate whether or not the memory slot is storing an active checksum.

Scavenger thread104cmay regulate the use bits by conducting a number of passes through cache memory104b. The duration of time between each pass may be based on a pre-determined time period. The time period may be a default time period or may be a time period that is selected by a user or other application based on usage data and/or other circumstances surrounding the writing of data to disk106. The time period may be a fixed time period or a variable period. If the time period is set too low, then scavenger thread104cwill pass through cache memory104btoo frequently, which could possibly slow the performance of generic disk driver filter104. On the other hand, if the time period is set too high, then scavenger thread104cwill not pass through cache memory104bfrequently enough, meaning that too many latent checksum entries may remain stored in cache memory104b. This could result in unduly large memory requirements and, if the memory becomes full, could result in a situation in which there is no availability for storage of active checksums. Thus, it is important that the time period between passes be set for a time that is not too low or too high.

A flowchart of an exemplary method for regulating filter cache104bis shown inFIG. 4. At act400, scavenger thread104cinitiates a first pass through cache memory104b. At act402, during the first pass, scavenger thread104cassigns a first value (i.e. a value of zero) to all the use bits for all the memory slots within cache memory104b, thereby essentially resetting the use bits. At act404, each time that a sector checksum is written to a memory slot, the corresponding use bit for the memory slot is flipped by assigning a second value to the use bit (i.e. the value of the use bit is flipped from zero to one).

At act406, scavenger thread104cinitiates a second pass through cache memory104b. At act408, as part of the second pass, scavenger thread104cevaluates each use bit on an individual basis to determine whether the first value is still assigned to the use bit. If the first value is still assigned to the use bit, this means that a sector checksum has not been written the corresponding memory slot since the first pass. Thus, the memory slot is either empty or is storing a latent sector checksum. Accordingly, at act412, the memory slot may be cleared so that it is available to store any newly recorded sector checksums. If, on the other hand, the first value is not still assigned to the use bit (i.e. the use bit has been flipped), this means that a sector checksum has been written to the use bit's corresponding memory slot since the first pass. Thus, there is an active sector checksum stored in the memory slot. At act410, the first value is reassigned to the use bit. The first value is reassigned so that, on the next pass, it can be determined whether or not the memory slot is still storing an active checksum. As should be appreciated, during the next pass, and any subsequent pass, steps408-412may be repeated.

To possibly improve efficiency, rather than allocating use bits to individual sectors, use bits may be allocated to “regions,” which are collections of contiguous sectors. If any sectors within the region are written to, then the use bit for the region may be assigned the first value. Thus, during the second pass, if none of the sectors within the region have been written to, then the entire region may released from cache memory104b. Since redundant flushes normally occur in close proximity to one another, the use of regions may improve efficiency by preserving checksums for a number of sectors that are in close proximity to an active sector, while also deleting checksums for those sectors which are no longer in close proximity to an active sector.

FIG. 5illustrates an example of a suitable computing system environment100in which the subject matter described above with reference toFIGS. 1-4may be implemented. The computing system environment100is only one example of a suitable computing environment and is not intended to suggest any limitation as to the scope of use or functionality of the subject matter described above. Neither should the computing environment100be interpreted as having any dependency or requirement relating to any one or combination of components illustrated in the exemplary operating environment100.

The drives and their associated computer storage media discussed above and illustrated inFIG. 5provide storage of computer readable instructions, data structures, program modules and other data for the computer110. InFIG. 5, for example, hard disk drive141is illustrated as storing operating system144, application programs145, other program modules146and program data147. Note that these components can either be the same as or different from operating system134, application programs135, other program modules136and program data137. Operating system144, application programs145, other program modules146and program data147are given different numbers here to illustrate that, at a minimum, they are different copies. A user may enter commands and information into the computer110through input devices such as a keyboard162and pointing device161, such as a mouse, trackball or touch pad. Other input devices (not shown) may include a microphone, joystick, game pad, satellite dish, scanner, or the like. These and other input devices are often connected to the processing unit120through a user input interface160that is coupled to the system bus121, but may be connected by other interface and bus structures, such as a parallel port, game port or a universal serial bus (USB). A graphics interface182may also be connected to the system bus121. One or more graphics processing units (GPUs)184may communicate with graphics interface182. A monitor191or other type of display device is also connected to the system bus121via an interface, such as a video interface190, which may in turn communicate with video memory186. In addition to monitor191, computers may also include other peripheral output devices such as speakers197and printer196, which may be connected through an output peripheral interface195.