bufq.9 revision 1.10 $NetBSD: bufq.9,v 1.10 2005/10/16 04:11:02 yamt Exp $ Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. This code is derived from software contributed to The NetBSD Foundation by Juergen Hannken-Illjes. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the NetBSD Foundation, Inc. and its contributors. 4. Neither the name of The NetBSD Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE..Dd October 16, 2005
.Dt BUFQ 9
.Os
.Sh NAME
.Nm bufq ,
.Nm bufq_state ,
.Nm bufq_alloc ,
.Nm bufq_drain ,
.Nm bufq_free ,
.Nm BUFQ_PUT ,
.Nm BUFQ_GET ,
.Nm BUFQ_PEEK
.Nd device buffer queues
.Sh SYNOPSIS
n sys/bufq.h .Ft int
.Fn bufq_alloc "struct bufq_state **bufq" "const char *strategy" "int flags"
.Ft void
.Fn bufq_drain "struct bufq_state *bufq"
.Ft void
.Fn bufq_free "struct bufq_state *bufq"
.Ft void
.Fn BUFQ_PUT "struct bufq_state *bufq" "struct buf *bp"
.Ft "struct buf *"
.Fn BUFQ_GET "struct bufq_state *bufq"
.Ft "struct buf *"
.Fn BUFQ_PEEK "struct bufq_state *bufq"
.Sh DESCRIPTION
The
.Nm
subsystem is a set of operations for the management of device buffer queues.
p
The primary data type for using the operations is the
.Em bufq_state
structure, which is opaque for users.
.Sh FUNCTIONS
l -tag -width compact 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.
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 uses one of available strategies.
.El
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_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.
.El
.Sh CODE REFERENCES
The actual code implementing the device buffer queues can be found
in the file
a sys/kern/subr_bufq.c .
.Sh HISTORY
The
.Nm
subsystem appeared in
.Nx 2.0 .
.Sh AUTHORS
The
.Nm
subsystem was written by
.Aq hannken (at] NetBSD.org .