xref: /netbsd-src/share/man/man9/bufq.9 (revision e5548b402ae4c44fb816de42c7bba9581ce23ef5)
1.\"     $NetBSD: bufq.9,v 1.12 2005/10/16 19:26:05 wiz Exp $
2.\"
3.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Juergen Hannken-Illjes.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
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.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd October 16, 2005
38.Dt BUFQ 9
39.Os
40.Sh NAME
41.Nm bufq ,
42.Nm bufq_state ,
43.Nm bufq_alloc ,
44.Nm bufq_drain ,
45.Nm bufq_free ,
46.Nm BUFQ_PUT ,
47.Nm BUFQ_GET ,
48.Nm BUFQ_PEEK
49.Nd device buffer queues
50.Sh SYNOPSIS
51.In sys/bufq.h
52.Ft int
53.Fn bufq_alloc "struct bufq_state **bufq" "const char *strategy" "int flags"
54.Ft void
55.Fn bufq_drain "struct bufq_state *bufq"
56.Ft void
57.Fn bufq_free "struct bufq_state *bufq"
58.Ft void
59.Fn BUFQ_PUT "struct bufq_state *bufq" "struct buf *bp"
60.Ft "struct buf *"
61.Fn BUFQ_GET "struct bufq_state *bufq"
62.Ft "struct buf *"
63.Fn BUFQ_PEEK "struct bufq_state *bufq"
64.Sh DESCRIPTION
65The
66.Nm
67subsystem is a set of operations for the management of device buffer queues.
68.Pp
69The primary data type for using the operations is the
70.Em bufq_state
71structure, which is opaque for users.
72.Sh FUNCTIONS
73.Bl -tag -width compact
74.It Fn bufq_alloc "bufq" "strategy" "flags"
75Allocate and initialize a
76.Em bufq_state
77descriptor.
78.Pp
79The argument
80.Fa strategy
81specifies a buffer queue strategy to be used for this buffer queue.
82The following special values can be used:
83.Pp
84.Bl -tag -offset indent -width BUFQ_DISK_DEFAULT_STRAT -compact
85.It Dv BUFQ_STRAT_ANY
86Let
87.Fn bufq_alloc
88select a strategy.
89.It Dv BUFQ_DISK_DEFAULT_STRAT
90Let
91.Fn bufq_alloc
92select a strategy, assuming it will be used for a normal disk device.
93.El
94.Pp
95Valid bits for the
96.Fa flags
97are:
98.Pp
99.Bl -tag -offset indent -width BUFQ_SORT_RAWBLOCK -compact
100.It Dv BUFQ_SORT_RAWBLOCK
101sort by
102.Em b_rawblkno
103.It Dv BUFQ_SORT_CYLINDER
104sort by
105.Em b_cylinder
106and then by
107.Em b_rawblkno
108.It Dv BUFQ_EXACT
109Fail if a strategy specified by
110.Fa strategy
111is not available.
112In that case,
113.Fa bufq_alloc
114returns
115.Dv ENOENT .
116If this flag is not specified,
117.Fn bufq_alloc
118will silently use one of available strategies.
119.El
120.It Fn bufq_drain "bufq"
121Drain a
122.Em bufq_state
123descriptor.
124.It Fn bufq_free "bufq"
125Destroy a
126.Em bufq_state
127descriptor.
128.It Fn BUFQ_PUT "bufq" "bp"
129Put the buf
130.Fa bp
131in the queue.
132.It Fn BUFQ_GET "bufq"
133Get the next buf from the queue and remove it from the queue.
134Returns
135.Dv NULL
136if the queue is empty.
137.It Fn BUFQ_PEEK "bufq"
138Get the next buf from the queue without removal.
139The next buf will remain the same until
140.Fn BUFQ_GET ,
141.Fn BUFQ_PUT ,
142or
143.Fn bufq_drain
144is called.
145Returns
146.Dv NULL
147if the queue is empty.
148.El
149.Sh CODE REFERENCES
150The actual code implementing the device buffer queues can be found
151in the file
152.Pa sys/kern/subr_bufq.c .
153.Sh HISTORY
154The
155.Nm
156subsystem appeared in
157.Nx 2.0 .
158.Sh AUTHORS
159The
160.Nm
161subsystem was written by
162.if t .An J\(:urgen Hannken-Illjes
163.if n .An Juergen Hannken-Illjes
164.Aq hannken@NetBSD.org .
165