Installation guide

Using the Cache With NFS
79
tune2fs -o user_xattr /dev/device
Alternatively, extended attributes for a file system can be enabled at mount time, as in:
mount /dev/device /path/to/cache -o user_xattr
The cache back-end works by maintaining a certain amount of free space on the partition hosting
the cache. It grows and shrinks the cache in response to other elements of the system using up free
space, making it safe to use on the root file system (for example, on a laptop). FS-Cache sets defaults
on this behavior, which can be configured via cache cull limits. For more information about configuring
cache cull limits, refer to Section 11.4, “Setting Cache Cull Limits”.
Once the configuration file is in place, start up the cachefilesd daemon:
service cachefilesd start
To configure cachefilesd to start at boot time, execute the following command as root:
chkconfig cachefilesd on
11.3. Using the Cache With NFS
NFS will not use the cache unless explicitly instructed. To configure an NFS mount to use FS-Cache,
include the -o fsc option to the mount command, as in:
mount nfs-share:/ /mount/point -o fsc
All access to files under /mount/point will go through the cache, unless the file is opened for
direct I/O or writing (refer to Section 11.3.2, “Cache Limitations With NFS” for more information). NFS
indexes cache contents using NFS file handle, not the file name; this means that hard-linked files
share the cache correctly.
Caching is supported in version 2, 3, and 4 of NFS. However, each version uses different branches for
caching.
11.3.1. Cache Sharing
There are several potential issues to do with NFS cache sharing. Because the cache is persistent,
blocks of data in the cache are indexed on a sequence of four keys:
Level 1: Server details
Level 2: Some mount options; security type; FSID; uniquifier
Level 3: File Handle
Level 4: Page number in file
To avoid coherency management problems between superblocks, all NFS superblocks that wish
to cache data have unique Level 2 keys. Normally, two NFS mounts with same source volume and
options will share a superblock, and thus share the caching, even if they mount different directories
within that volume. Take the following two mount commands:
mount home0:/disk0/fred /home/fred -o fsc
mount home0:/disk0/jim /home/jim -o fsc