BUFQ_INIT(9) Kernel Developer's Manual BUFQ_INIT(9)

bufq_init, bufq_switch, bufq_destroy, bufq_queue, bufq_dequeue, bufq_requeue, bufq_peek, bufq_drainbuf queues

#include <sys/buf.h>

int
bufq_init(struct bufq *bufq, int type);

int
bufq_switch(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);

void
bufq_requeue(struct bufq *bufq, struct buf *bp);

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.

() initialises the bufq structure and allocates any state required by the scheduling algorithm by the type argument.

() can be used to change the scheduler currently used by bufq to the algorithm specified by type.

The type argument to () and bufq_switch() can be one of the following scheduling algorithms:

A simple First-In First-Out queue.
Takes batches of "N" bufs from the queue and sorts them for optimal head movement.
This currently aliases BUFQ_NSCAN.

() frees any state that was used by the scheduler.

() is used to add the buf specified by bp to the bufq queue.

() 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.

() can be used to return a previously dequeued buf specified by bp to the head of the queue of bufq.

() allows the caller to determine if there are more bufs queued on bufq without modifying the list of bufs.

() 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(), bufq_switch(), and bufq_destroy() can be called during autoconf, or from process context.

bufq_queue, bufq_dequeue, bufq_requeue, bufq_peek, and bufq_drain can be called during autoconf, from process context, or from interrupt context.

bufq_init() and bufq_switch() 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.

errno(2), autoconf(9), biodone(9), disk(9)

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.

December 25, 2015 OpenBSD 7.5