1 .\" $NetBSD: bufq.9,v 1.19 2009/01/24 10:39:58 wiz Exp $
3 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Juergen Hannken-Illjes.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
39 .Nm bufq_getstrategyname ,
45 .Nd device buffer queues
49 .Fn bufq_alloc "struct bufq_state **bufq" "const char *strategy" "int flags"
51 .Fn bufq_drain "struct bufq_state *bufq"
53 .Fn bufq_free "struct bufq_state *bufq"
55 .Fn bufq_getstrategyname "struct bufq_state *bufq"
57 .Fn bufq_move "struct bufq_state *dst" "struct bufq_state *src"
59 .Fn bufq_put "struct bufq_state *bufq" "struct buf *bp"
61 .Fn bufq_get "struct bufq_state *bufq"
63 .Fn bufq_peek "struct bufq_state *bufq"
65 .Fn bufq_cancel "struct bufq_state *bufq" "struct buf *bp"
69 subsystem is a set of operations for the management of device buffer queues.
71 The primary data type for using the operations is the
73 structure, which is opaque for users.
75 .Bl -tag -width compact
76 .It Fn bufq_alloc "bufq" "strategy" "flags"
77 Allocate and initialize a
83 specifies a buffer queue strategy to be used for this buffer queue.
84 The following special values can be used:
86 .Bl -tag -offset indent -width BUFQ_DISK_DEFAULT_STRAT -compact
91 .It Dv BUFQ_DISK_DEFAULT_STRAT
94 select a strategy, assuming it will be used for a normal disk device.
101 .Bl -tag -offset indent -width BUFQ_SORT_RAWBLOCK -compact
102 .It Dv BUFQ_SORT_RAWBLOCK
105 .It Dv BUFQ_SORT_CYLINDER
111 Fail if a strategy specified by
118 If this flag is not specified,
120 will silently use one of available strategies.
122 .It Fn bufq_drain "bufq"
126 .It Fn bufq_free "bufq"
130 .It Fn bufq_getstrategyname "bufq"
131 Get a strategy identifier of a buffer queue, the
132 string returned will be NUL-terminated and it always
133 will be a valid strategy name.
134 .It Fn bufq_move "dst" "src"
135 Move all requests from the buffer queue
139 .It Fn bufq_put "bufq" "bp"
143 .It Fn bufq_get "bufq"
144 Get the next buf from the queue and remove it from the queue.
147 if the queue is empty.
148 .It Fn bufq_peek "bufq"
149 Get the next buf from the queue without removal.
150 The next buf will remain the same until
158 if the queue is empty.
159 .It Fn bufq_cancel "bufq" "bp"
162 issued earlier on the queue.
165 if the element can not be found on the queue or
167 if it has been found and removed.
168 This operation can be computationally expensive if there are
169 a lot of buffers queued.
172 The actual code implementing the device buffer queues can be found
174 .Pa sys/kern/subr_bufq.c .
178 subsystem appeared in
183 subsystem was written by
184 .An J\(:urgen Hannken-Illjes
185 .Aq hannken@NetBSD.org .