=head1 NAME

afs_cache - Format of data stored in an AFS client disk cache

=head1 DESCRIPTION

The disk cache on a client machine is composed of multiple F<VI<n>> files
that contain the data, a F<CacheItems> file that records index information
for all of the F<VI<n>> files, and a F<VolumeItems> file that records the
mapping between volume name and mount point for volumes.

When it initializes, the Cache Manager creates the cache files in the
configured cache location.  The standard directory name is
F</usr/vice/cache>, but it is acceptable to use a directory on a partition
with more available space. To designate a different directory, change the
value in the second field of the F</usr/vice/etc/cacheinfo> file before
issuing the B<afsd> command, or include the B<-cachedir> argument to the
B<afsd> command.

=head2 F<CacheItems>

The CacheItems file records information about each file in the disk cache
on a client machine (each F<VI<n>> file). The information includes the
file ID number and associated volume version number of the AFS file
currently stored in the B<V>I<n> file, which enables the Cache Manager to
determine which F<VI<n>> file contains the AFS data it needs to present to
an application.

As it initializes, the Cache Manager creates the binary-format
F<CacheItems> file in the same local disk cache directory as the F<VI<n>>
files that the F<CacheItems> file describes, and it must always remain
there.

=head2 F<VolumeItems>

The F<VolumeItems> file records the mapping between volume name and mount
point for each volume that the Cache Manager has accessed since it
initialized on a client machine using a disk cache. The Cache Manager uses
the mappings to respond correctly to queries about the current working
directory, which can come from the operating system or commands such as
the UNIX B<pwd> command.

As it initializes, the Cache Manager creates the binary-format
F<VolumeItems> file in the local disk cache directory, and it must always
remain there.

=head2 F<VI<n>>

A F<VI<n>> file can store a chunk of cached AFS data on a client machine
that is using a disk cache. As the Cache Manager initializes, it verifies
that the local disk cache directory houses a number of F<VI<n>> files
equal to the largest of the following:

=over 4

=item *

100

=item *

One and a half times the result of dividing the cache size by the chunk
size (cachesize/chunksize * 1.5).

=item *

The result of dividing the cache size by 10 MB (10,240).

=back

The Cache Manager determines the cache size from the B<-blocks> argument
to the B<afsd> command, or if the argument is not included, from the third
field of the F</usr/vice/etc/cacheinfo> file.  The default chunk size is
64 KB; use the B<-chunksize> argument to the B<afsd> command to override
it. To override the default number of chunks resulting from the
calculation, include the B<-files> argument to the B<afsd>
command. L<afsd(8)> describes the restrictions on acceptable values for
each of the arguments.

If the disk cache directory houses fewer F<VI<n>> files than necessary,
the Cache Manager creates new ones, assigning each a unique integer I<n>
that distinguishes it from the other files; the integers start with 1 and
increment by one for each F<VI<n>> file created. The Cache Manager removes
files if there are more than necessary. The Cache Manager also adds and
removes F<VI<n>> files in response to the B<fs setcachesize> command,
which can be used to alter the cache size between reboots.

F<VI<n>> files expand and contract to accommodate the size of the AFS
directory listing or file they temporarily house. As mentioned, by default
each F<VI<n>> file holds up to 64 KB (65,536 bytes) of a cached AFS
element. AFS elements larger than 64 KB are divided among multiple
B<V>I<n> files. If an element is smaller than 64 KB, the F<VI<n>> file
expands only to the required size. A F<VI<n>> file accommodates only a
single element, so if there many small cached elements, it is possible to
exhaust the available F<VI<n>> files without reaching the maximum cache
size.

=head1 CAUTIONS

Editing or removing the F<CacheItems> or F<VolumeItems> files or a
F<VI<n>> file can cause a kernel panic. If the contents of F<VI<n>> files
seem out of date, clear the files by using the B<fs flush> or B<fs
flushvolume> command. If any of the cache files are accidentally modified
or deleted, rebooting the machine usually restores normal performance.

To alter cache size (and thus the number of F<VI<n>> files) between
reboots, use the B<fs setcachesize> command. Alternatively, alter the
value of the B<-blocks>, B<-files> or B<-chunksize> arguments to the
B<afsd> command invoked in the machine's AFS initialization file, and
reboot. To refresh the contents of one or more F<VI<n>> files, use the
B<fs flush> or B<fs flushvolume> command.

=head1 SEE ALSO

L<cacheinfo(5)>,
L<afsd(8)>,
L<fs_checkvolumes(1)>,
L<fs_flush(1)>,
L<fs_flushvolume(1)>,
L<fs_setcachesize(1)>

=head1 COPYRIGHT

IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved.

This documentation is covered by the IBM Public License Version 1.0.  It was
converted from HTML to POD by software written by Chas Williams and Russ
Allbery, based on work by Alf Wachsmann and Elizabeth Cassell.
