zDIOWrite

Performs a direct write to an open file object that was opened in Direct I/O mode.

Service:File System Services (64-Bit)

Syntax

#include <zPublics.h>

STATUS zDIOWrite(
   Key_t      key,
   QUAD       unitOffset,
   NINT       unitsToWrite,
   ADDR       callBackContext,
   void     (*dioWriteCallBack)(
         ADDR   reserved,
         ADDR   callBackContext,
         NINT   retStatus),
 const void   *buffer);

Parameters

key

(IN) Specifies the file object to be written using Direct I/O as returned by zOpen or zCreate with the zRR_DIO_MODE set in requested rights.

unitOffset

(IN) Specifies a starting location in the file object where the write operation will begin. A unit is 512 bytes in length. For example, unit 0 starts at logical offset 0, unit 1 starts at logical offset 512, etc.

unitsToWrite

(IN) Specifies the number of 512-byte units to write to the file.

callBackContext

(IN) Specifies a user-provided cookie that is provided back to the user when the callback routine is called. This value can be anything you want, if it fits in an ADDR type.

dioReadCallBack

(IN) Points to a callback function:

  • NULL performs a synchronous write and waits until the write operation completes before it returns.

  • non-NULL performs an asynchronous write, calls the specified function, and returns when the write is queued.

IMPORTANT:Because the callback function can be called from fast work-to-do routines and can be called from any processor, the callback function must be SMP enabled and non-blocking.

reserved

Is used internally to optimize performance and should be ignored.

callBackContext

(IN) Specifies the context for the callback function.

retStatus

(OUT) Specifies the return code of the callback function.

buffer

(OUT) Points to a buffer that contains the data that is to be written to the file object. The buffer should be on a 512-byte boundary.

Return Values

zOK

The operation completed successfully.

non-0

An error occurred. See Section 4.1, Return Values for details.

zERR_FILE_NOT_IN_DIO_MODE

The file is not in direct file mode.

Remarks

A direct write is one that does not go through an internal file system cache buffer. Instead, the data is written directly to the media from the buffer provided by the caller. In order to perform a direct write, the file object must be opened by calling zOpen or zCreate with the zRR_DIO_MODE set in requested rights.

zDIOWrite writes the specified number of 512-byte units, starting at the specified logical unitNumber in the file identified by the key. If all of the units cannot be written, an error is returned.

zDIOWrite works with physical storage media of any sector size. However, it works optimally if the write operation begins on a sector boundary and if the read length is an integral number of sectors; otherwise, the file system must do some internal manipulation to write on non-sector boundaries. For example, if the media is made up of 512-byte sectors, all writes are optimal. However, if the media is made up of 1024-byte sectors, zDIOWrite works optimally by always writing an even number of units and by starting the writes on an even-numbered unit.

See Also

zCreate, zDIORead, zOpen