Partager via


Disk Cache Management (Windows Embedded CE 6.0)

1/6/2010

Disk cache services for file systems are provided by a LIB file that the file system driver (FSD) manager can link with to provide disk caching services. Disk caching can be used by any file system, including a custom file system. File systems interface with the disk cache through the FSD manager, and the disk cache interfaces with the disk itself.

In general, use the disk cache for metadata and the file system cache manager for file data. **

The following table shows how metadata is handled in the disk cache.

Type of cache Metadata handling

FAT cache

Caches the file allocation table (FAT).

Data cache

Caches the directory metadata.

Bitmap cache

Caches the allocation bitmap.

The disk cache manager supports both write-back and write-through modes. In the case of write-back mode, a low-priority lazy-writer thread commits any dirty cached pages. For more information about the lazy-writer thread, see Lazy-Writer Thread.

The cache is divided into a set of 64-KB buffers. The block size used for the cache must be less than the buffer size and also must be a power of 2. Dividing the cache into buffers enables the cache to be resized easily, depending on memory conditions.

In addition to cache data itself, a lookup table is implemented as an array of DWORDs that contain the block number that is stored in the cache at a specific cache index. A status table is also implemented as an array of bytes, which stores the status for a particular cache index.

On a read, all blocks to be read are searched to see if they are in the cache. If one or more blocks are not cached, the entire request is read from the disk, and the cache is updated. In a write-back cache, if the request must be read from the disk, the cache region mapping to the blocks to be read is flushed first, and then the read takes place.

On a write, in a write-through cache, the data is written to both the cache and the disk. In a write-back cache, the data is written to the cache, and any dirty blocks that must be replaced are committed first.

See Also

Reference

Registry Settings for FATFS Disk Caching

Concepts

Lazy-Writer Thread

Other Resources

File and Disk Caching
Disk Cache Manager Reference