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

unified buffer cache

#include <uvm/uvm.h>
ubc_uiomove(struct uvm_object *uobj, struct uio *uio, vsize_t todo, int advice, int flags);
ubc_zerorange(struct uvm_bject *uobj, off_t off, size_t len, int flags);
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
No hint
Random access hint
Sequential access hint (from lower offset to higher offset)
and the flags parameter is
Mapping will be accessed for read.
Mapping will be accessed for write.
Fault in window's pages already during mapping operation. Makes sense only for write.
Do not cache mapping.
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