Installation guide
Chapter 11. FS-Cache
78
FS-Cache cannot arbitrarily cache any file system, whether through the network or otherwise: the
shared file system's driver must be altered to allow interaction with FS-Cache, data storage/retrieval,
and metadata setup and validation. FS-Cache needs indexing keys and coherency data from the
cached file system to support persistence: indexing keys to match file system objects to cache objects,
and coherency data to determine whether the cache objects are still valid.
11.1. Performance Guarantee
FS-Cache does not guarantee increased performance. Rather, using a cache back-end incurs a
performance penalty: for example, cached NFS shares add disk accesses to cross-network lookups.
While FS-Cache tries to be as asynchronous as possible, there are synchronous paths (e.g. reads)
where this isn't possible.
For example, using FS-Cache to cache an NFS share between two computers over an otherwise
unladen GigE network will not demonstrate any performance improvements on file access. Rather,
NFS requests would be satisfied faster from server memory rather than from local disk.
The use of FS-Cache, therefore, is a compromise between various factors. If FS-Cache is being used
to cache NFS traffic, for instance, it may slow the client down a little, but massively reduce the network
and server loading by satisfying read requests locally without consuming network bandwidth.
11.2. Setting Up a Cache
Currently, Red Hat Enterprise Linux 6 only provides the cachefiles caching back-end. The
cachefilesd daemon initiates and manages cachefiles. The /etc/cachefilesd.conf file
controls how cachefiles provides caching services. To configure a cache back-end of this type, the
cachefilesd package must be installed.
The first setting to configure in a cache back-end is which directory to use as a cache. To configure
this, use the following parameter:
dir /path/to/cache
Typically, the cache back-end directory is set in /etc/cachefilesd.conf as /var/cache/
fscache, as in:
dir /var/cache/fscache
FS-Cache will store the cache in the file system that hosts /path/to/cache. On a laptop, it is
advisable to use the root file system (/) as the host file system, but for a desktop machine it would be
more prudent to mount a disk partition specifically for the cache.
File systems that support functionalities required by FS-Cache cache back-end include the Red Hat
Enterprise Linux 6 implementations of the following file systems:
• ext3 (with extended attributes enabled)
• ext4
• BTRFS
• XFS
The host file system must support user-defined extended attributes; FS-Cache uses these attributes
to store coherency maintenance information. To enable user-defined extended attributes for ext3 file
systems (i.e. device), use: