xref: /netbsd-src/share/man/man9/bufq.9 (revision 08c81a9c2dc8c7300e893321eb65c0925d60871c)
1.\"     $NetBSD: bufq.9,v 1.3 2002/07/23 14:00:17 hannken 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 July 16, 2002
38.Dt BUFQ 9
39.Os
40.Sh NAME
41.Nm bufq ,
42.Nm bufq_state ,
43.Nm bufq_alloc ,
44.Nm bufq_free ,
45.Nm BUFQ_PUT ,
46.Nm BUFQ_GET ,
47.Nm BUFQ_PEEK
48.Nd device buffer queues
49.Sh SYNOPSIS
50.Fd #include \*[Lt]buf.h\*[Gt]
51.Ft void
52.Fn bufq_alloc "struct bufq_state *bufq" "int flags"
53.Ft void
54.Fn bufq_free "struct bufq_state *bufq"
55.Ft void
56.Fn BUFQ_PUT "struct bufq_state *bufq" "struct buf *bp"
57.Ft "struct buf *"
58.Fn BUFQ_GET "struct bufq_state *bufq"
59.Ft "struct buf *"
60.Fn BUFQ_PEEK "struct bufq_state *bufq"
61.Sh DESCRIPTION
62The
63.Nm
64subsystem is a set of operations for the management of device buffer queues.
65.Pp
66The primary data type for using the operations is the
67.Em bufq_state
68structure in
69.Pa buf.h :
70.Bd -literal
71struct bufq_state {
72	void (*bq_put)(struct bufq_state *, struct buf *);
73	struct buf *(*bq_get)(struct bufq_state *, int);
74	void *bq_private;
75	int bq_flags;		/* Flags from bufq_alloc() */
76};
77.Ed
78.Pp
79Valid values for the
80.Em flags
81argument are:
82.Pp
83.Bl -tag -offset indent -width BUFQ_SORT_RAWBLOCK -compact
84.It Dv BUFQ_SORT_RAWBLOCK
85sort by
86.Em b_rawblkno
87.It Dv BUFQ_SORT_CYLINDER
88sort by
89.Em b_cylinder
90and then by
91.Em b_rawblkno
92.It Dv BUFQ_FCFS
93queue strategy is first-come first-serve
94.It Dv BUFQ_DISKSORT
95queue strategy is min seek sort
96.It Dv BUFQ_READ_PRIO
97queue strategy is min seek sort for writes and first-come first-serve
98for reads with read priority
99.El
100.Sh FUNCTIONS
101.Bl -tag -width compact
102.It Fn bufq_alloc "bufq" "flags"
103Initialize a
104.Em bufq_state
105descriptor.  The argument
106.Fa flags
107controls the strategy and sort order.
108.It Fn bufq_free "bufq"
109Destroy a
110.Em bufq_state
111descriptor.
112.It Fn BUFQ_PUT "bufq" "bp"
113Put the buf
114.Fa bp
115in the queue.
116.It Fn BUFQ_GET "bufq"
117Get the next buf from the queue and remove it from the queue.
118Returns
119.Dv NULL
120if the queue is empty.
121.It Fn BUFQ_PEEK "bufq"
122Get the next buf from the queue without removal.
123The next buf will remain the same until
124.Fn BUFQ_GET
125is called.
126Returns
127.Dv NULL
128if the queue is empty.
129.El
130.Sh CODE REFERENCES
131The actual code implementing the device buffer queues can be found
132in the file
133.Pa sys/kern/subr_disk.c .
134.Sh HISTORY
135The
136.Nm
137subsystem appeared in
138.Nx 1.7 .
139.Sh AUTHORS
140The
141.Nm
142subsystem was written by
143.if t .An J\(:urgen Hannken-Illjes
144.if n .An Juergen Hannken-Illjes
145.Aq hannken@NetBSD.org .
146