Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pbuf(9) [freebsd man page]

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

pbuf, getpbuf, trypbuf, relpbuf -- functions for managing physical buffers SYNOPSIS
#include <sys/param.h> #include <sys/systm.h> #include <sys/bio.h> #include <sys/buf.h> struct buf * getpbuf(int *pfreecnt); struct buf * trypbuf(int *pfreecnt); void relpbuf(struct buf *bp, int *pfreecnt); DESCRIPTION
These functions are used to allocate and release physical buffers. The physical buffers are allocated at system startup and are maintained in a separate pool from the main system buffers. They are intended for use by subsystems that cannot or should not be reliant on the main pool of buffers (for example the swap pager). The system allocates between 16 and 256 physical buffers depending on the amount of memory in the system. Each subsystem that allocates buffers via these calls is expected to manage its own percentage free counter. If the value is initialized to -1 the number of buffers available to the subsystem is limited only by the number of physical buffers available. The number of buffers is stored in nswbuf which is defined in <sys/buf.h> and initialized in cpu_startup(). A recommended initialization value is 1/2 nswbuf. The getpbuf() function returns the first available buffer to the user. If there are no buffers available, getpbuf() will sleep waiting for one to become available. If pfreecnt is zero, getpbuf() will sleep until it increases. pfreecnt is decremented prior to returning. The trypbuf() function returns the first available buffer. If there are no buffers available, NULL is returned. As well, if pfreecnt is zero, NULL is returned. pfreecnt is decremented prior to returning a valid buffer. If NULL is returned, pfreecnt is not modified. The relpbuf() function releases the buffer back to the free list. If the buffers b_rcred or b_wcred structures are not NULL, they are freed. See crfree(9). pfreecnt is incremented prior to returning. RETURN VALUES
getpbuf() and trypbuf() return a pointer to the buffer. In the case of trypbuf(), NULL can also be returned indicating that there are no buffers available. AUTHORS
This manual page was written by Chad David <>. BSD
July 9, 2001 BSD

Check Out this Related Man Page

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

vinvalbuf -- flushes and invalidates all buffers associated with a vnode SYNOPSIS
#include <sys/param.h> #include <sys/vnode.h> int vinvalbuf(struct vnode *vp, int flags, struct ucred *cred, int slpflag, int slptimeo); DESCRIPTION
The vinvalbuf() function invalidates all of the buffers associated with the given vnode. This includes buffers on the clean list and the dirty list. If the V_SAVE flag is specified then the buffers on the dirty list are synced prior to being released. If there is a VM Object associated with the vnode, it is removed. Its arguments are: vp A pointer to the vnode whose buffers will be invalidated. flags The only supported flag is V_SAVE and it indicates that dirty buffers should be synced with the disk. cred The user credentials that are used to VOP_FSYNC(9) buffers if V_SAVE is set. slpflag The slp flag that will be used in the priority of any sleeps in the function. slptimeo The timeout for any sleeps in the function. LOCKS
The vnode is assumed to be locked prior to the call and remains locked upon return. Giant must be held by prior to the call and remains locked upon return. RETURN VALUES
A 0 value is returned on success. PSEUDOCODE
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); error = vinvalbuf(devvp, V_SAVE, cred, 0, 0); VOP_UNLOCK(devvp, 0); if (error) return (error); ERRORS
[ENOSPC] The file system is full. (With V_SAVE) [EDQUOT] Disc quota exceeded. (With V_SAVE) [EWOULDBLOCK] Sleep operation timed out. (See slptimeo) [ERESTART] A signal needs to be delivered and the system call should be restarted. (With PCATCH set in slpflag) [EINTR] The system has been interrupted by a signal. (With PCATCH set in slpflag) SEE ALSO
brelse(9), bremfree(9), tsleep(9), VOP_FSYNC(9) AUTHORS
This manual page was written by Chad David <>. BSD
October 20, 2008 BSD
Man Page

Featured Tech Videos