Arguments
The argument types for the io probes are listed in Table 27-2. The arguments are
described in Table 27-1.
Table 27-2 io Probe Arguments
Probe |
args[0] |
args[1] |
args[2] |
start |
struct buf * |
devinfo_t * |
fileinfo_t * |
done |
struct buf * |
devinfo_t * |
fileinfo_t * |
wait-start |
struct buf * |
devinfo_t * |
fileinfo_t * |
wait-done |
struct buf * |
devinfo_t * |
fileinfo_t * |
Each io probe has arguments consisting of a pointer to a buf(9S) structure, a
pointer to a devinfo_t, and a pointer to a fileinfo_t. These structures
are described in greater detail in this section.
bufinfo_t structure
The bufinfo_t structure is the abstraction that describes an I/O request. The buffer
corresponding to an I/O request is pointed to by args[0] in the start,
done, wait-start, and wait-done probes. The bufinfo_t structure definition is as follows:
typedef struct bufinfo {
int b_flags; /* flags */
size_t b_bcount; /* number of bytes */
caddr_t b_addr; /* buffer address */
uint64_t b_blkno; /* expanded block # on device */
uint64_t b_lblkno; /* block # on device */
size_t b_resid; /* # of bytes not transferred */
size_t b_bufsize; /* size of allocated buffer */
caddr_t b_iodone; /* I/O completion routine */
dev_t b_edev; /* extended device */
} bufinfo_t;
The b_flags member indicates the state of the I/O buffer, and consists of
a bitwise-or of different state values. The valid state values are in Table 27-3.
Table 27-3 b_flags Values
B_DONE |
Indicates
that the data transfer has completed. |
B_ERROR |
Indicates an I/O transfer error. It is
set in conjunction with the b_error field. |
B_PAGEIO |
Indicates that the buffer is being
used in a paged I/O request. See the description of the b_addr field
for more information. |
B_PHYS |
Indicates that the buffer is being used for physical
(direct) I/O to a user data area. |
B_READ |
Indicates that data is to be read
from the peripheral device into main memory. |
B_WRITE |
Indicates that the data is to be
transferred from main memory to the peripheral device. |
B_ASYNC |
The I/O request is asynchronous, and
will not be waited upon. The wait-start and wait-done probes don't fire
for asynchronous I/O requests. Note that some I/Os directed to be asynchronous might not
have B_ASYNC set: the asynchronous I/O subsystem might implement the asynchronous request by
having a separate worker thread perform a synchronous I/O operation. |
The b_bcount field is the number of bytes to be transferred as part
of the I/O request.
The b_addr field is the virtual address of the I/O request, unless B_PAGEIO
is set. The address is a kernel virtual address unless B_PHYS is set,
in which case it is a user virtual address. If B_PAGEIO is set,
the b_addr field contains kernel private data. Exactly one of B_PHYS and
B_PAGEIO can be set, or neither flag will be set.
The b_lblkno field identifies which logical block on the device is to be
accessed. The mapping from a logical block to a physical block (such as
the cylinder, track, and so on) is defined by the device.
The b_resid field is set to the number of bytes not transferred because
of an error.
The b_bufsize field contains the size of the allocated buffer.
The b_iodone field identifies a specific routine in the kernel that is called
when the I/O is complete.
The b_error field may hold an error code returned from the driver in
the event of an I/O error. b_error is set in conjunction with the
B_ERROR bit set in the b_flags member.
The b_edev field contains the major and minor device numbers of the device
accessed. Consumers may use the D subroutines getmajor() and getminor() to extract
the major and minor device numbers from the b_edev field.
devinfo_t
The devinfo_t structure provides information about a device. The devinfo_t structure corresponding
to the destination device of an I/O is pointed to by args[1] in
the start, done, wait-start, and wait-done probes. The members of devinfo_t are as
follows:
typedef struct devinfo {
int dev_major; /* major number */
int dev_minor; /* minor number */
int dev_instance; /* instance number */
string dev_name; /* name of device */
string dev_statname; /* name of device + instance/minor */
string dev_pathname; /* pathname of device */
} devinfo_t;
The dev_major field is the major number of the device. See getmajor(9F) for more
information.
The dev_minor field is the minor number of the device. See getminor(9F) for more
information.
The dev_instance field is the instance number of the device. The instance of
a device is different from the minor number. The minor number is an
abstraction managed by the device driver. The instance number is a property of
the device node. You can display device node instance numbers with prtconf(1M).
The dev_name field is the name of the device driver that manages the
device. You can display device driver names with the -D option to prtconf(1M).
The dev_statname field is the name of the device as reported by iostat(1M). This
name also corresponds to the name of a kernel statistic as reported
by kstat(1M). This field is provided so that aberrant iostat or kstat output can
be quickly correlated to actual I/O activity.
The dev_pathname field is the full path of the device. This path may
be specified as an argument to prtconf(1M) to obtain detailed device information. The
path specified by dev_pathname includes components expressing the device node, the instance number,
and the minor node. However, all three of these elements aren't necessarily expressed
in the statistics name. For some devices, the statistics name consists of the device
name and the instance number. For other devices, the name consists of the
device name and the number of the minor node. As a result,
two devices that have the same dev_statname may differ in dev_pathname.
fileinfo_t
The fileinfo_t structure provides information about a file. The file to which an
I/O corresponds is pointed to by args[2] in the start, done, wait-start, and wait-done
probes. The presence of file information is contingent upon the filesystem providing this
information when dispatching I/O requests. Some filesystems, especially third-party filesystems, might not provide this
information. Also, I/O requests might emanate from a filesystem for which no file
information exists. For example, any I/O to filesystem metadata will not be associated
with any one file. Finally, some highly optimized filesystems might aggregate I/O from
disjoint files into a single I/O request. In this case, the filesystem might
provide the file information either for the file that represents the majority of
the I/O or for the file that represents some of the I/O.
Alternately, the filesystem might provide no file information at all in this case.
The definition of the fileinfo_t structure is as follows:
typedef struct fileinfo {
string fi_name; /* name (basename of fi_pathname) */
string fi_dirname; /* directory (dirname of fi_pathname) */
string fi_pathname; /* full pathname */
offset_t fi_offset; /* offset within file */
string fi_fs; /* filesystem */
string fi_mount; /* mount point of file system */
} fileinfo_t;
The fi_name field contains the name of the file but does not include
any directory components. If no file information is associated with an I/O, the
fi_name field will be set to the string <none>. In some rare
cases, the pathname associated with a file might be unknown. In this case,
the fi_name field will be set to the string <unknown>.
The fi_dirname field contains only the directory component of the file name. As
with fi_name, this string may be set to <none> if no file information is
present, or <unknown> if the pathname associated with the file is not known.
The fi_pathname field contains the full pathname to the file. As with fi_name,
this string may be set to <none> if no file information is
present, or <unknown> if the pathname associated with the file is not known.
The fi_offset field contains the offset within the file , or -1 if
either file information is not present or if the offset is otherwise unspecified
by the filesystem.