linux and block device drivers?

Richard S. Gray (sgray@preferred.com)
Sun, 12 Oct 1997 22:53:36 -0400


Hi,

My understanding of the states that a read/write operation goes
through are as follows:

1) A process generates the read/write request.

2) The Virtual File System (VFS) receives the read/write (r/w) request
and forwards it to the file system specific code through the appropriate
file_operations, inode_operations, or super_operations structure. What
other processing occurs at this time?

3) The filesystem (fs) specific code attempts to r/w data from/to
the buffer cache.

4) If the data block(s) in question are found within the cache and
are up to date then the request is satisfied via the buffer
cache. In other words, the block device driver is not involved.
I assume that "up to date means" means the data requested from the
physical disk is consistent with then the data in the buffer cache.

5) If the data block(s) in question are NOT found within the cache
then the fs specific code is responsible for allocating the required
number of blocks in the buffer cache. The fs specific code then
generates another r/w request on the appropriate device special file.
This r/w request goes though the VFS. The block device's file_operations
structure will contain the following function pointers: "block_read"
and "block_write". From within these functions, found in "fs/block_dev.c",
a call to the function ll_rw_block, found within "drivers/block/ll_rw_blk.c",
is made. ll_rw_blk.c contains code that is responsible for generating
and placing the r/w requests on a "request queue" that is SHARED between
the buffer cache and the block device driver.

6) The device driver monitors the request queue. For each request generated, the
device driver issues the appropriate commands to cause the device controller
to r/w data from/to the disk. Once a request has been serviced, the device driver
removes it from the request queue.

I have a diagram online at: http://www.preferred.com/~sgray/read-write.jpg . If you get
a chance take a look at this and let know what problems there are with it.
I would appreciate any comments or help. I've already been helped quit a bit and would
thank those people for their help. I know I've gotten some of this wrong but I think I'm
getting closer to understanding how this fits together.

Thanks,
Scott Gray :)