BUFQ(9)
BUFQ(9)
okay bestie, this is BUFQ(9) from the Kernel Developer's Manual, and it's literally all about device buffer queues β let's get into it π
πΈ NAME πΈ
bufq, bufq_init, bufq_register, bufq_unregister, bufq_state, bufq_alloc, bufq_drain, bufq_free, bufq_getstrategyname, bufq_move, bufq_put, bufq_get, bufq_peek, bufq_cancel β device buffer queues β¨
β¨ SYNOPSIS β¨
#include <sys/bufq.h>
void
bufq_init(void);
int
bufq_register(struct bufq_strat *);
int
bufq_unregister(struct bufq_strat *);
int
bufq_alloc(struct bufq_state **bufq, const char *strategy, int flags);
void
bufq_drain(struct bufq_state *bufq);
void
bufq_free(struct bufq_state *bufq);
const char *
bufq_getstrategyname(struct bufq_state *bufq);
void
bufq_move(struct bufq_state *dst, struct bufq_state *src);
void
bufq_put(struct bufq_state *bufq, struct buf *bp);
struct buf *
bufq_get(struct bufq_state *bufq);
struct buf *
bufq_peek(struct bufq_state *bufq);
struct buf *
bufq_cancel(struct bufq_state *bufq, struct buf *bp);
π¦ DESCRIPTION π¦
The bufq subsystem is a set of operations for the management of device buffer queues. Various strategies for ordering of entries in the buffer queues can be provided by loadable kernel modules (see module(9)). By default, the BUFQ_FCFS and BUFQ_DISKSORT strategies are included in the kernel; see options(4) for more details.
The primary data type for using the operations is the bufq_state structure, which is opaque for users. Each buffer queue strategy module is defined by the bufq_strat structure, which is also opaque for users.
π FUNCTIONS π
bufq_init(void)β Initialize thebufqsubsystem. This routine must be called before any otherbufqroutines. no cap, do this first bestie π«Άbufq_register(bs)β Registers the specified buffer queue strategy module so it can be used in subsequent operations.bufq_unregister(bs)β Unregisters the specified buffer queue strategy module. The routine will fail if any buffer queues for the specified strategy are in use (seebufq_alloc()below).bufq_alloc(bufq, strategy, flags)β Allocate and initialize abufq_statedescriptor.
The argument strategy specifies a buffer queue strategy to be used for this buffer queue. The following special values can be used:
BUFQ_STRAT_ANYβ Letbufq_alloc()select a strategy.BUFQ_DISK_DEFAULT_STRATβ Letbufq_alloc()select a strategy, assuming it will be used for a normal disk device.
Valid bits for the flags are:
BUFQ_SORT_RAWBLOCKβ sort byb_rawblknoBUFQ_SORT_CYLINDERβ sort byb_cylinderand then byb_rawblknoBUFQ_EXACTβ Fail if a strategy specified bystrategyis not available. In that case,bufq_allocreturnsENOENT. If this flag is not specified,bufq_alloc()will silently use one of available strategies.
If a specific strategy is specified but not currently available, the bufq subsystem will attempt to auto-load the corresponding kernel module using module_autoload(9).
bufq_drain(bufq)β Drain abufq_statedescriptor.bufq_free(bufq)β Destroy abufq_statedescriptor.bufq_getstrategyname(bufq)β Get a strategy identifier of a buffer queue, the string returned will beNUL-terminated and it always will be a valid strategy name.bufq_move(dst, src)β Move all requests from the buffer queuesrcto the buffer queuedst.bufq_put(bufq, bp)β Put the bufbpin the queue.bufq_get(bufq)β Get the next buf from the queue and remove it from the queue. ReturnsNULLif the queue is empty.bufq_peek(bufq)β Get the next buf from the queue without removal. The next buf will remain the same untilbufq_get(),bufq_put(), orbufq_drain()is called. ReturnsNULLif the queue is empty.bufq_cancel(bufq, bp)β Cancel the bufbpissued earlier on the queue. ReturnsNULLif the element can not be found on the queue orbpif it has been found and removed. This operation can be computationally expensive if there are a lot of buffers queued.
π₯ CODE REFERENCES π₯
The actual code implementing the device buffer queues can be found in the file sys/kern/subr_bufq.c. The code implementing specific buffer queue strategies can be found in the files sys/kern/bufq_*.c.
π NOTES π
A list of currently available buffer queue strategies is available via the kern.bufq.strategies sysctl(7) variables.
π HISTORY π
The bufq subsystem appeared in NetBSD 2.0.
π AUTHORS π
The bufq subsystem was written by JΓΌrgen Hannken-Illjes β¨hannken@NetBSD.orgβ©.
okay that's the whole page, bestie π«Ά β shoutout to Debian, November 17, 2016, and the BUFQ(9) manual page. periodt π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2002 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms