Submitting Requests

In this section, I discuss the mechanism that the kernel provides to submit data requests to peripheral devices. This also involves buffering and reordering requests to reduce disk head seek movements, for example, or to boost performance by bundling operations. Also covered are the operation of the device driver, which interacts with the specific hardware in order to process requests, and the general code of the virtual filesystem that is associated with device files and therefore with user applications and other parts of the kernel. As you will see in Chapters 16 and 8, the kernel employs caches to retain data already read from block devices for future reuse if the same request is submitted repeatedly. We are not interested in this particular aspect here. Instead, we will examine how the kernel goes about submitting a physical request to a device to read or write data.

The kernel submits a request in two steps.

□ It creates a bio instance to describe the request and then embeds the instance in a request that is placed on a request queue.

□ It processes the request queue and carries out the actions described by the bio.

Creating a new bio instance is not particularly interesting as all it involves is filling the desired locations on a block device and providing page frames to hold and transfer the relevant data. I won't bother with the details.

Once a BIO has been created, make_request_fn is invoked to generate a new request for insertion on the request queue.12 The requests are submitted by request_fn.

The implementation of these actions reside in block/ll_rw_blk.c up to kernel 2.6.24. The strangesounding filename is an abbreviation of low level read write handling for block devices. Later kernels split the implementation into a number of smaller files named by the scheme block/blk-*.c.

Continue reading here: Creating Requests

Was this article helpful?

0 0