The kiobuf Interface
As of version 2.3.12, the Linux kernel supports an I/O abstraction
called the kernel I/O buffer, or
kiobuf. The kiobuf interface is intended to hide
much of the complexity of the virtual memory system from device
drivers (and other parts of the system that do I/O). Many features
are planned for kiobufs, but their primary use in the 2.4 kernel is to
facilitate the mapping of user-space buffers into the kernel.
The kiobuf Structure
Any code that works with kiobufs must include
<linux/iobuf.h>. This file defines
struct kiobuf, which is the heart of the kiobuf
interface. This structure describes an array of pages that make up an
I/O operation; its fields include the following:
-
int nr_pages; The number of pages in this kiobuf
-
int length; The number of bytes of data in the buffer
-
int offset; The offset to the first valid byte in the buffer
-
struct page **maplist; An array of
pagestructures, one for each page of data in the kiobuf
The key to the kiobuf interface is the maplist
array. Functions that operate on pages stored in a kiobuf deal
directly with the page structures—all of the
virtual memory system overhead has been moved out of the way. This
implementation allows drivers to function independent of the
complexities of memory management, and in general simplifies life
greatly.
Prior to use, a kiobuf must be initialized. It is rare to initialize a single kiobuf in isolation, but, if need be, this initialization can be performed with kiobuf_init ...