Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


__REQ_ORDERED_COLOR, /* is before or after barrier */
__REQ_RW_SYNC, /* request is sync (O_DIRECT) */
__REQ_ALLOCED, /* request came from our alloc pool */
__REQ_RW_META, /* metadata io request */
__REQ_NR_BITS, /* stops here */
};

__REQ_RWis especially important because it indicates the direction of data transfer. If the bit is set, data
are written; if not, data are read. The remaining bitsare used to send special device-specific commands,
to set up barriers,^11 or to transfer control codes. Their meaning is concisely described by the kernel com-
mentary, so I need not add anything further.

6.5.6 BIOs


Before giving an exact definition of BIOs, it is advisable to discuss their underlying principles as illus-
trated in Figure 6-15.

BIO BIO BIO

bi_io_vec

struct page

Figure 6-15: Structure of BIOs.

The central management structure (bio) is associated with a vector whose individual entries each point
to a memory page (caution:Notthe address in memory but thepageinstance belonging to the page).
These pages are used to receive data from and send data to the device.

It is explicitly possible to use highmem pages that are not directly mapped in the
kernel and cannot therefore be addressed via virtual kernel addresses. This is
useful when data are copied directly to userspace applications that are able to access
the highmem pages using their page tables.

The memory pages can but need not be organized contiguously; this facilitates the implementation of
scatter-gather operations.

BIOs have the following (simplified) structure in the kernel sources:

<bio.h>
struct bio {
sector_t bi_sector;
struct bio *bi_next; /* request queue link */

(^11) If a device comes across a barrier in a request list, all still pending requests must be fully processed before any other actions can
be performed.

Free download pdf