[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Kernel and Subsystems, Volume 1

iostadd Kernel Service

Purpose

Registers an I/O statistics structure used for updating I/O statistics reported by the iostat subroutine.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/iostat.h>
#include <sys/devinfo.h>


int iostadd ( devtype, devstatp)
int devtype;
union {
       struct ttystat *ttystp;
       struct dkstat *dkstp;
       } devstatp;

Description

The iostadd kernel service is used to register the I/O statistics structure required to maintain statistics on a device. The iostadd service is typically called by a tty, disk, or CD-ROM device driver to provide the statistical information used by the iostat subroutine. The iostat subroutine displays statistic information for tty and disk devices on the system. The iostadd service should be used once for each configured device.

In AIX 5.2, support for Multi-Path I/O (MPIO) was added to the iostadd kernel service and the dkstat structure. The dkstat structure was expanded to accomodate the MPIO data. The iostadd kernel service was modified to handle the new version of the dkstat structure as well as older, legacy versions. For an MPIO device, the anchor is the disk's dkstat structure. This must be the first dkstat structure registered using the iostadd kernel service. Any path dkstat structures that are registered subsequently must reference the address of the anchor dkstat (disk) structure in the dkstat.dk_mpio_anchor field.

For tty devices, the devtype parameter has a value of DD_tty. In this case, the iostadd service uses the devstatp parameter to return a pointer to a ttystat structure.

For disk or CD-ROM devices with a devtype value of DD_DISK or DD_CD-ROM, the caller must provide a pinned and initialized dkstat structure as an input parameter. This structure is pointed to by the devstatp parameter on entry to the iostadd kernel service.

If the device driver support for a device is terminated, the dkstat or ttystat structure registered with the iostadd kernel service should be deregistered by calling the iostdel kernel service.

I/O Statistics Structures

The iostadd kernel service uses two structures that are found in the usr/include/sys/iostat.h file: the ttystat structure and the dkstat structure.

The ttystat structure contains the following tty-related fields:

Field Description
rawinch Count of raw characters received by the tty device
caninch Count of canonical characters generated from canonical processing
outch Count of the characters output to a tty device

The second structure used by the iostadd kernel service is the dkstat structure, which contains information about disk devices. This structure contains the following fields:

Field Description
diskname 32-character string name for the disk's logical device
dknextp Pointer to the next dkstat structure in the chain
dk_status Disk entry-status flags
dk_time Time the disk is active
dk_bsize Number of bytes in a block
dk_xfers Number of transfers to or from the disk
dk_rblks Number of blocks read from the disk
dk_wblks Number of blocks written to the disk
dk_seeks Number of seek operations for disks
dk_version Version of the dkstat structure
dk_q_depth Que depth
dk_mpio_anchor Pointer to the path data anchor (disk)
dk_mpio_next_path Pointer to the next path dkstat structure in the chain
dk_mpio_path_id Path ID

tty Device Driver Support

The rawinch field in the ttystat structure should be incremented by the number of characters received by the tty device. The caninch field in the ttystat structure should be incremented by the number of input characters generated from canonical processing. The outch field is increased by the number of characters output to tty devices. These fields should be incremented by the device driver, but never be cleared.

Disk Device Driver Support

A disk device driver must perform these four tasks:

If a disk device driver supports MPIO, it must perform the following tasks:

If the device supports discrete seek commands, the dkstat.dk_xrate field in the structure should be set to the transfer rate capability of the device (KB/sec). The device's dkstat structure should then be registered using the iostadd kernel service.

During drive operation update, the dkstat.dk_status field should show the busy/nonbusy state of the device. This can be done by setting and resetting the IOST_DK_BUSY flag. The dkstat.dk_xfers field should be incremented for each transfer initiated to or from the device. The dkstat.dk_rblks and dkstat.dk_wblks fields should be incremented by the number of blocks read or written.

If the device supports discrete seek commands, the dkstat.dk_seek field should be incremented by the number of seek commands sent to the device. If the device does not support discrete seek commands, both the dkstat.dk_seek and dkstat.dk_xrate fields should be left with a value of 0.

The base kernel updates the dkstat.dk_nextp and dkstat.dk_time fields. They should not be modified by the device driver after initialization. For MPIO devices, the base kernel also updates the dkstat.dk_mpio_next_path field.

Note
The same dkstat structure must not be registered more than once.

Parameters

devtype Specifies the type of device for which I/O statistics are kept. The various device types are defined in the /usr/include/sys/devinfo.h file. Currently, I/O statistics are only kept for disks, CD-ROMs, and tty devices. Possible values for this parameter are:
DD_DISK
For disks
DD_CD-ROM
For CD-ROMs
DD_TTY
For tty devices
devstatp Points to an I/O statistics structure for the device type specified by the devtype parameter. For a devtype parameter of DD_tty, the address of a pinned ttystat structure is returned. For a devtype parameter of DD_DISK or DD_CD-ROM, the parameter is an input parameter pointing to a dkstat structure previously allocated by the caller.

Execution Environment

The iostadd kernel service can be called from the process environment only.

Return Values

0 Indicates that no error has been detected.
EINVAL Indicates that the devtype parameter specified a device type that is not valid. For MPIO devices, indicates that an anchor for a path dkstat structure was not found.

Related Information

The iostat command.

The iostdel kernel service.

Kernel Extension and Device Driver Management Kernel Services in AIX 5L Version 5.2 Kernel Extensions and Device Support Programming Concepts.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]