File Data Cache Documentation


Contents:


Summary

The file data cache stores recently accessed file data in pages of physical memory. It can potentially cache data for any file system. It provides an easy interface by which any file system can add, delete, read, and write cached files. The default implementation of the cache uses a global LRU policy to choose victim blocks for replacement. However, the replacement mechanism is implemented with events that can be caught and handled to define different replacment schemes. Although mapping is not yet implemented, the cache is designed to provide a mappable memory object per cached file. In this initial implementation, all physical pages of memory are pinned -- the cache is not paged.


Implementation Components

The following is a description of the components that make up the cache implementation. It is organized by module/interface name.

Locking

The cache locking scheme can be somewhat confusing. The expected locks are present to avoid data races when multiple threads access DoubleLists as well as the file-to-FileMObjCache table in FileDataCache.m3. FileMObjCache, however, has a more interesting locking scheme. FileMObjCache locks are on three levels:

File Systems

There are two obstacles to caching a file system. The first is ensuring that file objects are of the proper type, and the second is ensuring that the cache is interposed between the file system and the disk (or other storage device).

File objects must be of the proper type because of the cache's reliance on Modula-3 table generic. A table is used in FileDataCache to translate from a file system File.T object to a FileMObjCache.T object. Since File.T is the table key, the File.i3 interface must have a Hash() and Equal() procedure. The File.i3 does not have these procedures. Instead, the File.T object has a public datafield of type FileId.T, and the FileId.i3 interface does have Hash() and Equal() procedures. Unfortunately, my experiences have indicated that the FileId field does not provide unique identification for files (for some file systems, every file had a FileId field consisting entirely of zeroes).

There are many approaches to fixing the file type problem. A few are suggested below:

There are also several approaches to interposing the cache into the filing service. A few are suggested below:


Commands

The cache implementation comes with a shell interface. Currently, the shell commands are very limited. A collection of cache statistics is available with the command:
cache stat
at the SPIN shell. In order to keep statistics, the KeepStats constant must be TRUE at compile time.


Todo List

There are a number of enhancements that would improve the file data cache implementation. These are not limited to the following:


ddion@cs.washington.edu
Last Modified: 21 June 1997