Data and Attribute Caching

There are a number of flags that can be passed to open() that control various aspects of the I/O. Also, some filesystems support additional but non standard methods for improving I/O performance.

Firstly, there are three options, supported under the Single UNIX Specification, that can be passed to open() that have an impact on subsequent I/O operations. When a write takes place, there are two items of data that must be written to disk, namely the file data and the file's inode. An inode is the object stored on disk that describes the file, including the properties seen by calling stat() together with a block map of all data blocks associated with the file.

The three options that are supported from a standards perspective are:

O_SYNC. For all types of writes, whether allocation is required or not, the data and any meta-data updates are committed to disk before the write returns. For reads, the access time stamp will be updated before the read returns.

O_DSYNC. When a write occurs, the data will be committed to disk before the write returns but the file's meta-data may not be written to disk at this stage. This will result in better I/O throughput because, if implemented efficiently by the filesystem, the number of inode updates will be minimized, effectively halving the number of writes. Typically, if the write results in an allocation to the file (a write over a hole or beyond the end of the file) the meta-data is also written to disk. However, if the ...

Get UNIX Filesystems: Evolution, Design, and Implementation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.