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 either reads the data before or after the write occurred. With the VX_CONCURRENT
advisory set on a file, the reads and writes are not serialized similar to character devices. This advisory is generally used by applications that require high performance for accessing data and do not perform overlapping writes to the same file. 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.
When concurrent I/O is enabled, the read and write behaves as follows:
write
() system call acquires a shared read-write lock instead of an exclusive lock.
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.
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.
Note
The read
() and write
() system calls are not atomic. The application must ensure that two threads will not write to the same region of a file at the same time.
VxFS 4.0 earlier introduced support for the -o cio
option for the mount
command and the O_CIO
open flag for the open
() system call. The open
() call with the O_CIO
flag is mutually exclusive from the standard open
() call. If the file is already opened with the O_CIO
flag, opening the file with the standard open
() call fails. If the file is already opened with the standard open
() call, another open
() call with the O_CIO
flag performed on the file fails.
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 will still follow the POSIX semantics. The VX_CONCURRENT
advisory can be set via the VX_SETCACHE
ioctl descriptor on a file.
CIO is a licensable feature of VxFS.
The VX_CONCURRENT
advisory cannot be set on a file that is actively open via Quick I/O or ODM, nor can that file be concurrently opened with the O_CIO flag. A file opened with the O_CIO
flag or that has the VX_CONCURRENT
advisory set may not be concurrently opened via Quick I/O or ODM. Quick I/O and ODM access are not allowed for any files on a file system mounted with the -o cio mount option.