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

ubc
unified buffer cache

#include <uvm/uvm.h>
int
ubc_uiomove(struct uvm_object *uobj, struct uio *uio, vsize_t todo, int advice, int flags);
void
ubc_zerorange(struct uvm_bject *uobj, off_t off, size_t len, int flags);
void
ubc_purge(struct uvm_object *uobj);

ubc_uiomove() allocates an UBC memory window, performs I/O on it and unmaps the window. The advice parameter is the access pattern hint, which must be one of
UVM_ADV_NORMAL
No hint
UVM_ADV_RANDOM
Random access hint
UVM_ADV_SEQUENTIAL
Sequential access hint (from lower offset to higher offset)
and the flags parameter is
UBC_READ
Mapping will be accessed for read.
UBC_WRITE
Mapping will be accessed for write.
UBC_FAULTBUSY
Fault in window's pages already during mapping operation. Makes sense only for write.
UBC_UNMAP
Do not cache mapping.
UBC_PARTIALOK
Indicate that it is acceptable to return if an error occurs mid-transfer.
UBC memory window is a kernel mapping of uobj starting at offset offset.
Once the mapping is created, it must be accessed only by methods that can handle faults, such as uiomove(9) or kcopy(9). Page faults on the mapping will result in the object's pager method being called to resolve the fault.
Size of individual UBC memory window is limited to ubc_winsize. ubc_uiomove() sequentially creates the UBC memory windows to eventually process the whole range according to offset and len parameters.
The mappings may be cached to speed future accesses to the same region of the object, unless UBC_UNMAP was specified in flags parameter.
ubc_zerorange() sets a range of bytes in a UVM object to zero. The flags parameter takes the same arguments as ubc_uiomove().
ubc_purge() disassociates all UBC structures from an empty UVM object, specified by uobj.

The ubc subsystem is implemented within the file sys/uvm/uvm_bio.c.

kcopy(9), pmap(9), uiomove(9), uvm(9), vnode(9), vnodeops(9)
Chuck Silvers, UBC: An Efficient Unified I/O and Memory Caching Subsystem for NetBSD, Proceedings of the FREENIX Track: 2000 USENIX Annual Technical Conference, USENIX Association, http://www.usenix.org/event/usenix2000/freenix/full_papers/silvers/silvers.pdf, 285-290, June 18-23, 2000.

UBC first appeared in NetBSD 1.6.

Chuck Silvers <chuq@chuq.com> designed and implemented the UBC part of UVM, which uses UVM pages to cache vnode data rather than the traditional buffer cache buffers.
May 12, 2018 NetBSD-current