Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

bufq(9) [netbsd man page]

BUFQ(9) 						   BSD Kernel Developer's Manual						   BUFQ(9)

NAME
bufq, 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> 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. The primary data type for using the operations is the bufq_state structure, which is opaque for users. FUNCTIONS
bufq_alloc(bufq, strategy, flags) Allocate and initialize a bufq_state descriptor. 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 Let bufq_alloc() select a strategy. BUFQ_DISK_DEFAULT_STRAT Let bufq_alloc() select a strategy, assuming it will be used for a normal disk device. Valid bits for the flags are: BUFQ_SORT_RAWBLOCK sort by b_rawblkno BUFQ_SORT_CYLINDER sort by b_cylinder and then by b_rawblkno BUFQ_EXACT Fail if a strategy specified by strategy is not available. In that case, bufq_alloc returns ENOENT. If this flag is not specified, bufq_alloc() will silently use one of available strategies. bufq_drain(bufq) Drain a bufq_state descriptor. bufq_free(bufq) Destroy a bufq_state descriptor. bufq_getstrategyname(bufq) Get a strategy identifier of a buffer queue, the string returned will be NUL-terminated and it always will be a valid strategy name. bufq_move(dst, src) Move all requests from the buffer queue src to the buffer queue dst. bufq_put(bufq, bp) Put the buf bp in the queue. bufq_get(bufq) Get the next buf from the queue and remove it from the queue. Returns NULL if the queue is empty. bufq_peek(bufq) Get the next buf from the queue without removal. The next buf will remain the same until bufq_get(), bufq_put(), or bufq_drain() is called. Returns NULL if the queue is empty. bufq_cancel(bufq, bp) Cancel the buf bp issued earlier on the queue. Returns NULL if the element can not be found on the queue or bp if 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. HISTORY
The bufq subsystem appeared in NetBSD 2.0. AUTHORS
The bufq subsystem was written by Jurgen Hannken-Illjes <hannken@NetBSD.org>. BSD
January 24, 2009 BSD

Check Out this Related Man Page

physio(9F)						   Kernel Functions for Drivers 						physio(9F)

NAME
physio, minphys - perform physical I/O SYNOPSIS
#include <sys/types.h> #include <sys/buf.h> #include <sys/uio.h> int physio(int(*strat)(struct buf *), struct buf *bp, dev_t dev, int rw, void (*mincnt)(struct buf *), struct uio *uio); void minphys(struct buf *bp); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI). PARAMETERS
physio() strat Pointer to device strategy routine. bp Pointer to a buf(9S) structure describing the transfer. If bp is set to NULL then physio() allocates one which is automatically released upon completion. dev The device number. rw Read/write flag. This is either B_READ when reading from the device, or B_WRITE when writing to the device. mincnt Routine which bounds the maximum transfer unit size. uio Pointer to the uio structure which describes the user I/O request. minphys() bp Pointer to a buf structure. DESCRIPTION
physio() performs unbuffered I/O operations between the device dev and the address space described in the uio structure. Prior to the start of the transfer physio() verifies the requested operation is valid by checking the protection of the address space spec- ified in the uio structure. It then locks the pages involved in the I/O transfer so they can not be paged out. The device strategy routine, strat(), is then called one or more times to perform the physical I/O operations. physio() uses biowait(9F) to block until strat() has com- pleted each transfer. Upon completion, or detection of an error, physio() unlocks the pages and returns the error status. physio() uses mincnt() to bound the maximum transfer unit size to the system, or device, maximum length. minphys() is the system mincnt() routine for use with physio() operations. Drivers which do not provide their own local mincnt() routines should call physio() with min- phys(). minphys() limits the value of bp->b_bcount to a sensible default for the capabilities of the system. Drivers that provide their own mincnt() routine should also call minphys() to make sure they do not exceed the system limit. RETURN VALUES
physio() returns: 0 Upon success. non-zero Upon failure. CONTEXT
physio() can be called from user context only. SEE ALSO
strategy(9E), biodone(9F), biowait(9F), buf(9S), uio(9S) Writing Device Drivers WARNINGS
Since physio() calls biowait() to block until each buf transfer is complete, it is the drivers responsibility to call biodone(9F) when the transfer is complete, or physio() will block forever. SunOS 5.11 2 Apr 1993 physio(9F)
Man Page