Oracle Internals Notes

File System Read/Write Locks

Because buffered reads cannot be guaranteed to be satisfied atomically, operating systems need file system read/write locks to ensure that file system buffers against which a read is pending cannot be modified. Otherwise, split reads could return inconsistent data, as follows.

Without read-write locks, inconsistent data could be returned by split reads

File system read/write locks are a POSIX requirement. They called inode locks under Unix, because that is where the lock is applied. Under Windows NT/2000, however, they are implemented as ERESOURCE locks on the File Control Block (FCB). These locks allow multiple concurrent readers, but ensure exclusive access for each writer. They are used for all file access, because the operating system cannot assume that concurrent reads and writes will not address the same buffers. This means that concurrent readers and writers must contend for file access.

For example, if a number of Oracle processes have reads pending against a particular datafile, DBWn must wait for all those reads to complete before it can acquire the file system read/write lock to write to that file. This applies even if the reads and the write address different parts of the file. Once DBWn has acquired the lock, all readers must wait for its write to complete. Similarly, if one process is performing a direct write to a temporary tablespace datafile or tempfile, then no other process can either read from or write to another extent in that file concurrently, even though their activities are entirely unrelated.

Unfortunately, although logically only needed for buffered I/O, read/write locks are nevertheless generally used for direct I/O too. The reason is that direct I/O requests may need to be performed with buffered I/O if the device block boundary alignment requirements are not met. It is possible to work around this difficulty, but the only file system that we know of that does so is Solaris UFS (from Solaris 8, update 3). Otherwise, to avoid read/write locks you have to use raw datafiles, or Quick I/O.


© Ixora Pty Ltd.   All rights reserved.
05-Apr-2002
Search   Questions   Feedback   Up   Home