Microsoft KB Archive/332023

From BetaArchive Wiki

Article ID: 332023

Article Last Modified on 10/27/2006



APPLIES TO

  • Microsoft Windows XP Professional
  • Microsoft Windows XP Home Edition
  • Microsoft Windows 2000 Service Pack 3
  • Microsoft Windows 2000 Service Pack 2
  • Microsoft Windows 2000 Service Pack 3
  • Microsoft Windows 2000 Service Pack 2
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Service Pack 3



This article was previously published under Q332023

SYMPTOMS

The performance of certain hard-disk write operations may be slower than expected if the hard disk implements write caching and your computer uses any of the following operating systems:

  • Windows 2000 Service Pack 3 (SP3)
  • Windows 2000 Service Pack 2 (SP2) on which you have installed the hotfix that is described in the following Microsoft Knowledge Base article:

    281672 Possible Data Loss After You Enable the "Write Cache Enabled" Feature

  • Windows XP

Specifically, the hard-disk write performance may be slower than that experienced with versions of Windows 2000 earlier than SP3. Also, on a cluster computer, hard-disk write operations to shared disks may cause large differences in write performance between each node.

CAUSE

Versions of Windows 2000 earlier than SP3 contain a bug that prevents certain disk commands from being issued. These commands are only issued to disks that have write caching enabled. These commands force critical data to be written to disk devices immediately instead of being held temporarily in the disk's write-behind cache.

For additional information about this bug, click the following article number to view the article in the Microsoft Knowledge Base:

281672 Possible Data Loss After You Enable the "Write Cache Enabled" Feature



The hotfix that is described in Knowledge Base article 281672 corrects this bug and causes these commands to be issued to the disk as expected when write caching is enabled. This fix is included in Windows 2000 SP3. A similar fix is also included in Windows XP.

By design, these commands sacrifice some performance for the sake of the safety of critical data. They make sure that critical data is written to the disk immediately. These commands are only issued if write caching is enabled for a specific disk device and if it can be detected by using standard mechanisms. When this safe behavior is enforced for disks that implement write caching, you will experience loss of performance during certain disk operations. See the "More Information" section of this article for more details. Also, on a cluster computer, hard-disk information may not be delivered to a node that takes over a cluster resource when the resource is failed over. Therefore, differences in hard-disk write operation performance between each node occurs.

RESOLUTION

For Computers That Run Windows 2000

Warning: If you implement this fix (by installing the updated drivers and turning on the Power Protected write cache option), protections that are built in to the Windows 2000 disk drivers to make sure that critical data is written to the disk immediately instead of being written to the disk later from the disk's built-in cache are removed. Do not implement this fix unless your computer and any connected hard disks are protected against accidental or inadvertent power loss through hardware design that may include such features as redundant battery-backed power supplies. Contact the vendors of your computer and storage devices to determine the degree of protection afforded by your hardware. Do not implement this fix unless you understand and accept the level of risk that may be involved, and are confident that this risk has been mitigated through appropriate hardware power protection. Also, on a cluster computer, differences in performance of hard-disk write operations to shared disks between nodes can be solved by setting the Power Protected write cache option on each node.

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

281672 Possible Data Loss After You Enable the "Write Cache Enabled" Feature


Part 1: Install Windows 2000 Update

A supported feature that modifies the product's default behavior is now available from Microsoft, but it is only intended to modify the behavior that this article describes. Apply it only to systems that specifically require it. This feature may receive additional testing. Therefore, if the system is not severely affected by the lack of this feature, we recommend that you wait for the next Windows 2000 Service Pack that contains this feature.

To obtain this feature immediately, contact Microsoft Product Support Services. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.

   Date         Time   Version        Size    File name
   -------------------------------------------------------
   15-Jan-2003  19:42  5.0.2195.6655  34,832  Classpnp.sys
   15-Jan-2003  19:43  5.0.2195.6655  30,768  Disk.sys
                

Note The files that are included in this hotfix have post-SP3 version numbers, but they can be used on both Windows 2000 SP2-based and Windows SP3-based computers. The hotfix package will install on both Windows 2000 SP2-based and Windows 2000 SP3-based computers.

Part 2: Configure the "Power Protected" Write Cache Option

After you install the Windows 2000 update and then restart your computer so that the updated drivers are loaded, you must also turn on the Power Protected write cache option for each disk that has write caching enabled and has its write cache protected against accidental loss of power. If the Power Protected write cache option is not turned on, this update does not implement any change in disk behavior or performance.

To configure the Power Protected write cache option on the selected disks, use the Dskcache.exe tool. Dskcache.exe is available separately. For additional information about the Dskcache.exe tool and how to enable the "power protected" write cache option, click the following article number to view the article in the Microsoft Knowledge Base:

811392 Obtain the Dskcache.exe Tool to Configure the "Power Protected" Write Cache Option


