[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1

iodone Kernel Service


Performs block I/O completion processing.


#include <sys/types.h>
#include <sys/errno.h>
#include <sys/buf.h>
void iodone (bp)
struct buf *bp;


bp Specifies the address of the buf structure for the buffer whose I/O has completed.


A device driver calls the iodone kernel service when a block I/O request is complete. The device driver must not reference or alter the buffer header or buffer after calling the iodone service.

The iodone service takes one of two actions, depending on the current interrupt level. Either it invokes the caller's individual iodone routine directly, or it schedules I/O completion processing for the buffer to be performed off-level, at the INTIODONE interrupt level. The interrupt handler for this level then calls the iodone routine for the individual device driver. In either case, the individual iodone routine is defined by the b_iodone buffer header field in the buffer header. This iodone routine is set up by the caller of the device's strategy routine.

For example, the file I/O system calls set up a routine that performs buffered I/O completion processing. The uphysio service sets up a routine that performs raw I/O completion processing. Similarly, the pager sets up a routine that performs page-fault completion processing.

Setting up an iodone Routine

Under certain circumstances, a device driver can set up an iodone routine. For example, the logical volume device driver can follow this procedure:

  1. Take a request for a logical volume.
  2. Allocate a buffer header.
  3. Convert the logical volume request into a physical volume request.
  4. Update the allocated buffer header with the information about the physical volume request. This includes setting the b_iodone buffer header field to the address of the individual iodone routine.
  5. Call the physical volume device driver strategy routine.

    Here, the caller of the logical volume strategy routine has set up an iodone routine that is started when the logical volume request is complete. The logical volume strategy routine in turn sets up an iodone routine that is invoked when the physical volume request is complete.

The key point of this example is that only the caller of a strategy routine can set up an iodone routine and even then, this can only be done while setting up the request in the buffer header.

The interface for the iodone routine is identical to the interface to the iodone service.

Execution Environment

The iodone kernel service can be called from either the process or interrupt environment.

Return Values

The iodone service has no return values.

Implementation Specifics

The iodone kernel service is part of Base Operating System (BOS) Runtime.

Related Information

The iowait kernel service.

The buf structure.

Understanding Interrupts and I/O Kernel Services in AIX Kernel Extensions and Device Support Programming Concepts.

[ Previous | Next | Contents | Home | Search ]