| BUFQ_INIT(9) | Kernel Developer's Manual | BUFQ_INIT(9) |
bufq_init,
bufq_destroy, bufq_queue,
bufq_dequeue, bufq_peek,
bufq_drain — buf
queues
#include
<sys/buf.h>
int
bufq_init(struct
bufq *bufq, int
type);
void
bufq_destroy(struct
bufq *bufq);
void
bufq_queue(struct
bufq *bufq, struct buf
*bp);
struct buf *
bufq_dequeue(struct
bufq *bufq);
int
bufq_peek(struct
bufq *bufq);
void
bufq_drain(struct
bufq *bufq);
The bufq API implements queueing and scheduling of I/O operations on disk devices. It provides multiple scheduling algorithms within the API.
It is the responsibility of the disk device driver to provide pre-allocated bufq structures.
bufq_init()
initialises the bufq structure and allocates any state
required by the scheduling algorithm by the type
argument.
The type argument to
bufq_init()
can be one of the following scheduling algorithms:
BUFQ_FIFOBUFQ_NSCANBUFQ_DEFAULTBUFQ_NSCAN.bufq_destroy()
frees any state that was used by the scheduler.
bufq_queue()
is used to add the buf specified by bp to the
bufq queue.
bufq_dequeue()
is used to get the next buf the bufq has scheduled to
be serviced by a disk. The buf will be removed from the queue.
bufq_peek()
allows the caller to determine if there are more bufs queued on
bufq without modifying the list of bufs.
bufq_drain()
is a convenience function for devices that have detached. It removes all the
bufs currently queued on bufq, marks them as failed
with an ENXIO error, and returns them to the block
layer via biodone(9).
bufq_init() and
bufq_destroy() can be called during autoconf, or
from process context.
bufq_queue,
bufq_dequeue, bufq_peek, and
bufq_drain can be called during autoconf, from
process context, or from interrupt context.
bufq_init() will return 0 on success, or
an error code as per errno(2).
bufq_dequeue() returns the next buf that
is scheduled to be serviced by the disk. NULL is
returned if there are no bufs available on the queue.
bufq_peek() returns 1 if there are bufs
available to be scheduled on the disk, otherwise 0.
The bufq API was written by Thordur I. Bjornsson and David Gwynne <dlg@openbsd.org>. The bufq API first appeared in OpenBSD 4.8 and finally succeeded in fully replacing disksort in OpenBSD 5.5.
| May 17, 2025 | Debian |