Note The Power Protected write cache option can only be enabled for disks that are currently present. By default, the Power Protected write cache option is disabled. As a result, this option is disabled for any disks that may be added after you apply this setting. If additional disks are added, enable the Power Protected write cache option for those added disks for the setting to take effect.

For Computers That Run Windows XP

Because of design differences between Windows 2000 and Windows XP, there are currently no plans to release a supported update for this behavior for Windows XP.

STATUS

This behavior is by design.

MORE INFORMATION

Many disk devices provide enhanced performance through the use of an onboard cache, which provides read-ahead caching for data that is being read from the disk, and write-behind caching (or delayed writes or "lazy" writes) for data that is being written to disk. In some cases, it is important for data to be written to the physical disk immediately, and not retained in the disk's onboard write cache to be written later during an otherwise idle moment. This prevents loss or corruption of this data if the disk or controller (wherever the write cache is implemented) suddenly loses power, for example.

There are two commands that are typically used to force cached data to be written to the physical disk immediately:

  • A flush buffers command, which is available for SCSI and IDE/ATAPI disk devices, instructs the disk to write all cached data to the disk immediately. For SCSI disks, this is implemented by issuing the SYNCHRONIZE CACHE command to the disk. For IDE/ATAPI disks, the FLUSH CACHE command is sent to the disk. This command is typically issued as a result of a Windows program calling the FlushFileBuffers API. Writing to the registry is an example of an operation that results in the FlushFileBuffers API being called and the SYNCHRONIZE CACHE command being sent to the disk.
  • A Write Through command, which is only available for SCSI disk devices, is implemented by issuing a WRITE command to the disk with the ForceUnitAccess (FUA) bit set. This type of command instructs the disk to write the current packet of data to the disk immediately, bypassing the onboard write cache. This typically occurs as a result of a Windows program that calls the WriteFile API to write to a file it has opened by calling the CreateFile API with the FILE_FLAG_WRITE_THROUGH flag set. Virus-scanning software typically opens files with the FILE_FLAG_WRITE_THROUGH flag set. Support for the FUA bit is optional, and only some SCSI and Fiber Channel (FC) devices, typically individual drives (as opposed to RAID arrays), implement this functionality.

By design, these commands sacrifice a measure of performance (which would typically be provided by the disk's onboard write cache) to maintain the safety of the data that is being written to the disk. If such data is not written to the disk immediately by these commands, and if the disk loses power suddenly, that data is lost, and the file that is being written may become corrupted.

In Windows 2000 versions earlier than SP3, these commands are not correctly issued to disk devices when expected. For example, the SYNCHRONIZE CACHE command is not issued to a disk when a program calls FlushFileBuffers, and the FUA bit is not set for WRITE commands when the file is opened with FILE_FLAG_WRITE_THROUGH set. The hotfix that is described in Knowledge Base article 281672 corrects this problem, so that these commands are issued as intended and, as a result, provide the expected protection against loss of such critical data.

Note Microsoft SQL Server uses FILE_FLAG_WRITE_THROUGH extensively on local database data, log files, and backup files. Local database data may include data on SCSI drives and SAN drives, but not data on NAS drives. If the Power Protected Storage feature is not enabled on hardware that protects its write-through cache, SQL Server's performance can be affected during the checkpoint process of a large database.

When the Write Cache Enabled option is configured for a disk device in Device Manager, two things occur:

  • A command to turn on or turn off Write Caching is sent to the disk device.
  • A registry value is saved, which the disk driver uses to determine whether or not to issue write-cache-management commands (Flush, Write-Through) to the disk.

The hotfix that is described in this article provides an additional configuration option, which is the Power Protected write cache option. When both Write Caching and Power Protected options are turned on, the disk's write cache is enabled and recognized as such by the disk driver, but the disk driver does not issue write-cache-management commands (Flush, Write-Through) to the disk. This avoids the performance penalty that would otherwise be incurred by flushing data from the write cache to the disk media, but exposes a risk of loss or corruption of disk data if power is lost while there is still data in the disk's write cache that has not been written to disk.

The following table summarizes the effects of the Write Caching and Power Protected options:

Write Caching Power Protected
Effect
Disabled N/A Disk does not cache writes.

Driver does not issue Flush/Write-Through commands.
(Only behavior possible for drives that do not have write caching enabled in hardware.)

Enabled Disabled Disk caches writes.

Driver issues Flush/Write-Through commands.
(Default behavior as of SP3, and with this update applied, for drives that have write caching enabled in hardware.)

Enabled Enabled Disk caches writes.

Driver does not issue Flush/Write-Through commands.
(Behavior resulting from pre-SP3 bug, for drives that have write caching enabled in hardware.)


Keywords: kbbug kbfix kbqfe kbhotfixserver KB332023