24.05.2014 Views

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.6.1 Opening Files for Direct I/O<br />

A new flag, O_DIRECT has been defined in fcntl.h. When an application opens a<br />

file specifying or calling this flag through the fcntl() system call, I/O to this file will<br />

be done using direct I/O.<br />

4.6.1.1 Inode Flags<br />

When a file is using direct I/O, the i_flag field in the inode is set with the IDIRECT<br />

flag, defined in inode.h. Even so, it is not enough to simply have a flag in the<br />

inode to determine if the file is using direct I/O or not. If a normal I/O application<br />

opens the file while a direct I/O application currently has it open, then all I/O will<br />

be done using normal I/O until the normal I/O reader or writer closes the file. A<br />

count of direct I/O readers is maintained to determine if the direct I/O can be<br />

resumed. A new field in the inode, i_diocnt, has been added for this purpose. This<br />

field indicates if any application has the file opened for direct I/O.<br />

4.6.2 JFS Function Calls for Direct I/O<br />

There are only a few functions that were affected in the JFS for direct I/O to be<br />

implemented. These functions are serialized by the inode lock and are described<br />

below.<br />

jfs_map() If a file opened for direct I/O is mapped, the IDIRECT flag is reset,<br />

and all subsequent I/O will be done using normal I/O. If the mapped<br />

file is then closed, direct I/O will be resumed.<br />

jfs_close() Close semantics are closed with direct I/O. When the final close<br />

occurs, (checked by the counts on gnode) the IDIRECT flag in the<br />

inode is turned off. If a close is initiated by a normal I/O reader or<br />

writer and another application opens the file for direct I/O, all cached<br />

pages are flushed to disk, and direct I/O is resumed on the file.<br />

jfs_dio() jfs_dio() is called from jfs_rdwr(). If the FDIRECT flag is set, jfs_dio()<br />

evaluates if direct I/O can be done for a particular file. This function<br />

performs all alignment and file state consistency checking.<br />

If a read or write request cannot be done using direct I/O, jfs_dio()<br />

returns a non-zero return code, and the request is done through<br />

normal cached I/O.<br />

4.6.3 System Archive Utilities<br />

Archive commands are typical applications that can benefit from the use of direct<br />

I/O. Therefore, the standard system commands tar, backup, restore, and cpio<br />

have been enabled to use direct I/O. Since these commands are read-once<br />

commands, that is, they do not reference the data again after it has been read<br />

and written to media, the copyin() and copyout() characteristics of normal cached<br />

I/O consume a lot of unnecessary CPU when these commands are executing.<br />

The enabling of these commands has been accomplished by changing all calls to<br />

open() and setting the O_DIRECT flag.<br />

78 <strong>AIX</strong> <strong>Version</strong> <strong>4.3</strong> <strong>Differences</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!