VERITAS File SystemÖ 3.5 (HP OnlineJFS/JFS3.5) AdministratorÆs Guide (December 2002)

Chapter 4
Application Interface
Cache Advisories
44
Cache Advisories
VxFS allows an application to set cache advisories for use when accessing files. These advisories are in
memory only and they do not persist across reboots. Some advisories are currently maintained on a per-file,
not a per-file-descriptor, basis. This means that only one set of advisories can be in effect for all accesses to the
file. If two conflicting applications set different advisories, both use the last advisories that were set.
All advisories are set using the VX_SETCACHE ioctl command. The current set of advisories can be obtained
with the VX_GETCACHE ioctl command. For details on the use of these ioctl commands, see the vxfsio (7)
manual page.
Direct I/O
Direct I/O is an unbuffered form of I/O. If the VX_DIRECT advisory is set, the user is requesting direct data
transfer between the disk and the user-supplied buffer for reads and writes. This bypasses the kernel
buffering of data, and reduces the CPU overhead associated with I/O by eliminating the data copy between
the kernel buffer and the user’s buffer. This also avoids taking up space in the buffer cache that might be
better used for something else. The direct I/O feature can provide significant performance gains for some
applications.
For an I/O operation to be performed as direct I/O, it must meet certain alignment criteria. The alignment
constraints are usually determined by the disk driver, the disk controller, and the system memory
management hardware and software. The file offset must be aligned on a 4-byte boundary.
If a request fails to meet the alignment constraints for direct I/O, the request is performed as data
synchronous I/O. If the file is currently being accessed by using memory mapped I/O, any direct I/O accesses
are done as data synchronous I/O.
Because direct I/O maintains the same data integrity as synchronous I/O, it can be used in many applications
that currently use synchronous I/O. If a direct I/O request does not allocate storage or extend the file, the
inode is not immediately written.
The CPU cost of direct I/O is about the same as a raw disk transfer. For sequential I/O to very large files,
using direct I/O with large transfer sizes can provide the same speed as buffered I/O with much less CPU
overhead.
If the file is being extended or storage is being allocated, direct I/O must write the inode change before
returning to the application. This eliminates some of the performance advantages of direct I/O.
The direct I/O and VX_DIRECT advisories are maintained on a per-file-descriptor basis.
Unbuffered I/O
If the VX_UNBUFFERED advisory is set, I/O behavior is the same as direct I/O with the VX_DIRECT advisory set,
so the alignment constraints that apply to direct I/O also apply to unbuffered I/O. For unbuffered I/O,
however, if the file is being extended, or storage is being allocated to the file, inode changes are not updated
synchronously before the write returns to the user. The VX_UNBUFFERED advisory is maintained on a
per-file-descriptor basis.