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