Veritas™ File System 5.0.1 Programmer's Reference Guide

Concurrent I/O
Concurrent I/O (VX_CONCURRENT) is a form of I/O for file access. This form of I/O
allows multiple processes to read or write to the same file without blocking other
read() or write() operations. POSIX semantics requires read() and write()
operations to be serialized on a file with other read() and write() operations. With
POSIX semantics, a read will either read the data before or after the write occurs.
With the VX_CONCURRENT advisory set on a file, the reads and writes are not
serialized similar to character devices. Applications that require high performance
for accessing data and do not perform overlapping writes to the same file generally
use this advisory. An example is database applications. Such applications perform
their own locking at the application level to avoid overlapping writes to the same
region of the file.
It is the responsibility of the application or threads to coordinate write activities
to the same file when using the VX_CONCURRENT advisory to avoid overlapping
writes. The consequence of two overlapping writes to the same file is unpredictable.
The best practice for applications is to avoid simultaneous write operations to
the same region of the same file.
If the VX_CONCURRENT advisory is set on a file, VxFS performs direct I/O for reads
and writes to the file. As such, concurrent I/O has the same alignment requirements
as direct I/O.
See Direct I/O on page 74.
When concurrent I/O is enabled, the read and write behaves as follows:
The write() system call acquires a shared read-write lock instead of an exclusive
lock.
The write() system call performs direct I/O to the disk instead of copying and
then writing the user data to the pages in the system page cache.
The read() system call acquires a shared read-write lock and performs direct
I/O from disk instead of reading the data into pages in the system page cache
and copying from the pages to the user buffer.
The read() and write() system calls are not atomic. The application must ensure
that two threads do not write to the same region of a file at the same time.
Concurrent I/O (CIO) can be set through the file descriptor and ioctl() operation
using the VX_SETCACHE ioctl command with the VX_CONCURRENT advisory flag.
Only the read() and write() operations occurring through this file descriptor use
concurrent I/O. read() and write() operations occurring through other file
descriptors still follows the POSIX semantics. The VX_CONCURRENT advisory can
be set by the VX_SETCACHE ioctl descriptor on a file.
75Veritas File System I/O
Caching advisories