io 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 */
int b_error; /* expanded error field */
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 the following:
-
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_errorfield. -
B_PAGEIO -
Indicates that the buffer is being used in a paged I/O request. See the description of the
b_addrfield 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-startandwait-doneprobes do not fire for asynchronous I/O requests. Note that some I/Os directed to be asynchronous might not haveB_ASYNCset: the asynchronous I/O subsystem might implement the asynchronous request by having a separate worker thread perform a synchronous I/O operation.
The following describes the other fields in the bufinfo structure:
-
b_bcount -
Is the number of bytes to be transferred as part of the I/O request.
-
b_addr -
Is the virtual address of the I/O request, unless
B_PAGEIOis set. The address is a kernel virtual address unlessB_PHYSis set, in which case it is a user virtual address. IfB_PAGEIOis set, theb_addrfield contains kernel private data. Exactly one ofB_PHYSandB_PAGEIOcan be set, or neither flag will be set. -
b_lblkno -
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.
-
b_resid -
Is set to the number of bytes not transferred because of an error.
-
b_bufsize -
Contains the size of the allocated buffer.
-
b_iodone -
Identifies a specific routine in the kernel that is called when the I/O is complete.
-
b_error -
May hold an error code returned from the driver in the event of an I/O error.
b_erroris set in conjunction with theB_ERRORbit set in theb_flagsmember. -
b_edev -
Contains the major and minor device numbers of the device accessed. Consumers may use the D subroutines
getmajorandgetminorto extract the major and minor device numbers from theb_edevfield.