1.\" $NetBSD: bufq.9,v 1.6 2003/04/16 13:35:25 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 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.In buf.h 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. 106The argument 107.Fa flags 108controls the strategy and sort order. 109.It Fn bufq_free "bufq" 110Destroy a 111.Em bufq_state 112descriptor. 113.It Fn BUFQ_PUT "bufq" "bp" 114Put the buf 115.Fa bp 116in the queue. 117.It Fn BUFQ_GET "bufq" 118Get the next buf from the queue and remove it from the queue. 119Returns 120.Dv NULL 121if the queue is empty. 122.It Fn BUFQ_PEEK "bufq" 123Get the next buf from the queue without removal. 124The next buf will remain the same until 125.Fn BUFQ_GET 126is called. 127Returns 128.Dv NULL 129if the queue is empty. 130.El 131.Sh CODE REFERENCES 132The actual code implementing the device buffer queues can be found 133in the file 134.Pa sys/kern/subr_disk.c . 135.Sh HISTORY 136The 137.Nm 138subsystem appeared in 139.Nx 2.0 . 140.Sh AUTHORS 141The 142.Nm 143subsystem was written by 144.if t .An J\(:urgen Hannken-Illjes 145.if n .An Juergen Hannken-Illjes 146.Aq hannken@NetBSD.org . 147