Creating Requests

submit_bio is the key function that creates a new request based on a passed bio instance and finally places it on the request queue of the driver using make_request_fn. Figure 6-16 shows the associated code flow diagram. Let's consider a simplified version first, but come back later to address some problems that can arise in certain cases, and how the kernel solves them with a little trick.

The function is invoked at various places in the kernel to initiate physical data transfers. submit_bio simply updates the kernel statistics, the actual work being delegated to_generic_make_request after a detour over generic_make_request, which is explained below. The work is done in three steps after a few sanity checks have been performed (one such check establishes, for example, whether the request exceeds the physical capabilities of the device).

□ The request queue of the block device to which the request refers is found using bdev_get_queue.

□ If the device is partitioned, the request is remapped with blk_partition_remap to ensure that the correct area is read or written. This enables the remaining kernel to treat individual partitions in the same way as independent, non-partitioned devices. If a partition starts at sector n and

12Or to store the request elsewhere if the driver has explicitly replaced the default implementation with its own function.

access is to be made to sector m within the partition, a request must be created to access sector m + n of the block device. The correct offset for the partition is held in the parts array of the gendisk instance associated with the queue. □ q->make_request_fn generates a request by reference to the bio and forwards it to the device driver. The kernel standard function (_make_request) is invoked for most devices.


Perform statistics acccounting


__generic_make_request 1



queue->make_request_fn |

Continue reading here: Figure 616 Code flow diagram for submitbio

Was this article helpful?

0 0