Each operation on a block device driver involves a large number of kernel components; the most important ones are shown in Figure 14-1.
Let us suppose, for instance, that a process issued a
read( ) system call on some disk file—we'll see that write
requests are handled essentially in the same way. Here is what the
kernel typically does to service the process request:
The service routine of the
) system call activates a suitable VFS function, passing
to it a file descriptor and an offset inside the file. The Virtual
Figure 14-1. Kernel components affected by a block device operation
is the upper layer of the block device handling architecture, and it provides a common file model adopted by all filesystems supported by Linux. We have described at length the VFS layer in Chapter 12.
The VFS function determines if the requested data is already available and, if necessary, how to perform the read operation. Sometimes there is no need to access the data on disk, because the kernel keeps in RAM the data most recently read from—or written to—a block device. The disk cache mechanism is explained in Chapter 15, while details on how the VFS handles the disk operations and how it interfaces with the disk cache and the filesystems are given in Chapter 16.
Let's assume that the kernel must read the data from the block device, thus it must determine the physical ...