Chapter 37 The Cache File System (Tasks)
The Cache File System (CacheFS) is a general purpose file system caching
mechanism that improves NFS server performance and scalability by reducing
server and network load. Designed as a layered file system, CacheFS provides
the ability to cache one file system on another. In an NFS environment, CacheFS
increases the client per server ratio, reduces server and network loads and
improves performance for clients on slow links, such as Point-to-Point Protocol
(PPP).
The following is a list of the step-by-step instructions in this chapter.
How CacheFS Works
You create a cache, using the cfsadmin(1M) command, on the client so that file
systems you specify to be mounted in the cache can be accessed by the user
locally instead of across the network. The figure below shows the relationship
of the components involved in using CacheFS.
The back file system is the file system that you specify to be mounted
in the cache, which can be either NFS or HSFS (High Sierra File System). When
the user attempts to access files that are part of the back file system, those
files are placed in the cache. To the user, the initial request to access
a file might seem slow, but subsequent uses of the same file will be faster.
Note -
You can mount only file systems that are shared. See share(1M) for information on sharing
file systems.
Figure 37-1 How CacheFS Works
Setting Up a Cached File System Task Map
Table 37-1 Setting Up a Cached File System Task Map
Creating a Cache
The following procedure describes how to create a cache directory.
How to Create a Cache
-
Become superuser.
-
Create a cache using the cfsadmin -c command.
# cfsadmin -c cache-directory
|
|
cache-directory
|
Indicates the name of the directory
where the cache resides. For more information, seecfsadmin(1M).
|
Note -
After you have created the cache, do not perform any operations within
the cache directory itself. This causes conflicts within the CacheFS software.
Example--Creating a Cache
The following example creates a cache in the /local/mycache directory by using the default cache parameter values.
# mkdir /local
# cfsadmin -c /local/mycache
|
Specifying a File System to Be Mounted in the Cache
You specify file systems to be mounted in the cache so that users can
locally access files in the file system you've specified. The files do not
actually get placed in the cache until the user accesses the files.
The table below describes three ways to mount cached file systems:
|
To Mount A Cached File System By ...
|
You Need To Do This ...
|
|
Using the mount(1M) command
|
Every time the system reboots in order to access the same file system.
|
|
Editing the /etc/vfstab file
|
Only once. The /etc/vfstab file remains
unchanged after the system reboots.
|
|
Using AutoFS
|
Only once. AutoFS
maps remain unchanged after the system reboots.
|
Choose the method of mounting file systems that best suits your environment.
Note -
Caching of the root (/) and /usr
file systems is not supported in CacheFS. To cache the root (/) and /usr file systems, you must purchase
the Solstice AutoClient product. For more information about the AutoClient
product, see the Solstice AutoClient 2.1 Administration Guide.
How to Specify a File System to Be Mounted in a Cache With mount
-
Become superuser.
-
Create a mount point.
The mount point allows user access to the file system specified under
that mount point. You can create the mount point from anywhere. The CacheFS
options used with the mount command, as shown in the next
step, will determine that the mount point you created will be cached in the
cache directory you specified.
-
Mount a file system in a cache with the mount command.
# mount -F cachefs -o backfstype=fstype,cachedir=cache-directory[, options]
back-filesystem mount-point
|
|
fstype
|
Indicates the file system type of the
back file system (can be either NFS or HSFS).
|
|
cache-directory
|
Indicates the name of the directory
where the cache resides. This is the same name you specified when you created
the cache in "How to Create a Cache".
|
|
options
|
Specifies other mount options that
you can include when mounting a file system in a cache. See mount_cachefs(1M) for a list
of CacheFS mount options.
|
|
back-filesystem
|
The mount point of the back file system
to cache. If the back file system is an NFS file system, you must specify
the host name of the server from which you are mounting the file system and
the name of the file system to cache (separated by a colon). For example, merlin: /usr/openwin.
|
|
mount-point
|
Indicates the directory where the file
system is mounted.
|
-
Verify that the cache you created was actually mounted by using the cachefsstat(1M)
command, as follows:
# cachefsstat mount-point
|
For example:
# cachefsstat /docs
/docs
cache hit rate: 100% (0 hits, 0 misses)
consistency checks: 1 (1 pass, 0 fail)
modifies: 0
garbage collection: 0
|
The mount point is the cached file system you created. For more information
about the cachefsstat command, see "CacheFS Statistics".
If the file system was not mounted in the cache, you will receive an
error message similar to the following:
# cachefsstat mount-point
cachefsstat: mount-point: not a cachefs mountpoint
|
Examples--Specifying a File System to be Mounted in a Cache With mount
The following example creates the mount point /docs,
and mounts the NFS file system merlin:/docs as a cached
file system named /docs in the cache named /local/mycache.
# mkdir /docs
# mount -F cachefs -o backfstype=nfs,cachedir=/local/mycache merlin:/docs /docs
|
The following example makes a CD-ROM (HSFS file system) available as
a cached file system named /docs. Because you cannot
write to the CD-ROM, the ro argument is specified to make
the cached file system read-only. You must specify the backpath
option because Volume Management automatically mounts the CD-ROM when it is
inserted. The mount point is in the /cdrom directory
and is determined by the name of the CD-ROM. The special device to mount is
the same as the value for the backpath command.
# mount -F cachefs -o backfstype=hsfs,cachedir=/local/mycache,ro backpath=/cdrom/cdrom_name
/cdrom/cdrom_name /docs
|
The following example uses the demandconst option
to specify consistency checking on demand for the NFS cached file system /docs, whose back file system is merlin:/docs.
See "Consistency Checking of Cached File Systems With the Back File System" for more information.
# mount -F cachefs -o backfstype=nfs,cachedir=/local/mycache,demandconst merlin:/docs /docs
|
How to Mount a File System in a Cache by Editing the /etc/vfstab File
-
Become superuser.
-
Using an editor, specify the file systems to be mounted in the /etc/vfstab file:
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
/dev/dsk/devicename /dev/rdsk/devicename /mount-point cachefs 2 yes -
|
This line represents the new entry.
-
Mount the cached file system using the mount command,
as follows:
or reboot.
Example--Mounting a File System in a Cache by Editing the /etc/vfstab File
The following example shows the /etc/vfstab entry
for the cache file system.
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
/dev/dsk/c0t1d0s0 /dev/rdsk/c0t1d0s0 /usr/local cachefs 2 yes -
|
The /usr/local directory is mounted in the cache
directory.
How to Mount a File System in a Cache With AutoFS
You can mount a file system in a cache with AutoFS by specifying the -fstype=cachefs mount option in your automount map. Note that CacheFS
mount options (for example, backfstype and cachedir) are also specified in the automount map. See automount(1M) for details
on automount maps. Also see System Administration Guide, Volume 3.
-
Become superuser.
-
Using an editor, add the following line to the auto_direct map:
/mount-point -fstype=cachefs,cachedir=/directory,backfstype=nfs
server:/file-system
|
-
Using an editor, add the following line to the auto_master map:
The /- entry is a pointer to check the auto_direct map.
-
Reboot the system.
-
Verify that the entry was made correctly by changing to the file system
you mounted in the cache, and then list the contents, as follows:
# cd filesystem
# ls filesystem
|
For more information about AutoFS and how to edit the maps, refer to
the AutoFS chapter of the System Administration Guide, Volume 3.
Example--Mounting a File System in a Cache With AutoFS
The following auto_master entry automatically mounts
the cache file system in the /docs directory.
/docs -fstype=cachefs,cachedir=/local/mycache,backfstype=nfs
merlin:/docs
|
Maintaining a Cached File System Task Map
Table 37-2 Maintaining a Cached File System Task Map
Maintaining the Cache
After you set up the cache, you can perform the following maintenance
tasks on it:
-
Modify file systems in the cache (by unmounting, deleting,
recreating, and remounting the cache)
-
Display cache information
-
Check cache consistency
-
Delete a file system from the cache
-
Check cached file system integrity
Note -
If you are using the /etc/vfstab file to mount
file systems, you modify the cache by editing the file systems options in
the /etc/vfstab file. If you are using AutoFS, you modify
the cache by editing the file systems options in the AutoFS maps.
How to Modify File Systems in a Cache
For information on how to modify specific options of a file system,
refer to Chapter 36, Mounting and Unmounting File Systems (Tasks). When you modify a file system in
the cache, you need to delete the cache and then recreate it. You might also
need to reboot your machine in single user mode, depending on how your file
systems are shared and accessed.
The following example shows some of the steps involved in this procedure.
Example--Modifying File Systems in a Cache
In the following example, the cache is deleted, then re-created, and
then mounted again with the demandconst option specified
for the file system /docs. This example shows the steps
including rebooting to single user mode. You might have other commands you
prefer to use to accomplish some of the tasks shown in this example.
# shutdown -g30 -y
.
.
.
Type Cntrl-d to proceed with normal startup,
(or give root password for system maintenance):
# enter password:
.
.
.
Here is where you might be prompted from system to run fsck on the
file system where the cache is located.
# fsck /local
# mount /local
# cfsadmin -d all /local/mycache
# cfsadmin -c /local/mycache
# init 6
.
.
.
console login:
password:
# mount -F cachefs -o backfstype=nfs,cachedir=/local/cache1, demandconst merlin:/docs /docs
#
|
If you did not successfully remount the file system in the cache, the
system displays an error message similar to the following:
cachefsstat: /doc: not a cachefs mount point
|
How to Display Information About Cached File Systems
-
Become superuser.
-
Display information about all file systems cached under a specified
cache.
# cfsadmin -l cache-directory
|
cache-directory is the name of the directory
where the cache resides.
Example--Displaying Information About Cached File Systems
The following example shows information about the cache directory named /local/mycache. In this example, the file system /docs is cached in /local/mycache. The last line
displays the name of the cached file system.
# cfsadmin -l /local/mycache
cfsadmin: list cache FS information
maxblocks 90%
minblocks 0%
threshblocks 85%
maxfiles 90%
minfiles 0%
threshfiles 85%
maxfilesize 3MB
merlin:_docs:_docs
#
|
How to Specify Consistency Checking on Demand
-
Become superuser.
-
Mount the file system in the cache specifying the demandconst option of the mount command, as follows:
# mount -F cachefs -o backfstype=nfs,cachedir=/directory,demandconst
server:/file-system /mount-point
|
-
To initiate consistency checking on a specific cached file system, use
the cfsadmin -s command as follows:
# cfsadmin -s /mount-point
|
For more information about consistency checking, see "Consistency Checking of Cached File Systems With the Back File System".
How to Delete a Cached File System
-
Become superuser.
-
Unmount the cached file system.
mount-point specifies the cached file system
that you want to delete.
-
Determine the cache ID from the cfsadmin -l output,
as follows:
# cfsadmin -l cache-directory
cfsadmin: list cache FS information
maxblocks 90%
minblocks 0%
threshblocks 85%
maxfiles 90%
minfiles 0%
threshfiles 85%
maxfilesize 3MB
cache-ID
#
|
-
Delete a cached file system from a specified cache.
# cfsadmin -d cache-id cache-directory
|
|
cache-id
|
Indicates the name of the cached file
system, which is the last line of the cfsadmin -l output.
See "How to Display Information About Cached File Systems" for more information. You can delete
all the cached file systems in a particular cache by specifying all for cache-id.
|
|
cache-directory
|
Specifies the directory where the cache
resides.
|
-
Verify that the file system has been deleted.
The cache ID of the file system you just deleted should be missing from
the output of the following command. Refer to cfsadmin(1M) for more
information about the fields specified in the command output.
# cfsadmin -l cache-directory
cfsadmin: list cache FS information
maxblocks 90%
minblocks 0%
threshblocks 85%
maxfiles 90%
minfiles 0%
threshfiles 85%
maxfilesize 3MB
#
|
Examples--Deleting a Cached File System
The following example unmounts a cached file system and deletes the
cached file system from the cache.
# umount /docs
# cfsadmin -d merlin:_docs:_docs /local/mycache
|
The following example deletes all the cached file systems in the /local/mycache cache. This also deletes the cache.
# cfsadmin -d all /local/mycache
|
How to Check the Integrity of Cached File Systems
Use the fsck command to check the integrity of cached
file systems. The CacheFS version of fsck automatically
corrects problems without requiring user interaction. You should not need
to run fsck manually for cached file systems; fsck is run automatically at boot time or when the file system is
mounted. If you want to manually check the integrity, you can use the following
procedure.
See fsck_cachefs(1M)
for more information.
-
Become superuser.
-
Check the cached file systems under a specified cache.
# fsck -F cachefs [-m -o noclean] cache-directory
|
|
-m
|
Causes fsck to check
the cached file systems without making any repairs.
|
|
-o noclean
|
Forces a check on the cached file systems
only. Does not make any repairs.
|
|
cache-directory
|
Indicates the name of the directory
where the cache resides.
|
Example--Checking the Integrity of Cached File Systems
The following example checks the cached file systems that are part of
the /local/mycache cache.
# fsck -F cachefs /local/mycache
#
|
Managing Your Cache File Systems With cachefspack
For general use, CacheFS operates automatically, without requiring any
action from the user. Files are cached on a most recently used basis. With
the packing feature, you can take a more active role
in managing your cache by ensuring that certain files or directories are always
updated in the cache.
Packing enables you to specify files and directories to be loaded in
the cache. It ensures that current copies of these files are available in
the cache.
The packing list contains the names of specific
files and directories. It can also contain other packing lists. This saves
you having to specify individual files and directories in case you have many
items to pack in your cache.
The cachefspack command provides you with added control
of your CacheFS file systems, employing the packing functionality.
How to Pack Files in the Cache
Pack files in the cache using the cachefspack command.
$ cachefspack -p filename
|
|
-p
|
Specifies that you want the file or
files packed. This is also the default.
|
|
filename
|
Specifies the name of the file or directory
you want packed in the cache. When you specify a directory, all of its subdirectories
are also packed. For more information, see cachefspack(1M).
|
Examples--Packing Files in the Cache
The following example shows the file projects specified
to be packed in the cache.
$ cachefspack -p projects
|
The following example shows several files specified to be packed in
the cache.
$ cachefspack -p projects updates master_plan
|
The following example shows a directory specified to be packed in the
cache.
$ cachefspack -p /usr/openwin/bin
|
Packing Lists
One of the features of the cachefspack command is
the ability to pack packing lists. This saves the time of having to specify
each individual file that you want packed in the cache.
A packing list contains files or directories to be packed in the cache.
If a directory is in the packing list, all of its subdirectories and files
will also be packed.
How to Create a Packing List
To create a packing list, open a file by using vi
or the editor of your choice. The packing list file format uses the same format
as the filesync command. See filesync(1) for more information.
Example--Creating a Packing List
The following example shows the contents of a packing list file.
BASE /home/ignatz
LIST plans
LIST docs
IGNORE *.ps
|
-
The path identified with the BASE statement
is the directory where you have items you wish to pack.
-
The two LIST statements identify
specific files within that directory to pack.
-
The IGNORE statement identifies
the file type of .ps, which you do not wish to pack.
How to Pack Files in the Cache as Specified in a Packing List
To pack files using the packing list, use the cachefspack -f command, as follows:
$ cachefspack -f packing-list
|
This means you want the software to read the packing list and pack files
based on the information specified in the packing list.
|
-f
|
Specifies that you want to use a packing
list.
|
|
packing-list
|
Specifies the name of the packing list.
|
Example--Packing Files in the Cache as Specified in a Packing
List
This examples uses the list.pkg file as the packing
list for the cachefspack command.
$ cachefspack -f list.pkg
|
How to Specify Files in the Packing List to be Treated as Regular Expressions
To specify that one or more files in the packing list should be treated
as regular expressions (not as literal file names), use the -r
option with the -f option of the cachefspack
command. The -r option cannot be used alone.
$ cachefspack -rf packing_list
|
where packing_list contains a LIST command defined as follows:
|
-r
|
Specifies that you want the file or
files defined in the LIST command treated as regular expressions,
and not as literal file names.
|
|
-f
|
Specifies that you want the packing
list packed in the cache.
|
|
packing_list
|
Indicates the name of the packing list
that contains the LIST command with the file or files you
want treated as regular expressions.
|
Example--Specifying Files in the Packing List to be Treated as
Regular Expressions
The following example shows the packing list list.pkg
specified to be packed in the cache. list.pkg contains
a LIST command that defines a regular expression.
$ cachefspack -rf list.pkg
|
The software will pack the file list.pkg into the
cache and treat the file names defined in the LIST command
as regular expressions, and not as literal file names.
How to Pack Files From a Shared Directory
-
To pack files from a shared directory, and to ensure that you pack only
those files that you own, define the LIST command within
the packing list file as follows:
LIST !find . -user your_user_name -print
|
-
Pack the packing list in the cache using the cachefspack -sf command.
$ cachefspack -sf packing_list
|
|
-s
|
Adjusts the output of the find command
to be suitable for the packing list.
|
|
-f
|
Specifies a packing list to read.
|
|
filename
|
Specifies the name of the packing list
to read.
|
Note -
The -s option must be used with the -f
option. The -s option cannot be used alone.
Example--Packing Files From a Shared Directory
The following example shows how to define a LIST
command in the packing list to pack only the files from the base directory
that you own:
LIST !find . -user jones -print
|
The following example shows how you would then specify packing the packing
list.
$ cachefspack -sf /projects/proj_1
|
Unpacking Files
You might need to remove, or unpack, a file from the cache. Perhaps
you have some files or directories that are a higher priority than others,
so you need to unpack the less critical files. For example, you finished up
a project and have archived the files associated with that project. You are
now working on a new project, and therefore, a new set of files.
How to Unpack Files or Packing Lists From the Cache
Unpack files or packing lists from the cache using the -u
or -U option of the cachefspack command.
$ cachefspack -u filename | -U cache-directory
|
|
-u
|
Specifies that you want the file or
files unpacked. You must specify a filename with this option.
|
|
filename
|
Specifies the name of the file or packing
list you want unpacked in the cache. For more information about the cachefspack command, see the man page.
|
|
-U
|
Specifies that you want to unpack all
files in the cache.
|
Examples--Unpacking Files or Packing Lists From the Cache
The following example shows the file /usr/openwin/bin/xlogo specified to be unpacked from the cache.
$ cachefspack -u /usr/openwin/bin/xlogo
|
The following example shows several files specified to be unpacked from
the cache.
$ cd /usr/openwin/bin
$ cachefspack -u xlogo xview xcolor
|
You can also unpack a packing list, which is a file that contains the
path to a directory of files, as follows:
$ cachefspack -uf list.pkg
|
The following example uses the -U option to specify
all files in a cache directory to be unpacked.
$ cachefspack -U /local/mycache
|
You cannot unpack a cache that does not have at least one file system
mounted. With the -U option, if you specify a cache that
does not contain mounted file systems, you will see output similar to the
following:
$ cachefspack -U /local/mycache
cachefspack: Could not unpack cache /local/mycache, no mounted
filesystems in the cache.
|
Displaying Packed Files Information
You might want to view information about the files that you've specified
to be packed, and what their packing status is.
How to Display Packed Files Information
To display packed files information, use cachefspack -i
command.
$ cachefspack -i[v] cached-filename-or-directory
|
|
-i
|
Specifies you want to view information
about your packed files.
|
|
-v
|
The verbose option.
|
|
cached-filename-or-directory
|
Specifies
the name of the file or directory for which to display information.
|
Example--Displaying Packed Files Information
The following example shows that a file called doc_file
is successfully packed.
$ cachefspack -i doc_file
cachefspack: file doc_file marked packed YES, packed YES
|
The following example shows a directory called /usr/openwin, which contains a subdirectory bin. The subdirectory bin has three files: xterm, textedit, and resize. Although the files xterm and resize are specified to be packed,
they are not. The file textedit is successfully packed.
$ cd /usr/openwin
$ cachefspack -i bin
.
.
.
cachefspack: file /bin/xterm marked packed YES, packed NO
cachefspack: file /bin/textedit marked packed YES,
packed YES
cachefspack: file /bin/resize marked packed YES,
packed NO
.
.
.
|
If you use the -iv options in combination, you will
get additional information as to whether or not the file or directory specified
has been flushed from the cache. For example:
$ cd /usr/openwin
$ cachefspack -iv bin
.
.
.
cachefspack: file /bin/xterm marked packed YES, packed NO,
nocache YES
cachefspack: file /bin/textedit marked packed YES,
packed YES, nocache NO
cachefspack: file /bin/resize marked packed YES,
packed NO
nocache NO
.
.
.
|
The last line of the example above shows that the directory contents
have not been flushed from the cache.
Viewing Help on the cachefspack Command
You can print out a brief help summary of all the cachefspack options and what they mean by using the -h option
as follows:
$ cachefspack -h
Must select 1 and only 1 of the following 5 options
-d Display selected filenames
-i Display selected filenames packing status
-p Pack selected filenames
-u Unpack selected filenames
-U Unpack all files in directory 'dir'
-f Specify input file containing rules
-h Print usage information
-r Interpret strings in LIST rules as regular expressions
-s Strip './' from the beginning of a pattern name
-v Verbose option
files - a list of filenames to be packed/unpacked
|
cachefspack Errors
You might see the following error messages when you use the cachefspack command.
cachefspack: pathname - can't open directory: permission denied
|
- Cause
-
You might not have the correct permissions to access the file or directory.
- Action
-
Set the correct permissions.
cachefspack: pathname - can't open directory: no such file or
directory
|
- Cause
-
You might not have the correct file or directory.
- Action
-
Check for a possible typo.
cachefspack: pathname - can't open directory: stale NFS file handle
|
- Cause
-
The file or directory might have been moved or deleted from the server
at the time you attempted to access it.
- Action
-
Verify that the file or directory
on the server is still accessible.
cachefspack: pathname - can't open directory: interrupted system
call
|
- Cause
-
You might have pressed Control-c inadvertently while issuing the command.
- Action
-
Reissue the command.
cachefspack: pathname - can't open directory: I/O error
|
- Cause
-
A hardware problem.
- Action
-
Check your hardware connections.
cachefspack: error opening dir
|
- Cause
-
You might not have the correct file or directory. The path identified
after the BASE command in the file format could be a file
and not a directory. The path specified must be a directory.
- Action
-
Check for a possible typo.
Check the path identified after the BASE command in your
file format. Make sure it is a directory, and not a file.
cachefspack: unable to get shared objects
|
- Cause
-
The executable might be corrupt or it's a format that is not recognizable.
- Action
-
No corrective action can
be taken.
cachefspack: filename - can't pack file: permission denied
|
- Cause
-
You might not have the correct permissions to access the file or directory.
- Action
-
Set the correct permissions.
cachefspack: filename - can't pack file: no such file or directory
|
- Cause
-
You might not have the correct file or directory.
- Action
-
Check for a possible typo.
cachefspack: filename- can't pack file: stale NFS file handle
|
- Cause
-
The file or directory might have been moved or deleted from the server
at the time you attempted to access it.
- Action
-
Verify that the file or directory
on the server is still accessible.
cachefspack: filename- can't pack file: interrupted system call
|
- Cause
-
You might have pressed Control-c inadvertently while issuing the command.
- Action
-
Reissue the command.
cachefspack: filename- can't pack file: I/O error
|
- Cause
-
A hardware problem.
- Action
-
Check your hardware connections.
cachefspack: filename- can't pack file: no space left on device.
|
- Cause
-
You are out of disk space. The cache is at maximum capacity.
- Action
-
You need to increase disk
space. Increase the size of the cache.
cachefspack: filename - can't unpack file: permission denied
|
- Cause
-
You might not have the correct permissions to access the file or directory.
- Action
-
Set the correct permissions.
cachefspack: filename - can't unpack file: no such file or directory
|
- Cause
-
You might not have the correct file or directory.
- Action
-
Check for a possible typo.
cachefspack: filename- can't unpack file: stale NFS file handle
|
- Cause
-
The file or directory might have been moved or deleted from the server
at the time you attempted to access it.
- Action
-
Verify that the file or directory
on the server is still accessible.
cachefspack: filename - can't unpack file: interrupted system call
|
- Cause
-
You might have pressed Control-c inadvertently while issuing the command.
- Action
-
Reissue the command.
cachefspack: filename- can't unpack file I/O error
|
- Cause
-
A hardware problem.
- Action
-
Check your hardware connections.
cachefspack: only one `d', `i', `p', or `u' option allowed
|
- Cause
-
You entered more than one of the above options in a command session.
- Action
-
Select one option for the
command session.
cachefspack: can't find environment variable.
|
- Cause
-
You forgot to set a corresponding environment variable to match the $ in your configuration file.
- Action
-
Define the environment variable
in the proper location.
cachefspack: skipping LIST command - no active base
|
- Cause
-
A LIST command is present in your configuration file
that has no corresponding BASE command.
- Action
-
Define the BASE command.
CacheFS Statistics
CacheFS statistics enable you to:
These two pieces of information will help you determine the trade-off
between your cache size and the desired performance of the cache.
The CacheFS statistics consist of three commands:
|
cachefslog(1M)
|
Specifies the location of the log file.
This command also displays where the statistics are currently being logged,
and enables you to halt logging.
|
|
cachefswssize(1M)
|
Interprets the log file to give a recommended
cache size.
|
|
cachefsstat(1M)
|
Displays statistical information about
a specific file system or all cached file systems. The information provided
in the output of this command is taken directly from the cache.
|
Note -
The CacheFS statistics commands can be issued from any directory. You
must be superuser to issue the cachefswssize command.
The statistics begin accumulating when you create the log file. When
the work session length of time is up, stop the logging by using the cachefslog -h command, as described in "How to Stop the Logging Process".
Prerequisites for Setting Up and Viewing the CacheFS Statistics
Before using the CacheFS statistics commands, you must:
-
Set up your cache using the cfsadmin(1M) command.
-
Decide on an appropriate length of time to allow
statistical information to collect in the log file you create. The length
of time should equal a typical work session; for example, a day, a week, or
a month.
-
Select a location or path for the log file. Make
sure there is enough space to allow for the growth of the log file. The longer
you intend to allow statistical information to collect in the log file, the
more space you will need.
Note -
The following procedures are presented in a recommended order. The order
is not required.
Setting Up CacheFS Statistics Task Map
The table below shows the steps involved in setting up CacheFS statistics.
Table 37-3 Setting Up CacheFS Statistics Task Map
CacheFS Logging
This section describes how to set up and view CacheFS logging.
How to Set Up the Logging Process
-
Set up the logging process with the cachefslog command.
$ cachefslog -f log-file-path mount-point
|
|
-f
|
Sets up the logging process.
|
|
log-file-path
|
Specifies the location of the log file.
The log file is a standard file you create with an editor, such as vi.
|
|
mount-point
|
Designates the mount point (cached
file system) for which statistics are being collected.
|
-
Verify that you set up the log file correctly by using the cachefslog command, as follows:
Example--Setting Up the Logging Process
The following example sets up the log file samlog
to collect statistics about /home/sam. The location of samlog is /var/tmp/samlog.
$ cachefslog -f /var/tmp/samlog /home/sam
/var/tmp/samlog: /home/sam
|
How to Locate the Log File
You can also use the cachefslog(1M) command with no options to locate a
log file for a particular mount point.
|
mount-point
|
Specifies the cached
file system for which you want to view the statistics.
|
Examples--Locating the Log File
The following example shows what you would see if a log file has been
set up. The location of the log file is /var/tmp/stufflog.
$ cachefslog /home/stuff
/var/tmp/stufflog: /home/stuff
|
The following example shows that no log file has been set up for the
specified file system.
$ cachefslog /home/zap
not logged: /home/zap
|
How to Stop the Logging Process
Use the -h option of the cachefslog(1M) command to
stop the logging process.
$ cachefslog -h mount-point
|
Example--Stopping the Logging Process
The following example halts logging on /home/stuff.
$ cachefslog -h /home/stuff
not logged: /home/stuff
|
If you get a system response other than the one specified in the above
example, you did not successfully stop the logging process. Check to see if
you are using the correct log file name and mount point.
Viewing the Cache Size
You might want to check if you need to increase the size of the cache
or determine what the ideal cache size is based on your activity since you
last used the cachefslog(1M)
command for a particular mount point.
How to View the Working Set (Cache) Size
-
Become superuser.
-
View the current and highest logged cache size with the cachefswssize(1M) command.
# cachefswssize log-file-path
|
Example--Viewing the Working Set (Cache) Size
In the following example, the end size is the size of the cache at the
time you issued the cachefswssize command. The high water
size is the largest size of the cache during the time frame in which logging
has occurred.
# cachefswssize /var/tmp/samlog
/home/sam
end size: 10688k
high water size: 10704k
/
end size: 1736k
high water size: 1736k
/opt
end size: 128k
high water size: 128k
/nfs/saturn.dist
end size: 1472k
high water size: 1472k
/usr/openwin
end size: 7168k
high water size: 7168k
/nfs/venus.svr4
end size: 4688k
high water size: 5000k
/usr
end size: 4992k
high water size: 4992k
total for cache
initial size: 110960k
end size: 30872k
high water size: 30872k
|
Viewing the Statistics
You might want to view certain information about a specific cached file
system. The following table explains the terminology displayed in the statistics
output.
Table 37-4 Statistics Output Terminology
|
Output Term
|
Description
|
|
hit rate
|
The rate of cache hits versus cache
misses, followed by the actual number of hits and misses. A cache hit occurs
when the user wants to perform an operation on a file or files, and the file
or files are actually in the cache. A cache miss occurs when the file was
not in the cache. The load on the server is the sum of cache misses, consistency
checks, and modifications (modifies).
|
|
checks
|
The number of consistency checks performed,
followed by the number that passed, and the number that failed.
|
|
modifies
|
The number of modify operations; for
example, writes or creates.
|
How to View Cache Statistics
View the statistics with the cachefsstat(1M) command. You can do this at any time.
For example, you do not have to set up logging in order to view the statistics.
$ cachefsstat mount-point
|
|
mount-point
|
Specifies the cached file system for
which you want to view the statistics.
|
If you do not specify the mount point, statistics for all mounted CacheFS
file systems will be displayed.
Example--Viewing Cache Statistics
$ cachefsstat /home/sam
cache hit rate: 73% (1234 hits, 450 misses)
consistency checks: 700 (650 pass, 50 fail)
modifies: 321
garbage collection: 0
|
The Cache Structure and Behavior
Each cache has a set of parameters that determines how it behaves and
its structure. The parameters are set to default values which are listed in Table 37-5. The default values specify that the entire
front file system is used for caching, which is the recommended method of
caching file systems.
Table 37-5 Cache Parameters and Their Default Values
|
Cache Parameter
|
Default Value
|
Definition
|
|
maxblocks
|
90%
|
Sets the maximum number of blocks that CacheFS is allowed
to claim within the front file system.
|
|
minblocks
|
0%
|
Sets the minimum number of blocks that CacheFS is allowed
to claim within the front file system.
|
|
threshblocks
|
85%
|
Sets the number of blocks that must be available in the
front file system before CacheFS can claim more than the blocks specified
by minblocks.
|
|
maxfiles
|
90%
|
Sets the maximum number of available inodes (number of
files) that CacheFS is allowed to claim within the front file system.
|
|
minfiles
|
0%
|
Sets the minimum number of available inodes (number of
files) that CacheFS is allowed to claim within the front file system.
|
|
threshfiles
|
85%
|
Sets the number of inodes (number of files) that must be
available in the front file system before CacheFS can claim more than the
files specified in minfiles.
|
Typically, you should not change any of these parameter values. They
are set to default values to achieve optimal cache behavior. However, you
might want to modify the maxblocks and maxfiles settings if you have some room in the front file system that is
not used by the cache, and you wish to use it for some other file system.
You do this using the cfsadmin(1M) command. For example:
$ cfsadmin -o maxblocks=60
|
Consistency Checking of Cached File Systems With the Back File System
To ensure that the cached directories and files are kept up to date,
CacheFS periodically checks consistency of files stored in the cache. To check
consistency, CacheFS compares the current modification time to the previous
modification time. If the modification times are different, all data and attributes
for the directory or file are purged from the cache and new data and attributes
are retrieved from the back file system.
When a user requests an operation on a directory or file, CacheFS checks
if it is time to verify consistency. If it is, CacheFS obtains the modification
time from the back file system and performs the comparison.
Consistency Checking on Demand
By specifying the demandconst option of the mount(1M)
command, consistency checks can be performed only when you explicitly request
them for file systems mounted with this option. After specifying the demandconst option when you mount a file system in a cache, you
use the cfsadmin(1M)
command with the -s option to request a consistency check.
By default, consistency checking is performed file by file as the files are
accessed. If no files are accessed, no checks are performed. Use of the demandconst option will avoid the situation where the network is
flooded with consistency checks.