p The primary data type for using the operations is the .Em bufq_state structure, which is opaque for users. Each buffer queue strategy module is defined by the .Em bufq_strat structure, which is also opaque for users. .Sh FUNCTIONS l -tag -width compact t Fn bufq_init "void" Initialize the .Nm subsystem. This routine must be called before any other .Nm routines. t Fn bufq_register "bs" Registers the specified buffer queue strategy module so it can be used in subsequent operations. t Fn bufq_unregister "bs" Unregisters the specified buffer queue strategy module. The routine will fail if any buffer queues for the specified strategy are in use (see .Fn bufq_alloc below). t Fn bufq_alloc "bufq" "strategy" "flags" Allocate and initialize a .Em bufq_state descriptor.
p The argument .Fa strategy specifies a buffer queue strategy to be used for this buffer queue. The following special values can be used:
p l -tag -offset indent -width BUFQ_DISK_DEFAULT_STRAT -compact t Dv BUFQ_STRAT_ANY Let .Fn bufq_alloc select a strategy. t Dv BUFQ_DISK_DEFAULT_STRAT Let .Fn bufq_alloc select a strategy, assuming it will be used for a normal disk device. .El
p Valid bits for the .Fa flags are:
p l -tag -offset indent -width BUFQ_SORT_RAWBLOCK -compact t Dv BUFQ_SORT_RAWBLOCK sort by .Em b_rawblkno t Dv BUFQ_SORT_CYLINDER sort by .Em b_cylinder and then by .Em b_rawblkno t Dv BUFQ_EXACT Fail if a strategy specified by .Fa strategy is not available. In that case, .Fa bufq_alloc returns .Dv ENOENT . If this flag is not specified, .Fn bufq_alloc will silently use one of available strategies. .El
p If a specific strategy is specified but not currently available, the .Nm bufq subsystem will attempt to auto-load the corresponding kernel module using .Xr module_autoload 9 . t Fn bufq_drain "bufq" Drain a .Em bufq_state descriptor. t Fn bufq_free "bufq" Destroy a .Em bufq_state descriptor. t Fn bufq_getstrategyname "bufq" Get a strategy identifier of a buffer queue, the string returned will be NUL-terminated and it always will be a valid strategy name. t Fn bufq_move "dst" "src" Move all requests from the buffer queue .Fa src to the buffer queue .Fa dst . t Fn bufq_put "bufq" "bp" Put the buf .Fa bp in the queue. t Fn bufq_get "bufq" Get the next buf from the queue and remove it from the queue. Returns .Dv NULL if the queue is empty. t Fn bufq_peek "bufq" Get the next buf from the queue without removal. The next buf will remain the same until .Fn bufq_get , .Fn bufq_put , or .Fn bufq_drain is called. Returns .Dv NULL if the queue is empty. t Fn bufq_cancel "bufq" "bp" Cancel the buf .Fa bp issued earlier on the queue. Returns .Dv NULL if the element can not be found on the queue or .Fa bp if it has been found and removed. This operation can be computationally expensive if there are a lot of buffers queued. .El .Sh CODE REFERENCES The actual code implementing the device buffer queues can be found in the file
a sys/kern/subr_bufq.c . The code implementing specific buffer queue strategies can be found in the files
a sys/kern/bufq_*.c . .Sh NOTES A list of currently available buffer queue strategies is available via the .Dq kern.bufq.strategies .Xr sysctl 7 variables. .Sh HISTORY The .Nm subsystem appeared in .Nx 2.0 . .Sh AUTHORS The .Nm subsystem was written by .An J\(:urgen Hannken-Illjes .Aq hannken (at] NetBSD.org .